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
This commit is contained in:
Emmanuele Bassi 2011-04-12 17:00:46 +01:00
parent d6fbdf6904
commit 3a071a4787
2 changed files with 22 additions and 11 deletions

View File

@ -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);

View File

@ -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;