From afd9709afff151e04b84b91c6d90b7cff48d6630 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 30 Oct 2014 10:30:33 +0100 Subject: [PATCH] GdkWindowX11: Keep the impl window cairo surface around until destroy We used to have a weak ref to the cairo surface and it was keep alive by the references in the normal windows, but that reference was removed by d48adf9cee7e340acd7f8b9a5f9716695352b848, causing us to constantly create and destroy the surface. https://bugzilla.gnome.org/show_bug.cgi?id=738648 --- gdk/x11/gdkwindow-x11.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index cdecf66d98..1a7281d61d 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -180,8 +180,6 @@ _gdk_x11_window_get_toplevel (GdkWindow *window) return impl->toplevel; } -static const cairo_user_data_key_t gdk_x11_cairo_key; - /** * _gdk_x11_window_update_size: * @impl: a #GdkWindowImplX11. @@ -441,14 +439,6 @@ gdk_x11_window_end_frame (GdkWindow *window) * X11 specific implementations of generic functions * *****************************************************/ -static void -gdk_x11_cairo_surface_destroy (void *data) -{ - GdkWindowImplX11 *impl = data; - - impl->cairo_surface = NULL; -} - static cairo_surface_t * gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl, int width, @@ -479,16 +469,12 @@ gdk_x11_ref_cairo_surface (GdkWindow *window) #ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE cairo_surface_set_device_scale (impl->cairo_surface, impl->window_scale, impl->window_scale); #endif - - if (impl->cairo_surface) - cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, - impl, gdk_x11_cairo_surface_destroy); if (WINDOW_IS_TOPLEVEL (window) && impl->toplevel->in_frame) hook_surface_changed (window); } - else - cairo_surface_reference (impl->cairo_surface); + + cairo_surface_reference (impl->cairo_surface); return impl->cairo_surface; } @@ -1318,8 +1304,8 @@ gdk_x11_window_destroy (GdkWindow *window, if (impl->cairo_surface) { cairo_surface_finish (impl->cairo_surface); - cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, - NULL, NULL); + cairo_surface_destroy (impl->cairo_surface); + impl->cairo_surface = NULL; } if (!recursing && !foreign_destroy)