[cairo-commit] cairo/src cairo-gstate.c, 1.191, 1.192 cairo-paginated-surface.c, 1.2, 1.3 cairo-surface.c, 1.117, 1.118 cairoint.h, 1.241, 1.242

Carl Worth commit at pdx.freedesktop.org
Fri Jan 6 14:11:09 PST 2006


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv20722/src

Modified Files:
	cairo-gstate.c cairo-paginated-surface.c cairo-surface.c 
	cairoint.h 
Log Message:
2006-01-06  Carl Worth  <cworth at cworth.org>

        Reviewed by keithp

        * src/cairo-paginated-surface.c: (_cairo_paginated_surface_create),
        (_cairo_paginated_surface_copy_page),
        (_cairo_paginated_surface_show_page): Implement copy_page for
        paginated surface. Fix show_page to destroy the meta-surface and
        create a new one.

        * src/cairoint.h:
        * src/cairo-surface.c: (_cairo_surface_copy_page),
        (_cairo_surface_show_page): Change these functions to advertise
        when they are not supported, so that _cairo_paginated_copy_page
        can implement things differently depending on whether or not it is
        personal.

        * src/cairo-gstate.c: (_cairo_gstate_copy_page),
        (_cairo_gstate_show_page): Check return values from
        _cairo_surface_show/copy_page.


Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- cairo-gstate.c	21 Dec 2005 16:19:47 -0000	1.191
+++ cairo-gstate.c	6 Jan 2006 22:11:07 -0000	1.192
@@ -1040,13 +1040,29 @@
 cairo_status_t
 _cairo_gstate_copy_page (cairo_gstate_t *gstate)
 {
-    return _cairo_surface_copy_page (gstate->target);
+    cairo_int_status_t status;
+
+    status = _cairo_surface_copy_page (gstate->target);
+
+    /* It's fine if some surfaces just don't support this. */
+    if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+	return CAIRO_STATUS_SUCCESS;
+
+    return status;
 }
 
 cairo_status_t
 _cairo_gstate_show_page (cairo_gstate_t *gstate)
 {
-    return _cairo_surface_show_page (gstate->target);
+    cairo_int_status_t status;
+
+    status = _cairo_surface_show_page (gstate->target);
+
+    /* It's fine if some surfaces just don't support this. */
+    if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+	return CAIRO_STATUS_SUCCESS;
+
+    return status;
 }
 
 cairo_status_t

Index: cairo-paginated-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-paginated-surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo-paginated-surface.c	22 Dec 2005 01:04:01 -0000	1.2
+++ cairo-paginated-surface.c	6 Jan 2006 22:11:07 -0000	1.3
@@ -72,6 +72,14 @@
 typedef struct _cairo_paginated_surface {
     cairo_surface_t base;
 
+    /* XXX: These shouldn't actually exist. We inherit this ugliness
+     * from _cairo_meta_surface_create. The width/height parameters
+     * from that function also should not exist. The fix that will
+     * allow us to remove all of these is to fix acquire_source_image
+     * to pass an interest rectangle. */
+    int width;
+    int height;
+
     /* The target surface to hold the final result. */
     cairo_surface_t *target;
 
@@ -100,6 +108,9 @@
 
     _cairo_surface_init (&surface->base, &cairo_paginated_surface_backend);
 
+    surface->width = width;
+    surface->height = height;
+
     surface->target = target;
 
     surface->meta = _cairo_meta_surface_create (width, height);
@@ -158,12 +169,53 @@
 }
 
 static cairo_int_status_t
+_cairo_paginated_surface_copy_page (void *abstract_surface)
+{
+    cairo_paginated_surface_t *surface = abstract_surface;
+    cairo_int_status_t status;
+
+    _cairo_meta_surface_replay (surface->meta, surface->target);
+
+    status = _cairo_surface_copy_page (surface->target);
+
+    /* If the surface does not support copy_page then we use show_page
+     * instead, and we leave the meta-surface untouched so that its
+     * contents will remain for the next page. */
+    if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+	status = _cairo_surface_show_page (surface->target);
+	/* And if the surface doesn't support show_page either, we
+	 * also fall through and clear the meta-surface. */
+	if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+	    return status;
+    }
+
+    /* Otherwise, we clear the meta-surface since the target surface
+     * has already taken care of any copying in its implementation of
+     * copy_page. */
+    cairo_surface_destroy (surface->meta);
+
+    surface->meta = _cairo_meta_surface_create (surface->width, surface->height);
+    if (cairo_surface_status (surface->meta))
+	return cairo_surface_status (surface->meta);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_int_status_t
 _cairo_paginated_surface_show_page (void *abstract_surface)
 {
     cairo_paginated_surface_t *surface = abstract_surface;
 
     _cairo_meta_surface_replay (surface->meta, surface->target);
 
+    _cairo_surface_show_page (surface->target);
+
+    cairo_surface_destroy (surface->meta);
+
+    surface->meta = _cairo_meta_surface_create (surface->width, surface->height);
+    if (cairo_surface_status (surface->meta))
+	return cairo_surface_status (surface->meta);
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -308,7 +360,7 @@
     NULL, /* composite */
     NULL, /* fill_rectangles */
     NULL, /* composite_trapezoids */
-    NULL, /* copy_page */
+    _cairo_paginated_surface_copy_page,
     _cairo_paginated_surface_show_page,
     NULL, /* set_clip_region */
     _cairo_paginated_surface_intersect_clip_path,

Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- cairo-surface.c	20 Dec 2005 06:45:42 -0000	1.117
+++ cairo-surface.c	6 Jan 2006 22:11:07 -0000	1.118
@@ -1091,7 +1091,10 @@
 							  traps, num_traps);
 }
 
-cairo_status_t
+/* _copy_page and _show_page are unique among _cairo_surface functions
+ * in that they will actually return CAIRO_INT_STATUS_UNSUPPORTED
+ * rather than performing any fallbacks. */
+cairo_int_status_t
 _cairo_surface_copy_page (cairo_surface_t *surface)
 {
     assert (! surface->is_snapshot);
@@ -1102,14 +1105,16 @@
     if (surface->finished)
 	return CAIRO_STATUS_SURFACE_FINISHED;
 
-    /* It's fine if some backends just don't support this. */
     if (surface->backend->copy_page == NULL)
-	return CAIRO_STATUS_SUCCESS;
+	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     return surface->backend->copy_page (surface);
 }
 
-cairo_status_t
+/* _show_page and _copy_page are unique among _cairo_surface functions
+ * in that they will actually return CAIRO_INT_STATUS_UNSUPPORTED
+ * rather than performing any fallbacks. */
+cairo_int_status_t
 _cairo_surface_show_page (cairo_surface_t *surface)
 {
     assert (! surface->is_snapshot);
@@ -1120,9 +1125,8 @@
     if (surface->finished)
 	return CAIRO_STATUS_SURFACE_FINISHED;
 
-    /* It's fine if some backends just don't support this. */
     if (surface->backend->show_page == NULL)
-	return CAIRO_STATUS_SUCCESS;
+	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     return surface->backend->show_page (surface);
 }

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -d -r1.241 -r1.242
--- cairoint.h	5 Jan 2006 01:59:03 -0000	1.241
+++ cairoint.h	6 Jan 2006 22:11:07 -0000	1.242
@@ -1688,10 +1688,10 @@
 				     cairo_trapezoid_t	*traps,
 				     int		ntraps);
 
-cairo_private cairo_status_t
+cairo_private cairo_int_status_t
 _cairo_surface_copy_page (cairo_surface_t *surface);
 
-cairo_private cairo_status_t
+cairo_private cairo_int_status_t
 _cairo_surface_show_page (cairo_surface_t *surface);
 
 cairo_private cairo_status_t



More information about the cairo-commit mailing list