[PATCH 8/8] Add test for GTK rendering bug in glamor.
Eric Anholt
eric at anholt.net
Mon Apr 21 11:56:22 PDT 2014
Signed-off-by: Eric Anholt <eric at anholt.net>
---
COPYING | 19 +++++++
Makefile.am | 1 +
main.c | 2 +
rendercheck.h | 4 ++
t_gtk_argb_xbgr.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests.c | 10 ++++
6 files changed, 186 insertions(+)
create mode 100644 t_gtk_argb_xbgr.c
diff --git a/COPYING b/COPYING
index af1d06b..efe8756 100644
--- a/COPYING
+++ b/COPYING
@@ -1,3 +1,22 @@
+Rendercheck is a combination of GPLv2-or-later and MIT-licensed code.
+
+/* Copyright © 2014 Keith Packard <keithp at 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 \
diff --git a/main.c b/main.c
index 853cc12..78b42fd 100644
--- a/main.c
+++ b/main.c
@@ -223,6 +223,8 @@ int main(int argc, char **argv)
enabled_tests |= TEST_TRIANGLES;
} else if (strcmp(test, "bug7366") == 0) {
enabled_tests |= TEST_BUG7366;
+ } else if (strcmp(test, "gtk_argb_xbgr") == 0) {
+ enabled_tests |= TEST_GTK_ARGB_XBGR;
} else {
usage(argv[0]);
}
diff --git a/rendercheck.h b/rendercheck.h
index ad30dd6..125a929 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;
@@ -217,3 +218,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 at 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;
+}
diff --git a/tests.c b/tests.c
index d59b938..7f75922 100644
--- a/tests.c
+++ b/tests.c
@@ -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);
--
1.9.2
More information about the xorg-devel
mailing list