[gtk+/rendering-cleanup: 74/141] gdk: Make csw windows have their own cairo surface



commit e118499e35ac7d3ad5e350a43c0a208564383683
Author: Benjamin Otte <otte redhat com>
Date:   Thu Aug 26 10:15:59 2010 +0200

    gdk: Make csw windows have their own cairo surface
    
    With Cairo 1.10 now having cairo_surface_create_for_rectangle(), we can
    use them. No need to create multiple native surfaces for the same X
    window (ugh) anymore.

 gdk/gdkwindow.c |   57 +++++++++++++++++++++++-------------------------------
 1 files changed, 24 insertions(+), 33 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index dd8446c..8f7a06d 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -1040,27 +1040,14 @@ recompute_visible_regions_internal (GdkWindowObject *private,
       recompute_visible_regions_internal (private->parent, TRUE, FALSE, FALSE);
     }
 
-  if (private->cairo_surface)
+  if (private->cairo_surface &&
+      (!gdk_window_has_impl (private) ||
+       !_gdk_windowing_set_cairo_surface_size (private->cairo_surface,
+                                               private->width,
+                                               private->height)))
     {
-      int width, height;
-
-      /* It would be nice if we had some cairo support here so we
-	 could set the clip rect on the cairo surface */
-      width = private->abs_x + private->width;
-      height = private->abs_y + private->height;
-
-      if (_gdk_windowing_set_cairo_surface_size (private->cairo_surface,
-                                                 width, height))
-        {
-          cairo_surface_set_device_offset (private->cairo_surface,
-                                           private->abs_x,
-                                           private->abs_y);
-        }
-      else
-        {
-          cairo_surface_destroy (private->cairo_surface);
-          private->cairo_surface = NULL;
-        }
+      cairo_surface_destroy (private->cairo_surface);
+      private->cairo_surface = NULL;
     }
 }
 
@@ -3733,7 +3720,20 @@ gdk_window_create_cairo_surface (GdkDrawable *drawable,
 				 int width,
 				 int height)
 {
-  return _gdk_drawable_ref_cairo_surface (GDK_WINDOW_OBJECT(drawable)->impl);
+  GdkWindowObject *private = GDK_WINDOW_OBJECT(drawable);
+  cairo_surface_t *surface, *subsurface;
+  
+  surface =_gdk_drawable_ref_cairo_surface (private->impl);
+  if (gdk_window_has_impl (private))
+    return surface;
+
+  subsurface = cairo_surface_create_for_rectangle (surface,
+                                                   private->abs_x,
+                                                   private->abs_y,
+                                                   width,
+                                                   height);
+  cairo_surface_destroy (surface);
+  return subsurface;
 }
 
 
@@ -3758,23 +3758,14 @@ gdk_window_ref_cairo_surface (GdkDrawable *drawable)
 
       if (!private->cairo_surface)
 	{
-	  int width, height;
-
-	  /* It would be nice if we had some cairo support here so we
-	     could set the clip rect on the cairo surface */
-	  width = private->abs_x + private->width;
-	  height = private->abs_y + private->height;
-
-	  private->cairo_surface = _gdk_drawable_create_cairo_surface (drawable, width, height);
+	  private->cairo_surface = _gdk_drawable_create_cairo_surface (drawable,
+                                                                       private->width,
+                                                                       private->height);
 
 	  if (private->cairo_surface)
 	    {
 	      private->impl_window->outstanding_surfaces++;
 
-	      cairo_surface_set_device_offset (private->cairo_surface,
-					       private->abs_x,
-					       private->abs_y);
-
 	      cairo_surface_set_user_data (private->cairo_surface, &gdk_window_cairo_key,
 					   drawable, gdk_window_cairo_surface_destroy);
 	    }



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