[gtk/wip/baedert/for-master: 10/10] renderborder: Make simple border case more obvious



commit 1301a2fa42c2a8bad919e879a382f2a147451c0a
Author: Timm Bäder <mail baedert org>
Date:   Wed Jan 29 10:40:10 2020 +0100

    renderborder: Make simple border case more obvious
    
    When reaching this point, it is impossible that all border styles are
    HIDDEN or NONE, but up to 3 of them can still be that style. In any
    case, the "none or solid" border style is the most common on there is,
    so try to make this simpler here by just appending a border node
    directly instead of going through the snaphshot_border path.

 gtk/gtkrenderborder.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c
index 232418ad64..74033a8671 100644
--- a/gtk/gtkrenderborder.c
+++ b/gtk/gtkrenderborder.c
@@ -703,12 +703,27 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
       border_width[3] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
 
       gtk_snapshot_push_debug (snapshot, "CSS border");
-      snapshot_border (snapshot,
-                       gtk_css_boxes_get_border_box (boxes),
-                       border_width,
-                       colors,
-                       border_style);
-      gtk_snapshot_pop (snapshot);
+      if (border_style[0] <= GTK_BORDER_STYLE_SOLID &&
+          border_style[1] <= GTK_BORDER_STYLE_SOLID &&
+          border_style[2] <= GTK_BORDER_STYLE_SOLID &&
+          border_style[3] <= GTK_BORDER_STYLE_SOLID)
+        {
+          /* The most common case of a solid border */
+          gtk_snapshot_append_border (snapshot,
+                                      gtk_css_boxes_get_border_box (boxes),
+                                      border_width,
+                                      colors);
+        }
+      else
+        {
+           snapshot_border (snapshot,
+                            gtk_css_boxes_get_border_box (boxes),
+                            border_width,
+                            colors,
+                            border_style);
+        }
+       gtk_snapshot_pop (snapshot);
+
     }
 }
 


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