Skip to content

Commit

Permalink
pdf (debug API): Export the ability to force fallbacks
Browse files Browse the repository at this point in the history
We need to occasionally force fallbacks whilst testing the PDF
output, so export a debug interface to do so in order to avoid poking
around inside cairo internals.

References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
  • Loading branch information
Chris Wilson committed Apr 12, 2012
1 parent a3f97d1 commit 25abe58
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
19 changes: 6 additions & 13 deletions boilerplate/cairo-boilerplate-pdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#if CAIRO_CAN_TEST_PDF_SURFACE

#include <cairo-pdf.h>
#include <cairo-pdf-surface-private.h>
#include <cairo-paginated-surface-private.h>

#if HAVE_SIGNAL_H
#include <signal.h>
Expand Down Expand Up @@ -221,23 +219,18 @@ _cairo_boilerplate_pdf_cleanup (void *closure)
}

static void
_cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
_cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *surface,
double x_pixels_per_inch,
double y_pixels_per_inch)
{
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;
pdf_target_closure_t *ptc =
cairo_surface_get_user_data (surface, &pdf_closure_key);

if (ptc->target)
abstract_surface = ptc->target;
surface = ptc->target;

paginated = (cairo_paginated_surface_t*) abstract_surface;
surface = (cairo_pdf_surface_t*) paginated->target;
surface->force_fallbacks = TRUE;
cairo_surface_set_fallback_resolution (&paginated->base,
cairo_pdf_surface_debug_force_fallbacks (surface);
cairo_surface_set_fallback_resolution (surface,
x_pixels_per_inch,
y_pixels_per_inch);
}
Expand Down
21 changes: 21 additions & 0 deletions src/cairo-pdf-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,27 @@ cairo_pdf_surface_set_size (cairo_surface_t *surface,
status = _cairo_surface_set_error (surface, status);
}

/**
* cairo_pdf_surface_debug_force_fallbacks:
* @surface: a PDF #cairo_surface_t
*
* This is purely a debugging interface, intended only to be used in
* conformation testing, to force the surface to contain only rasterised
* graphics and no native PDF drawing.
*
* Since: 1.12.2
**/
void
cairo_pdf_surface_debug_force_fallbacks (cairo_surface_t *abstract_surface)
{
cairo_pdf_surface_t *surface = NULL;

if (! _extract_pdf_surface (abstract_surface, &surface))
return;

surface->force_fallbacks = TRUE;
}

static void
_cairo_pdf_surface_clear (cairo_pdf_surface_t *surface)
{
Expand Down
5 changes: 5 additions & 0 deletions src/cairo-pdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ cairo_pdf_surface_set_size (cairo_surface_t *surface,
double width_in_points,
double height_in_points);

/* debug interface */

cairo_public void
cairo_pdf_surface_debug_force_fallbacks (cairo_surface_t *abstract_surface);

CAIRO_END_DECLS

#else /* CAIRO_HAS_PDF_SURFACE */
Expand Down

0 comments on commit 25abe58

Please sign in to comment.