Re: [patch] gl: create BGRA texture and avoid conversion

"Henry (Yu) Song - SISA" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <3955FA337689574EB32F94B12A7E6E9E434AF4C5@sisaex01sj>
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

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.