[cairo-commit] 3 commits - boilerplate/cairo-boilerplate.c
src/cairo-paginated-surface.c test/cairo-test.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Feb 28 11:32:17 PST 2007
boilerplate/cairo-boilerplate.c | 5 +++++
src/cairo-paginated-surface.c | 21 ++++++++++++++++-----
test/cairo-test.c | 2 --
3 files changed, 21 insertions(+), 7 deletions(-)
New commits:
diff-tree 5f5afac8f470ae13ab2827f04e05ca585d69b898 (from efe8c82738bd417402a18871c40cf831e4df31e4)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Feb 28 14:32:11 2007 -0500
[boilerplate/test-paginated] Issue a show_page before writing buffer
This is needed since cairo-test does not issue a show_page now, and
the one coming from paginated layer is too late (around finish).
The way we force the show_page is kinda funny. That is, we create
a temporary cairo_t and call cairo_show_page() on it. But works.
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index aff747e..1bb102b 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -210,6 +210,11 @@ test_paginated_write_to_png (cairo_surfa
cairo_format_t format;
test_paginated_closure_t *tpc;
+ /* show page first. the automatic show_page is too late for us */
+ cairo_t *cr = cairo_create (surface);
+ cairo_show_page (cr);
+ cairo_destroy (cr);
+
tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
switch (tpc->content) {
diff-tree efe8c82738bd417402a18871c40cf831e4df31e4 (from 07d61af8093be501e93d64cc7df69f95ecb83b6c)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Feb 28 14:19:18 2007 -0500
[paginated] Also do an automatic show page if nothing ever drawn
That is, we always emit at least one page of output. Otherwise our
PS/PDF/SVG files would be corrupt, and output with zero pages does
not make much sense.
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index b093bca..419eb5b 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -70,6 +70,7 @@ typedef struct _cairo_paginated_surface
* fallbacks. */
cairo_surface_t *meta;
+ int page_num;
cairo_bool_t page_is_blank;
} cairo_paginated_surface_t;
@@ -122,6 +123,7 @@ _cairo_paginated_surface_create (cairo_s
if (cairo_surface_status (surface->meta))
goto FAIL_CLEANUP_SURFACE;
+ surface->page_num = 1;
surface->page_is_blank = TRUE;
return &surface->base;
@@ -157,7 +159,7 @@ _cairo_paginated_surface_finish (void *a
cairo_paginated_surface_t *surface = abstract_surface;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
- if (!surface->page_is_blank)
+ if (surface->page_is_blank == FALSE || surface->page_num == 1)
status = _cairo_paginated_surface_show_page (abstract_surface);
if (status == CAIRO_STATUS_SUCCESS)
@@ -330,6 +332,7 @@ _cairo_paginated_surface_show_page (void
if (cairo_surface_status (surface->meta))
return cairo_surface_status (surface->meta);
+ surface->page_num++;
surface->page_is_blank = TRUE;
return CAIRO_STATUS_SUCCESS;
diff-tree 07d61af8093be501e93d64cc7df69f95ecb83b6c (from d30178b3dcebcdd89dc773881fc1b9097f1f50a7)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Feb 28 13:46:27 2007 -0500
[paginated] Automatically issue a final cairo_show_page()
This means, PS/PDF/SVG do not need the final cairo_show_page() anymore.
If there is any drawing in the page, a cairo_show_page() is done
automatically.
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 6c1ff6a..b093bca 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -155,12 +155,22 @@ static cairo_status_t
_cairo_paginated_surface_finish (void *abstract_surface)
{
cairo_paginated_surface_t *surface = abstract_surface;
+ cairo_status_t status = CAIRO_STATUS_SUCCESS;
- cairo_surface_destroy (surface->meta);
+ if (!surface->page_is_blank)
+ status = _cairo_paginated_surface_show_page (abstract_surface);
+
+ if (status == CAIRO_STATUS_SUCCESS)
+ cairo_surface_finish (surface->target);
+
+ if (status == CAIRO_STATUS_SUCCESS)
+ cairo_surface_finish (surface->meta);
cairo_surface_destroy (surface->target);
- return CAIRO_STATUS_SUCCESS;
+ cairo_surface_destroy (surface->meta);
+
+ return status;
}
static cairo_surface_t *
@@ -296,9 +306,7 @@ _cairo_paginated_surface_copy_page (void
* show_page and we implement the copying by simply not destroying
* the meta-surface. */
- _cairo_surface_show_page (surface->target);
-
- return CAIRO_STATUS_SUCCESS;
+ return _cairo_surface_show_page (surface->target);
}
static cairo_int_status_t
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 498eb8e..16173b6 100755
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -287,8 +287,6 @@ cairo_test_for_target (cairo_test_t *
goto UNWIND_CAIRO;
}
- cairo_show_page (cr);
-
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
cairo_test_log ("Error: Function under test left cairo status in an error state: %s\n",
cairo_status_to_string (cairo_status (cr)));
More information about the cairo-commit
mailing list