From 2574cc35b3478e7333bd4953e90a3edc5f7c4f16 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 11 Jan 2008 22:07:26 +1030 Subject: [PATCH] win32-printing: Do not clip and paint with an empty path For non solid patterns _fill and _show_glyphs sets a clip path then paints the pattern. Previously if the path is empty SelectClipPath did not set clip. This was probably the cause of bug 13657 where the entire page was black. Fix this by not painting anything if the path is empty. --- src/cairo-win32-printing-surface.c | 8 ++++++-- src/cairo-win32-private.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c index ac41e903d..3a5a3b882 100644 --- a/src/cairo-win32-printing-surface.c +++ b/src/cairo-win32-printing-surface.c @@ -874,6 +874,7 @@ _cairo_win32_printing_surface_path_line_to (void *closure, cairo_point_t *point) { win32_path_info_t *path_info = closure; + path_info->surface->path_empty = FALSE; if (path_info->surface->has_ctm) { double x, y; @@ -899,6 +900,7 @@ _cairo_win32_printing_surface_path_curve_to (void *closure, win32_path_info_t *path_info = closure; POINT points[3]; + path_info->surface->path_empty = FALSE; if (path_info->surface->has_ctm) { double x, y; @@ -1244,6 +1246,7 @@ _cairo_win32_printing_surface_fill (void *abstract_surface, assert (_cairo_win32_printing_surface_operation_supported (surface, op, source)); + surface->path_empty = TRUE; BeginPath (surface->dc); status = _cairo_win32_printing_surface_emit_path (surface, path); EndPath (surface->dc); @@ -1266,7 +1269,7 @@ _cairo_win32_printing_surface_fill (void *abstract_surface, FillPath (surface->dc); _cairo_win32_printing_surface_done_solid_brush (surface); - } else { + } else if (surface->path_empty == FALSE) { SaveDC (surface->dc); SelectClipPath (surface->dc, RGN_AND); status = _cairo_win32_printing_surface_paint_pattern (surface, source); @@ -1358,6 +1361,7 @@ _cairo_win32_printing_surface_show_glyphs (void *abstract_surfac old_ctm = surface->ctm; old_has_ctm = surface->has_ctm; surface->has_ctm = TRUE; + surface->path_empty = TRUE; BeginPath (surface->dc); for (i = 0; i < num_glyphs; i++) { status = _cairo_scaled_glyph_lookup (scaled_font, @@ -1373,7 +1377,7 @@ _cairo_win32_printing_surface_show_glyphs (void *abstract_surfac EndPath (surface->dc); surface->ctm = old_ctm; surface->has_ctm = old_has_ctm; - if (status == CAIRO_STATUS_SUCCESS) { + if (status == CAIRO_STATUS_SUCCESS && surface->path_empty == FALSE) { if (source->type == CAIRO_PATTERN_TYPE_SOLID) { status = _cairo_win32_printing_surface_select_solid_brush (surface, source); if (status) diff --git a/src/cairo-win32-private.h b/src/cairo-win32-private.h index 0eff4d102..7857d1875 100644 --- a/src/cairo-win32-private.h +++ b/src/cairo-win32-private.h @@ -83,6 +83,7 @@ typedef struct _cairo_win32_surface { /* printing surface bits */ cairo_paginated_mode_t paginated_mode; cairo_content_t content; + cairo_bool_t path_empty; cairo_bool_t has_ctm; cairo_matrix_t ctm; int clip_saved_dc;