renderborder: Make simple border case more obvious
authorTimm Bäder <mail@baedert.org>
Wed, 29 Jan 2020 09:40:10 +0000 (10:40 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 7 Feb 2020 18:15:59 +0000 (13:15 -0500)
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 snapshot_border path.

gtk/gtkrenderborder.c

index 1396e7833e708c8fca20651f5720cec8c6b12430..a137d0814c9edcd65dd7a0781f79e2106dd62519 100644 (file)
@@ -707,12 +707,26 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
       border_width[3] = _gtk_css_number_value_get (border->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);
     }
 }