Bug 539165. Fix single and multi-stop solid gradients by multiplying by the alpha component. r=roc

This cairo commit that caused the problem: 2d790daa957471670f4ae0d3b22da89e4ee7111f.
It was merged into mozilla-central with 1effb72d30cf
This commit is contained in:
Jeff Muizelaar 2010-01-12 17:04:00 -05:00
parent d2247e1c10
commit 5562b46b91
6 changed files with 138 additions and 2 deletions

View File

@ -64,6 +64,8 @@ quartz-first-stop.patch: return the first stop for negative positions on the gra
quartz-glyph-extents.patch: bug 534260; work around incorrect glyph extents returned by quartz for anomalous empty glyphs
premultiply-alpha-solid-gradients.patch: bug 539165; multiply the solid color by the alpha component before using it for a solid surface
==== pixman patches ====
pixman-neon.patch: add ARM NEON optimized compositing functions

View File

@ -2262,8 +2262,17 @@ _cairo_pattern_acquire_surface (const cairo_pattern_t *pattern,
if (src->n_stops)
{
cairo_color_t color;
/* multiply by alpha */
_cairo_color_init_rgba (&color,
src->stops->color.red,
src->stops->color.green,
src->stops->color.blue,
src->stops->color.alpha);
_cairo_pattern_init_solid (&solid,
&src->stops->color,
&color,
CAIRO_CONTENT_COLOR_ALPHA);
}
else
@ -2295,9 +2304,17 @@ _cairo_pattern_acquire_surface (const cairo_pattern_t *pattern,
}
if (i == src->n_stops) {
cairo_solid_pattern_t solid;
cairo_color_t color;
/* multiply by alpha */
_cairo_color_init_rgba (&color,
src->stops->color.red,
src->stops->color.green,
src->stops->color.blue,
src->stops->color.alpha);
_cairo_pattern_init_solid (&solid,
&src->stops->color,
&color,
CAIRO_CONTENT_COLOR_ALPHA);
status =

View File

@ -0,0 +1,46 @@
Fix single and multi-stop solid gradients by multiplying by the alpha component. r=roc
This cairo commit that caused the problem: 2d790daa957471670f4ae0d3b22da89e4ee7111f.
It was merged into mozilla-central with 1effb72d30cf
diff --git a/gfx/cairo/cairo/src/cairo-pattern.c b/gfx/cairo/cairo/src/cairo-pattern.c
--- a/gfx/cairo/cairo/src/cairo-pattern.c
+++ b/gfx/cairo/cairo/src/cairo-pattern.c
@@ -2262,8 +2262,17 @@ _cairo_pattern_acquire_surface (const ca
if (src->n_stops)
{
+ cairo_color_t color;
+
+ /* multiply by alpha */
+ _cairo_color_init_rgba (&color,
+ src->stops->color.red,
+ src->stops->color.green,
+ src->stops->color.blue,
+ src->stops->color.alpha);
+
_cairo_pattern_init_solid (&solid,
- &src->stops->color,
+ &color,
CAIRO_CONTENT_COLOR_ALPHA);
}
else
@@ -2295,9 +2304,17 @@ _cairo_pattern_acquire_surface (const ca
}
if (i == src->n_stops) {
cairo_solid_pattern_t solid;
+ cairo_color_t color;
+
+ /* multiply by alpha */
+ _cairo_color_init_rgba (&color,
+ src->stops->color.red,
+ src->stops->color.green,
+ src->stops->color.blue,
+ src->stops->color.alpha);
_cairo_pattern_init_solid (&solid,
- &src->stops->color,
+ &color,
CAIRO_CONTENT_COLOR_ALPHA);
status =

View File

@ -0,0 +1,42 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<title>Testcase for opacity on elements referencing a gradient</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=539165 -->
<defs>
<linearGradient id="lime" gradientUnits="userSpaceOnUse">
<stop stop-color="lime"/>
</linearGradient>
<linearGradient id="red" gradientUnits="userSpaceOnUse">
<stop stop-color="red"/>
</linearGradient>
<linearGradient id="red2" gradientUnits="userSpaceOnUse">
<stop stop-color="red" offset="0%"/>
<stop stop-color="red" offset="100%"/>
</linearGradient>
<linearGradient id="redgreen" gradientUnits="userSpaceOnUse">
<stop stop-color="red" offset="0%"/>
<stop stop-color="lime" offset="100%"/>
</linearGradient>
</defs>
<rect width="100%" height="100%" fill="url(#lime)"/>
<!-- test 'opacity' -->
<rect width="25%" height="100%" fill="url(#red)" opacity="0.5"/>
<!-- test 'fill-opacity' -->
<rect x="25%" width="25%" height="100%" fill="url(#red)" fill-opacity="0.5"/>
<!-- test 'fill-opacity' -->
<rect x="50%" width="25%" height="100%" fill="url(#red2)" fill-opacity="0.5"/>
<!-- test 'fill-opacity' -->
<rect x="75%" width="25%" height="100%" fill="url(#redgreen)" fill-opacity="0"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,28 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<title>Testcase for opacity on elements referencing a gradient</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=539165 -->
<defs>
<linearGradient id="lime" gradientUnits="userSpaceOnUse">
<stop stop-color="lime"/>
</linearGradient>
</defs>
<rect width="100%" height="100%" fill="url(#lime)"/>
<!-- test 'opacity' -->
<rect width="25%" height="100%" fill="red" opacity="0.5"/>
<!-- test 'fill-opacity' -->
<rect x="25%" width="25%" height="100%" fill="red" fill-opacity="0.5"/>
<!-- test 'fill-opacity' -->
<rect x="50%" width="25%" height="100%" fill="red" fill-opacity="0.5"/>
</svg>

After

Width:  |  Height:  |  Size: 818 B

View File

@ -101,6 +101,7 @@ fails == inline-in-xul-basic-01.xul pass.svg
== objectBoundingBox-and-pattern-01b.svg objectBoundingBox-and-pattern-01-ref.svg
== objectBoundingBox-and-pattern-01c.svg objectBoundingBox-and-pattern-01-ref.svg
fails-if(http.oscpu.match(/Mac\x20OS\x20X\x2010\.4$/)) == opacity-and-gradient-01.svg pass.svg # fails on OS X 10.4 (bug 379610)
== opacity-and-gradient-02.svg opacity-and-gradient-02-ref.svg
== opacity-and-pattern-01.svg pass.svg
== path-01.svg path-01-ref.svg
== pattern-live-01a.svg pattern-live-01-ref.svg