[gtk+] wayland: Add custom create_similar_image implementation



commit 83c5e354bd866e52cadd32f892f1e22cad32e3e2
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Jul 3 16:03:25 2013 +0200

    wayland: Add custom create_similar_image implementation
    
    The fallback method is used on other backends, but it caused
    problems for wayland when it tried to create a surface for
    the root window.

 gdk/gdkwindow.c                 |   21 ++++++++++++++-------
 gdk/gdkwindowimpl.h             |    5 +++++
 gdk/wayland/gdkwindow-wayland.c |    9 +++++++++
 3 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 9a88a19..40519a3 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -9316,6 +9316,7 @@ gdk_window_create_similar_image_surface (GdkWindow *     window,
                                         int             height,
                                         int             scale)
 {
+  GdkWindowImplClass *impl_class;
   cairo_surface_t *window_surface, *surface;
   GdkDisplay *display;
   GdkScreen *screen;
@@ -9329,17 +9330,23 @@ gdk_window_create_similar_image_surface (GdkWindow *     window,
       window = gdk_screen_get_root_window (screen);
     }
 
-  window_surface = gdk_window_ref_impl_surface (window);
   if (scale == 0)
     scale = gdk_window_get_scale_factor (window);
 
-  surface =
-    cairo_surface_create_similar_image (window_surface,
-                                       format,
-                                       width,
-                                       height);
+  impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
 
-  cairo_surface_destroy (window_surface);
+  if (impl_class->create_similar_image_surface)
+    surface = impl_class->create_similar_image_surface (window, format, width, height);
+  else
+    {
+      window_surface = gdk_window_ref_impl_surface (window);
+      surface =
+        cairo_surface_create_similar_image (window_surface,
+                                            format,
+                                            width,
+                                            height);
+      cairo_surface_destroy (window_surface);
+    }
 
 #ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
   cairo_surface_set_device_scale (surface, scale, scale);
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index b1117a7..97ac21c 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -51,6 +51,11 @@ struct _GdkWindowImplClass
 
   cairo_surface_t *
                (* ref_cairo_surface)    (GdkWindow       *window);
+  cairo_surface_t *
+               (* create_similar_image_surface) (GdkWindow *     window,
+                                                 cairo_format_t  format,
+                                                 int             width,
+                                                 int             height);
 
   void         (* show)                 (GdkWindow       *window,
                                         gboolean         already_mapped);
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index a6e68d5..109e642 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -746,6 +746,14 @@ gdk_wayland_window_ref_cairo_surface (GdkWindow *window)
   return impl->cairo_surface;
 }
 
+static cairo_surface_t *
+gdk_wayland_window_create_similar_image_surface (GdkWindow *     window,
+                                                 cairo_format_t  format,
+                                                 int             width,
+                                                 int             height)
+{
+  return cairo_image_surface_create (format, width, height);
+}
 
 static gboolean
 gdk_window_impl_wayland_begin_paint_region (GdkWindow       *window,
@@ -1989,6 +1997,7 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
   object_class->finalize = gdk_window_impl_wayland_finalize;
 
   impl_class->ref_cairo_surface = gdk_wayland_window_ref_cairo_surface;
+  impl_class->create_similar_image_surface = gdk_wayland_window_create_similar_image_surface;
   impl_class->show = gdk_wayland_window_show;
   impl_class->hide = gdk_wayland_window_hide;
   impl_class->withdraw = gdk_window_wayland_withdraw;


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