Commit a3d68af9 authored by Benjamin Otte's avatar Benjamin Otte

themingbackground: Add a quick exit for default case

In the case where the background is completely transparent, exit the
rendering functions before doing any expensive calculations.
parent 14d16614
...@@ -280,6 +280,9 @@ GtkCssChange _gtk_css_change_for_child (GtkCssChange ...@@ -280,6 +280,9 @@ GtkCssChange _gtk_css_change_for_child (GtkCssChange
GtkCssDependencies _gtk_css_dependencies_union (GtkCssDependencies first, GtkCssDependencies _gtk_css_dependencies_union (GtkCssDependencies first,
GtkCssDependencies second); GtkCssDependencies second);
/* for lack of better place to put it */
/* mirror what cairo does */
#define gtk_rgba_is_clear(rgba) ((rgba)->alpha < ((double)0x00ff / (double)0xffff))
G_END_DECLS G_END_DECLS
......
...@@ -305,14 +305,20 @@ gtk_theming_background_render (GtkStyleContext *context, ...@@ -305,14 +305,20 @@ gtk_theming_background_render (GtkStyleContext *context,
GtkCssValue *box_shadow; GtkCssValue *box_shadow;
const GdkRGBA *bg_color; const GdkRGBA *bg_color;
bg.context = context; background_image = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
bg_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
box_shadow = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BOX_SHADOW);
/* This is the common default case of no background */
if (gtk_rgba_is_clear (bg_color) &&
_gtk_css_array_value_get_n_values (background_image) == 1 &&
_gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) == NULL &&
_gtk_css_shadows_value_is_none (box_shadow))
return;
bg.context = context;
_gtk_theming_background_init_context (&bg, width, height, junction); _gtk_theming_background_init_context (&bg, width, height, junction);
background_image = _gtk_style_context_peek_property (bg.context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
bg_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (bg.context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
box_shadow = _gtk_style_context_peek_property (bg.context, GTK_CSS_PROPERTY_BOX_SHADOW);
cairo_save (cr); cairo_save (cr);
cairo_translate (cr, x, y); cairo_translate (cr, x, y);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment