[Pixman] [PATCH] test: List more details of the operation when running scaling-test verbosely

Ben Avison bavison at riscosopen.org
Thu Aug 20 05:07:48 PDT 2015


---
I've been doing a fair bit of work on scaled plots again recently, and I was
finding that scaling-test omitted to mention lots of useful information
(notably whether a mask was used, and what the mask parameers were).

 test/scaling-test.c |   63 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/test/scaling-test.c b/test/scaling-test.c
index e2f7fa9..02bd0d0 100644
--- a/test/scaling-test.c
+++ b/test/scaling-test.c
@@ -73,7 +73,7 @@ test_composite (int      testnum,
     pixman_op_t        op;
     pixman_repeat_t    repeat = PIXMAN_REPEAT_NONE;
     pixman_repeat_t    mask_repeat = PIXMAN_REPEAT_NONE;
-    pixman_format_code_t src_fmt, dst_fmt;
+    pixman_format_code_t src_fmt, mask_fmt, dst_fmt;
     uint32_t *         srcbuf;
     uint32_t *         dstbuf;
     uint32_t *         maskbuf;
@@ -145,6 +145,7 @@ test_composite (int      testnum,
     prng_randmemset (dstbuf, dst_stride * dst_height, 0);
 
     src_fmt = get_format (src_bpp);
+    mask_fmt = PIXMAN_a8;
     dst_fmt = get_format (dst_bpp);
 
     if (prng_rand_n (2))
@@ -169,7 +170,7 @@ test_composite (int      testnum,
         src_fmt, src_width, src_height, srcbuf, src_stride);
 
     mask_img = pixman_image_create_bits (
-        PIXMAN_a8, mask_width, mask_height, maskbuf, mask_stride);
+        mask_fmt, mask_width, mask_height, maskbuf, mask_stride);
 
     dst_img = pixman_image_create_bits (
         dst_fmt, dst_width, dst_height, dstbuf, dst_stride);
@@ -255,21 +256,6 @@ test_composite (int      testnum,
     else
 	pixman_image_set_filter (mask_img, PIXMAN_FILTER_BILINEAR, NULL, 0);
 
-    if (verbose)
-    {
-	printf ("src_fmt=%s, dst_fmt=%s\n", 
-		format_name (src_fmt), format_name (dst_fmt));
-	printf ("op=%s, scale_x=%d, scale_y=%d, repeat=%d\n",
-	        operator_name (op), scale_x, scale_y, repeat);
-	printf ("translate_x=%d, translate_y=%d\n",
-	        translate_x, translate_y);
-	printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
-	        src_width, src_height, dst_width, dst_height);
-	printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n",
-	        src_x, src_y, dst_x, dst_y);
-	printf ("w=%d, h=%d\n", w, h);
-    }
-
     if (prng_rand_n (8) == 0)
     {
 	pixman_box16_t clip_boxes[2];
@@ -352,10 +338,42 @@ test_composite (int      testnum,
     }
 
     if (prng_rand_n (2) == 0)
-	pixman_image_composite (op, src_img, NULL, dst_img,
-                            src_x, src_y, 0, 0, dst_x, dst_y, w, h);
-    else
-	pixman_image_composite (op, src_img, mask_img, dst_img,
+    {
+        mask_fmt = PIXMAN_null;
+        pixman_image_unref (mask_img);
+        mask_img = NULL;
+        mask_x = 0;
+        mask_y = 0;
+    }
+
+    if (verbose)
+    {
+        printf ("op=%s, src_fmt=%s, mask_fmt=%s, dst_fmt=%s\n",
+                operator_name (op), format_name (src_fmt), format_name (mask_fmt), format_name (dst_fmt));
+        printf ("scale_x=%d, scale_y=%d, repeat=%d, filter=%d\n",
+                scale_x, scale_y, repeat, src_img->common.filter);
+        printf ("translate_x=%d, translate_y=%d\n",
+                translate_x, translate_y);
+        if (mask_fmt != PIXMAN_null)
+        {
+            printf ("mask_scale_x=%d, mask_scale_y=%d, mask_repeat=%d, mask_filter=%d\n",
+                    mask_scale_x, mask_scale_y, mask_repeat, mask_img->common.filter);
+            printf ("mask_translate_x=%d, mask_translate_y=%d\n",
+                    mask_translate_x, mask_translate_y);
+        }
+        printf ("src_width=%d, src_height=%d, ",
+                src_width, src_height);
+        if (mask_fmt != PIXMAN_null)
+        {
+            printf ("mask_width=%d, mask_height=%d, ",
+                    mask_width, mask_height);
+        }
+        printf ("dst_width=%d, dst_height=%d\n",
+                dst_width, dst_height);
+        printf ("w=%d, h=%d\n", w, h);
+    }
+
+    pixman_image_composite (op, src_img, mask_img, dst_img,
                             src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h);
 
     crc32 = compute_crc32_for_image (0, dst_img);
@@ -364,7 +382,8 @@ test_composite (int      testnum,
 	print_image (dst_img);
 
     pixman_image_unref (src_img);
-    pixman_image_unref (mask_img);
+    if (mask_img != NULL)
+        pixman_image_unref (mask_img);
     pixman_image_unref (dst_img);
 
     if (src_stride < 0)
-- 
1.7.5.4



More information about the Pixman mailing list