diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-16 16:48:54 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-21 11:37:16 +0100 |
commit | df357f26ff72571acb840715efa4930054d4fdbe (patch) | |
tree | 66e9174c24c52564a5d691a21653c8b31a3b7156 /src/cairo-gstate.c | |
parent | f0cd20e6cec445eb627c2708c2230c8bad1b64ce (diff) |
Support component-alpha.
Within our code base we carried a few hacks to utilize the component
alpha capabilities of pixman, whilst not supporting the concept for our
own masks. Thus we were setting it upon the pixman_image_t that we
passed around through code that was blissfully unaware and indeed the
component-alpha property was forgotten (e.g. upgrading glyph masks).
The real issue is that without explicit support that a pattern carries
subpixel masking information, that information is lost when using that
pattern with composite. Again we can look at the example of compositing
a sub-pixel glyph mask onto a remote xlib surface for further failure.
Diffstat (limited to 'src/cairo-gstate.c')
-rw-r--r-- | src/cairo-gstate.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index 7ee88d6d..86e20bc9 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1002,17 +1002,22 @@ _cairo_gstate_mask (cairo_gstate_t *gstate, _cairo_gstate_copy_transformed_source (gstate, &source_pattern.base); _cairo_gstate_copy_transformed_mask (gstate, &mask_pattern.base, mask); - /* XXX: This optimization assumes that there is no color - * information in mask, so this will need to change if we - * support RENDER-style 4-channel masks. - */ if (source_pattern.type == CAIRO_PATTERN_TYPE_SOLID && mask_pattern.type == CAIRO_PATTERN_TYPE_SOLID) { cairo_color_t combined; - combined = source_pattern.solid.color; - _cairo_color_multiply_alpha (&combined, mask_pattern.solid.color.alpha); + if (mask_pattern.base.has_component_alpha) { +#define M(R, A, B, c) R.c = A.c * B.c + M(combined, source_pattern.solid.color, mask_pattern.solid.color, red); + M(combined, source_pattern.solid.color, mask_pattern.solid.color, green); + M(combined, source_pattern.solid.color, mask_pattern.solid.color, blue); + M(combined, source_pattern.solid.color, mask_pattern.solid.color, alpha); +#undef M + } else { + combined = source_pattern.solid.color; + _cairo_color_multiply_alpha (&combined, mask_pattern.solid.color.alpha); + } _cairo_pattern_init_solid (&source_pattern.solid, &combined, source_pattern.solid.content | |