diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2008-03-24 12:16:20 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2008-03-24 12:16:20 +1030 |
commit | ae9635bf33cb989f5c525800b82b81daad699e01 (patch) | |
tree | 3c2ec79fab4bb3661d798f178633b994369649c8 | |
parent | 179ab7d2860b8ff94fe491896c50505fde7cf6af (diff) |
Fix assertion in PS/PDF/Win32-print when fallback image is off the page
If during analysis the bounding box of an operation or the number of
traps is 0, the operation is marked as natively supported. The problem
here is if the operation is unsupported by the backend, we get an
assertion when the operation is replayed during
CAIRO_PAGINATED_MODE_RENDER.
This bug was found in Inkscape when printing to the
win32_printing_surface a page that has been layed out as landscape but
landscape paper had not been selected in the print dialog.
Fix this by being careful not to mark unsupported operations as
supported during analysis even they may not be visible on the page.
-rw-r--r-- | src/cairo-analysis-surface.c | 73 |
1 files changed, 55 insertions, 18 deletions
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c index 29919f01..749f3e37 100644 --- a/src/cairo-analysis-surface.c +++ b/src/cairo-analysis-surface.c @@ -125,8 +125,20 @@ _cairo_analysis_surface_add_operation (cairo_analysis_surface_t *surface, cairo_int_status_t status; cairo_box_t bbox; - if (rect->width == 0 || rect->height == 0) - return CAIRO_STATUS_SUCCESS; + if (rect->width == 0 || rect->height == 0) { + /* Even though the operation is not visible we must be careful + * to not allow unsupported operations to be replayed to the + * backend during CAIRO_PAGINATED_MODE_RENDER */ + if (backend_status == CAIRO_STATUS_SUCCESS || + backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) + { + return CAIRO_STATUS_SUCCESS; + } + else + { + return CAIRO_INT_STATUS_IMAGE_FALLBACK; + } + } if (surface->has_ctm) { double x1, y1, x2, y2; @@ -143,8 +155,21 @@ _cairo_analysis_surface_add_operation (cairo_analysis_surface_t *surface, x2 = ceil (x2) - rect->x; y2 = ceil (y2) - rect->y; - if (x2 <= 0 || y2 <= 0) - return CAIRO_STATUS_SUCCESS; + if (x2 <= 0 || y2 <= 0) { + /* Even though the operation is not visible we must be + * careful to not allow unsupported operations to be + * replayed to the backend during + * CAIRO_PAGINATED_MODE_RENDER */ + if (backend_status == CAIRO_STATUS_SUCCESS || + backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) + { + return CAIRO_STATUS_SUCCESS; + } + else + { + return CAIRO_INT_STATUS_IMAGE_FALLBACK; + } + } rect->width = x2; rect->height = y2; @@ -434,17 +459,23 @@ _cairo_analysis_surface_stroke (void *abstract_surface, ctm, ctm_inverse, tolerance, &traps); - - if (status || traps.num_traps == 0) { + if (status) { _cairo_traps_fini (&traps); return status; } - _cairo_traps_extents (&traps, &box); - extents.x = _cairo_fixed_integer_floor (box.p1.x); - extents.y = _cairo_fixed_integer_floor (box.p1.y); - extents.width = _cairo_fixed_integer_ceil (box.p2.x) - extents.x; - extents.height = _cairo_fixed_integer_ceil (box.p2.y) - extents.y; + if (traps.num_traps == 0) { + extents.x = 0; + extents.y = 0; + extents.width = 0; + extents.height = 0; + } else { + _cairo_traps_extents (&traps, &box); + extents.x = _cairo_fixed_integer_floor (box.p1.x); + extents.y = _cairo_fixed_integer_floor (box.p1.y); + extents.width = _cairo_fixed_integer_ceil (box.p2.x) - extents.x; + extents.height = _cairo_fixed_integer_ceil (box.p2.y) - extents.y; + } _cairo_traps_fini (&traps); } @@ -506,17 +537,23 @@ _cairo_analysis_surface_fill (void *abstract_surface, fill_rule, tolerance, &traps); - - if (status || traps.num_traps == 0) { + if (status) { _cairo_traps_fini (&traps); return status; } - _cairo_traps_extents (&traps, &box); - extents.x = _cairo_fixed_integer_floor (box.p1.x); - extents.y = _cairo_fixed_integer_floor (box.p1.y); - extents.width = _cairo_fixed_integer_ceil (box.p2.x) - extents.x; - extents.height = _cairo_fixed_integer_ceil (box.p2.y) - extents.y; + if (traps.num_traps == 0) { + extents.x = 0; + extents.y = 0; + extents.width = 0; + extents.height = 0; + } else { + _cairo_traps_extents (&traps, &box); + extents.x = _cairo_fixed_integer_floor (box.p1.x); + extents.y = _cairo_fixed_integer_floor (box.p1.y); + extents.width = _cairo_fixed_integer_ceil (box.p2.x) - extents.x; + extents.height = _cairo_fixed_integer_ceil (box.p2.y) - extents.y; + } _cairo_traps_fini (&traps); } |