Use CLUTTER_CAIRO_FORMAT_ARGB32: rather then doing a byte order check

Clutter 1.7.x introduced CLUTTER_CAIRO_FORMAT_ARGB32: which can be used when
sharing textures/data with cairo without having to do check the
byte order and choose the appropriate format by hand.

https://bugzilla.gnome.org/show_bug.cgi?id=654577
This commit is contained in:
Adel Gadllah 2011-07-13 22:14:45 +02:00
parent a92b7342ba
commit 0f49f36519
5 changed files with 8 additions and 32 deletions

View File

@ -64,7 +64,7 @@ fi
AM_CONDITIONAL(BUILD_RECORDER, $build_recorder) AM_CONDITIONAL(BUILD_RECORDER, $build_recorder)
CLUTTER_MIN_VERSION=1.5.15 CLUTTER_MIN_VERSION=1.7.5
GOBJECT_INTROSPECTION_MIN_VERSION=0.10.1 GOBJECT_INTROSPECTION_MIN_VERSION=0.10.1
GJS_MIN_VERSION=0.7.11 GJS_MIN_VERSION=0.7.11
MUTTER_MIN_VERSION=3.0.0 MUTTER_MIN_VERSION=3.0.0

View File

@ -198,7 +198,7 @@ create_recording_icon (void)
texture = cogl_texture_new_from_data (32, 32, texture = cogl_texture_new_from_data (32, 32,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_BGRA_8888, CLUTTER_CAIRO_FORMAT_ARGB32,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
cairo_image_surface_get_stride (surface), cairo_image_surface_get_stride (surface),
cairo_image_surface_get_data (surface)); cairo_image_surface_get_data (surface));
@ -529,7 +529,7 @@ recorder_record_frame (ShellRecorder *recorder)
cogl_read_pixels (0, 0, cogl_read_pixels (0, 0,
recorder->stage_width, recorder->stage_height, recorder->stage_width, recorder->stage_height,
COGL_READ_PIXELS_COLOR_BUFFER, COGL_READ_PIXELS_COLOR_BUFFER,
COGL_PIXEL_FORMAT_BGRA_8888_PRE, CLUTTER_CAIRO_FORMAT_ARGB32,
data); data);
recorder_draw_cursor (recorder, buffer); recorder_draw_cursor (recorder, buffer);

View File

@ -232,11 +232,7 @@ xfixes_cursor_reset_image (ShellXFixesCursor *xfixes_cursor)
sprite = cogl_texture_new_from_data (cursor_image->width, sprite = cogl_texture_new_from_data (cursor_image->width,
cursor_image->height, cursor_image->height,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
#if G_BYTE_ORDER == G_LITTLE_ENDIAN CLUTTER_CAIRO_FORMAT_ARGB32,
COGL_PIXEL_FORMAT_BGRA_8888_PRE,
#else
COGL_PIXEL_FORMAT_ARGB_8888_PRE,
#endif
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
cursor_image->width * 4, /* stride */ cursor_image->width * 4, /* stride */
cursor_data); cursor_data);

View File

@ -36,15 +36,6 @@
#include <cairo.h> #include <cairo.h>
/* 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 PIXEL_FORMAT COGL_PIXEL_FORMAT_BGRA_8888_PRE
#else
#define PIXEL_FORMAT COGL_PIXEL_FORMAT_ARGB_8888_PRE
#endif
G_DEFINE_TYPE(StDrawingArea, st_drawing_area, ST_TYPE_WIDGET); G_DEFINE_TYPE(StDrawingArea, st_drawing_area, ST_TYPE_WIDGET);
struct _StDrawingAreaPrivate { struct _StDrawingAreaPrivate {
@ -122,7 +113,7 @@ st_drawing_area_paint (ClutterActor *self)
{ {
priv->texture = cogl_texture_new_with_size (width, height, priv->texture = cogl_texture_new_with_size (width, height,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
PIXEL_FORMAT); CLUTTER_CAIRO_FORMAT_ARGB32);
priv->needs_repaint = TRUE; priv->needs_repaint = TRUE;
} }
@ -142,7 +133,7 @@ st_drawing_area_paint (ClutterActor *self)
priv->context = NULL; priv->context = NULL;
cogl_texture_set_region (priv->texture, 0, 0, 0, 0, width, height, width, height, cogl_texture_set_region (priv->texture, 0, 0, 0, 0, width, height, width, height,
PIXEL_FORMAT, CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_stride (surface), cairo_image_surface_get_stride (surface),
cairo_image_surface_get_data (surface)); cairo_image_surface_get_data (surface));

View File

@ -167,11 +167,7 @@ create_corner_material (StCornerSpec *corner)
texture = cogl_texture_new_from_data (size, size, texture = cogl_texture_new_from_data (size, size,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
#if G_BYTE_ORDER == G_LITTLE_ENDIAN CLUTTER_CAIRO_FORMAT_ARGB32,
COGL_PIXEL_FORMAT_BGRA_8888_PRE,
#else
COGL_PIXEL_FORMAT_ARGB_8888_PRE,
#endif
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
rowstride, rowstride,
data); data);
@ -1250,14 +1246,7 @@ st_theme_node_prerender_background (StThemeNode *node)
texture = cogl_texture_new_from_data (paint_box.x2 - paint_box.x1, texture = cogl_texture_new_from_data (paint_box.x2 - paint_box.x1,
paint_box.y2 - paint_box.y1, paint_box.y2 - paint_box.y1,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
#if G_BYTE_ORDER == G_LITTLE_ENDIAN CLUTTER_CAIRO_FORMAT_ARGB32,
COGL_PIXEL_FORMAT_BGRA_8888_PRE,
#elif G_BYTE_ORDER == G_BIG_ENDIAN
COGL_PIXEL_FORMAT_ARGB_8888_PRE,
#else
COGL_PIXEL_FORMAT_ANY,
#error unknown endianness type
#endif
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
rowstride, rowstride,
data); data);