diff options
20 files changed, 50 insertions, 22 deletions
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index a05fe40c..8a378687 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -624,7 +624,7 @@ operator_always_translucent (cairo_operator_t op) } 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 *pattern) 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_scaled_font_t *scaled_font, 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 *abstract_surface, 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 *abstract_surface, 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 *abstract_surface, 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_surface, 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 *abstract_surface, 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 0d8a9619..b937fe6d 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -1415,8 +1415,7 @@ cairo_test_for_target (cairo_test_t *test, /* 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 Binary files differnew file mode 100644 index 00000000..d6742957 --- /dev/null +++ b/test/caps-joins-ps-argb32-ref.png diff --git a/test/caps-sub-paths-ps-argb32-ref.png b/test/caps-sub-paths-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..a7bc1acb --- /dev/null +++ b/test/caps-sub-paths-ps-argb32-ref.png diff --git a/test/clip-fill-rule-ps-argb32-ref.png b/test/clip-fill-rule-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..6d97e04d --- /dev/null +++ b/test/clip-fill-rule-ps-argb32-ref.png diff --git a/test/clip-nesting-ps-argb32-ref.png b/test/clip-nesting-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..1bd43d7a --- /dev/null +++ b/test/clip-nesting-ps-argb32-ref.png diff --git a/test/clip-twice-ps-argb32-ref.png b/test/clip-twice-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..9ec76b4e --- /dev/null +++ b/test/clip-twice-ps-argb32-ref.png diff --git a/test/dash-offset-negative-ps-argb32-ref.png b/test/dash-offset-negative-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..518e1c92 --- /dev/null +++ b/test/dash-offset-negative-ps-argb32-ref.png diff --git a/test/fill-and-stroke-ps-argb32-ref.png b/test/fill-and-stroke-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..0df3205d --- /dev/null +++ b/test/fill-and-stroke-ps-argb32-ref.png diff --git a/test/fill-rule-ps-argb32-ref.png b/test/fill-rule-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..b5487e68 --- /dev/null +++ b/test/fill-rule-ps-argb32-ref.png diff --git a/test/leaky-polygon-ps-argb32-ref.png b/test/leaky-polygon-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..23af504e --- /dev/null +++ b/test/leaky-polygon-ps-argb32-ref.png diff --git a/test/line-width-ps-argb32-ref.png b/test/line-width-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..ef6abb74 --- /dev/null +++ b/test/line-width-ps-argb32-ref.png diff --git a/test/path-data-ps-argb32-ref.png b/test/path-data-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..b724a0f8 --- /dev/null +++ b/test/path-data-ps-argb32-ref.png diff --git a/test/rectangle-rounding-error-ps-argb32-ref.png b/test/rectangle-rounding-error-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..2753f6d2 --- /dev/null +++ b/test/rectangle-rounding-error-ps-argb32-ref.png diff --git a/test/show-text-current-point-ps-argb32-ref.png b/test/show-text-current-point-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..f00681b9 --- /dev/null +++ b/test/show-text-current-point-ps-argb32-ref.png diff --git a/test/text-antialias-gray-ps-argb32-ref.png b/test/text-antialias-gray-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..acb273cb --- /dev/null +++ b/test/text-antialias-gray-ps-argb32-ref.png diff --git a/test/text-antialias-none-ps-argb32-ref.png b/test/text-antialias-none-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..acb273cb --- /dev/null +++ b/test/text-antialias-none-ps-argb32-ref.png diff --git a/test/text-antialias-subpixel-ps-argb32-ref.png b/test/text-antialias-subpixel-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..acb273cb --- /dev/null +++ b/test/text-antialias-subpixel-ps-argb32-ref.png diff --git a/test/transforms-ps-argb32-ref.png b/test/transforms-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..4858364f --- /dev/null +++ b/test/transforms-ps-argb32-ref.png diff --git a/test/unantialiased-shapes-ps-argb32-ref.png b/test/unantialiased-shapes-ps-argb32-ref.png Binary files differnew file mode 100644 index 00000000..dc64e361 --- /dev/null +++ b/test/unantialiased-shapes-ps-argb32-ref.png |