[cairo-commit] 5 commits - src/cairo-surface.c src/cairo-win32-printing-surface.c src/cairo-xlib-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Fri May 22 08:42:36 PDT 2009


 src/cairo-surface.c                |   10 ++++++++--
 src/cairo-win32-printing-surface.c |    6 +++++-
 src/cairo-xlib-surface.c           |    4 ++--
 3 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit efd0f0b2922d0801e4e0e8e75ddf9b9892a2f2e6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 20 18:49:28 2009 +0100

    [xlib] Handle too-large images gracefully.
    
    Trigger a fallback to an image surface for massive patterns.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index bbbdc4b..e456691 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -208,7 +208,7 @@ _cairo_xlib_surface_create_similar (void	       *abstract_src,
     Pixmap pix;
 
     if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
-	return _cairo_surface_create_in_error (_cairo_error(CAIRO_STATUS_INVALID_SIZE));
+	return NULL;
 
     _cairo_xlib_display_notify (src->display);
 
@@ -1199,7 +1199,7 @@ _cairo_xlib_surface_clone_similar (void			*abstract_surface,
 	cairo_format_t format;
 
 	if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
-	    return _cairo_error (CAIRO_STATUS_INVALID_SIZE);
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
 
 	format = image_src->format;
 	if (format == CAIRO_FORMAT_INVALID ||
commit 3c6838532a62c294e7f18b13b0b7f8da9a1a1e1e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 20 18:46:35 2009 +0100

    [surface] Early return if the backend cannot clone an image
    
    If the backend cannot create a similar surface to hold the image, then
    report back the failure before embarking upon an infinite recursion.
    The UNSUPPORTED return should percolate up through the call stack and
    trigger a fallback.

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index a5a9b72..fc994b0 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1332,6 +1332,9 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
 						  clone_out);
 
 	if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+	    if (_cairo_surface_is_image (src))
+		return CAIRO_INT_STATUS_UNSUPPORTED;
+
 	    /* First check to see if we can replay to a similar surface */
 	    if (_cairo_surface_is_meta (src)) {
 		cairo_surface_t *similar;
@@ -1375,7 +1378,7 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
     }
 
     /* If we're still unsupported, hit our fallback path to get a clone */
-    if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+    if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
 	status =
 	    _cairo_surface_fallback_clone_similar (surface, src,
 						   content,
@@ -1384,6 +1387,7 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
 						   clone_offset_x,
 						   clone_offset_y,
 						   clone_out);
+    }
 
     /* We should never get UNSUPPORTED here, so if we have an error, bail. */
     if (unlikely (status))
commit bf2c7356d4c955fb770863874a0ea111e9ba02a4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri May 22 12:52:43 2009 +0100

    [surface] Provide nil-surface for INVALID_SIZE
    
    So that we can faithfully report back failure if the user tries to create
    a surface larger than the backend can support.

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index dbc1490..a5a9b72 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -79,6 +79,7 @@ static DEFINE_NIL_SURFACE(CAIRO_STATUS_TEMP_FILE_ERROR, _cairo_surface_nil_temp_
 static DEFINE_NIL_SURFACE(CAIRO_STATUS_READ_ERROR, _cairo_surface_nil_read_error);
 static DEFINE_NIL_SURFACE(CAIRO_STATUS_WRITE_ERROR, _cairo_surface_nil_write_error);
 static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_STRIDE, _cairo_surface_nil_invalid_stride);
+static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_SIZE, _cairo_surface_nil_invalid_size);
 
 static cairo_status_t
 _cairo_surface_copy_pattern_for_destination (const cairo_pattern_t **pattern,
@@ -2967,6 +2968,8 @@ _cairo_surface_create_in_error (cairo_status_t status)
 	return (cairo_surface_t *) &_cairo_surface_nil_temp_file_error;
     case CAIRO_STATUS_INVALID_STRIDE:
 	return (cairo_surface_t *) &_cairo_surface_nil_invalid_stride;
+    case CAIRO_STATUS_INVALID_SIZE:
+	return (cairo_surface_t *) &_cairo_surface_nil_invalid_size;
     case CAIRO_STATUS_SUCCESS:
     case CAIRO_STATUS_LAST_STATUS:
 	ASSERT_NOT_REACHED;
@@ -2993,7 +2996,6 @@ _cairo_surface_create_in_error (cairo_status_t status)
     case CAIRO_STATUS_INVALID_CLUSTERS:
     case CAIRO_STATUS_INVALID_SLANT:
     case CAIRO_STATUS_INVALID_WEIGHT:
-    case CAIRO_STATUS_INVALID_SIZE:
     case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED:
     default:
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
commit 6717f0d748000416172057d0aab2471377456e27
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 20 17:35:19 2009 +0100

    [win32] Wrap win32-font usage with CAIRO_HAS_WIN32_FONT
    
    Bug 19251: --enable-win32=yes and --enable-win32-font=no causes
    compilation failure
    [https://bugs.freedesktop.org/show_bug.cgi?id=19251]
    
    Wrap use of the win32 font backend within win32-printing-surface within
    CAIRO_HAS_WIN32_FONT ifdefs to prevent compilation failure if the user
    explicitly disables the win32 font backend.

diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 0dc889b..e7ff3bb 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -1451,6 +1451,7 @@ _cairo_win32_printing_surface_show_glyphs (void                 *abstract_surfac
 	 * If we are printing a bitmap font, use fallback images to
 	 * ensure the font is not substituted.
 	 */
+#if CAIRO_HAS_WIN32_FONT
 	if (cairo_scaled_font_get_type (scaled_font) == CAIRO_FONT_TYPE_WIN32) {
 	    if (_cairo_win32_scaled_font_is_bitmap (scaled_font))
 		return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -1472,6 +1473,7 @@ _cairo_win32_printing_surface_show_glyphs (void                 *abstract_surfac
 	    if (status)
 		return status;
 	}
+#endif
 
 	return _cairo_win32_printing_surface_analyze_operation (surface, op, source);
     }
@@ -1490,6 +1492,7 @@ _cairo_win32_printing_surface_show_glyphs (void                 *abstract_surfac
 	source = opaque;
     }
 
+#if CAIRO_HAS_WIN32_FONT
     if (cairo_scaled_font_get_type (scaled_font) == CAIRO_FONT_TYPE_WIN32 &&
 	source->type == CAIRO_PATTERN_TYPE_SOLID)
     {
@@ -1554,6 +1557,7 @@ _cairo_win32_printing_surface_show_glyphs (void                 *abstract_surfac
 
 	return status;
     }
+#endif
 
     SaveDC (surface->dc);
     old_ctm = surface->ctm;
commit c7d2b0de830f4c653fbb5016c4efdc5f0e5af0eb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 20 17:34:56 2009 +0100

    [win32] Typo
    
    Correct function name in error string.

diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 989f018..0dc889b 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -722,7 +722,7 @@ _cairo_win32_printing_surface_paint_image_pattern (cairo_win32_surface_t   *surf
     _cairo_matrix_to_win32_xform (&m, &xform);
 
     if (! SetWorldTransform (surface->dc, &xform)) {
-	status = _cairo_win32_print_gdi_error ("_win32_scaled_font_set_world_transform");
+	status = _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_paint_image_pattern");
 	goto CLEANUP_OPAQUE_IMAGE;
     }
 


More information about the cairo-commit mailing list