Simplify the gtk_snapshot_icon_texture API
authorMatthias Clasen <mclasen@redhat.com>
Thu, 9 Nov 2017 03:21:42 +0000 (22:21 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 9 Nov 2017 03:21:42 +0000 (22:21 -0500)
Instead of passing the color matrix in from the outside,
just pass a boolean and set up the matrix internally.

gtk/gtkiconhelper.c
gtk/gtkrendericon.c
gtk/gtkrendericonprivate.h
gtk/gtksnapshot.c

index f0fa3cfd9a83a00aee98921f0f1d8d8723d4580d..094802ee8c25052bfbc36c571d0093022c2378c1 100644 (file)
@@ -609,38 +609,18 @@ gtk_icon_helper_snapshot (GtkIconHelper *self,
                           GtkSnapshot   *snapshot)
 {
   GtkCssStyle *style;
-  GdkTexture *texture;
-  graphene_matrix_t matrix;
-  graphene_vec4_t offset;
 
   style = gtk_css_node_get_style (self->node);
 
   gtk_icon_helper_ensure_texture (self);
-  texture = self->texture;
-  if (texture == NULL)
+  if (self->texture == NULL)
     return;
 
-  if (self->texture_is_symbolic)
-    {
-      GdkRGBA fg, sc, wc, ec;
-
-      gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
-
-      graphene_matrix_init_from_float (&matrix, (float[16]) {
-                                         sc.red - fg.red, sc.green - fg.green, sc.blue - fg.blue, 0,
-                                         wc.red - fg.red, wc.green - fg.green, wc.blue - fg.blue, 0,
-                                         ec.red - fg.red, ec.green - fg.green, ec.blue - fg.blue, 0,
-                                         0, 0, 0, fg.alpha
-                                       });
-      graphene_vec4_init (&offset, fg.red, fg.green, fg.blue, 0);
-    }
-
   gtk_css_style_snapshot_icon_texture (style,
                                        snapshot,
-                                       texture,
+                                       self->texture,
                                        self->texture_scale,
-                                       self->texture_is_symbolic ? &matrix : NULL,
-                                       self->texture_is_symbolic ? &offset : NULL);
+                                       self->texture_is_symbolic);
 }
 
 gboolean
index 2876e2d215b97de75786be4611e85790e4c83d40..620052a4e028debd9701bb2da30654634ec24c80 100644 (file)
@@ -264,12 +264,11 @@ gtk_css_style_render_icon_get_extents (GtkCssStyle  *style,
 }
 
 void
-gtk_css_style_snapshot_icon_texture (GtkCssStyle       *style,
-                                     GtkSnapshot       *snapshot,
-                                     GdkTexture        *texture,
-                                     double             texture_scale,
-                                     graphene_matrix_t *color_matrix,
-                                     graphene_vec4_t *  color_offset)
+gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
+                                     GtkSnapshot *snapshot,
+                                     GdkTexture  *texture,
+                                     double       texture_scale,
+                                     gboolean     recolor)
 {
   const GtkCssValue *shadows_value, *transform_value, *filter_value;
   graphene_matrix_t transform_matrix;
@@ -295,8 +294,24 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle       *style,
 
   has_shadow = gtk_css_shadows_value_push_snapshot (shadows_value, snapshot);
 
-  if (color_matrix)
-    gtk_snapshot_push_color_matrix (snapshot, color_matrix, color_offset, "Recoloring Icon");
+  if (recolor)
+    {
+      graphene_matrix_t color_matrix;
+      graphene_vec4_t color_offset;
+      GdkRGBA fg, sc, wc, ec;
+
+      gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
+
+      graphene_matrix_init_from_float (&color_matrix, (float[16]) {
+                                         sc.red - fg.red, sc.green - fg.green, sc.blue - fg.blue, 0,
+                                         wc.red - fg.red, wc.green - fg.green, wc.blue - fg.blue, 0,
+                                         ec.red - fg.red, ec.green - fg.green, ec.blue - fg.blue, 0,
+                                         0, 0, 0, fg.alpha
+                                       });
+      graphene_vec4_init (&color_offset, fg.red, fg.green, fg.blue, 0);
+
+      gtk_snapshot_push_color_matrix (snapshot, &color_matrix, &color_offset, "Recoloring Icon");
+    }
 
   if (graphene_matrix_is_identity (&transform_matrix))
     {
@@ -322,7 +337,7 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle       *style,
       gtk_snapshot_pop (snapshot);
     }
 
-  if (color_matrix)
+  if (recolor)
     gtk_snapshot_pop (snapshot);
 
   if (has_shadow)
index ae96b0803c2efad37639e703509e32c7bd144216..b8ea37380a0966bde9ff45d6e7e4a31132d4cddc 100644 (file)
@@ -51,8 +51,7 @@ void    gtk_css_style_snapshot_icon_texture     (GtkCssStyle            *style,
                                                  GtkSnapshot            *snapshot,
                                                  GdkTexture             *texture,
                                                  double                  texture_scale,
-                                                 graphene_matrix_t *     color_matrix,
-                                                 graphene_vec4_t *       color_offset);
+                                                 gboolean                recolor);
 
 void    gtk_css_style_render_icon_get_extents   (GtkCssStyle            *style,
                                                  GdkRectangle           *extents,
index bc85f9826dda950c61842b07e255cff6661ca4c6..888580604e08cdb97ed66304080b369f0b777af6 100644 (file)
@@ -1510,7 +1510,7 @@ gtk_snapshot_render_icon (GtkSnapshot     *snapshot,
                                        snapshot,
                                        texture,
                                        1,
-                                       NULL, NULL);
+                                       FALSE);
   gtk_snapshot_offset (snapshot, -x, -y);
   g_object_unref (texture);
 }