Skip to content

Commit

Permalink
ps (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 PostScript
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 6ad8c96 commit a3f97d1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
20 changes: 6 additions & 14 deletions boilerplate/cairo-boilerplate-ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@

#include <cairo-ps.h>

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

#if HAVE_SIGNAL_H
#include <signal.h>
#endif
Expand Down Expand Up @@ -265,23 +262,18 @@ _cairo_boilerplate_ps_cleanup (void *closure)
}

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

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

paginated = (cairo_paginated_surface_t*) abstract_surface;
surface = (cairo_ps_surface_t*) paginated->target;
surface->force_fallbacks = TRUE;
cairo_surface_set_fallback_resolution (&paginated->base,
cairo_ps_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-ps-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,27 @@ cairo_ps_surface_debug_set_creation_date (cairo_surface_t *abstract_surface,
surface->creation_date = date;
}

/**
* cairo_ps_surface_debug_force_fallbacks:
* @surface: a PostScript #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 PostScript drawing.
*
* Since: 1.12.2
**/
void
cairo_ps_surface_debug_force_fallbacks (cairo_surface_t *abstract_surface)
{
cairo_ps_surface_t *surface = NULL;

if (! _extract_ps_surface (abstract_surface, TRUE, &surface))
return;

surface->force_fallbacks = TRUE;
}

/**
* cairo_ps_surface_dsc_comment:
* @surface: a PostScript #cairo_surface_t
Expand Down
3 changes: 3 additions & 0 deletions src/cairo-ps.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ cairo_public void
cairo_ps_surface_debug_set_creation_date (cairo_surface_t *abstract_surface,
time_t date);

cairo_public void
cairo_ps_surface_debug_force_fallbacks (cairo_surface_t *abstract_surface);

CAIRO_END_DECLS

#else /* CAIRO_HAS_PS_SURFACE */
Expand Down

0 comments on commit a3f97d1

Please sign in to comment.