[cairo-commit] 2 commits - src/cairo-ps-surface.c test/fallback.c test/reference

Adrian Johnson ajohnson at kemper.freedesktop.org
Sun Jan 15 03:00:56 PST 2012


 src/cairo-ps-surface.c                 |   26 +++++++++++++++++++-------
 test/fallback.c                        |   25 ++++++++++++++++++++-----
 test/reference/fallback.argb32.ref.png |binary
 test/reference/fallback.rgb24.ref.png  |binary
 4 files changed, 39 insertions(+), 12 deletions(-)

New commits:
commit 88d589aa47995e724a7723b6114ee64a0d0ed0d2
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Jan 15 21:29:15 2012 +1030

    ps: handle different x/y fallback resolution in Fallback Image comment

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 9dfd9d0..8fdc46f 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -3048,15 +3048,27 @@ _cairo_ps_surface_paint_surface (cairo_ps_surface_t      *surface,
     cairo_p2d = pattern->base.matrix;
 
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_FALLBACK) {
-	double scale = cairo_p2d.xx;
+	double x_scale = cairo_p2d.xx;
+	double y_scale = cairo_p2d.yy;
 
 	_cairo_output_stream_printf (surface->stream,
-				     "%% Fallback Image: x=%f y=%f w=%d h=%d res=%fppi size=%ld\n",
-				     -cairo_p2d.x0/scale,
-				     -cairo_p2d.y0/scale,
-				     (int)(width/scale),
-				     (int)(height/scale),
-				     scale*72,
+				     "%% Fallback Image: x=%f y=%f w=%d h=%d ",
+				     -cairo_p2d.x0/x_scale,
+				     -cairo_p2d.y0/y_scale,
+				     (int)(width/x_scale),
+				     (int)(height/y_scale));
+	if (x_scale == y_scale) {
+	    _cairo_output_stream_printf (surface->stream,
+					 "res=%fppi ",
+					 x_scale*72);
+	} else {
+	    _cairo_output_stream_printf (surface->stream,
+					 "res=%fx%fppi ",
+					 x_scale*72,
+					 y_scale*72);
+	}
+	_cairo_output_stream_printf (surface->stream,
+				     "size=%ld\n",
 				     (long)width*height*3);
     } else {
 	if (op == CAIRO_OPERATOR_SOURCE) {
commit 284cba1f3776b9d9e80f6f0acdca67e4828861c1
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Jan 15 20:56:25 2012 +1030

    test: add push/pop group to fallback test

diff --git a/test/fallback.c b/test/fallback.c
index d4421d8..a3cfc40 100644
--- a/test/fallback.c
+++ b/test/fallback.c
@@ -27,16 +27,16 @@
 #include "cairo-test.h"
 
 #define SIZE 40
-#define WIDTH (4*SIZE)
-#define HEIGHT WIDTH
+#define WIDTH (7*SIZE)
+#define HEIGHT (5*SIZE)
 
 #define FALLBACK_RES_X 300
 #define FALLBACK_RES_Y 150
 
-static cairo_test_status_t
-draw (cairo_t *cr, int width, int height)
+static void
+rectangles (cairo_t *cr)
 {
-    cairo_surface_set_fallback_resolution (cairo_get_target (cr), FALLBACK_RES_X, FALLBACK_RES_Y);
+    cairo_save (cr);
 
     cairo_rotate (cr, M_PI/8);
     cairo_translate (cr, 2*SIZE, SIZE/16);
@@ -53,6 +53,21 @@ draw (cairo_t *cr, int width, int height)
     cairo_set_source_rgba (cr, 0, 1, 0, 0.5);
     cairo_fill (cr);
 
+    cairo_restore (cr);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_set_fallback_resolution (cairo_get_target (cr), FALLBACK_RES_X, FALLBACK_RES_Y);
+
+    rectangles (cr);
+    cairo_translate (cr, 3*SIZE, 0);
+    cairo_push_group (cr);
+    rectangles (cr);
+    cairo_pop_group_to_source (cr);
+    cairo_paint (cr);
+
     return CAIRO_TEST_SUCCESS;
 }
 
diff --git a/test/reference/fallback.argb32.ref.png b/test/reference/fallback.argb32.ref.png
index 323b504..6db06bb 100644
Binary files a/test/reference/fallback.argb32.ref.png and b/test/reference/fallback.argb32.ref.png differ
diff --git a/test/reference/fallback.rgb24.ref.png b/test/reference/fallback.rgb24.ref.png
index 9c6c5e2..b42e6bb 100644
Binary files a/test/reference/fallback.rgb24.ref.png and b/test/reference/fallback.rgb24.ref.png differ


More information about the cairo-commit mailing list