shithub: libgraphics

Download patch

ref: a09cfff78a96a10169a30324b75554827945fed4
parent: 91dfb6853d7b6d7ae49f54488b89e0eb73b5ff01
author: rodri <rgl@antares-labs.eu>
date: Sat Oct 5 06:07:34 EDT 2024

patch a leak in rectclipline. fix a pixel-discarding logic statement.

--- a/clip.c
+++ b/clip.c
@@ -199,8 +199,10 @@
 	perc = len == 0? 0: hypot(Δp.x, Δp.y)/len;
 	lerpvertex(&v[1], v0, v1, perc);
 
-	*v0 = dupvertex(&v[0]);
-	*v1 = dupvertex(&v[1]);
+	delvattrs(v0);
+	delvattrs(v1);
+	*v0 = v[0];
+	*v1 = v[1];
 }
 
 /*
--- a/fb.c
+++ b/fb.c
@@ -92,7 +92,7 @@
 	/* first run: get the domain */
 	f = (float*)src->data;
 	len = Dx(dst->r)*Dy(dst->r);
-	for(min = 0, max = 0; len--; f++){
+	for(min = max = 0; len--; f++){
 		if(isInf(*f, -1))	/* -∞ is the DNotacolor of the z-buffer */
 			continue;
 		min = min(*f, min);
--- a/render.c
+++ b/render.c
@@ -260,8 +260,8 @@
 
 			z = flerp(prim->v[0].p.z, prim->v[1].p.z, perc);
 			/* TODO get rid of the bounds check and make sure the clipping doesn't overflow */
-			if((ropts & RODepth) &&
-			   !ptinrect(p, params->fb->r) || z <= getdepth(zr, p))
+			if(!ptinrect(p, params->fb->r) ||
+			   ((ropts & RODepth) && z <= getdepth(zr, p)))
 				goto discard;
 
 			/* interpolate z⁻¹ and get actual z */