mothra: fast (offscreen) alpha drawing on scroll

This commit is contained in:
cinap_lenrek 2012-09-23 04:18:39 +02:00
parent 74cdf2c10a
commit da8dd94a7a
2 changed files with 27 additions and 33 deletions

View file

@ -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.

View file

@ -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);
}
/*