diff options
author | Eric Anholt <eric@anholt.net> | 2014-04-21 09:06:28 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2014-04-22 14:55:23 -0700 |
commit | 589bb58df06f6cf3b5e92c05f8cf6f997f31ab12 (patch) | |
tree | d2654e546944a7e6df725562a6c8c20db7e8336b | |
parent | 03934f1569b9e0a357e016350985b803f7b5572d (diff) |
Add test for GTK rendering bug in glamor.
I converted this from a standalone testcase Keith sent me to a
rendercheck test, with a reformat and a minor fixup to make sure we
actually found the PictFormats we wanted.
Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | COPYING | 19 | ||||
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | rendercheck.h | 4 | ||||
-rw-r--r-- | t_gtk_argb_xbgr.c | 150 | ||||
-rw-r--r-- | tests.c | 10 |
6 files changed, 185 insertions, 0 deletions
@@ -1,3 +1,22 @@ +Rendercheck is a combination of GPLv2-or-later and MIT-licensed code. + +/* Copyright © 2014 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + Copyright 2004 Eric Anholt Permission to use, copy, modify, distribute, and sell this software and its diff --git a/Makefile.am b/Makefile.am index 9afbed5..36d38e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,7 @@ rendercheck_SOURCES = \ t_dstcoords.c \ t_fill.c \ t_gradient.c \ + t_gtk_argb_xbgr.c \ t_repeat.c \ t_srccoords.c \ t_tsrccoords.c \ @@ -121,6 +121,7 @@ struct { {TEST_REPEAT, "repeat"}, {TEST_TRIANGLES, "triangles"}, {TEST_BUG7366, "bug7366"}, + {TEST_GTK_ARGB_XBGR, "gtk_argb_xbgr"}, {0, NULL} }; diff --git a/rendercheck.h b/rendercheck.h index 2b71bf2..c8ad9d6 100644 --- a/rendercheck.h +++ b/rendercheck.h @@ -81,6 +81,7 @@ struct op_info { #define TEST_REPEAT 0x0400 #define TEST_TRIANGLES 0x0800 #define TEST_BUG7366 0x1000 +#define TEST_GTK_ARGB_XBGR 0x2000 extern int pixmap_move_iter; extern int win_width, win_height; @@ -219,3 +220,6 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op, Bool bug7366_test(Display *dpy); + +Bool +gtk_argb_xbgr_test(Display *dpy); diff --git a/t_gtk_argb_xbgr.c b/t_gtk_argb_xbgr.c new file mode 100644 index 0000000..b80e58b --- /dev/null +++ b/t_gtk_argb_xbgr.c @@ -0,0 +1,150 @@ +/* Copyright © 2014 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* Test Render's ability to flip bytes around when the source and mask are the + * same pixmap. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <strings.h> +#include "rendercheck.h" + +#define WIDTH 1 +#define HEIGHT 1 + +#define PIXEL_ABGR 0xff886644 +#define PIXEL_RGB 0x446688 + +Bool +gtk_argb_xbgr_test(Display *dpy) +{ + int x, y; + Pixmap pix_32; + Pixmap pix_24; + Picture pic_24; + Picture pic_32_xbgr; + Picture pic_32_argb; + XRenderPictFormat templ; + XRenderPictFormat *pic_xbgr_format; + XRenderPictFormat *pic_argb_format; + XRenderPictFormat *pic_rgb_format; + GC gc_32; + XImage *image_24, *image_32; + + templ.type = PictTypeDirect; + templ.depth = 32; + templ.direct.alphaMask = 0; + templ.direct.red = 0; + templ.direct.green = 8; + templ.direct.blue = 16; + + pic_xbgr_format = XRenderFindFormat(dpy, + PictFormatType | + PictFormatDepth | + PictFormatAlphaMask | + PictFormatRed | + PictFormatGreen | + PictFormatBlue, + &templ, 0); + + templ.type = PictTypeDirect; + templ.depth = 32; + templ.direct.alpha = 24; + templ.direct.red = 16; + templ.direct.green = 8; + templ.direct.blue = 0; + + pic_argb_format = XRenderFindFormat(dpy, + PictFormatType | + PictFormatDepth | + PictFormatAlpha | + PictFormatRed | + PictFormatGreen | + PictFormatBlue, + &templ, 0); + + templ.type = PictTypeDirect; + templ.depth = 24; + templ.direct.red = 16; + templ.direct.green = 8; + templ.direct.blue = 0; + + pic_rgb_format = XRenderFindFormat(dpy, + PictFormatType | + PictFormatDepth | + PictFormatRed | + PictFormatGreen | + PictFormatBlue, + &templ, 0); + + if (!pic_argb_format || !pic_xbgr_format || !pic_rgb_format) { + printf("Couldn't find xBGR and ARGB formats\n"); + return FALSE; + } + + pix_32 = XCreatePixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), + WIDTH, HEIGHT, 32); + + pic_32_xbgr = XRenderCreatePicture(dpy, pix_32, pic_xbgr_format, 0, + NULL); + pic_32_argb = XRenderCreatePicture(dpy, pix_32, pic_argb_format, 0, + NULL); + + image_32 = XCreateImage(dpy, + NULL, + 32, + ZPixmap, + 0, + NULL, + WIDTH, HEIGHT, 32, 0); + + image_32->data = malloc(HEIGHT * image_32->bytes_per_line); + + for (y = 0; y < HEIGHT; y++) + for (x = 0; x < WIDTH; x++) + XPutPixel(image_32, x, y, PIXEL_ABGR); + + gc_32 = XCreateGC(dpy, pix_32, 0, NULL); + + XPutImage(dpy, pix_32, gc_32, image_32, 0, 0, 0, 0, WIDTH, HEIGHT); + + pix_24 = XCreatePixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), + WIDTH, HEIGHT, 24); + + pic_24 = XRenderCreatePicture(dpy, pix_24, pic_rgb_format, 0, NULL); + + XRenderComposite(dpy, PictOpOver, pic_32_xbgr, pic_32_argb, pic_24, + 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); + + image_24 = XGetImage(dpy, pix_24, 0, 0, WIDTH, HEIGHT, 0xffffffff, + ZPixmap); + for (y = 0; y < HEIGHT; y++) { + for (x = 0; x < WIDTH; x++) { + unsigned long pixel = XGetPixel(image_24, x, y); + if (pixel != PIXEL_RGB) { + printf("fail: pixel value is %08lx " + "should be %08x\n", + pixel, PIXEL_RGB); + return FALSE; + } + } + } + + return TRUE; +} @@ -732,6 +732,16 @@ do { \ success_mask |= TEST_BUG7366; } + if (enabled_tests & TEST_GTK_ARGB_XBGR) { + Bool ok, group_ok = TRUE; + + ok = gtk_argb_xbgr_test(dpy); + RECORD_RESULTS(); + + if (group_ok) + success_mask |= TEST_GTK_ARGB_XBGR; + } + free(test_ops); free(test_src); free(test_mask); |