[cairo-commit] 2 commits - src/cairo-ps-surface.c test/cairo-test.c test/caps-joins-ps-argb32-ref.png test/caps-sub-paths-ps-argb32-ref.png test/clip-fill-rule-ps-argb32-ref.png test/clip-nesting-ps-argb32-ref.png test/clip-twice-ps-argb32-ref.png test/dash-offset-negative-ps-argb32-ref.png test/fill-and-stroke-ps-argb32-ref.png test/fill-rule-ps-argb32-ref.png test/leaky-polygon-ps-argb32-ref.png test/line-width-ps-argb32-ref.png test/path-data-ps-argb32-ref.png test/rectangle-rounding-error-ps-argb32-ref.png test/show-text-current-point-ps-argb32-ref.png test/text-antialias-gray-ps-argb32-ref.png test/text-antialias-none-ps-argb32-ref.png test/text-antialias-subpixel-ps-argb32-ref.png test/transforms-ps-argb32-ref.png test/unantialiased-shapes-ps-argb32-ref.png

Carl Worth cworth at kemper.freedesktop.org
Thu Apr 6 09:46:12 PDT 2006


 src/cairo-ps-surface.c                          |   71 ++++++++++++++++--------
 test/cairo-test.c                               |   14 +---
 test/caps-joins-ps-argb32-ref.png               |binary
 test/caps-sub-paths-ps-argb32-ref.png           |binary
 test/clip-fill-rule-ps-argb32-ref.png           |binary
 test/clip-nesting-ps-argb32-ref.png             |binary
 test/clip-twice-ps-argb32-ref.png               |binary
 test/dash-offset-negative-ps-argb32-ref.png     |binary
 test/fill-and-stroke-ps-argb32-ref.png          |binary
 test/fill-rule-ps-argb32-ref.png                |binary
 test/leaky-polygon-ps-argb32-ref.png            |binary
 test/line-width-ps-argb32-ref.png               |binary
 test/path-data-ps-argb32-ref.png                |binary
 test/rectangle-rounding-error-ps-argb32-ref.png |binary
 test/show-text-current-point-ps-argb32-ref.png  |binary
 test/text-antialias-gray-ps-argb32-ref.png      |binary
 test/text-antialias-none-ps-argb32-ref.png      |binary
 test/text-antialias-subpixel-ps-argb32-ref.png  |binary
 test/transforms-ps-argb32-ref.png               |binary
 test/unantialiased-shapes-ps-argb32-ref.png     |binary
 20 files changed, 55 insertions(+), 30 deletions(-)

New commits:
diff-tree b87726ee2aa0220b66ee4d97513c0ac89ffc4621 (from c4fc7b06b53c811ddc20def91aaccd756c28a924)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Apr 6 09:43:39 2006 -0700

    Tweak initial erase so it doesn't trigger fallbacks for every PS test case.
    
    Add an optimization to cairo-ps-surface.c so that it ignores any
    CAIRO_OPERATOR_CLEAR drawing operation that occurs on a blank page.
    Also change the test suite to erase with OPERATOR_CLEAR instead of
    OPERATOR_SOURCE with an all-0 source pattern.
    
    With this change, 32 of the 61 test cases change from all-fallback to
    all-native for the ps backend.
    
    Of these 32 test cases, 13 pass the test suite with the original
    reference images. Another 18 cases differ only in the single-pixel
    boundary of objects due to cairo vs. ghostscript rasterization
    differences. We ignore these by adding new ps-specific reference
    images, (included in this commit).
    
    Finally, there appears to be one genuine failure, (dash-caps-joins),
    in which the PostScript dashes (at least as rendered by ghostscript)
    differ significantly from the cairo-rendered dashes.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index a05fe40..8a37868 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -624,7 +624,7 @@ operator_always_translucent (cairo_opera
 }
 
 static cairo_bool_t
-pattern_surface_supported (const cairo_surface_pattern_t *pattern)
+surface_pattern_supported (const cairo_surface_pattern_t *pattern)
 {
     if (pattern->surface->backend->acquire_source_image != NULL)
 	return TRUE;
@@ -637,29 +637,38 @@ pattern_supported (const cairo_pattern_t
     if (pattern->type == CAIRO_PATTERN_TYPE_SOLID)
 	return TRUE;
     if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE)
-	return pattern_surface_supported ((const cairo_surface_pattern_t *) pattern);
+	return surface_pattern_supported ((const cairo_surface_pattern_t *) pattern);
 	
     return FALSE;
 }
 
-static cairo_bool_t
-pattern_operation_supported (cairo_operator_t op,
-			     const cairo_pattern_t *pattern)
-{
+static cairo_int_status_t
+operation_supported (cairo_ps_surface_t *surface,
+		      cairo_operator_t op,
+		      const cairo_pattern_t *pattern)
+{
+    /* As a special-case, (see all drawing operations below), we
+     * optimize away any erasing where nothing has been drawn yet. */
+    if (surface->need_start_page && op == CAIRO_OPERATOR_CLEAR)
+	return TRUE;
+
     if (! pattern_supported (pattern))
 	return FALSE;
+
     if (operator_always_opaque (op))
 	return TRUE;
     if (operator_always_translucent (op))
 	return FALSE;
+
     return pattern_is_opaque (pattern);
 }
 
 static cairo_int_status_t
-pattern_operation_analyze (cairo_operator_t op,
-			   const cairo_pattern_t *pattern)
+_analyze_operation (cairo_ps_surface_t *surface,
+		    cairo_operator_t op,
+		    const cairo_pattern_t *pattern)
 {
-    if (pattern_operation_supported (op, pattern))
+    if (operation_supported (surface, op, pattern))
 	return CAIRO_STATUS_SUCCESS;
     else
 	return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -1177,8 +1186,12 @@ _cairo_ps_surface_old_show_glyphs (cairo
     if (surface->fallback)
 	return CAIRO_STATUS_SUCCESS;
 
-    if (surface->need_start_page)
+    if (surface->need_start_page) {
+	/* Optimize away erasing of nothing. */
+	if (op == CAIRO_OPERATOR_CLEAR)
+	    return CAIRO_STATUS_SUCCESS;
 	_cairo_ps_surface_start_page (surface);
+    }
 
     /* XXX: Need to fix this to work with a general cairo_scaled_font_t. */
     if (! _cairo_scaled_font_is_ft (scaled_font))
@@ -1237,7 +1250,7 @@ _cairo_ps_surface_paint (void			*abstrac
     cairo_ps_surface_path_info_t info;
 
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
-	return pattern_operation_analyze (op, source);
+	return _analyze_operation (surface, op, source);
 
     /* XXX: It would be nice to be able to assert this condition
      * here. But, we actually allow one 'cheat' that is used when
@@ -1249,8 +1262,12 @@ _cairo_ps_surface_paint (void			*abstrac
     assert (pattern_operation_supported (op, source));
     */
     
-    if (surface->need_start_page)
+    if (surface->need_start_page) {
+	/* Optimize away erasing of nothing. */
+	if (op == CAIRO_OPERATOR_CLEAR)
+	    return CAIRO_STATUS_SUCCESS;
 	_cairo_ps_surface_start_page (surface);
+    }
 
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_paint\n");
@@ -1318,12 +1335,16 @@ _cairo_ps_surface_stroke (void			*abstra
     cairo_ps_surface_path_info_t info;
 
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
-	return pattern_operation_analyze (op, source);
+	return _analyze_operation (surface, op, source);
 
-    assert (pattern_operation_supported (op, source));
+    assert (operation_supported (surface, op, source));
     
-    if (surface->need_start_page)
+    if (surface->need_start_page) {
+	/* Optimize away erasing of nothing. */
+	if (op == CAIRO_OPERATOR_CLEAR)
+	    return CAIRO_STATUS_SUCCESS;
 	_cairo_ps_surface_start_page (surface);
+    }
 
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_stroke\n");
@@ -1394,12 +1415,16 @@ _cairo_ps_surface_fill (void		*abstract_
     const char *ps_operator;
 
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
-	return pattern_operation_analyze (op, source);
+	return _analyze_operation (surface, op, source);
 
-    assert (pattern_operation_supported (op, source));
+    assert (operation_supported (surface, op, source));
     
-    if (surface->need_start_page)
+    if (surface->need_start_page) {
+	/* Optimize away erasing of nothing. */
+	if (op == CAIRO_OPERATOR_CLEAR)
+	    return CAIRO_STATUS_SUCCESS;
 	_cairo_ps_surface_start_page (surface);
+    }
 
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_fill\n");
@@ -1448,12 +1473,16 @@ _cairo_ps_surface_show_glyphs (void		   
     cairo_path_fixed_t *path;
 
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
-	return pattern_operation_analyze (op, source);
+	return _analyze_operation (surface, op, source);
 
-    assert (pattern_operation_supported (op, source));
+    assert (operation_supported (surface, op, source));
 
-    if (surface->need_start_page)
+    if (surface->need_start_page) {
+	/* Optimize away erasing of nothing. */
+	if (op == CAIRO_OPERATOR_CLEAR)
+	    return CAIRO_STATUS_SUCCESS;
 	_cairo_ps_surface_start_page (surface);
+    }
 
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_show_glyphs\n");
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 0d8a961..b937fe6 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1415,8 +1415,7 @@ cairo_test_for_target (cairo_test_t *tes
     /* Clear to transparent (or black) depending on whether the target
      * surface supports alpha. */
     cairo_save (cr);
-    cairo_set_source_rgba (cr, 0, 0, 0, 0);
-    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+    cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
     cairo_paint (cr);
     cairo_restore (cr);
 
diff --git a/test/caps-joins-ps-argb32-ref.png b/test/caps-joins-ps-argb32-ref.png
new file mode 100644
index 0000000..d674295
Binary files /dev/null and b/test/caps-joins-ps-argb32-ref.png differ
diff --git a/test/caps-sub-paths-ps-argb32-ref.png b/test/caps-sub-paths-ps-argb32-ref.png
new file mode 100644
index 0000000..a7bc1ac
Binary files /dev/null and b/test/caps-sub-paths-ps-argb32-ref.png differ
diff --git a/test/clip-fill-rule-ps-argb32-ref.png b/test/clip-fill-rule-ps-argb32-ref.png
new file mode 100644
index 0000000..6d97e04
Binary files /dev/null and b/test/clip-fill-rule-ps-argb32-ref.png differ
diff --git a/test/clip-nesting-ps-argb32-ref.png b/test/clip-nesting-ps-argb32-ref.png
new file mode 100644
index 0000000..1bd43d7
Binary files /dev/null and b/test/clip-nesting-ps-argb32-ref.png differ
diff --git a/test/clip-twice-ps-argb32-ref.png b/test/clip-twice-ps-argb32-ref.png
new file mode 100644
index 0000000..9ec76b4
Binary files /dev/null and b/test/clip-twice-ps-argb32-ref.png differ
diff --git a/test/dash-offset-negative-ps-argb32-ref.png b/test/dash-offset-negative-ps-argb32-ref.png
new file mode 100644
index 0000000..518e1c9
Binary files /dev/null and b/test/dash-offset-negative-ps-argb32-ref.png differ
diff --git a/test/fill-and-stroke-ps-argb32-ref.png b/test/fill-and-stroke-ps-argb32-ref.png
new file mode 100644
index 0000000..0df3205
Binary files /dev/null and b/test/fill-and-stroke-ps-argb32-ref.png differ
diff --git a/test/fill-rule-ps-argb32-ref.png b/test/fill-rule-ps-argb32-ref.png
new file mode 100644
index 0000000..b5487e6
Binary files /dev/null and b/test/fill-rule-ps-argb32-ref.png differ
diff --git a/test/leaky-polygon-ps-argb32-ref.png b/test/leaky-polygon-ps-argb32-ref.png
new file mode 100644
index 0000000..23af504
Binary files /dev/null and b/test/leaky-polygon-ps-argb32-ref.png differ
diff --git a/test/line-width-ps-argb32-ref.png b/test/line-width-ps-argb32-ref.png
new file mode 100644
index 0000000..ef6abb7
Binary files /dev/null and b/test/line-width-ps-argb32-ref.png differ
diff --git a/test/path-data-ps-argb32-ref.png b/test/path-data-ps-argb32-ref.png
new file mode 100644
index 0000000..b724a0f
Binary files /dev/null and b/test/path-data-ps-argb32-ref.png differ
diff --git a/test/rectangle-rounding-error-ps-argb32-ref.png b/test/rectangle-rounding-error-ps-argb32-ref.png
new file mode 100644
index 0000000..2753f6d
Binary files /dev/null and b/test/rectangle-rounding-error-ps-argb32-ref.png differ
diff --git a/test/show-text-current-point-ps-argb32-ref.png b/test/show-text-current-point-ps-argb32-ref.png
new file mode 100644
index 0000000..f00681b
Binary files /dev/null and b/test/show-text-current-point-ps-argb32-ref.png differ
diff --git a/test/text-antialias-gray-ps-argb32-ref.png b/test/text-antialias-gray-ps-argb32-ref.png
new file mode 100644
index 0000000..acb273c
Binary files /dev/null and b/test/text-antialias-gray-ps-argb32-ref.png differ
diff --git a/test/text-antialias-none-ps-argb32-ref.png b/test/text-antialias-none-ps-argb32-ref.png
new file mode 100644
index 0000000..acb273c
Binary files /dev/null and b/test/text-antialias-none-ps-argb32-ref.png differ
diff --git a/test/text-antialias-subpixel-ps-argb32-ref.png b/test/text-antialias-subpixel-ps-argb32-ref.png
new file mode 100644
index 0000000..acb273c
Binary files /dev/null and b/test/text-antialias-subpixel-ps-argb32-ref.png differ
diff --git a/test/transforms-ps-argb32-ref.png b/test/transforms-ps-argb32-ref.png
new file mode 100644
index 0000000..4858364
Binary files /dev/null and b/test/transforms-ps-argb32-ref.png differ
diff --git a/test/unantialiased-shapes-ps-argb32-ref.png b/test/unantialiased-shapes-ps-argb32-ref.png
new file mode 100644
index 0000000..dc64e36
Binary files /dev/null and b/test/unantialiased-shapes-ps-argb32-ref.png differ
diff-tree c4fc7b06b53c811ddc20def91aaccd756c28a924 (from e01047a76a5c44302c24e2ab285cf1b1cd490677)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Apr 6 08:54:59 2006 -0700

    Revert "Use ghostscript's pngalpha rather than png16m target for PS->PNG"
    
    This reverts 3b873c66be54522d6cc3f025572a78bbef0efba7 commit.
    
    It seemed like a good idea at the time, but...
    The pngalpha target only gets the fully transparent regions correct.
    But we still need to get the partially translucent regions correct.
    The pngalpha target doesn't help here---instead we were already
    flattening the reference image during testing. And in that case,
    having anything other than alpha==1 in the output png doesn't really
    help, (and meanwhile it was tripping up the current buffer_diff code).

diff --git a/test/cairo-test.c b/test/cairo-test.c
index f946b3e..0d8a961 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1185,7 +1185,7 @@ ps_surface_write_to_png (cairo_surface_t
     }
 
     cairo_surface_finish (surface);
-    sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s",
+    sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -sOutputFile=%s %s",
 	     ptc->width, ptc->height, filename, ptc->filename);
     if (system (command) == 0)
 	return CAIRO_STATUS_SUCCESS;
@@ -1414,14 +1414,11 @@ cairo_test_for_target (cairo_test_t *tes
 
     /* Clear to transparent (or black) depending on whether the target
      * surface supports alpha. */
-    /* XXX: We're cheating by not clearing the PostScript surface. */
-    if (strcmp (target->name, "ps")) {
-	cairo_save (cr);
-	cairo_set_source_rgba (cr, 0, 0, 0, 0);
-	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-	cairo_paint (cr);
-	cairo_restore (cr);
-    }
+    cairo_save (cr);
+    cairo_set_source_rgba (cr, 0, 0, 0, 0);
+    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+    cairo_paint (cr);
+    cairo_restore (cr);
 
     status = (draw) (cr, test->width, test->height);
 


More information about the cairo-commit mailing list