[cairo] [patch] gl: create BGRA texture and avoid conversion
Henry (Yu) Song - SISA
hsong at sisa.samsung.com
Fri Feb 1 08:10:40 PST 2013
Hi, Chris
Thanks for comments. First patch - add _cairo_image_surface_coerce_to_pixman_format().
Thanks, Henry
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 3fe6e43..4778610 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1057,6 +1057,17 @@ cairo_image_surface_t *
_cairo_image_surface_coerce_to_format (cairo_image_surface_t *surface,
cairo_format_t format)
{
+ pixman_format_code_t pixman_format = _cairo_format_to_pixman_format_code (format);
+
+ return _cairo_image_surface_coerce_to_pixman_format (surface, pixman_format);
+}
+
+/* A convenience function for when one needs to coerce an image
+ * surface to a specific pixman format. */
+cairo_private cairo_image_surface_t *
+_cairo_image_surface_coerce_to_pixman_format (cairo_image_surface_t *surface,
+ pixman_format_code_t pixman_format)
+{
cairo_image_surface_t *clone;
cairo_status_t status;
@@ -1064,11 +1075,15 @@ _cairo_image_surface_coerce_to_format (cairo_image_surface_t *surface,
if (unlikely (status))
return (cairo_image_surface_t *)_cairo_surface_create_in_error (status);
- if (surface->format == format)
+ if (surface->pixman_format == pixman_format)
return (cairo_image_surface_t *)cairo_surface_reference(&surface->base);
clone = (cairo_image_surface_t *)
- cairo_image_surface_create (format, surface->width, surface->height);
+ _cairo_image_surface_create_with_pixman_format (NULL,
+ pixman_format,
+ surface->width,
+ surface->height,
+ 0);
if (unlikely (clone->base.status))
return clone;
diff --git a/src/cairoint.h b/src/cairoint.h
index 861e2f7..18ce2df 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1536,6 +1536,10 @@ cairo_private cairo_image_surface_t *
_cairo_image_surface_coerce_to_format (cairo_image_surface_t *surface,
cairo_format_t format);
+cairo_private cairo_image_surface_t *
+_cairo_image_surface_coerce_to_pixman_format (cairo_image_surface_t *surface,
+ pixman_format_code_t pixman_format);
+
cairo_private cairo_image_transparency_t
_cairo_image_analyze_transparency (cairo_image_surface_t *image);
--
1.7.9.5
More information about the cairo
mailing list