[gtk+/gtk-3-14] GdkWindowX11: Keep the impl window cairo surface around until destroy



commit 0ddb4fd989be2c302fc691901d668274df3c2e29
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Oct 30 10:30:33 2014 +0100

    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
    (cherry picked from commit afd9709afff151e04b84b91c6d90b7cff48d6630)

 gdk/x11/gdkwindow-x11.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)
---
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index c41e595..2d0f824 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -181,8 +181,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.
@@ -442,14 +440,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,
@@ -480,16 +470,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;
 }
@@ -1329,8 +1315,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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]