summaryrefslogtreecommitdiff
path: root/gdk/gdkwindow.c
diff options
context:
space:
mode:
authorChristian Hergert <christian@hergert.me>2015-06-16 14:40:09 -0700
committerChristian Hergert <christian@hergert.me>2015-06-16 14:40:09 -0700
commit213b92e644645d4228b98ec86a0db4e84ef48120 (patch)
tree09dd0a34e9ef110d47ebac1c9aeb0d34b5b1947e /gdk/gdkwindow.c
parent569e59b2c580be4261e5e82252ee197a016697a2 (diff)
downloadgtk+-213b92e644645d4228b98ec86a0db4e84ef48120.tar.gz
gdkwindow: avoid updating background pattern if it matches previous
Background patterns are often updated when style changes. In many cases, the new pattern will match the previous. We can optimize out the invalidation that will occur upon resetting the same pattern.
Diffstat (limited to 'gdk/gdkwindow.c')
-rw-r--r--gdk/gdkwindow.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index faa848c243..f1971cb7d2 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -5977,10 +5977,25 @@ gdk_window_set_background_rgba (GdkWindow *window,
const GdkRGBA *rgba)
{
cairo_pattern_t *pattern;
+ GdkRGBA prev_rgba;
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (rgba != NULL);
+ /*
+ * If the new RGBA matches the previous pattern, ignore the change so that
+ * we do not invalidate the window contents.
+ */
+ if ((window->background != NULL) &&
+ (cairo_pattern_get_type (window->background) == CAIRO_PATTERN_TYPE_SOLID) &&
+ (cairo_pattern_get_rgba (window->background,
+ &prev_rgba.red,
+ &prev_rgba.green,
+ &prev_rgba.blue,
+ &prev_rgba.alpha) == CAIRO_STATUS_SUCCESS) &&
+ gdk_rgba_equal (&prev_rgba, rgba))
+ return;
+
pattern = cairo_pattern_create_rgba (rgba->red, rgba->green,
rgba->blue, rgba->alpha);