summaryrefslogtreecommitdiff
path: root/sys/src/cmd/mothra
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-09-23 04:18:39 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-09-23 04:18:39 +0200
commitda8dd94a7a6c759c499b3dd67423f293e3104c75 (patch)
tree011dab10ae7bd2e75ac91701ab928344758e3c21 /sys/src/cmd/mothra
parent74cdf2c10a6c23147c348a4d87fb548f58acc5c2 (diff)
mothra: fast (offscreen) alpha drawing on scroll
Diffstat (limited to 'sys/src/cmd/mothra')
-rw-r--r--sys/src/cmd/mothra/libpanel/rtext.c33
-rw-r--r--sys/src/cmd/mothra/libpanel/textview.c27
2 files changed, 27 insertions, 33 deletions
diff --git a/sys/src/cmd/mothra/libpanel/rtext.c b/sys/src/cmd/mothra/libpanel/rtext.c
index 1071dae95..c9aa548fe 100644
--- a/sys/src/cmd/mothra/libpanel/rtext.c
+++ b/sys/src/cmd/mothra/libpanel/rtext.c
@@ -151,17 +151,27 @@ int pl_rtfmt(Rtext *t, int wid){
}
return p.y;
}
+
+/*
+ * If we draw the text in a backup bitmap and copy it onto the screen,
+ * the bitmap pointers in all the subpanels point to the wrong bitmap.
+ * This code fixes them.
+ */
+void pl_stuffbitmap(Panel *p, Image *b){
+ p->b=b;
+ for(p=p->child;p;p=p->next)
+ pl_stuffbitmap(p, b);
+}
+
void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){
Point offs, lp;
Rectangle dr;
- Rectangle cr;
- Rectangle xr;
+ Image *bb;
+
+ bb = b;
+ if((b = allocimage(display, r, bb->chan, 0, DNofill)) == nil)
+ b = bb;
- xr=r;
- cr=b->clipr;
- if(!rectclip(&xr, cr))
- return;
- replclipr(b, b->repl, xr);
pl_clr(b, r);
lp=ZP;
offs=subpt(r.min, Pt(0, yoffs));
@@ -176,6 +186,9 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){
else if(t->p){
plmove(t->p, subpt(dr.min, t->p->r.min));
pldraw(t->p, b);
+
+ if(b != bb)
+ pl_stuffbitmap(t->p, bb);
}
else{
string(b, dr.min, display->black, ZP, t->font, t->text);
@@ -195,7 +208,11 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){
pl_highlight(b, dr);
}
}
- replclipr(b, b->repl, cr);
+
+ if(b != bb){
+ draw(bb, r, b, 0, b->r.min);
+ freeimage(b);
+ }
}
/*
* Reposition text already drawn in the window.
diff --git a/sys/src/cmd/mothra/libpanel/textview.c b/sys/src/cmd/mothra/libpanel/textview.c
index 8dc060e81..da38003f9 100644
--- a/sys/src/cmd/mothra/libpanel/textview.c
+++ b/sys/src/cmd/mothra/libpanel/textview.c
@@ -24,21 +24,6 @@ struct Textview{
int buttons;
};
-void pl_stuffbitmap(Panel *p, Image *b){
- p->b=b;
- for(p=p->child;p;p=p->next)
- pl_stuffbitmap(p, b);
-}
-/*
- * If we draw the text in a backup bitmap and copy it onto the screen,
- * the bitmap pointers in all the subpanels point to the wrong bitmap.
- * This code fixes them.
- */
-void pl_drawnon(Rtext *rp, Image *b){
- for(;rp!=0;rp=rp->next)
- if(rp->b==0 && rp->p!=0)
- pl_stuffbitmap(rp->p, b);
-}
void pl_setscrpos(Panel *p, Textview *tp, Rectangle r){
Panel *sb;
int lo, hi;
@@ -51,11 +36,8 @@ void pl_drawtextview(Panel *p){
int twid;
Rectangle r;
Textview *tp;
- Image *b;
tp=p->data;
- b=allocimage(display, p->r, screen->chan, 0, DNofill);
- if(b==0) b=p->b;
- r=pl_outline(b, p->r, UP);
+ r=pl_outline(p->b, p->r, UP);
twid=r.max.x-r.min.x;
if(twid!=tp->twid){
tp->twid=twid;
@@ -63,12 +45,7 @@ void pl_drawtextview(Panel *p){
p->scr.size.y=tp->thgt;
}
p->scr.pos.y=tp->yoffs;
- pl_rtdraw(b, r, tp->text, tp->yoffs);
- if(b!=p->b){
- draw(p->b, p->r, b, 0, b->r.min);
- freeimage(b);
- pl_drawnon(tp->text, p->b);
- }
+ pl_rtdraw(p->b, r, tp->text, tp->yoffs);
pl_setscrpos(p, tp, r);
}
/*