[gtk/wip/baedert/gl-rework: 170/176] renderborder: Only get border width if we really need to



commit 58b4791d47d1a18d61ee59a8c1b86be1e9d3596e
Author: Timm Bäder <mail baedert org>
Date:   Fri Dec 20 20:56:28 2019 +0100

    renderborder: Only get border width if we really need to
    
    We did this unconditionally before the if statement, but we don't need
    to do it if any of the early-out checks in the not-border-image branch
    hits.

 gtk/gtkrenderborder.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c
index d39c736ff8..45c4e25321 100644
--- a/gtk/gtkrenderborder.c
+++ b/gtk/gtkrenderborder.c
@@ -654,16 +654,16 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
   GtkBorderImage border_image;
   float border_width[4];
 
-  border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
-  border_width[1] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
-  border_width[2] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
-  border_width[3] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
-
   if (gtk_border_image_init (&border_image, boxes->style))
     {
       cairo_t *cr;
       const graphene_rect_t *bounds;
 
+      border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
+      border_width[1] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
+      border_width[2] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
+      border_width[3] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
+
       bounds = gtk_css_boxes_get_border_rect (boxes);
 
       gtk_snapshot_push_debug (snapshot, "CSS border image");
@@ -697,6 +697,11 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
       border_style[2] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
       border_style[3] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
 
+      border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
+      border_width[1] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
+      border_width[2] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, 
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
+      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),


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