From: Søren Sandmann Pedersen Date: Fri, 18 Oct 2013 20:39:38 +0000 (-0400) Subject: pixman-combine32.c: Fix bugs related to integer promotion X-Git-Tag: pixman-0.33.2~75 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89662adf77c69c3f71ded9cd8818ac5626b68451;p=platform%2Fupstream%2Fpixman.git pixman-combine32.c: Fix bugs related to integer promotion In the component alpha part of the PDF_SEPARABLE_BLEND_MODE macro, the expression ~RED_8 (m) is used. Because RED_8(m) gets promoted to int before ~ is applied, the whole expression typically becomes some negative value rather than (255 - RED_8(m)) as desired. Fix this by using unsigned temporary variables. This reduces the number of failures in pixel-test to 363. --- diff --git a/pixman/pixman-combine32.c b/pixman/pixman-combine32.c index 977c057..01c2523 100644 --- a/pixman/pixman-combine32.c +++ b/pixman/pixman-combine32.c @@ -640,13 +640,18 @@ combine_multiply_ca (pixman_implementation_t *imp, uint8_t da = ALPHA_8 (d); \ uint8_t ida = ~da; \ int32_t ra, rr, rg, rb; \ + uint8_t ira, iga, iba; \ \ combine_mask_ca (&s, &m); \ \ + ira = ~RED_8 (m); \ + iga = ~GREEN_8 (m); \ + iba = ~BLUE_8 (m); \ + \ ra = da * 0xff + ALPHA_8 (s) * 0xff - ALPHA_8 (s) * da; \ - rr = (~RED_8 (m)) * RED_8 (d) + ida * RED_8 (s); \ - rg = (~GREEN_8 (m)) * GREEN_8 (d) + ida * GREEN_8 (s); \ - rb = (~BLUE_8 (m)) * BLUE_8 (d) + ida * BLUE_8 (s); \ + rr = ira * RED_8 (d) + ida * RED_8 (s); \ + rg = iga * GREEN_8 (d) + ida * GREEN_8 (s); \ + rb = iba * BLUE_8 (d) + ida * BLUE_8 (s); \ \ rr += blend_ ## name (RED_8 (d), da, RED_8 (s), RED_8 (m)); \ rg += blend_ ## name (GREEN_8 (d), da, GREEN_8 (s), GREEN_8 (m)); \ diff --git a/test/blitters-test.c b/test/blitters-test.c index ac8901f..e2a2e7f 100644 --- a/test/blitters-test.c +++ b/test/blitters-test.c @@ -394,6 +394,6 @@ main (int argc, const char *argv[]) } return fuzzer_test_main("blitters", 2000000, - 0x613BBD64, + 0xB1D1F40E, test_composite, argc, argv); }