[gtk+/wip/matthiasc/icon-texture-cache: 6/6] wip: use a color matrix for symbolic icons



commit 1dc1da960c9b03163cdbd7293d3132ab1073b378
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 23 09:08:25 2017 +0200

    wip: use a color matrix for symbolic icons
    
    The recoloring of symbolic icons is just a color matrix
    operation.
    
    Currently does not quite yield the correct highlight colors.

 gtk/gtkiconhelper.c |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 4ea8428..e7aea5d 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -505,11 +505,7 @@ find_cached_texture (GtkIconHelper *self)
     return NULL;
 
   if (gtk_icon_info_is_symbolic (info))
-    {
-      // FIXME
-      g_object_unref (info);
-      return NULL;
-    }
+      self->rendered_surface_is_symbolic = TRUE;
 
   texture = gtk_icon_info_load_texture (info);
 
@@ -798,11 +794,34 @@ gtk_icon_helper_snapshot (GtkIconHelper *self,
   texture = self->texture;
   if (texture == NULL)
     return;
- 
+
+  if (self->rendered_surface_is_symbolic)
+    {
+      GdkRGBA fg, sc, wc, ec;
+      graphene_matrix_t matrix;
+      graphene_vec4_t offset, r0, r1, r2, r3;
+
+      gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
+
+      graphene_vec4_init (&r0, sc.red   - fg.red,   wc.red   - fg.red,   ec.red   - fg.red,   0);
+      graphene_vec4_init (&r1, sc.green - fg.green, wc.green - fg.green, ec.green - fg.green, 0);
+      graphene_vec4_init (&r2, sc.blue  - fg.blue,  wc.blue  - fg.blue,  ec.blue  - fg.blue,  0);
+      graphene_vec4_init (&r3, 0, 0, 0, fg.alpha);
+      graphene_vec4_init (&offset, fg.red, fg.green, fg.blue, 0);
+      graphene_matrix_init_from_vec4 (&matrix, &r0, &r1, &r2, &r3);
+
+      gtk_snapshot_push_color_matrix (snapshot, &matrix, &offset, "Symbolic Icon");
+    }
+
   gtk_css_style_snapshot_icon_texture (style,
                                        snapshot,
                                        texture,
                                        gtk_widget_get_scale_factor (self->owner));
+
+  if (self->rendered_surface_is_symbolic)
+    {
+      gtk_snapshot_pop (snapshot);
+    }
 }
 
 gboolean


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