shithub: riscv

Download patch

ref: da8dd94a7a6c759c499b3dd67423f293e3104c75
parent: 74cdf2c10a6c23147c348a4d87fb548f58acc5c2
author: cinap_lenrek <[email protected]>
date: Sun Sep 23 00:18:39 EDT 2012

mothra: fast (offscreen) alpha drawing on scroll

--- a/sys/src/cmd/mothra/libpanel/rtext.c
+++ b/sys/src/cmd/mothra/libpanel/rtext.c
@@ -151,17 +151,27 @@
 	}
 	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;
 
-	xr=r;
-	cr=b->clipr;
-	if(!rectclip(&xr, cr))
-		return;
-	replclipr(b, b->repl, xr);
+	bb = b;
+	if((b = allocimage(display, r, bb->chan, 0, DNofill)) == nil)
+		b = bb;
+
 	pl_clr(b, r);
 	lp=ZP;
 	offs=subpt(r.min, Pt(0, yoffs));
@@ -176,6 +186,9 @@
 			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 @@
 				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.
--- a/sys/src/cmd/mothra/libpanel/textview.c
+++ b/sys/src/cmd/mothra/libpanel/textview.c
@@ -24,21 +24,6 @@
 	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 @@
 	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 @@
 		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);
 }
 /*