2 * Copyright (c) 2008-2009 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include <X11/Xutil.h>
27 #include <va/va_x11.h>
29 static Window win_thread0, win_thread1;
30 static int multi_thread = 0;
31 static Pixmap pixmap_thread0, pixmap_thread1;
32 static GC context_thread0, context_thread1;
33 static pthread_mutex_t gmutex;
35 #include "putsurface_common.c"
37 static Pixmap create_pixmap(int width, int height)
39 int screen = DefaultScreen(x11_display);
42 XWindowAttributes attr;
44 root = RootWindow(x11_display, screen);
46 XGetWindowAttributes (x11_display, root, &attr);
48 printf("Create a pixmap from ROOT window %dx%d, pixmap size %dx%d\n\n", attr.width, attr.height, width, height);
49 pixmap = XCreatePixmap(x11_display, root, width, height,
50 DefaultDepth(x11_display, DefaultScreen(x11_display)));
55 static int create_window(int width, int height)
57 int screen = DefaultScreen(x11_display);
60 root = RootWindow(x11_display, screen);
62 printf("Create window0 for thread0\n");
63 win_thread0 = win = XCreateSimpleWindow(x11_display, root, 0, 0, width, height,
64 0, 0, WhitePixel(x11_display, 0));
67 sizehints.width = width;
68 sizehints.height = height;
69 sizehints.flags = USSize;
70 XSetNormalHints(x11_display, win, &sizehints);
71 XSetStandardProperties(x11_display, win, "Thread 0", "Thread 0",
72 None, (char **)NULL, 0, &sizehints);
74 XMapWindow(x11_display, win);
76 context_thread0 = XCreateGC(x11_display, win, 0, 0);
77 XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
78 XSync(x11_display, False);
81 pixmap_thread0 = create_pixmap(width, height);
83 if (multi_thread == 0)
86 printf("Create window1 for thread1\n");
88 win_thread1 = win = XCreateSimpleWindow(x11_display, root, width, 0, width, height,
89 0, 0, WhitePixel(x11_display, 0));
92 sizehints.width = width;
93 sizehints.height = height;
94 sizehints.flags = USSize;
95 XSetNormalHints(x11_display, win, &sizehints);
96 XSetStandardProperties(x11_display, win, "Thread 1", "Thread 1",
97 None, (char **)NULL, 0, &sizehints);
99 XMapWindow(x11_display, win);
102 pixmap_thread1 = create_pixmap(width, height);
104 context_thread1 = XCreateGC(x11_display, win, 0, 0);
105 XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask);
106 XSync(x11_display, False);