summaryrefslogtreecommitdiff
path: root/boilerplate/cairo-boilerplate-pdf.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-pdf.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-pdf.c')
-rw-r--r--boilerplate/cairo-boilerplate-pdf.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index 470fb06d2..700023858 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -25,7 +25,6 @@
*/
#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-pdf.h"
#include "cairo-boilerplate-pdf-private.h"
#include <cairo-pdf.h>
@@ -174,26 +173,27 @@ _cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const cha
}
static cairo_surface_t *
-_cairo_boilerplate_pdf_convert_to_image (cairo_surface_t *surface)
+_cairo_boilerplate_pdf_convert_to_image (cairo_surface_t *surface, int page)
{
pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface,
&pdf_closure_key);
- return cairo_boilerplate_convert_to_image (ptc->filename, 1);
+ return cairo_boilerplate_convert_to_image (ptc->filename, page+1);
}
cairo_surface_t *
_cairo_boilerplate_pdf_get_image_surface (cairo_surface_t *surface,
+ int page,
int width,
int height)
{
cairo_surface_t *image;
- image = _cairo_boilerplate_pdf_convert_to_image (surface);
+ image = _cairo_boilerplate_pdf_convert_to_image (surface, page);
cairo_surface_set_device_offset (image,
cairo_image_surface_get_width (image) - width,
cairo_image_surface_get_height (image) - height);
- surface = _cairo_boilerplate_get_image_surface (image, width, height);
+ surface = _cairo_boilerplate_get_image_surface (image, 0, width, height);
cairo_surface_destroy (image);
return surface;
@@ -209,18 +209,21 @@ _cairo_boilerplate_pdf_cleanup (void *closure)
free (ptc);
}
-cairo_status_t
-cairo_boilerplate_pdf_surface_force_fallbacks (cairo_surface_t *abstract_surface)
+
+void
+_cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
+ unsigned int flags)
{
- cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface;
+ pdf_target_closure_t *ptc = cairo_surface_get_user_data (abstract_surface,
+ &pdf_closure_key);
+
+ cairo_paginated_surface_t *paginated;
cairo_pdf_surface_t *surface;
- if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PDF)
- return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+ if (ptc->target)
+ abstract_surface = ptc->target;
+ paginated = (cairo_paginated_surface_t*) abstract_surface;
surface = (cairo_pdf_surface_t*) paginated->target;
-
surface->force_fallbacks = TRUE;
-
- return CAIRO_STATUS_SUCCESS;
}