shithub: libgraphics

Download patch

ref: 8aa0dc8601656db1390617d24bc77be17f099686
parent: 071b70df067ffa192e64511f2a88f1d4efad241b
author: rodri <rgl@antares-labs.eu>
date: Sat Jul 20 07:58:47 EDT 2024

reduce the volume of Camera.times records. clean up.

--- a/camera.c
+++ b/camera.c
@@ -94,6 +94,7 @@
 	c->times.E[c->times.cur] = j->times.E;
 	c->times.Tn[c->times.cur] = j->times.Tn;
 	c->times.Rn[c->times.cur] = j->times.Rn;
+	c->times.last = c->times.cur;
 	c->times.cur = ++c->times.cur % nelem(c->times.R);
 }
 
--- a/fb.c
+++ b/fb.c
@@ -94,7 +94,6 @@
 	Rectangle blkr;
 	Point sp, dp;
 	ulong *blk;
-	int i;
 
 	blk = emalloc(scale.x*scale.y*4);
 	blkr = Rect(0,0,scale.x,scale.y);
@@ -102,14 +101,14 @@
 	qlock(ctl);
 	fb = ctl->getfb(ctl);
 	for(sp.y = fb->r.min.y, dp.y = dst->r.min.y; sp.y < fb->r.max.y; sp.y++, dp.y += scale.y)
-		for(sp.x = fb->r.min.x, dp.x = dst->r.min.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){
-			/*if(scale.x == 2 && scale.y == 2)
-				scale2x_filter(blk, fb, &sp);
-			else if(scale.x == 3 && scale.y == 3)
-				scale3x_filter(blk, fb, &sp);
-			else */memsetl(blk, getpixel(fb, sp), scale.x*scale.y);
-			loadimage(dst, rectaddpt(blkr, dp), (uchar*)blk, scale.x*scale.y*4);
-		}
+	for(sp.x = fb->r.min.x, dp.x = dst->r.min.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){
+		/*if(scale.x == 2 && scale.y == 2)
+			scale2x_filter(blk, fb, &sp);
+		else if(scale.x == 3 && scale.y == 3)
+			scale3x_filter(blk, fb, &sp);
+		else */memsetl(blk, getpixel(fb, sp), scale.x*scale.y);
+		loadimage(dst, rectaddpt(blkr, dp), (uchar*)blk, scale.x*scale.y*4);
+	}
 	qunlock(ctl);
 	free(blk);
 }
@@ -132,7 +131,6 @@
 	Rectangle blkr;
 	Point sp, dp;
 	ulong *blk;
-	int i;
 
 	blk = emalloc(scale.x*scale.y*4);
 	blkr = Rect(0,0,scale.x,scale.y);
@@ -140,14 +138,14 @@
 	qlock(ctl);
 	fb = ctl->getfb(ctl);
 	for(sp.y = fb->r.min.y, dp.y = dst->r.min.y; sp.y < fb->r.max.y; sp.y++, dp.y += scale.y)
-		for(sp.x = fb->r.min.x, dp.x = dst->r.min.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){
-			/*if(scale.x == 2 && scale.y == 2)
-				scale2x_filter(blk, fb, &sp);
-			else if(scale.x == 3 && scale.y == 3)
-				scale3x_filter(blk, fb, &sp);
-			else */memsetl(blk, getpixel(fb, sp), scale.x*scale.y);
-			loadmemimage(dst, rectaddpt(blkr, dp), (uchar*)blk, scale.x*scale.y*4);
-		}
+	for(sp.x = fb->r.min.x, dp.x = dst->r.min.x; sp.x < fb->r.max.x; sp.x++, dp.x += scale.x){
+		/*if(scale.x == 2 && scale.y == 2)
+			scale2x_filter(blk, fb, &sp);
+		else if(scale.x == 3 && scale.y == 3)
+			scale3x_filter(blk, fb, &sp);
+		else */memsetl(blk, getpixel(fb, sp), scale.x*scale.y);
+		loadmemimage(dst, rectaddpt(blkr, dp), (uchar*)blk, scale.x*scale.y*4);
+	}
 	qunlock(ctl);
 	free(blk);
 }
--- a/graphics.h
+++ b/graphics.h
@@ -295,8 +295,8 @@
 		uvlong nframes;
 	} stats;
 	struct {
-		Rendertime R[100], E[100], Tn[100], Rn[100];
-		int cur;
+		Rendertime R[10], E[10], Tn[10], Rn[10];
+		int last, cur;
 	} times;
 };