summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-02-23 21:01:13 +0100
committerBenjamin Otte <otte@redhat.com>2010-02-23 21:03:31 +0100
commit8bb06915ed6628c6d8978b6c2fec474bbf08d7e9 (patch)
tree8e1e9bc1a1bb0e68f1963e260f2b130975d9d9b0
parentb7c42b6aaa2dba09ed3ff9ae85eae27bec268713 (diff)
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.
-rw-r--r--src/cairo-gl-glyphs.c3
-rw-r--r--src/cairo-gl-surface.c3
-rw-r--r--src/cairo-image-surface.c14
-rw-r--r--src/cairo-png.c3
-rw-r--r--src/cairo-scaled-font.c2
-rw-r--r--src/cairo-script-surface.c4
-rw-r--r--src/cairo-svg-surface.c4
-rw-r--r--src/cairo-type3-glyph-surface.c2
-rw-r--r--src/cairo-xcb-surface-render.c21
-rw-r--r--src/cairoint.h8
10 files changed, 30 insertions, 34 deletions
diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index b9b1117d..06c29c5b 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 69b6dd3e..076fc3f3 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 8dbf2e70..854e98df 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 ecb27d84..8b9b43c7 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 480488fb..4171c465 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 af4abbc5..77cac9bd 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 fe09f58d..c0fdd54b 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 d9fee4fc..9359a272 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 5212caee..37528721 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 16c9a44e..c2a48661 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,