[gtk+] gdkwindow: avoid updating background pattern if it matches previous
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdkwindow: avoid updating background pattern if it matches previous
- Date: Tue, 16 Jun 2015 22:35:22 +0000 (UTC)
commit 213b92e644645d4228b98ec86a0db4e84ef48120
Author: Christian Hergert <christian hergert me>
Date: Tue Jun 16 14:40:09 2015 -0700
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 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index faa848c..f1971cb 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]