[gtk+/wip/baedert/gl: 168/216] renderborder: Don't create border nodes for transparent borders



commit 31971c0574683641e09adbe4241bb6d919fdeabf
Author: Timm Bäder <mail baedert org>
Date:   Fri Dec 1 09:15:55 2017 +0100

    renderborder: Don't create border nodes for transparent borders
    
    Additionally to the existing early-out checks in that function already,
    check whether any side with border_width > 0 even has a non-transparent
    border.
    
    This saves absolutely not a single node in Adwaita. Damn you, Lapo.

 gtk/gtkrenderborder.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c
index 8e9c059..f036d35 100644
--- a/gtk/gtkrenderborder.c
+++ b/gtk/gtkrenderborder.c
@@ -953,6 +953,8 @@ gtk_css_style_snapshot_border (GtkCssStyle *style,
       GskRoundedRect border_box;
       GdkRGBA colors[4];
       graphene_simd4f_t alpha_test_vector;
+      int i;
+      gboolean render_border = FALSE;
 
       /* Optimize the most common case of "This widget has no border" */
       if (border_width[0] == 0 &&
@@ -970,6 +972,18 @@ gtk_css_style_snapshot_border (GtkCssStyle *style,
       if (graphene_simd4f_is_zero4 (alpha_test_vector))
         return;
 
+      for (i = 0; i < 4; i ++)
+        {
+          if (border_width[i] > 0 && !gdk_rgba_is_clear (&colors[i]))
+              {
+                render_border = TRUE;
+                break;
+              }
+        }
+
+      if (!render_border)
+        return;
+
       border_style[0] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, 
GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
       border_style[1] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, 
GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
       border_style[2] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, 
GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));


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