[gtk/ngl-less-shaders: 1/13] ngl: Consistently use gsk_scaled_premultiply




commit 2a995ece99fd8f3b0b1eb85c8fa29b7fe8790408
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Mar 13 10:17:34 2021 -0500

    ngl: Consistently use gsk_scaled_premultiply
    
    Its not going to make much of a difference, but we
    can just as well be consistent.

 gsk/ngl/resources/border.glsl        | 2 +-
 gsk/ngl/resources/color.glsl         | 2 +-
 gsk/ngl/resources/color_matrix.glsl  | 4 +---
 gsk/ngl/resources/coloring.glsl      | 2 +-
 gsk/ngl/resources/inset_shadow.glsl  | 2 +-
 gsk/ngl/resources/outset_shadow.glsl | 2 +-
 6 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/gsk/ngl/resources/border.glsl b/gsk/ngl/resources/border.glsl
index a9c04556a4..4f47ab87dc 100644
--- a/gsk/ngl/resources/border.glsl
+++ b/gsk/ngl/resources/border.glsl
@@ -11,7 +11,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
 void main() {
   gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
 
-  final_color = gsk_premultiply(aColor) * u_alpha;
+  final_color = gsk_scaled_premultiply(aColor, u_alpha);
 
   GskRoundedRect outside = gsk_create_rect(u_outline_rect);
   GskRoundedRect inside = gsk_rounded_rect_shrink (outside, u_widths);
diff --git a/gsk/ngl/resources/color.glsl b/gsk/ngl/resources/color.glsl
index 670b9979a2..ba98b1b170 100644
--- a/gsk/ngl/resources/color.glsl
+++ b/gsk/ngl/resources/color.glsl
@@ -6,7 +6,7 @@ _OUT_ vec4 final_color;
 void main() {
   gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
 
-  final_color = gsk_premultiply(aColor) * u_alpha;
+  final_color = gsk_scaled_premultiply(aColor, u_alpha);
 }
 
 // FRAGMENT_SHADER:
diff --git a/gsk/ngl/resources/color_matrix.glsl b/gsk/ngl/resources/color_matrix.glsl
index 44dcf9a044..51835f056f 100644
--- a/gsk/ngl/resources/color_matrix.glsl
+++ b/gsk/ngl/resources/color_matrix.glsl
@@ -23,7 +23,5 @@ void main() {
   color = u_color_matrix * color + u_color_offset;
   color = clamp(color, 0.0, 1.0);
 
-  color.rgb *= color.a;
-
-  gskSetOutputColor(color * u_alpha);
+  gskSetOutputColor(gsk_scaled_premultiply(color, u_alpha));
 }
diff --git a/gsk/ngl/resources/coloring.glsl b/gsk/ngl/resources/coloring.glsl
index 69b21c6e2e..ccdc292dc4 100644
--- a/gsk/ngl/resources/coloring.glsl
+++ b/gsk/ngl/resources/coloring.glsl
@@ -17,7 +17,7 @@ void main() {
   else
     use_color = 1;
 
-  final_color = gsk_premultiply(aColor) * u_alpha;
+  final_color = gsk_scaled_premultiply(aColor, u_alpha);
 }
 
 // FRAGMENT_SHADER:
diff --git a/gsk/ngl/resources/inset_shadow.glsl b/gsk/ngl/resources/inset_shadow.glsl
index 1c3c955035..8cff1edee1 100644
--- a/gsk/ngl/resources/inset_shadow.glsl
+++ b/gsk/ngl/resources/inset_shadow.glsl
@@ -12,7 +12,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
 void main() {
   gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
 
-  final_color = gsk_premultiply(aColor) * u_alpha;
+  final_color = gsk_scaled_premultiply(aColor, u_alpha);
 
   GskRoundedRect outside = gsk_create_rect(u_outline_rect);
   GskRoundedRect inside = gsk_rounded_rect_shrink(outside, vec4(u_spread));
diff --git a/gsk/ngl/resources/outset_shadow.glsl b/gsk/ngl/resources/outset_shadow.glsl
index 427aee956c..0ab943b070 100644
--- a/gsk/ngl/resources/outset_shadow.glsl
+++ b/gsk/ngl/resources/outset_shadow.glsl
@@ -11,7 +11,7 @@ void main() {
 
   vUv = vec2(aUv.x, aUv.y);
 
-  final_color = gsk_premultiply(aColor) * u_alpha;
+  final_color = gsk_scaled_premultiply(aColor, u_alpha);
 
   GskRoundedRect outline = gsk_create_rect(u_outline_rect);
   gsk_rounded_rect_transform(outline, u_modelview);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]