From 0f49f36519b2721575dd77a8a61dd373240c9fcb Mon Sep 17 00:00:00 2001 From: Adel Gadllah Date: Wed, 13 Jul 2011 22:14:45 +0200 Subject: [PATCH] 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 --- configure.ac | 2 +- src/shell-recorder.c | 4 ++-- src/shell-xfixes-cursor.c | 6 +----- src/st/st-drawing-area.c | 13 ++----------- src/st/st-theme-node-drawing.c | 15 ++------------- 5 files changed, 8 insertions(+), 32 deletions(-) diff --git a/configure.ac b/configure.ac index eb8098e8c..26f343451 100644 --- a/configure.ac +++ b/configure.ac @@ -64,7 +64,7 @@ fi 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 GJS_MIN_VERSION=0.7.11 MUTTER_MIN_VERSION=3.0.0 diff --git a/src/shell-recorder.c b/src/shell-recorder.c index d297923e0..0171045de 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -198,7 +198,7 @@ create_recording_icon (void) texture = cogl_texture_new_from_data (32, 32, COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_BGRA_8888, + CLUTTER_CAIRO_FORMAT_ARGB32, COGL_PIXEL_FORMAT_ANY, cairo_image_surface_get_stride (surface), cairo_image_surface_get_data (surface)); @@ -529,7 +529,7 @@ recorder_record_frame (ShellRecorder *recorder) cogl_read_pixels (0, 0, recorder->stage_width, recorder->stage_height, COGL_READ_PIXELS_COLOR_BUFFER, - COGL_PIXEL_FORMAT_BGRA_8888_PRE, + CLUTTER_CAIRO_FORMAT_ARGB32, data); recorder_draw_cursor (recorder, buffer); diff --git a/src/shell-xfixes-cursor.c b/src/shell-xfixes-cursor.c index 334503df9..0da2397c6 100644 --- a/src/shell-xfixes-cursor.c +++ b/src/shell-xfixes-cursor.c @@ -232,11 +232,7 @@ xfixes_cursor_reset_image (ShellXFixesCursor *xfixes_cursor) sprite = cogl_texture_new_from_data (cursor_image->width, cursor_image->height, COGL_TEXTURE_NONE, -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - COGL_PIXEL_FORMAT_BGRA_8888_PRE, -#else - COGL_PIXEL_FORMAT_ARGB_8888_PRE, -#endif + CLUTTER_CAIRO_FORMAT_ARGB32, COGL_PIXEL_FORMAT_ANY, cursor_image->width * 4, /* stride */ cursor_data); diff --git a/src/st/st-drawing-area.c b/src/st/st-drawing-area.c index 2235842d8..2b904e219 100644 --- a/src/st/st-drawing-area.c +++ b/src/st/st-drawing-area.c @@ -36,15 +36,6 @@ #include -/* 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); struct _StDrawingAreaPrivate { @@ -122,7 +113,7 @@ st_drawing_area_paint (ClutterActor *self) { priv->texture = cogl_texture_new_with_size (width, height, COGL_TEXTURE_NONE, - PIXEL_FORMAT); + CLUTTER_CAIRO_FORMAT_ARGB32); priv->needs_repaint = TRUE; } @@ -142,7 +133,7 @@ st_drawing_area_paint (ClutterActor *self) priv->context = NULL; 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_data (surface)); diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c index a600179a4..7513a48f9 100644 --- a/src/st/st-theme-node-drawing.c +++ b/src/st/st-theme-node-drawing.c @@ -167,11 +167,7 @@ create_corner_material (StCornerSpec *corner) texture = cogl_texture_new_from_data (size, size, COGL_TEXTURE_NONE, -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - COGL_PIXEL_FORMAT_BGRA_8888_PRE, -#else - COGL_PIXEL_FORMAT_ARGB_8888_PRE, -#endif + CLUTTER_CAIRO_FORMAT_ARGB32, COGL_PIXEL_FORMAT_ANY, rowstride, data); @@ -1250,14 +1246,7 @@ st_theme_node_prerender_background (StThemeNode *node) texture = cogl_texture_new_from_data (paint_box.x2 - paint_box.x1, paint_box.y2 - paint_box.y1, COGL_TEXTURE_NONE, -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - 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 + CLUTTER_CAIRO_FORMAT_ARGB32, COGL_PIXEL_FORMAT_ANY, rowstride, data);