diff options
author | Timm Bäder <mail@baedert.org> | 2017-10-19 15:41:20 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2017-10-20 14:56:29 +0200 |
commit | 09750f9937b981aca8cc72de5f621433fe38c96d (patch) | |
tree | 0d6b15591211e446c521779c204fda1bc49f6bdc /gtk/gtkrenderborder.c | |
parent | 99026d2df8ceb0989cfb0cafcfe91d73a5ef7f4e (diff) | |
download | gtk+-09750f9937b981aca8cc72de5f621433fe38c96d.tar.gz |
renderborder: Don't snapshot all-invisible borders
If all of the borders have an alpha of 0, we don't need to snapshot
anything.
Diffstat (limited to 'gtk/gtkrenderborder.c')
-rw-r--r-- | gtk/gtkrenderborder.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gtk/gtkrenderborder.c b/gtk/gtkrenderborder.c index 7d671a2fb3..8e9c059e07 100644 --- a/gtk/gtkrenderborder.c +++ b/gtk/gtkrenderborder.c @@ -952,6 +952,7 @@ gtk_css_style_snapshot_border (GtkCssStyle *style, GtkBorderStyle border_style[4]; GskRoundedRect border_box; GdkRGBA colors[4]; + graphene_simd4f_t alpha_test_vector; /* Optimize the most common case of "This widget has no border" */ if (border_width[0] == 0 && @@ -960,16 +961,20 @@ gtk_css_style_snapshot_border (GtkCssStyle *style, border_width[3] == 0) 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)); - border_style[3] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE)); - colors[0] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_COLOR)); colors[1] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR)); colors[2] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR)); colors[3] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_COLOR)); + alpha_test_vector = graphene_simd4f_init (colors[0].alpha, colors[1].alpha, colors[2].alpha, colors[3].alpha); + if (graphene_simd4f_is_zero4 (alpha_test_vector)) + 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)); + border_style[3] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE)); + gtk_rounded_boxes_init_for_style (&border_box, NULL, NULL, style, 0, 0, width, height); snapshot_border (snapshot, &border_box, border_width, colors, border_style); |