1 /*
2 * Copyright 2011 Red Hat, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Adam Jackson <ajax@redhat.com>
25 *
26 */
27
28 /** @file glx-pixmap13-life.c
29 *
30 * Test that GLXPixmaps and their associated X Pixmaps can be destroyed in
31 * either order, without error. Same as glx-pixmap-life.c but with
32 * fbconfigs.
33 */
34
35 #include "piglit-util-gl.h"
36 #include "piglit-glx-util.h"
37
38 int piglit_width = 50, piglit_height = 50;
39 static Display *dpy;
40 static XVisualInfo *visinfo;
41
42 int pass = 1;
43
44 static int
handler(Display * dpy,XErrorEvent * err)45 handler(Display *dpy, XErrorEvent *err)
46 {
47 pass = 0;
48
49 #if 0
50 printf("Error serial %x error %x request %x minor %x xid %x\n",
51 err->serial, err->error_code, err->request_code, err->minor_code,
52 err->resourceid);
53 #endif
54
55 return 0;
56 }
57
58 int
main(int argc,char ** argv)59 main(int argc, char **argv)
60 {
61 Pixmap p;
62 GLXPixmap g;
63 GLXFBConfig fbc;
64
65 dpy = XOpenDisplay(NULL);
66 if (dpy == NULL) {
67 fprintf(stderr, "couldn't open display\n");
68 piglit_report_result(PIGLIT_FAIL);
69 }
70
71 piglit_require_glx_version(dpy, 1, 3);
72
73 visinfo = piglit_get_glx_visual(dpy);
74 fbc = piglit_glx_get_fbconfig_for_visinfo(dpy, visinfo);
75
76 XSetErrorHandler(handler);
77
78 /* test destroying glxpixmap before pixmap */
79 p = XCreatePixmap(dpy, DefaultRootWindow(dpy), piglit_width,
80 piglit_height, visinfo->depth);
81 g = glXCreatePixmap(dpy, fbc, p, NULL);
82
83 glXDestroyPixmap(dpy, g);
84 XFreePixmap(dpy, p);
85
86 XSync(dpy, 0);
87
88 /* test destroying pixmap before glxpixmap */
89 p = XCreatePixmap(dpy, DefaultRootWindow(dpy), piglit_width,
90 piglit_height, visinfo->depth);
91 g = glXCreatePixmap(dpy, fbc, p, NULL);
92
93 XFreePixmap(dpy, p);
94 glXDestroyPixmap(dpy, g);
95
96 XSync(dpy, 0);
97
98 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
99
100 return 0;
101 }
102