[gtk+: 3/5] Allow passing a color matrix when rendering icons



commit e4cdbef092d8dfd8ce23f4ca80beff5894fed8c3
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 23 11:42:23 2017 +0200

    Allow passing a color matrix when rendering icons
    
    This will be used for symbolic icons.
    Update all callers.

 gtk/gtkiconhelper.c        |    3 ++-
 gtk/gtkrendericon.c        |   16 ++++++++++++----
 gtk/gtkrendericonprivate.h |    4 +++-
 gtk/gtksnapshot.c          |    3 ++-
 4 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 4ea8428..5d47954 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -802,7 +802,8 @@ gtk_icon_helper_snapshot (GtkIconHelper *self,
   gtk_css_style_snapshot_icon_texture (style,
                                        snapshot,
                                        texture,
-                                       gtk_widget_get_scale_factor (self->owner));
+                                       gtk_widget_get_scale_factor (self->owner),
+                                       NULL, NULL);
 }
 
 gboolean
diff --git a/gtk/gtkrendericon.c b/gtk/gtkrendericon.c
index e38c2aa..b028d77 100644
--- a/gtk/gtkrendericon.c
+++ b/gtk/gtkrendericon.c
@@ -271,10 +271,12 @@ gtk_css_style_render_icon_get_extents (GtkCssStyle  *style,
 }
 
 void
-gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
-                                     GtkSnapshot *snapshot,
-                                     GskTexture  *texture,
-                                     double       texture_scale)
+gtk_css_style_snapshot_icon_texture (GtkCssStyle       *style,
+                                     GtkSnapshot       *snapshot,
+                                     GskTexture        *texture,
+                                     double             texture_scale,
+                                     graphene_matrix_t *color_matrix,
+                                     graphene_vec4_t *  color_offset)
 {
   const GtkCssValue *shadows_value, *transform_value, *filter_value;
   graphene_matrix_t transform_matrix;
@@ -307,6 +309,9 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
       gtk_snapshot_push_shadow (snapshot, shadows, n_shadows, "IconShadow<%zu>", n_shadows);
     }
 
+  if (color_matrix)
+    gtk_snapshot_push_color_matrix (snapshot, color_matrix, color_offset, "Recoloring Icon");
+
   if (graphene_matrix_is_identity (&transform_matrix))
     {
       graphene_rect_init (&bounds, 0, 0, width, height);
@@ -331,6 +336,9 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
       gtk_snapshot_pop (snapshot);
     }
 
+  if (color_matrix)
+    gtk_snapshot_pop (snapshot);
+
   if (n_shadows > 0)
     gtk_snapshot_pop (snapshot);
   
diff --git a/gtk/gtkrendericonprivate.h b/gtk/gtkrendericonprivate.h
index 2ab38f7..29b81c4 100644
--- a/gtk/gtkrendericonprivate.h
+++ b/gtk/gtkrendericonprivate.h
@@ -50,7 +50,9 @@ void    gtk_css_style_render_icon_surface       (GtkCssStyle            *style,
 void    gtk_css_style_snapshot_icon_texture     (GtkCssStyle            *style,
                                                  GtkSnapshot            *snapshot,
                                                  GskTexture             *texture,
-                                                 double                  texture_scale);
+                                                 double                  texture_scale,
+                                                 graphene_matrix_t *     color_matrix,
+                                                 graphene_vec4_t *       color_offset);
 
 void    gtk_css_style_render_icon_get_extents   (GtkCssStyle            *style,
                                                  GdkRectangle           *extents,
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 4413667..d9d463a 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -1517,7 +1517,8 @@ gtk_snapshot_render_icon (GtkSnapshot     *snapshot,
   gtk_css_style_snapshot_icon_texture (gtk_style_context_lookup_style (context),
                                        snapshot,
                                        texture,
-                                       1);
+                                       1,
+                                       NULL, NULL);
   gtk_snapshot_offset (snapshot, -x, -y);
   g_object_unref (texture);
 }


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