[cairo] [PATCH 2/2] ps (debug API): Export the ability to force fallbacks

Chris Wilson chris at chris-wilson.co.uk
Thu Apr 12 03:05:00 PDT 2012


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 at chris-wilson.co.uk>
---
 boilerplate/cairo-boilerplate-ps.c |   20 ++++++--------------
 src/cairo-ps-surface.c             |   21 +++++++++++++++++++++
 src/cairo-ps.h                     |    5 +++++
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
index 411c11e..8fc2fc9 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -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
@@ -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);
 }
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index fae3ba3..a0dd9e2 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1382,6 +1382,27 @@ cairo_ps_surface_set_creation_date (cairo_surface_t *abstract_surface,
     surface->creation_date = date;
 }
 
+/**
+ * cairo_ps_surface_debug_force_fallbacs:
+ * @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:
diff --git a/src/cairo-ps.h b/src/cairo-ps.h
index 920052b..5666ff5 100644
--- a/src/cairo-ps.h
+++ b/src/cairo-ps.h
@@ -112,6 +112,11 @@ cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface);
 cairo_public void
 cairo_ps_surface_dsc_begin_page_setup (cairo_surface_t *surface);
 
+/* debug interface */
+
+cairo_public void
+cairo_ps_surface_debug_force_fallbacks (cairo_surface_t *abstract_surface);
+
 CAIRO_END_DECLS
 
 #else  /* CAIRO_HAS_PS_SURFACE */
-- 
1.7.9.5



More information about the cairo mailing list