[cairo-commit] 2 commits - boilerplate/cairo-boilerplate.c boilerplate/cairo-boilerplate-xcb.c configure.ac src/cairo-debug.c src/cairo-gl-glyphs.c src/cairo.h src/cairo-image-surface.c src/cairoint.h src/cairo-png.c src/cairo-scaled-font.c src/cairo-script-surface.c src/cairo-win32-surface.c src/cairo-xcb-surface-render.c src/cairo-xlib-display.c src/cairo-xlib-surface.c src/cairo-xml-surface.c src/drm test/any2ppm.c test/png.c util/cairo-script util/cairo-sphinx util/cairo-trace

M. Joonas Pihlaja joonas at kemper.freedesktop.org
Sun Feb 28 15:54:54 PST 2010


 boilerplate/cairo-boilerplate-xcb.c        |    6 ++++++
 boilerplate/cairo-boilerplate.c            |    2 +-
 configure.ac                               |    5 ++++-
 src/cairo-debug.c                          |    1 +
 src/cairo-gl-glyphs.c                      |    6 ++++++
 src/cairo-image-surface.c                  |    6 +++++-
 src/cairo-png.c                            |    1 +
 src/cairo-scaled-font.c                    |    1 +
 src/cairo-script-surface.c                 |   22 ++++++++++++++--------
 src/cairo-win32-surface.c                  |    6 ++++++
 src/cairo-xcb-surface-render.c             |    3 +++
 src/cairo-xlib-display.c                   |    1 +
 src/cairo-xlib-surface.c                   |    3 +++
 src/cairo-xml-surface.c                    |   28 +++++++++-------------------
 src/cairo.h                                |   10 ++++++----
 src/cairoint.h                             |    4 ++--
 src/drm/cairo-drm-gallium-surface.c        |    1 +
 src/drm/cairo-drm-i915-surface.c           |    1 +
 src/drm/cairo-drm-intel-surface.c          |    2 +-
 src/drm/cairo-drm-intel.c                  |   11 ++++++++---
 src/drm/cairo-drm-radeon-surface.c         |    2 +-
 test/any2ppm.c                             |    1 +
 test/png.c                                 |    1 +
 util/cairo-script/cairo-script-operators.c |    5 +++++
 util/cairo-sphinx/sphinx.c                 |    9 ++++++---
 util/cairo-trace/trace.c                   |    4 ++++
 26 files changed, 98 insertions(+), 44 deletions(-)

New commits:
commit 1a7ba1a8061c373cd66d15b3a1c8dfada92745ef
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Mon Mar 1 01:23:17 2010 +0200

    xcb: Update minimum required versions of libxcb.
    
    The new xcb surface uses xcb_writev() and xcb_take_socket()
    which were introduced in libxcb 1.1.92.  The boilerplate
    in turn uses the major_code and minor_code fields in
    xcb_generic_error_t, which were introduced in 1.4.

diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index ed173e6..0e5c3b9 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -564,9 +564,15 @@ _cairo_boilerplate_xcb_finish_surface (cairo_surface_t		*surface)
 	if (ev->response_type == 0 /* trust me! */) {
 	    xcb_generic_error_t *error = (xcb_generic_error_t *) ev;
 
+#if XCB_GENERIC_ERROR_HAS_MAJOR_MINOR_CODES
 	    fprintf (stderr,
 		     "Detected error during xcb run: %d major=%d, minor=%d\n",
 		     error->error_code, error->major_code, error->minor_code);
+#else
+	    fprintf (stderr,
+		     "Detected error during xcb run: %d\n",
+		     error->error_code);
+#endif
 	    free (error);
 
 	    status = CAIRO_STATUS_WRITE_ERROR;
diff --git a/configure.ac b/configure.ac
index 7d0cde0..b483dd2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,10 +116,13 @@ CAIRO_ENABLE_SURFACE_BACKEND(xlib_xrender, Xlib Xrender, auto, [
 dnl ===========================================================================
 
 CAIRO_ENABLE_SURFACE_BACKEND(xcb, XCB, no, [
-  xcb_REQUIRES="xcb >= 0.9.92 xcb-render >= 0.9.92"
+  xcb_REQUIRES="xcb >= 1.1.92 xcb-render >= 0.9.92"
   PKG_CHECK_MODULES(xcb, $xcb_REQUIRES, ,
 		    [AC_MSG_RESULT(no)
 		    use_xcb="no (requires $xcb_REQUIRES http://xcb.freedesktop.org)"])
+  if $PKG_CONFIG --atleast-version=1.4 xcb; then
+    CAIRO_CFLAGS="$CAIRO_CFLAGS -DXCB_GENERIC_ERROR_HAS_MAJOR_MINOR_CODES"
+  fi
 ])
 
 CAIRO_ENABLE_FUNCTIONS(xlib_xcb, Xlib/XCB, no, [
commit 5b7f4bb241f3191c1589cd714f373719efded56e
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun Feb 28 23:31:06 2010 +0200

    api: Introduce CAIRO_FORMAT_INVALID formally in the API.
    
    We were exposing the actual value of CAIRO_FORMAT_INVALID
    through API functions already, so it makes sense to just
    go ahead and put it in the cairo_format_t enum.

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index d3f312f..2a3a354 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -115,7 +115,7 @@ cairo_boilerplate_format_from_content (cairo_content_t content)
 	case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
 	default:
 	    assert (0); /* not reached */
-	    format = (cairo_format_t) -1;
+	    format = CAIRO_FORMAT_INVALID;
 	    break;
     }
 
diff --git a/src/cairo-debug.c b/src/cairo-debug.c
index e364069..359018a 100644
--- a/src/cairo-debug.c
+++ b/src/cairo-debug.c
@@ -110,6 +110,7 @@ _cairo_debug_check_image_surface_is_defined (const cairo_surface_t *surface)
     case CAIRO_FORMAT_ARGB32:
 	width = image->width*4;
 	break;
+    case CAIRO_FORMAT_INVALID:
     default:
 	/* XXX compute width from pixman bpp */
 	return;
diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index 06c29c5..5e9b7bb 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -164,6 +164,9 @@ cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx,
 	cache = &ctx->glyph_cache[1];
 	format = CAIRO_FORMAT_A8;
 	break;
+    case CAIRO_FORMAT_INVALID:
+	ASSERT_NOT_REACHED;
+	return NULL;
     }
 
     if (unlikely (cache->tex == 0)) {
@@ -182,6 +185,9 @@ cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx,
 	    case CAIRO_FORMAT_A8:
 		internal_format = GL_ALPHA;
 		break;
+	    case CAIRO_FORMAT_INVALID:
+		ASSERT_NOT_REACHED;
+		return NULL;
 	}
 
 	glGenTextures (1, &cache->tex);
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 9d74350..e53f53f 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -277,6 +277,7 @@ _cairo_format_to_pixman_format_code (cairo_format_t format)
 	ret = PIXMAN_x8r8g8b8;
 	break;
     case CAIRO_FORMAT_ARGB32:
+    case CAIRO_FORMAT_INVALID:
     default:
 	ret = PIXMAN_a8r8g8b8;
 	break;
@@ -626,7 +627,7 @@ _cairo_format_from_content (cairo_content_t content)
     }
 
     ASSERT_NOT_REACHED;
-    return CAIRO_FORMAT_ARGB32;
+    return CAIRO_FORMAT_INVALID;
 }
 
 cairo_content_t
@@ -640,6 +641,8 @@ _cairo_content_from_format (cairo_format_t format)
     case CAIRO_FORMAT_A8:
     case CAIRO_FORMAT_A1:
 	return CAIRO_CONTENT_ALPHA;
+    case CAIRO_FORMAT_INVALID:
+	break;
     }
 
     ASSERT_NOT_REACHED;
@@ -658,6 +661,7 @@ _cairo_format_bits_per_pixel (cairo_format_t format)
 	return 8;
     case CAIRO_FORMAT_A1:
 	return 1;
+    case CAIRO_FORMAT_INVALID:
     default:
 	ASSERT_NOT_REACHED;
 	return 0;
diff --git a/src/cairo-png.c b/src/cairo-png.c
index 8b9b43c..6e0563d 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -230,6 +230,7 @@ write_png (cairo_surface_t	*surface,
 	png_set_packswap (png);
 #endif
 	break;
+    case CAIRO_FORMAT_INVALID:
     default:
 	status = _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
 	goto BAIL4;
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 4171c46..a5db3f1 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2146,6 +2146,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t	*scaled_font,
 		mask_format = glyph_surface->format;
 		break;
 	    case CAIRO_FORMAT_RGB24:
+	    case CAIRO_FORMAT_INVALID:
 	    default:
 		ASSERT_NOT_REACHED;
 		mask_format = CAIRO_FORMAT_ARGB32;
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 77cac9b..e342ced 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -817,14 +817,15 @@ _emit_stroke_style (cairo_script_surface_t *surface,
 static const char *
 _format_to_string (cairo_format_t format)
 {
-    static const char *names[] = {
-	"ARGB32",	/* CAIRO_FORMAT_ARGB32 */
-	"RGB24",	/* CAIRO_FORMAT_RGB24 */
-	"A8",		/* CAIRO_FORMAT_A8 */
-	"A1"		/* CAIRO_FORMAT_A1 */
-    };
-    assert (format < ARRAY_LENGTH (names));
-    return names[format];
+    switch (format) {
+    case CAIRO_FORMAT_ARGB32:  return "ARGB32";
+    case CAIRO_FORMAT_RGB24:   return "RGB24";
+    case CAIRO_FORMAT_A8:      return "A8";
+    case CAIRO_FORMAT_A1:      return "A1";
+    case CAIRO_FORMAT_INVALID: return "INVALID";
+    }
+    ASSERT_NOT_REACHED;
+    return "INVALID";
 }
 
 static cairo_status_t
@@ -1057,6 +1058,7 @@ _write_image_surface (cairo_output_stream_t *output,
 	    data += stride;
 	}
 	break;
+    case CAIRO_FORMAT_INVALID:
     default:
 	ASSERT_NOT_REACHED;
 	break;
@@ -1110,6 +1112,7 @@ _write_image_surface (cairo_output_stream_t *output,
 	    data += stride;
 	}
 	break;
+    case CAIRO_FORMAT_INVALID:
     default:
 	ASSERT_NOT_REACHED;
 	break;
@@ -1230,6 +1233,9 @@ _emit_image_surface (cairo_script_surface_t *surface,
 	case CAIRO_FORMAT_ARGB32:
 	    len = clone->width * 4;
 	    break;
+	case CAIRO_FORMAT_INVALID:
+	    ASSERT_NOT_REACHED;
+	    break;
 	}
 	len *= clone->height;
 
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index ce872f7..a7786cb 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -176,6 +176,9 @@ _create_dc_and_bitmap (cairo_win32_surface_t *surface,
     surface->is_dib = FALSE;
 
     switch (format) {
+    default:
+    case CAIRO_FORMAT_INVALID:
+	return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
     case CAIRO_FORMAT_ARGB32:
     case CAIRO_FORMAT_RGB24:
 	num_palette = 0;
@@ -337,6 +340,9 @@ _cairo_win32_surface_create_for_dc (HDC             original_dc,
     unsigned char *bits;
     int rowstride;
 
+    if (! CAIRO_FORMAT_VALID (format))
+	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
+
     surface = malloc (sizeof (cairo_win32_surface_t));
     if (surface == NULL)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 3752872..e7a1014 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -3829,6 +3829,7 @@ _cairo_xcb_scaled_font_get_glyphset_info_for_format (cairo_scaled_font_t *scaled
 
     switch (format) {
     default:
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_RGB24:
     case CAIRO_FORMAT_ARGB32: glyphset_index = GLYPHSET_INDEX_ARGB32; break;
     case CAIRO_FORMAT_A8:     glyphset_index = GLYPHSET_INDEX_A8;     break;
@@ -3892,6 +3893,7 @@ _cairo_xcb_scaled_font_get_glyphset_info_for_pending_free_glyph (
     if (surface != NULL) {
 	switch (surface->format) {
 	default:
+	case CAIRO_FORMAT_INVALID:
 	case CAIRO_FORMAT_RGB24:
 	case CAIRO_FORMAT_ARGB32: i = GLYPHSET_INDEX_ARGB32; break;
 	case CAIRO_FORMAT_A8:     i = GLYPHSET_INDEX_A8;     break;
@@ -4058,6 +4060,7 @@ _cairo_xcb_surface_add_glyph (cairo_xcb_connection_t *connection,
 	break;
 
     case CAIRO_FORMAT_RGB24:
+    case CAIRO_FORMAT_INVALID:
     default:
 	ASSERT_NOT_REACHED;
 	break;
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index d8715c6..f9b9617 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -591,6 +591,7 @@ _cairo_xlib_display_get_xrender_format (cairo_xlib_display_t	*display,
 	    pict_format = PictStandardA8; break;
 	case CAIRO_FORMAT_RGB24:
 	    pict_format = PictStandardRGB24; break;
+	case CAIRO_FORMAT_INVALID:
 	default:
 	    ASSERT_NOT_REACHED;
 	case CAIRO_FORMAT_ARGB32:
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 8545948..f8620e3 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3749,6 +3749,7 @@ _cairo_xlib_scaled_font_get_glyphset_info_for_format (cairo_scaled_font_t *scale
 
     switch (format) {
     default:
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_RGB24:
     case CAIRO_FORMAT_ARGB32: glyphset_index = GLYPHSET_INDEX_ARGB32; break;
     case CAIRO_FORMAT_A8:     glyphset_index = GLYPHSET_INDEX_A8;     break;
@@ -3810,6 +3811,7 @@ _cairo_xlib_scaled_font_get_glyphset_info_for_pending_free_glyph (
     if (surface != NULL) {
 	switch (surface->format) {
 	default:
+	case CAIRO_FORMAT_INVALID:
 	case CAIRO_FORMAT_RGB24:
 	case CAIRO_FORMAT_ARGB32: i = GLYPHSET_INDEX_ARGB32; break;
 	case CAIRO_FORMAT_A8:     i = GLYPHSET_INDEX_A8;     break;
@@ -3999,6 +4001,7 @@ _cairo_xlib_surface_add_glyph (Display *dpy,
 	}
 	break;
     case CAIRO_FORMAT_RGB24:
+    case CAIRO_FORMAT_INVALID:
     default:
 	ASSERT_NOT_REACHED;
 	break;
diff --git a/src/cairo-xml-surface.c b/src/cairo-xml-surface.c
index 53247a0..407aa96 100644
--- a/src/cairo-xml-surface.c
+++ b/src/cairo-xml-surface.c
@@ -72,17 +72,6 @@ slim_hidden_proto (cairo_xml_for_recording_surface);
 static const cairo_surface_backend_t _cairo_xml_surface_backend;
 
 static const char *
-_direction_to_string (cairo_bool_t backward)
-{
-    static const char *names[] = {
-	"FORWARD",
-	"BACKWARD"
-    };
-    assert (backward < ARRAY_LENGTH (names));
-    return names[backward];
-}
-
-static const char *
 _operator_to_string (cairo_operator_t op)
 {
     static const char *names[] = {
@@ -214,14 +203,15 @@ _content_to_string (cairo_content_t content)
 static const char *
 _format_to_string (cairo_format_t format)
 {
-    static const char *names[] = {
-	"ARGB32",	/* CAIRO_FORMAT_ARGB32 */
-	"RGB24",	/* CAIRO_FORMAT_RGB24 */
-	"A8",		/* CAIRO_FORMAT_A8 */
-	"A1"		/* CAIRO_FORMAT_A1 */
-    };
-    assert (format < ARRAY_LENGTH (names));
-    return names[format];
+    switch (format) {
+    case CAIRO_FORMAT_ARGB32:  return "ARGB32";
+    case CAIRO_FORMAT_RGB24:   return "RGB24";
+    case CAIRO_FORMAT_A8:      return "A8";
+    case CAIRO_FORMAT_A1:      return "A1";
+    case CAIRO_FORMAT_INVALID: return "INVALID";
+    }
+    ASSERT_NOT_REACHED;
+    return "INVALID";
 }
 
 static void
diff --git a/src/cairo.h b/src/cairo.h
index 453874d..7e98461 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2231,6 +2231,7 @@ cairo_surface_has_show_text_glyphs (cairo_surface_t *surface);
 
 /**
  * cairo_format_t:
+ * @CAIRO_FORMAT_INVALID: no such format exists or is supported.
  * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
  *   alpha in the upper 8 bits, then red, then green, then blue.
  *   The 32-bit quantities are stored native-endian. Pre-multiplied
@@ -2257,10 +2258,11 @@ cairo_surface_has_show_text_glyphs (cairo_surface_t *surface);
  * New entries may be added in future versions.
  **/
 typedef enum _cairo_format {
-    CAIRO_FORMAT_ARGB32,
-    CAIRO_FORMAT_RGB24,
-    CAIRO_FORMAT_A8,
-    CAIRO_FORMAT_A1
+    CAIRO_FORMAT_INVALID   = -1,
+    CAIRO_FORMAT_ARGB32    = 0,
+    CAIRO_FORMAT_RGB24     = 1,
+    CAIRO_FORMAT_A8        = 2,
+    CAIRO_FORMAT_A1        = 3
     /* The value of 4 is reserved by a deprecated enum value.
      * The next format added must have an explicit value of 5.
     CAIRO_FORMAT_RGB16_565 = 4,
diff --git a/src/cairoint.h b/src/cairoint.h
index c2a4866..741ccf3 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2148,8 +2148,8 @@ _cairo_surface_has_device_transform (cairo_surface_t *surface) cairo_pure;
  * to support it (at least cairo_surface_write_to_png() and a few spots
  * in cairo-xlib-surface.c--again see -Wswitch-enum).
  */
-#define CAIRO_FORMAT_INVALID ((unsigned int) -1)
-#define CAIRO_FORMAT_VALID(format) ((format) <= CAIRO_FORMAT_A1)
+#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&		\
+                                    (format) <= CAIRO_FORMAT_A1)
 
 /* pixman-required stride alignment in bytes. */
 #define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
diff --git a/src/drm/cairo-drm-gallium-surface.c b/src/drm/cairo-drm-gallium-surface.c
index 73d7547..faea87b 100644
--- a/src/drm/cairo-drm-gallium-surface.c
+++ b/src/drm/cairo-drm-gallium-surface.c
@@ -522,6 +522,7 @@ gallium_surface_create_for_name (cairo_drm_device_t *base_dev,
 
     switch (format) {
     default:
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_A1:
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
     case CAIRO_FORMAT_A8:
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index 851c373..dabc02e 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -1594,6 +1594,7 @@ i915_buffer_cache_init (intel_buffer_cache_t *cache,
     cache->buffer.height = height;
 
     switch (format) {
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_A1:
     case CAIRO_FORMAT_RGB24:
 	ASSERT_NOT_REACHED;
diff --git a/src/drm/cairo-drm-intel-surface.c b/src/drm/cairo-drm-intel-surface.c
index 5b7c60b..965772d 100644
--- a/src/drm/cairo-drm-intel-surface.c
+++ b/src/drm/cairo-drm-intel-surface.c
@@ -349,7 +349,7 @@ intel_surface_create_for_name (cairo_drm_device_t *device,
     cairo_status_t status;
 
     switch (format) {
-    default:
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_A1:
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
     case CAIRO_FORMAT_ARGB32:
diff --git a/src/drm/cairo-drm-intel.c b/src/drm/cairo-drm-intel.c
index 748acee..dd5883a 100644
--- a/src/drm/cairo-drm-intel.c
+++ b/src/drm/cairo-drm-intel.c
@@ -708,7 +708,6 @@ intel_bo_put_image (intel_device_t *dev,
     offset = dst_y * stride;
     data = src->data + src_y * src->stride;
     switch (src->format) {
-    default:
     case CAIRO_FORMAT_ARGB32:
     case CAIRO_FORMAT_RGB24:
 	offset += 4 * dst_x;
@@ -726,6 +725,8 @@ intel_bo_put_image (intel_device_t *dev,
 				       src_x, src_y,
 				       width, height,
 				       dst_x, dst_y);
+    default:
+	return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
     }
 
     if (bo->tiling == I915_TILING_NONE) {
@@ -1016,8 +1017,6 @@ intel_glyph_cache_add_glyph (intel_device_t *device,
 	}
 	break;
 
-    default:
-	ASSERT_NOT_REACHED;
     case CAIRO_FORMAT_RGB24:
     case CAIRO_FORMAT_ARGB32:
 	dst  += 4*node->x;
@@ -1028,6 +1027,9 @@ intel_glyph_cache_add_glyph (intel_device_t *device,
 	    src += glyph_surface->stride;
 	}
 	break;
+    default:
+	ASSERT_NOT_REACHED;
+	return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
     }
 
     /* leave mapped! */
@@ -1113,6 +1115,7 @@ intel_get_glyph_cache (intel_device_t *device,
 	break;
     default:
 	ASSERT_NOT_REACHED;
+	return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
     }
 
     if (unlikely (cache->buffer.bo == NULL)) {
@@ -1227,7 +1230,9 @@ intel_buffer_cache_init (intel_buffer_cache_t *cache,
     switch (format) {
     case CAIRO_FORMAT_A1:
     case CAIRO_FORMAT_RGB24:
+    case CAIRO_FORMAT_INVALID:
 	ASSERT_NOT_REACHED;
+	return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
     case CAIRO_FORMAT_ARGB32:
 	cache->buffer.map0 = MAPSURF_32BIT | MT_32BIT_ARGB8888;
 	cache->buffer.stride = width * 4;
diff --git a/src/drm/cairo-drm-radeon-surface.c b/src/drm/cairo-drm-radeon-surface.c
index 7521199..e43a975 100644
--- a/src/drm/cairo-drm-radeon-surface.c
+++ b/src/drm/cairo-drm-radeon-surface.c
@@ -367,7 +367,7 @@ radeon_surface_create_for_name (cairo_drm_device_t *device,
     cairo_content_t content;
 
     switch (format) {
-    default:
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_A1:
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
     case CAIRO_FORMAT_ARGB32:
diff --git a/test/any2ppm.c b/test/any2ppm.c
index 4d215e0..a7bb49a 100644
--- a/test/any2ppm.c
+++ b/test/any2ppm.c
@@ -191,6 +191,7 @@ write_ppm (cairo_surface_t *surface, int fd)
 	format_str = "P5";
 	break;
     case CAIRO_FORMAT_A1:
+    case CAIRO_FORMAT_INVALID:
     default:
 	return "unhandled image format";
     }
diff --git a/test/png.c b/test/png.c
index fb50a9b..9f082c9 100644
--- a/test/png.c
+++ b/test/png.c
@@ -57,6 +57,7 @@ format_to_string (cairo_format_t format)
     case CAIRO_FORMAT_A8:     return "a8";
     case CAIRO_FORMAT_RGB24:  return "rgb24";
     case CAIRO_FORMAT_ARGB32: return "argb32";
+    case CAIRO_FORMAT_INVALID:
     default: return "???";
     }
 }
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index 2456c3a..1f8ae90 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -2844,6 +2844,7 @@ _image_read_raw (csi_file_t *src,
 	len = 3 * width * height;
 	break;
     default:
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_ARGB32:
 	len = 4 * width * height;
 	break;
@@ -2894,6 +2895,7 @@ _image_read_raw (csi_file_t *src,
 #endif
 		}
 		break;
+	    case CAIRO_FORMAT_INVALID:
 	    case CAIRO_FORMAT_ARGB32:
 		/* stride == width */
 		break;
@@ -2968,6 +2970,7 @@ _image_read_raw (csi_file_t *src,
 #endif
 	    }
 	    break;
+	case CAIRO_FORMAT_INVALID:
 	case CAIRO_FORMAT_ARGB32:
 	    /* stride == width */
 	    break;
@@ -2994,6 +2997,7 @@ _image_read_raw (csi_file_t *src,
 	    break;
 
 	case CAIRO_FORMAT_RGB24:
+	case CAIRO_FORMAT_INVALID:
 	default:
 	    break;
 	}
@@ -6140,6 +6144,7 @@ _integer_constants[] = {
     { "A8",			CAIRO_FORMAT_A8 },
     { "RGB24",			CAIRO_FORMAT_RGB24 },
     { "ARGB32",			CAIRO_FORMAT_ARGB32 },
+    { "INVALID",		CAIRO_FORMAT_INVALID },
 
     { NULL, 0 }
 };
diff --git a/util/cairo-sphinx/sphinx.c b/util/cairo-sphinx/sphinx.c
index 6d2cda7..20d9f01 100644
--- a/util/cairo-sphinx/sphinx.c
+++ b/util/cairo-sphinx/sphinx.c
@@ -618,6 +618,9 @@ compare_images (cairo_surface_t *a,
 	    bb += stride;
 	}
 	break;
+
+    case CAIRO_FORMAT_INVALID:
+	break;
     }
 
     return TRUE;
@@ -831,7 +834,7 @@ request_image (struct client *c,
     unsigned long offset = -1;
     int len;
 
-    assert (format != (cairo_format_t) -1);
+    assert (format != CAIRO_FORMAT_INVALID);
 
     len = sprintf (buf, ".image %lu %d %d %d %d\n",
 		   closure->id, format, width, height, stride);
@@ -900,14 +903,14 @@ send_surface (struct client *c,
 {
     cairo_surface_t *source = closure->surface;
     cairo_surface_t *image;
-    cairo_format_t format = (cairo_format_t) -1;
+    cairo_format_t format = CAIRO_FORMAT_INVALID;
     cairo_t *cr;
     int width, height, stride;
     void *data;
     unsigned long serial;
 
     get_surface_size (source, &width, &height, &format);
-    if (format == (cairo_format_t) -1)
+    if (format == CAIRO_FORMAT_INVALID)
 	format = format_for_content (cairo_surface_get_content (source));
 
     stride = cairo_format_stride_for_width (format, width);
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index 46ec7f2..9bc06e0 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -1439,6 +1439,7 @@ _format_to_string (cairo_format_t format)
 {
 #define f(name) case CAIRO_FORMAT_ ## name: return #name
     switch (format) {
+	f(INVALID);
 	f(ARGB32);
 	f(RGB24);
 	f(A8);
@@ -1570,6 +1571,7 @@ _emit_image (cairo_surface_t *image,
     case CAIRO_FORMAT_A8:     len =  width; break;
     case CAIRO_FORMAT_RGB24:  len = 3*width; break;
     default:
+    case CAIRO_FORMAT_INVALID:
     case CAIRO_FORMAT_ARGB32: len = 4*width; break;
     }
 
@@ -1607,6 +1609,7 @@ _emit_image (cairo_surface_t *image,
 	    data += stride;
 	}
 	break;
+    case CAIRO_FORMAT_INVALID:
     default:
 	break;
     }
@@ -1659,6 +1662,7 @@ _emit_image (cairo_surface_t *image,
 	    data += stride;
 	}
 	break;
+    case CAIRO_FORMAT_INVALID:
     default:
 	break;
     }


More information about the cairo-commit mailing list