From: Siarhei Siamashka <[email protected]>

Looks like PDF blend modes have some problems with fixed point arithmetics.

But probably 'composite' test program is a more appropriate place for
verifying this.

---
 test/blitters-test.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/test/blitters-test.c b/test/blitters-test.c
index 21685b1..c58de09 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -248,6 +248,7 @@ test_composite (int testnum, int verbose)
     int mask_x, mask_y;
     int w, h;
     int op;
+    int src_repeat_flag = 0;
     pixman_format_code_t src_fmt, dst_fmt, mask_fmt;
     uint32_t *dstbuf, *srcbuf, *maskbuf;
     uint32_t crc32;
@@ -283,6 +284,7 @@ test_composite (int testnum, int verbose)
                                       max_extra_stride, &src_fmt);
 
        pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL);
+       src_repeat_flag = 1;
     }
 
     dst_img = create_random_image (img_fmt_list, max_width, max_height,
@@ -363,6 +365,57 @@ test_composite (int testnum, int verbose)
        printf ("w=%d, h=%d\n", w, h);
     }
 
+    /*
+     * Extra test for correctness.
+     */
+    if (src_fmt != PIXMAN_a8r8g8b8)
+    {
+       int j;
+       pixman_image_t *test_src_img = pixman_image_create_bits (
+           PIXMAN_a8r8g8b8, src_width, src_height, NULL, src_width * 4);
+       pixman_image_t *test_dst1_img = pixman_image_create_bits (
+           PIXMAN_a8r8g8b8, dst_width, dst_height, NULL, dst_width * 4);
+       pixman_image_t *test_dst2_img = pixman_image_create_bits (
+           PIXMAN_a8r8g8b8, dst_width, dst_height, NULL, dst_width * 4);
+
+       uint8_t *bits_dst1 = (uint8_t *) test_dst1_img->bits.bits;
+       uint8_t *bits_dst2 = (uint8_t *) test_dst2_img->bits.bits;
+
+       pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, test_src_img,
+                               0, 0, 0, 0, 0, 0, src_width, src_height);
+       if (src_repeat_flag)
+           pixman_image_set_repeat (test_src_img, PIXMAN_REPEAT_NORMAL);
+       pixman_image_composite (PIXMAN_OP_SRC, dst_img, NULL, test_dst1_img,
+                               0, 0, 0, 0, 0, 0, dst_width, dst_height);
+       pixman_image_composite (PIXMAN_OP_SRC, dst_img, NULL, test_dst2_img,
+                               0, 0, 0, 0, 0, 0, dst_width, dst_height);
+
+       pixman_image_composite (op, test_src_img, mask_img, test_dst1_img, 
src_x, src_y,
+                               mask_x, mask_y, dst_x, dst_y, w, h);
+       pixman_image_composite (op, src_img, mask_img, test_dst2_img, src_x, 
src_y,
+                               mask_x, mask_y, dst_x, dst_y, w, h);
+
+       for (i = 0; i < dst_height; i++)
+       {
+           for (j = 0; j < dst_width * 4; j++)
+           {
+               int pix1 = *(bits_dst1 + i * dst_width * 4 + j);
+               int pix2 = *(bits_dst2 + i * dst_width * 4 + j);
+               if (abs (pix1 - pix2) > 8)
+               {
+                   printf ("test=%d, op=0x%X, %d != %d, i=%d, j=%d\n",
+                           testnum, op, pix1, pix2, i, j);
+                   if (!verbose)
+                       abort ();
+               }
+           }
+       }
+
+       pixman_image_unref (test_src_img);
+       pixman_image_unref (test_dst1_img);
+       pixman_image_unref (test_dst2_img);
+    }
+
     pixman_image_composite (op, src_img, mask_img, dst_img,
                            src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h);
 
-- 
1.7.2.2

_______________________________________________
Pixman mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pixman

Reply via email to