[gtk+] Simplify the gtk_snapshot_icon_texture API



commit 2aa52c7d0083f39615f33f663f247dc3fe2e23df
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 8 22:21:42 2017 -0500

    Simplify the gtk_snapshot_icon_texture API
    
    Instead of passing the color matrix in from the outside,
    just pass a boolean and set up the matrix internally.

 gtk/gtkiconhelper.c        |   26 +++-----------------------
 gtk/gtkrendericon.c        |   33 ++++++++++++++++++++++++---------
 gtk/gtkrendericonprivate.h |    3 +--
 gtk/gtksnapshot.c          |    2 +-
 4 files changed, 29 insertions(+), 35 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index f0fa3cf..094802e 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -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
diff --git a/gtk/gtkrendericon.c b/gtk/gtkrendericon.c
index 2876e2d..620052a 100644
--- a/gtk/gtkrendericon.c
+++ b/gtk/gtkrendericon.c
@@ -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)
diff --git a/gtk/gtkrendericonprivate.h b/gtk/gtkrendericonprivate.h
index ae96b08..b8ea373 100644
--- a/gtk/gtkrendericonprivate.h
+++ b/gtk/gtkrendericonprivate.h
@@ -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,
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index bc85f98..8885806 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -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);
 }


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