From 213b92e644645d4228b98ec86a0db4e84ef48120 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 16 Jun 2015 14:40:09 -0700 Subject: [PATCH] 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. --- gdk/gdkwindow.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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); -- GitLab