mothra: fast (offscreen) alpha drawing on scroll
This commit is contained in:
parent
74cdf2c10a
commit
da8dd94a7a
|
@ -151,17 +151,27 @@ int pl_rtfmt(Rtext *t, int wid){
|
||||||
}
|
}
|
||||||
return p.y;
|
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){
|
void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){
|
||||||
Point offs, lp;
|
Point offs, lp;
|
||||||
Rectangle dr;
|
Rectangle dr;
|
||||||
Rectangle cr;
|
Image *bb;
|
||||||
Rectangle xr;
|
|
||||||
|
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);
|
pl_clr(b, r);
|
||||||
lp=ZP;
|
lp=ZP;
|
||||||
offs=subpt(r.min, Pt(0, yoffs));
|
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){
|
else if(t->p){
|
||||||
plmove(t->p, subpt(dr.min, t->p->r.min));
|
plmove(t->p, subpt(dr.min, t->p->r.min));
|
||||||
pldraw(t->p, b);
|
pldraw(t->p, b);
|
||||||
|
|
||||||
|
if(b != bb)
|
||||||
|
pl_stuffbitmap(t->p, bb);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
string(b, dr.min, display->black, ZP, t->font, t->text);
|
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);
|
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.
|
* Reposition text already drawn in the window.
|
||||||
|
|
|
@ -24,21 +24,6 @@ struct Textview{
|
||||||
int buttons;
|
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){
|
void pl_setscrpos(Panel *p, Textview *tp, Rectangle r){
|
||||||
Panel *sb;
|
Panel *sb;
|
||||||
int lo, hi;
|
int lo, hi;
|
||||||
|
@ -51,11 +36,8 @@ void pl_drawtextview(Panel *p){
|
||||||
int twid;
|
int twid;
|
||||||
Rectangle r;
|
Rectangle r;
|
||||||
Textview *tp;
|
Textview *tp;
|
||||||
Image *b;
|
|
||||||
tp=p->data;
|
tp=p->data;
|
||||||
b=allocimage(display, p->r, screen->chan, 0, DNofill);
|
r=pl_outline(p->b, p->r, UP);
|
||||||
if(b==0) b=p->b;
|
|
||||||
r=pl_outline(b, p->r, UP);
|
|
||||||
twid=r.max.x-r.min.x;
|
twid=r.max.x-r.min.x;
|
||||||
if(twid!=tp->twid){
|
if(twid!=tp->twid){
|
||||||
tp->twid=twid;
|
tp->twid=twid;
|
||||||
|
@ -63,12 +45,7 @@ void pl_drawtextview(Panel *p){
|
||||||
p->scr.size.y=tp->thgt;
|
p->scr.size.y=tp->thgt;
|
||||||
}
|
}
|
||||||
p->scr.pos.y=tp->yoffs;
|
p->scr.pos.y=tp->yoffs;
|
||||||
pl_rtdraw(b, r, tp->text, tp->yoffs);
|
pl_rtdraw(p->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_setscrpos(p, tp, r);
|
pl_setscrpos(p, tp, r);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue