diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2013-10-18 16:39:38 -0400 |
---|---|---|
committer | Søren Sandmann <ssp@redhat.com> | 2014-01-04 16:13:27 -0500 |
commit | 89662adf77c69c3f71ded9cd8818ac5626b68451 (patch) | |
tree | 9aac45c00cebef6154e556e55dcfe51009ce472d /pixman | |
parent | e7a99b3b0f605d3f9937bc79e4385c6b71df7845 (diff) |
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.
Diffstat (limited to 'pixman')
-rw-r--r-- | pixman/pixman-combine32.c | 11 |
1 files changed, 8 insertions, 3 deletions
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)); \ |