diff --git a/gsk/gl/resources/conic_gradient.glsl b/gsk/gl/resources/conic_gradient.glsl index eaa04aa3ad..9f56978439 100644 --- a/gsk/gl/resources/conic_gradient.glsl +++ b/gsk/gl/resources/conic_gradient.glsl @@ -75,10 +75,10 @@ void main() { if (offset < next_offset) { float f = (offset - curr_offset) / (next_offset - curr_offset); - vec4 curr_color = get_color(i); - vec4 next_color = get_color(i + 1); + vec4 curr_color = gsk_scaled_premultiply (get_color(i), u_alpha); + vec4 next_color = gsk_scaled_premultiply (get_color(i + 1), u_alpha); vec4 color = mix(curr_color, next_color, f); - gskSetScaledOutputColor(gsk_premultiply(color), u_alpha); + gskSetOutputColor(color); return; } } diff --git a/gsk/gl/resources/linear_gradient.glsl b/gsk/gl/resources/linear_gradient.glsl index 8a7a557f8e..d266cdbc79 100644 --- a/gsk/gl/resources/linear_gradient.glsl +++ b/gsk/gl/resources/linear_gradient.glsl @@ -97,10 +97,10 @@ void main() { if (offset < next_offset) { float f = (offset - curr_offset) / (next_offset - curr_offset); - vec4 curr_color = get_color(i); - vec4 next_color = get_color(i + 1); + vec4 curr_color = gsk_scaled_premultiply (get_color(i), u_alpha); + vec4 next_color = gsk_scaled_premultiply (get_color(i + 1), u_alpha); vec4 color = mix(curr_color, next_color, f); - gskSetScaledOutputColor(gsk_premultiply (color), u_alpha); + gskSetOutputColor(color); return; } } diff --git a/gsk/gl/resources/radial_gradient.glsl b/gsk/gl/resources/radial_gradient.glsl index d03ca96b8c..df95516237 100644 --- a/gsk/gl/resources/radial_gradient.glsl +++ b/gsk/gl/resources/radial_gradient.glsl @@ -77,10 +77,10 @@ void main() { if (offset < next_offset) { float f = (offset - curr_offset) / (next_offset - curr_offset); - vec4 curr_color = get_color(i); - vec4 next_color = get_color(i + 1); + vec4 curr_color = gsk_scaled_premultiply (get_color(i), u_alpha); + vec4 next_color = gsk_scaled_premultiply (get_color(i + 1), u_alpha); vec4 color = mix(curr_color, next_color, f); - gskSetScaledOutputColor(gsk_premultiply(color), u_alpha); + gskSetOutputColor(color); return; } } diff --git a/testsuite/gsk/compare/conic-gradient-premultiplied-nocairo.node b/testsuite/gsk/compare/conic-gradient-premultiplied-nocairo.node new file mode 100644 index 0000000000..904f92e269 --- /dev/null +++ b/testsuite/gsk/compare/conic-gradient-premultiplied-nocairo.node @@ -0,0 +1,15 @@ +color-matrix { + matrix: matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 100); + child: container { + conic-gradient { + bounds: 0 0 50 50; + center: 25 25; + stops: 0 rgb(255,0,0), 0.6 rgba(0,255,255,0); + } + conic-gradient { + bounds: 0 0 50 50; + center: 25 25; + stops: 0.4 rgba(0,255,255,0), 1 rgb(255,0,0); + } + } +} diff --git a/testsuite/gsk/compare/conic-gradient-premultiplied-nocairo.png b/testsuite/gsk/compare/conic-gradient-premultiplied-nocairo.png new file mode 100644 index 0000000000..f38936c8ed Binary files /dev/null and b/testsuite/gsk/compare/conic-gradient-premultiplied-nocairo.png differ diff --git a/testsuite/gsk/compare/linear-gradient-premultiplied-nocairo.node b/testsuite/gsk/compare/linear-gradient-premultiplied-nocairo.node new file mode 100644 index 0000000000..deac742b4b --- /dev/null +++ b/testsuite/gsk/compare/linear-gradient-premultiplied-nocairo.node @@ -0,0 +1,9 @@ +color-matrix { + matrix: matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 100); + child: linear-gradient { + bounds: 0 0 50 50; + start: 0 -50; + end: 0 100; + stops: 0 rgb(255,0,0), 1 rgba(0,255,255,0); + } +} diff --git a/testsuite/gsk/compare/linear-gradient-premultiplied-nocairo.png b/testsuite/gsk/compare/linear-gradient-premultiplied-nocairo.png new file mode 100644 index 0000000000..f38936c8ed Binary files /dev/null and b/testsuite/gsk/compare/linear-gradient-premultiplied-nocairo.png differ diff --git a/testsuite/gsk/compare/radial-gradient-premultiplied-nocairo.node b/testsuite/gsk/compare/radial-gradient-premultiplied-nocairo.node new file mode 100644 index 0000000000..4f76663c0f --- /dev/null +++ b/testsuite/gsk/compare/radial-gradient-premultiplied-nocairo.node @@ -0,0 +1,10 @@ +color-matrix { + matrix: matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 100); + child: radial-gradient { + bounds: 0 0 50 50; + center: 25 25; + hradius: 40; + vradius: 40; + stops: 0 rgb(255,0,0), 1 rgba(0,255,255,0); + } +} diff --git a/testsuite/gsk/compare/radial-gradient-premultiplied-nocairo.png b/testsuite/gsk/compare/radial-gradient-premultiplied-nocairo.png new file mode 100644 index 0000000000..f38936c8ed Binary files /dev/null and b/testsuite/gsk/compare/radial-gradient-premultiplied-nocairo.png differ diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index ca6d210f82..fa6cda3eca 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -48,6 +48,7 @@ compare_render_tests = [ 'color-matrix-merge', 'color-matrix-parsing', 'color-states', + 'conic-gradient-premultiplied-nocairo', 'conic-gradient-with-64-colorstops', 'container-single-child-offscreen-for-opacity', 'crossfade-clip-both-children', @@ -100,6 +101,7 @@ compare_render_tests = [ 'issue-3615', 'linear-gradient-3d-nocairo', 'linear-gradient-nonorthogonal-scale-nogl', + 'linear-gradient-premultiplied-nocairo', 'linear-gradient-with-64-colorstops', 'lots-of-offscreens-nogl', 'mask', @@ -133,6 +135,7 @@ compare_render_tests = [ 'outset-shadow-scale-offset', 'outset_shadow_simple', 'premul-color-nogl', + 'radial-gradient-premultiplied-nocairo', 'radial-gradient-with-64-colorstops', 'repeat', 'repeating-linear-gradient-edge-colors',