diff options
author | marha <marha@users.sourceforge.net> | 2013-02-27 10:48:05 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-02-27 10:48:05 +0100 |
commit | 9bed5520560f553ac8ad4985ed41b31499d903fc (patch) | |
tree | e7e6587df3f87e4d5398da78a6b0761171da7d68 /pixman/demos/gtk-utils.c | |
parent | b14c3b05e45201bbbbb3a4beba260c3d6ff31003 (diff) | |
parent | c74ef795c7282681616decc36a9a81cd1b1b6ec7 (diff) | |
download | vcxsrv-9bed5520560f553ac8ad4985ed41b31499d903fc.tar.gz vcxsrv-9bed5520560f553ac8ad4985ed41b31499d903fc.tar.bz2 vcxsrv-9bed5520560f553ac8ad4985ed41b31499d903fc.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
libX11 mesa pixman xkeyboard-config
Diffstat (limited to 'pixman/demos/gtk-utils.c')
-rw-r--r-- | pixman/demos/gtk-utils.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/pixman/demos/gtk-utils.c b/pixman/demos/gtk-utils.c index d7e946ded..32d4aecc7 100644 --- a/pixman/demos/gtk-utils.c +++ b/pixman/demos/gtk-utils.c @@ -95,14 +95,31 @@ pixbuf_from_argb32 (uint32_t *bits, static gboolean on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data) { - GdkPixbuf *pixbuf = data; + pixman_image_t *pimage = data; + int width = pixman_image_get_width (pimage); + int height = pixman_image_get_height (pimage); + int stride = pixman_image_get_stride (pimage); + cairo_surface_t *cimage; + cairo_format_t format; + cairo_t *cr; + + if (pixman_image_get_format (pimage) == PIXMAN_x8r8g8b8) + format = CAIRO_FORMAT_RGB24; + else + format = CAIRO_FORMAT_ARGB32; + + cimage = cairo_image_surface_create_for_data ( + (uint8_t *)pixman_image_get_data (pimage), + format, width, height, stride); - gdk_draw_pixbuf (widget->window, NULL, - pixbuf, 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NONE, - 0, 0); + cr = gdk_cairo_create (widget->window); + + cairo_rectangle (cr, 0, 0, width, height); + cairo_set_source_surface (cr, cimage, 0, 0); + cairo_fill (cr); + + cairo_destroy (cr); + cairo_surface_destroy (cimage); return TRUE; } @@ -111,7 +128,6 @@ void show_image (pixman_image_t *image) { GtkWidget *window; - GdkPixbuf *pixbuf; int width, height; int argc; char **argv; @@ -132,22 +148,15 @@ show_image (pixman_image_t *image) format = pixman_image_get_format (image); - /* 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. + /* We always display the image as if it contains sRGB data. That + * means that no conversion should take place when the image + * has the a8r8g8b8_sRGB format. */ switch (format) { case PIXMAN_a8r8g8b8_sRGB: case PIXMAN_a8r8g8b8: + case PIXMAN_x8r8g8b8: copy = pixman_image_ref (image); break; @@ -161,11 +170,7 @@ show_image (pixman_image_t *image) 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, "expose_event", G_CALLBACK (on_expose), copy); g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (window); |