[clutter] cairo-texture: Make the pixel order macro public



commit 3a071a4787c614144579e080f0d9b545e256a4ad
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Apr 12 17:00:46 2011 +0100

    cairo-texture: Make the pixel order macro public
    
    It stands to reason that any piece of code using Cairo and Cogl at the
    same time, and dealing with texture data, will want to use the same
    logic Clutter uses to determine the compatible pixel format between the
    two.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=647875

 clutter/clutter-cairo-texture.c |   13 ++-----------
 clutter/clutter-cairo-texture.h |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/clutter/clutter-cairo-texture.c b/clutter/clutter-cairo-texture.c
index 7931c05..3ac096a 100644
--- a/clutter/clutter-cairo-texture.c
+++ b/clutter/clutter-cairo-texture.c
@@ -125,15 +125,6 @@ static guint cairo_signals[LAST_SIGNAL] = { 0, };
 
 #define CLUTTER_CAIRO_TEXTURE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_CAIRO_TEXTURE, ClutterCairoTexturePrivate))
 
-/* Cairo stores the data in native byte order as ARGB but Cogl's pixel
-   formats specify the actual byte order. Therefore we need to use a
-   different format depending on the architecture */
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CLUTTER_CAIRO_TEXTURE_PIXEL_FORMAT COGL_PIXEL_FORMAT_BGRA_8888_PRE
-#else
-#define CLUTTER_CAIRO_TEXTURE_PIXEL_FORMAT COGL_PIXEL_FORMAT_ARGB_8888_PRE
-#endif
-
 struct _ClutterCairoTexturePrivate
 {
   cairo_surface_t *cr_surface;
@@ -356,7 +347,7 @@ clutter_cairo_texture_create_surface (ClutterCairoTexture *self,
   /* create a backing Cogl texture */
   cogl_texture = cogl_texture_new_from_data (width, height,
                                              COGL_TEXTURE_NONE,
-                                             CLUTTER_CAIRO_TEXTURE_PIXEL_FORMAT,
+                                             CLUTTER_CAIRO_FORMAT_ARGB32,
                                              COGL_PIXEL_FORMAT_ANY,
                                              cairo_stride,
                                              cairo_data);
@@ -560,7 +551,7 @@ clutter_cairo_texture_context_destroy (void *data)
                            ctxt->rect.x, ctxt->rect.y,
                            cairo_width, cairo_height,
                            cairo_width, cairo_height,
-                           CLUTTER_CAIRO_TEXTURE_PIXEL_FORMAT,
+                           CLUTTER_CAIRO_FORMAT_ARGB32,
                            cairo_stride,
                            cairo_data);
 
diff --git a/clutter/clutter-cairo-texture.h b/clutter/clutter-cairo-texture.h
index 5dca82e..3de9cc6 100644
--- a/clutter/clutter-cairo-texture.h
+++ b/clutter/clutter-cairo-texture.h
@@ -44,6 +44,26 @@ G_BEGIN_DECLS
 #define CLUTTER_IS_CAIRO_TEXTURE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CAIRO_TEXTURE))
 #define CLUTTER_CAIRO_TEXTURE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CAIRO_TEXTURE, ClutterCairoTextureClass))
 
+/**
+ * CLUTTER_CAIRO_FORMAT_ARGB32:
+ *
+ * The #CoglPixelFormat to be used when uploading image data from
+ * and to a Cairo image surface using %CAIRO_FORMAT_ARGB32 and
+ * %CAIRO_FORMAT_RGB24 as #cairo_format_t.
+ *
+ * Since: 1.8
+ */
+
+/* Cairo stores the data in native byte order as ARGB but Cogl's pixel
+ * formats specify the actual byte order. Therefore we need to use a
+ * different format depending on the architecture
+ */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define CLUTTER_CAIRO_FORMAT_ARGB32     (COGL_PIXEL_FORMAT_BGRA_8888_PRE)
+#else
+#define CLUTTER_CAIRO_FORMAT_ARGB32     (COGL_PIXEL_FORMAT_ARGB_8888_PRE)
+#endif
+
 typedef struct _ClutterCairoTexture             ClutterCairoTexture;
 typedef struct _ClutterCairoTextureClass        ClutterCairoTextureClass;
 typedef struct _ClutterCairoTexturePrivate      ClutterCairoTexturePrivate;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]