diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-09-24 23:32:57 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-09-24 23:32:57 +0200 |
commit | a8a71a36f5f0f8262b76cc04b113312f8c87fc23 (patch) | |
tree | 82c62bb080fe88aed2c1ff164f6ab00231042659 /sys/src/cmd/mothra | |
parent | 80075967797d5ccd098ad496a9f9f963ddd95ce0 (diff) |
mothra: cache backup bitmap in pl_rtdraw()
Diffstat (limited to 'sys/src/cmd/mothra')
-rw-r--r-- | sys/src/cmd/mothra/libpanel/rtext.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/src/cmd/mothra/libpanel/rtext.c b/sys/src/cmd/mothra/libpanel/rtext.c index 1a289c50c..0fa1bcdc4 100644 --- a/sys/src/cmd/mothra/libpanel/rtext.c +++ b/sys/src/cmd/mothra/libpanel/rtext.c @@ -164,14 +164,18 @@ void pl_stuffbitmap(Panel *p, Image *b){ } void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){ + static Image *backup; Point offs, lp; Rectangle dr; Image *bb; bb = b; - if((b = allocimage(display, r, bb->chan, 0, DNofill)) == nil) - b = bb; - + if(backup==0 || rectinrect(r, backup->r)==0){ + freeimage(backup); + backup=allocimage(display, bb->r, bb->chan, 0, DNofill); + } + if(backup) + b=backup; pl_clr(b, r); lp=ZP; offs=subpt(r.min, Pt(0, yoffs)); @@ -188,7 +192,7 @@ 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) + if(b!=bb) pl_stuffbitmap(t->p, bb); } else{ @@ -208,11 +212,8 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){ lp=ZP; } } - - if(b != bb){ - draw(bb, r, b, 0, b->r.min); - freeimage(b); - } + if(b!=bb) + draw(bb, r, b, 0, r.min); } /* * Reposition text already drawn in the window. |