aboutsummaryrefslogtreecommitdiff
path: root/pixman/demos/gtk-utils.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-08-13 10:09:30 +0200
committermarha <marha@users.sourceforge.net>2012-08-13 10:09:30 +0200
commit9ddf44af81782451cee798e06749ce3067a14a41 (patch)
treef84b06f6897929113f080d8e505621fa6bf73fb9 /pixman/demos/gtk-utils.c
parentf8e35ebbe71eed74ccf68af8ccda4182f1edc7f0 (diff)
downloadvcxsrv-9ddf44af81782451cee798e06749ce3067a14a41.tar.gz
vcxsrv-9ddf44af81782451cee798e06749ce3067a14a41.tar.bz2
vcxsrv-9ddf44af81782451cee798e06749ce3067a14a41.zip
mesa pixman xkeyboard-config xserver git update 13 Aug 2012
Diffstat (limited to 'pixman/demos/gtk-utils.c')
-rw-r--r--pixman/demos/gtk-utils.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/pixman/demos/gtk-utils.c b/pixman/demos/gtk-utils.c
index 1ff89ebd3..8291a1ed2 100644
--- a/pixman/demos/gtk-utils.c
+++ b/pixman/demos/gtk-utils.c
@@ -5,7 +5,6 @@
GdkPixbuf *
pixbuf_from_argb32 (uint32_t *bits,
- gboolean has_alpha,
int width,
int height,
int stride)
@@ -47,12 +46,12 @@ show_image (pixman_image_t *image)
{
GtkWidget *window;
GdkPixbuf *pixbuf;
- int width, height, stride;
+ int width, height;
int argc;
char **argv;
char *arg0 = g_strdup ("pixman-test-program");
- gboolean has_alpha;
pixman_format_code_t format;
+ pixman_image_t *copy;
argc = 1;
argv = (char **)&arg0;
@@ -62,21 +61,43 @@ show_image (pixman_image_t *image)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
width = pixman_image_get_width (image);
height = pixman_image_get_height (image);
- stride = pixman_image_get_stride (image);
gtk_window_set_default_size (GTK_WINDOW (window), width, height);
-
+
format = pixman_image_get_format (image);
-
- if (format == PIXMAN_a8r8g8b8)
- has_alpha = TRUE;
- else if (format == PIXMAN_x8r8g8b8)
- has_alpha = FALSE;
- else
- g_error ("Can't deal with this format: %x\n", format);
-
- pixbuf = pixbuf_from_argb32 (pixman_image_get_data (image), has_alpha,
- width, height, stride);
+
+ /* Three cases:
+ *
+ * - image is a8r8g8b8_sRGB: we will display without modification
+ * under the assumption that the monitor is sRGB
+ *
+ * - image is a8r8g8b8: we will display without modification
+ * under the assumption that whoever created the image
+ * probably did it wrong by using sRGB inputs
+ *
+ * - other: we will convert to a8r8g8b8 under the assumption that
+ * whoever created the image probably did it wrong.
+ */
+ switch (format)
+ {
+ case PIXMAN_a8r8g8b8_sRGB:
+ case PIXMAN_a8r8g8b8:
+ copy = pixman_image_ref (image);
+ break;
+
+ default:
+ copy = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+ width, height, NULL, -1);
+ pixman_image_composite32 (PIXMAN_OP_SRC,
+ image, NULL, copy,
+ 0, 0, 0, 0, 0, 0,
+ width, height);
+ break;
+ }
+
+ pixbuf = pixbuf_from_argb32 (pixman_image_get_data (copy),
+ width, height,
+ pixman_image_get_stride (copy));
g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), pixbuf);
g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);