summaryrefslogtreecommitdiff
path: root/boilerplate/cairo-boilerplate-ps.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-09-28 13:34:50 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-09-28 14:57:12 +0100
commit9841d9d58ea286f798626d325d50a85bf3f02c8f (patch)
treed42133d4101b98bbde056f8fdee6e72ab3ef19a8 /boilerplate/cairo-boilerplate-ps.c
parentcca1fc6358e9d0213dd2b41a5bfd1629eec6511e (diff)
downloadcairo-9841d9d58ea286f798626d325d50a85bf3f02c8f.tar.gz
Automate error checking for fallback-resolution.
For this we extend the boilerplate get_image() routines to extract a single page out of a paginated document and then proceed to manually check each page of the fallback-resolution test. (Well that's the theory, in practice SVG doesn't support multiple pages and so we just generate a new surface for each resolution. But the infrastructure is in place so that we can automate other tests, e.g. test/multi-pages.)
Diffstat (limited to 'boilerplate/cairo-boilerplate-ps.c')
-rw-r--r--boilerplate/cairo-boilerplate-ps.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
index 7c6ebe9ce..b2e1e122a 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -25,7 +25,6 @@
*/
#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-ps.h"
#include "cairo-boilerplate-ps-private.h"
#include <cairo-ps.h>
@@ -235,19 +234,27 @@ _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char
cairo_surface_t *
_cairo_boilerplate_ps_get_image_surface (cairo_surface_t *surface,
- int width,
- int height)
+ int page,
+ int width,
+ int height)
{
ps_target_closure_t *ptc = cairo_surface_get_user_data (surface,
&ps_closure_key);
char *filename;
cairo_status_t status;
- xasprintf (&filename, "%s.png", ptc->filename);
+ if (page == 0)
+ xasprintf (&filename, "%s.png", ptc->filename);
+ else
+ xasprintf (&filename, "%s-%%05d.png", ptc->filename);
status = _cairo_boilerplate_ps_surface_write_to_png (surface, filename);
if (status)
return cairo_boilerplate_surface_create_in_error (status);
+ if (page != 0) {
+ free (filename);
+ xasprintf (&filename, "%s-%05d.png", ptc->filename, page);
+ }
surface = cairo_boilerplate_get_image_surface_from_png (filename,
width,
height,
@@ -269,18 +276,20 @@ _cairo_boilerplate_ps_cleanup (void *closure)
free (ptc);
}
-cairo_status_t
-cairo_boilerplate_ps_surface_force_fallbacks (cairo_surface_t *abstract_surface)
+void
+_cairo_boilerplate_ps_force_fallbacks (cairo_surface_t *abstract_surface,
+ unsigned int flags)
{
- cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface;
+ ps_target_closure_t *ptc = cairo_surface_get_user_data (abstract_surface,
+ &ps_closure_key);
+
+ cairo_paginated_surface_t *paginated;
cairo_ps_surface_t *surface;
- if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PS)
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ if (ptc->target)
+ abstract_surface = ptc->target;
+ paginated = (cairo_paginated_surface_t*) abstract_surface;
surface = (cairo_ps_surface_t*) paginated->target;
-
surface->force_fallbacks = TRUE;
-
- return CAIRO_STATUS_SUCCESS;
}