shithub: pplay

Download patch

ref: cf4c29056644b29a7f9f615a4c0d12bf6c15409c
parent: 5f5ba7ed32140f1bd9a35de52a361fd192afcdcd
author: qwx <[email protected]>
date: Sat Feb 4 12:19:35 EST 2023

draw: improve panning drawing performance by reducing updates

--- a/draw.c
+++ b/draw.c
@@ -28,6 +28,7 @@
 static usize T;
 static int sampwidth = 1;
 static double zoom = 1.0;
+int viewdone;
 
 static Image *
 eallocimage(Rectangle r, int repl, ulong col)
@@ -162,9 +163,10 @@
 				draw(viewbg, r, col[Csamp], nil, ZP);
 			unlockdisplay(display);
 			x = (d.pos - views) / T;
-			if(x % 100 == 0)
+			if(x % 320 == 0)
 				update();
 		}
+		viewdone = 1;
 		update();
 		qunlock(&lsync);
 	}
@@ -205,6 +207,8 @@
 	int x;
 	usize p;
 
+	if(!viewdone)
+		return;
 	p = dot.pos;
 	lockdisplay(display);
 	drawview();
@@ -360,7 +364,7 @@
 		resetdraw();
 	unlockdisplay(display);
 	nbsendul(drawc, 1);
-	update();
+	viewdone = 0;
 }
 
 void
--- a/pplay.c
+++ b/pplay.c
@@ -40,7 +40,8 @@
 		}
 		nerr = 0;
 		advance(&dot, n);
-		update();
+		if(viewdone)
+			update();
 		yield();
 	}
 }