[cairo-commit] src/cairo-gl-glyphs.c src/cairo-gl-surface.c src/cairo-image-surface.c src/cairoint.h src/cairo-png.c src/cairo-scaled-font.c src/cairo-script-surface.c src/cairo-svg-surface.c src/cairo-type3-glyph-surface.c src/cairo-xcb-surface-render.c

Benjamin Otte company at kemper.freedesktop.org
Tue Feb 23 12:04:54 PST 2010


 src/cairo-gl-glyphs.c           |    3 +--
 src/cairo-gl-surface.c          |    3 +--
 src/cairo-image-surface.c       |   14 ++++++++++++--
 src/cairo-png.c                 |    3 +--
 src/cairo-scaled-font.c         |    2 +-
 src/cairo-script-surface.c      |    4 +---
 src/cairo-svg-surface.c         |    4 ++--
 src/cairo-type3-glyph-surface.c |    2 +-
 src/cairo-xcb-surface-render.c  |   21 ++++-----------------
 src/cairoint.h                  |    8 ++++++--
 10 files changed, 30 insertions(+), 34 deletions(-)

New commits:
commit 8bb06915ed6628c6d8978b6c2fec474bbf08d7e9
Author: Benjamin Otte <otte at redhat.com>
Date:   Tue Feb 23 21:01:13 2010 +0100

    image: split cairo_image_surface_coerce()
    
    Split into a general cairo_image_surface_coerce() that coerces to one of
    the 3 supported formats (ARGB32, RGB24, A8) based on content and the
    more general cairo_image_surface_coerce_to_format() that coerces to a
    specified format.

diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index b9b1117..06c29c5 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -71,8 +71,7 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
     {
 	cairo_bool_t is_supported;
 
-	clone = _cairo_image_surface_coerce (glyph_surface,
-		                             _cairo_format_from_content (glyph_surface->base.content));
+	clone = _cairo_image_surface_coerce (glyph_surface);
 	if (unlikely (clone->base.status))
 	    return clone->base.status;
 
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 69b6dd3..076fc3f 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -693,8 +693,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
     {
 	cairo_bool_t is_supported;
 
-	clone = _cairo_image_surface_coerce (src,
-		_cairo_format_from_content (src->base.content));
+	clone = _cairo_image_surface_coerce (src);
 	if (unlikely (clone->base.status))
 	    return clone->base.status;
 
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 8dbf2e7..854e98d 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -4320,8 +4320,18 @@ const cairo_surface_backend_t _cairo_image_surface_backend = {
 /* A convenience function for when one needs to coerce an image
  * surface to an alternate format. */
 cairo_image_surface_t *
-_cairo_image_surface_coerce (cairo_image_surface_t	*surface,
-			     cairo_format_t		 format)
+_cairo_image_surface_coerce (cairo_image_surface_t *surface)
+{
+    return _cairo_image_surface_coerce_to_format (surface,
+		                                  _cairo_format_from_content (surface->base.content));
+        
+}
+
+/* A convenience function for when one needs to coerce an image
+ * surface to an alternate format. */
+cairo_image_surface_t *
+_cairo_image_surface_coerce_to_format (cairo_image_surface_t *surface,
+			               cairo_format_t	      format)
 {
     cairo_image_surface_t *clone;
     cairo_status_t status;
diff --git a/src/cairo-png.c b/src/cairo-png.c
index ecb27d8..8b9b43c 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -172,8 +172,7 @@ write_png (cairo_surface_t	*surface,
     /* Handle the various fallback formats (e.g. low bit-depth XServers)
      * by coercing them to a simpler format using pixman.
      */
-    clone = _cairo_image_surface_coerce (image,
-                                         _cairo_format_from_content (image->base.content));
+    clone = _cairo_image_surface_coerce (image);
     status = clone->base.status;
     if (unlikely (status))
         goto BAIL1;
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 480488f..4171c46 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2302,7 +2302,7 @@ _trace_mask_to_path (cairo_image_surface_t *mask,
     cairo_fixed_t px, py;
     cairo_status_t status;
 
-    mask = _cairo_image_surface_coerce (mask, CAIRO_FORMAT_A1);
+    mask = _cairo_image_surface_coerce_to_format (mask, CAIRO_FORMAT_A1);
     status = mask->base.status;
     if (unlikely (status))
 	return status;
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index af4abbc..77cac9b 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -1202,9 +1202,7 @@ _emit_image_surface (cairo_script_surface_t *surface,
 	uint32_t len;
 
 	if (image->format == CAIRO_FORMAT_INVALID) {
-	    clone =
-		_cairo_image_surface_coerce (image,
-					     _cairo_format_from_content (image->base.content));
+	    clone = _cairo_image_surface_coerce (image);
 	} else {
 	    clone = (cairo_image_surface_t *)
 		cairo_surface_reference (&image->base);
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index fe09f58..c0fdd54 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -736,8 +736,8 @@ _cairo_svg_document_emit_bitmap_glyph_data (cairo_svg_document_t	*document,
     if (unlikely (status))
 	return status;
 
-    image = _cairo_image_surface_coerce (scaled_glyph->surface,
-					 CAIRO_FORMAT_A1);
+    image = _cairo_image_surface_coerce_to_format (scaled_glyph->surface,
+					           CAIRO_FORMAT_A1);
     status = image->base.status;
     if (unlikely (status))
 	return status;
diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c
index d9fee4f..9359a27 100644
--- a/src/cairo-type3-glyph-surface.c
+++ b/src/cairo-type3-glyph-surface.c
@@ -120,7 +120,7 @@ _cairo_type3_glyph_surface_emit_image (cairo_type3_glyph_surface_t *surface,
     cairo_status_t status;
 
     /* The only image type supported by Type 3 fonts are 1-bit masks */
-    image = _cairo_image_surface_coerce (image, CAIRO_FORMAT_A1);
+    image = _cairo_image_surface_coerce_to_format (image, CAIRO_FORMAT_A1);
     status = image->base.status;
     if (unlikely (status))
 	return status;
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 5212cae..3752872 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -1342,29 +1342,16 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 	    _cairo_surface_release_source_image (source, image, image_extra);
 	} else {
 	    cairo_image_surface_t *conv;
-	    cairo_format_t format;
 	    xcb_render_pictformat_t render_format;
 
 	    /* XXX XRenderPutImage! */
 
-	    switch (image->base.content) {
-	    case CAIRO_CONTENT_ALPHA:
-		format = CAIRO_FORMAT_A8;
-		break;
-	    case CAIRO_CONTENT_COLOR:
-		format = CAIRO_FORMAT_RGB24;
-		break;
-	    case CAIRO_CONTENT_COLOR_ALPHA:
-		format = CAIRO_FORMAT_ARGB32;
-		break;
-	    }
-
-	    conv = _cairo_image_surface_coerce (image, format);
+	    conv = _cairo_image_surface_coerce (image);
 	    _cairo_surface_release_source_image (source, image, image_extra);
 	    if (unlikely (conv->base.status))
 		return (cairo_xcb_picture_t *) conv;
 
-	    render_format = target->screen->connection->standard_formats[format];
+	    render_format = target->screen->connection->standard_formats[conv->format];
 	    picture = _picture_from_image (target, render_format, conv, NULL);
 	    cairo_surface_destroy (&conv->base);
 	}
@@ -4000,8 +3987,8 @@ _cairo_xcb_surface_add_glyph (cairo_xcb_connection_t *connection,
      * format.
      */
     if (glyph_surface->format != glyphset_info->format) {
-	glyph_surface = _cairo_image_surface_coerce (glyph_surface,
-						     glyphset_info->format);
+	glyph_surface = _cairo_image_surface_coerce_to_format (glyph_surface,
+						               glyphset_info->format);
 	status = glyph_surface->base.status;
 	if (unlikely (status))
 	    goto BAIL;
diff --git a/src/cairoint.h b/src/cairoint.h
index 16c9a44..c2a4866 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2205,8 +2205,12 @@ cairo_private void
 _cairo_image_surface_assume_ownership_of_data (cairo_image_surface_t *surface);
 
 cairo_private cairo_image_surface_t *
-_cairo_image_surface_coerce (cairo_image_surface_t	*surface,
-			     cairo_format_t		 format);
+_cairo_image_surface_coerce (cairo_image_surface_t	*surface);
+
+cairo_private cairo_image_surface_t *
+_cairo_image_surface_coerce_to_format (cairo_image_surface_t	*surface,
+			               cairo_format_t		 format);
+
 cairo_private void
 _cairo_image_surface_span_render_row (int				 y,
 				      const cairo_half_open_span_t	 *spans,


More information about the cairo-commit mailing list