[Piglit] [PATCH 2/2] gbm: Use caca_flop to vertically flop the output

Jordan Justen jordan.l.justen at intel.com
Mon Jan 5 08:41:48 PST 2015


Ken pointed out cucul_flop in the original libcaca patch, but going
back to 2008-09-27, r2821,
http://caca.zoy.org/browser/libcaca/trunk/caca/caca.h?rev=2821#L251
caca_flop seems to be preferred.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 .../util/piglit-framework-gl/piglit_gbm_framework.c  | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/tests/util/piglit-framework-gl/piglit_gbm_framework.c b/tests/util/piglit-framework-gl/piglit_gbm_framework.c
index 8728f58..cec438c 100644
--- a/tests/util/piglit-framework-gl/piglit_gbm_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_gbm_framework.c
@@ -110,7 +110,6 @@ piglit_gbm_console_display(void)
 	uint32_t *pixels;
 	size_t export_size;
 	int width = 40, height = 20;
-	int i;
 
 	canvas = caca_create_canvas(width, height);
 	if (!canvas) {
@@ -130,8 +129,7 @@ piglit_gbm_console_display(void)
 		return;
 	}
 
-	/* Note: we allocate memory for 1 extra row */
-	pixels = malloc(4 * piglit_width * (piglit_height + 1));
+	pixels = malloc(4 * piglit_width * piglit_height);
 
 	while (!piglit_check_gl_error(GL_NO_ERROR)) {
 		/* Clear any OpenGL errors */
@@ -146,21 +144,7 @@ piglit_gbm_console_display(void)
 		return;
 	}
 
-	/* Swap the image's pixels vertically using the extra
-	 * row of pixels that we allocated as swap space.
-	 */
-	for (i = 0; i < (piglit_height / 2); i++) {
-		memcpy(&pixels[piglit_width * piglit_height],
-		       &pixels[piglit_width * i],
-		       4 * piglit_width);
-		memcpy(&pixels[piglit_width * i],
-		       &pixels[piglit_width * (piglit_height - 1 - i)],
-		       4 * piglit_width);
-		memcpy(&pixels[piglit_width * (piglit_height - 1 - i)],
-		       &pixels[piglit_width * piglit_height],
-		       4 * piglit_width);
-	}
-
+	caca_flop(canvas);
 	caca_dither_bitmap(canvas, 0, 0, width, height, dither, pixels);
 	caca_free_dither(dither);
 	free(pixels);
-- 
2.1.3



More information about the Piglit mailing list