[gtk/wip/baedert/stb-rect-pack: 3/6] rendericon: Ignore transparent icons



commit 20827db6debd88932bfdaa39c8ee8ce2769edc39
Author: Timm Bäder <mail baedert org>
Date:   Fri Feb 8 06:12:57 2019 +0100

    rendericon: Ignore transparent icons
    
    Icon recoloring is implemented via a color matrix, but the GtkSnapshot
    code only has an optimization for opacity nodes for the "everything is
    transparent anyway" case.
    
    Just skip icon entirely if the color matrix would multiply their alpha
    value with 0 and cause them to be entirely invisible.

 gtk/gtkrendericon.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gtk/gtkrendericon.c b/gtk/gtkrendericon.c
index 2d2dfa05f5..a4d867001f 100644
--- a/gtk/gtkrendericon.c
+++ b/gtk/gtkrendericon.c
@@ -133,6 +133,9 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle  *style,
 
       gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
 
+      if (fg.alpha == 0.0f)
+        goto transparent;
+
       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,
@@ -171,5 +174,6 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle  *style,
   if (has_shadow)
     gtk_snapshot_pop (snapshot);
 
+transparent:
   gtk_css_filter_value_pop_snapshot (filter_value, snapshot);
 }


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