[cairo] [PATCH] [win32] Trust the clipping code to trim interest roi to our surface

Chris Wilson chris at chris-wilson.co.uk
Thu Aug 20 12:39:46 PDT 2009


The higher level code ensures that the interest is trimmed to the our
declared surface extents, so performing the intersection again is
redundant. Furthermore with the change in the clipping code, the
destination region is no longer expected to be clipped, especially as the
clip that is currently set upon the DC is likely to be stale and
inappropriate.

Hopefully this resolves the assertion failure reported by Damianl Frank,
http://lists.cairographics.org/archives/cairo/2009-August/018015.html

CC:  Damian Frank <damian.frank at gmail.com>
---
 src/cairo-win32-surface.c |   53 +++++++-------------------------------------
 1 files changed, 9 insertions(+), 44 deletions(-)

diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 12219e9..4139a24 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -569,13 +569,12 @@ _cairo_win32_surface_acquire_source_image (void                    *abstract_sur
 					   void                   **image_extra)
 {
     cairo_win32_surface_t *surface = abstract_surface;
-    cairo_win32_surface_t *local = NULL;
+    cairo_win32_surface_t *local;
     cairo_status_t status;
 
     if (surface->image) {
 	*image_out = (cairo_image_surface_t *)surface->image;
 	*image_extra = NULL;
-
 	return CAIRO_STATUS_SUCCESS;
     }
 
@@ -587,7 +586,6 @@ _cairo_win32_surface_acquire_source_image (void                    *abstract_sur
 
     *image_out = (cairo_image_surface_t *)local->image;
     *image_extra = local;
-
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -612,61 +610,28 @@ _cairo_win32_surface_acquire_dest_image (void                    *abstract_surfa
     cairo_win32_surface_t *surface = abstract_surface;
     cairo_win32_surface_t *local = NULL;
     cairo_status_t status;
-    RECT clip_box;
-    int x1, y1, x2, y2;
 
     if (surface->image) {
 	GdiFlush();
 
-	image_rect->x = 0;
-	image_rect->y = 0;
-	image_rect->width = surface->extents.width;
-	image_rect->height = surface->extents.height;
-
-	*image_out = (cairo_image_surface_t *)surface->image;
+	*image_out = (cairo_image_surface_t *) surface->image;
 	*image_extra = NULL;
-
-	return CAIRO_STATUS_SUCCESS;
-    }
-
-    if (GetClipBox (surface->dc, &clip_box) == ERROR)
-	return _cairo_win32_print_gdi_error ("_cairo_win3_surface_acquire_dest_image");
-
-    x1 = clip_box.left;
-    x2 = clip_box.right;
-    y1 = clip_box.top;
-    y2 = clip_box.bottom;
-
-    if (interest_rect->x > x1)
-	x1 = interest_rect->x;
-    if (interest_rect->y > y1)
-	y1 = interest_rect->y;
-    if ((int) (interest_rect->x + interest_rect->width) < x2)
-	x2 = interest_rect->x + interest_rect->width;
-    if ((int) (interest_rect->y + interest_rect->height) < y2)
-	y2 = interest_rect->y + interest_rect->height;
-
-    if (x1 >= x2 || y1 >= y2) {
-	*image_out = NULL;
-	*image_extra = NULL;
-
+	*image_rect = surface->extents;
 	return CAIRO_STATUS_SUCCESS;
     }
 
     status = _cairo_win32_surface_get_subimage (abstract_surface,
-						x1, y1, x2 - x1, y2 - y1,
+						interest_rect->x,
+						interest_rect->y,
+						interest_rect->width,
+						interest_rect->height,
 						&local);
     if (status)
 	return status;
 
-    *image_out = (cairo_image_surface_t *)local->image;
+    *image_out = (cairo_image_surface_t *) local->image;
     *image_extra = local;
-
-    image_rect->x = x1;
-    image_rect->y = y1;
-    image_rect->width = x2 - x1;
-    image_rect->height = y2 - y1;
-
+    *image_rect = *interest_rect;
     return CAIRO_STATUS_SUCCESS;
 }
 
-- 
1.6.3.3



More information about the cairo mailing list