From 4e4b38e75930e3da8c33a02eae77fb736659ff44 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 12 Jan 2006 16:47:05 +0000 Subject: [PATCH] Add a call to cairo_copy_page, so that that gets called at least once within the test suite. Fix broken implementation of copy_page in the paginated surface by hiding it from the target surface which sees only show_page operations. (It's hard to do better than that unless we can guarantee thathe subsequent page won't trigger any image fallbacks.) --- ChangeLog | 13 +++++++++++++ src/cairo-paginated-surface.c | 29 ++++++++--------------------- test/multi-page.c | 20 ++++++++++++++------ 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74612dffd..81a288390 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-01-12 Carl Worth + + * test/multi-page.c: (draw_some_pages), (main): Add a call to + cairo_copy_page, so that that gets called at least once within the + test suite. + + * src/cairo-paginated-surface.c: + (_cairo_paginated_surface_copy_page): Fix broken implementation of + copy_page in the paginated surface by hiding it from the target + surface which sees only show_page operations. (It's hard to do + better than that unless we can guarantee thathe subsequent page + won't trigger any image fallbacks.) + 2006-01-12 Carl Worth * configure.in: Add a new CAIRO_HAS_MULTI_PAGE_SURFACES automake diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index 175c1f1bc..0a28db2fe 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -222,31 +222,18 @@ 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; _paint_page (surface); - status = _cairo_surface_copy_page (surface->target); + /* XXX: It might make sense to add some suport here for calling + * _cairo_surface_copy_page on the target surface. It would be an + * optimization for the output, (so that PostScript could include + * copypage, for example), but the interaction with image + * fallbacks gets tricky. For now, we just let the target see a + * show_page and we implement the copying by simply not destroying + * the meta-surface. */ - /* 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); + _cairo_surface_show_page (surface->target); return CAIRO_STATUS_SUCCESS; } diff --git a/test/multi-page.c b/test/multi-page.c index 06024131e..91360843e 100644 --- a/test/multi-page.c +++ b/test/multi-page.c @@ -103,16 +103,24 @@ draw (cairo_t *cr, double width, double height, double smile_ratio) } static void -draw_five_pages (cairo_surface_t *surface) +draw_some_pages (cairo_surface_t *surface) { cairo_t *cr; int i; cr = cairo_create (surface); -#define NUM_PAGES 5 - for (i=0; i < NUM_PAGES; i++) { - draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS, (double) i / (NUM_PAGES - 1)); +#define NUM_FRAMES 5 + for (i=0; i < NUM_FRAMES; i++) { + draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS, + (double) i / (NUM_FRAMES - 1)); + + /* Duplicate the last frame onto another page. (This is just a + * way to sneak cairo_copy_page into the test). + */ + if (i == (NUM_FRAMES - 1)) + cairo_copy_page (cr); + cairo_show_page (cr); } @@ -140,7 +148,7 @@ main (void) return CAIRO_TEST_FAILURE; } - draw_five_pages (surface); + draw_some_pages (surface); cairo_surface_destroy (surface); @@ -159,7 +167,7 @@ main (void) return CAIRO_TEST_FAILURE; } - draw_five_pages (surface); + draw_some_pages (surface); cairo_surface_destroy (surface);