1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "test.h"
const char *test_target_name(enum target target)
{
switch (target) {
default:
case ROOT: return "root";
case CHILD: return "child";
case PIXMAP: return "pixmap";
}
}
void test_target_create_render(struct test_display *dpy,
enum target target,
struct test_target *tt)
{
XSetWindowAttributes attr;
XGCValues gcv;
tt->dpy = dpy;
tt->target = target;
tt->draw = dpy->root;
tt->format = dpy->format;
tt->width = dpy->width;
tt->height = dpy->height;
tt->depth = dpy->depth;
switch (target) {
case ROOT:
break;
case CHILD:
attr.override_redirect = 1;
tt->width /= 4;
tt->height /= 4;
tt->draw = XCreateWindow(dpy->dpy, tt->draw,
dpy->width/2, dpy->height/2,
tt->width, tt->height,
0, tt->format->depth,
InputOutput,
DefaultVisual(dpy->dpy,
DefaultScreen(dpy->dpy)),
CWOverrideRedirect, &attr);
XMapWindow(dpy->dpy, tt->draw);
break;
case PIXMAP:
tt->format = XRenderFindStandardFormat(dpy->dpy, PictStandardARGB32);
tt->draw = XCreatePixmap(dpy->dpy, tt->draw,
dpy->width, dpy->height,
tt->format->depth);
tt->depth = 32;
break;
}
tt->picture =
XRenderCreatePicture(dpy->dpy, tt->draw, tt->format, 0, NULL);
gcv.graphics_exposures = 0;
tt->gc = XCreateGC(dpy->dpy, tt->draw, GCGraphicsExposures, &gcv);
}
void test_target_destroy_render(struct test_display *dpy,
struct test_target *tt)
{
XRenderFreePicture(dpy->dpy, tt->picture);
switch (tt->target) {
case ROOT:
break;
case CHILD:
XDestroyWindow(dpy->dpy, tt->draw);
break;
case PIXMAP:
XFreePixmap(dpy->dpy, tt->draw);
break;
}
}
#if 0
static int random_bool(void)
{
return rand() > RAND_MAX/2;
}
static Picture create_alpha_map(void)
{
return 0;
}
static Pixmap create_clip_mask(void)
{
return 0;
}
unsigned int test_render_randomize_picture_attributes(XRenderPictureAttributes *pa)
{
unsigned int flags = 0;
memset(pa, 0, sizeof(*pa));
if (random_bool()) {
pa->repeat = repeat_modes[rand() % ARRAY_SIZE(repeat_modes)];
flags |= CPRepeat;
}
if (random_bool()) {
pa->alpha_map = create_alpha_map();
pa->alpha_x_origin = rand() % 1024;
pa->alpha_y_origin = rand() % 1024;
flags |= CPAlphaMap;
}
if (random_bool()) {
pa->clip_mask = create_clip_mask();
pa->clip_x_orgin = rand() % 1024;
pa->clip_y_orgin = rand() % 1024;
flags |= CPClipMask;
}
if (random_bool()) {
pa->subwindow_mode = random_bool();
flags |= CPSubwindowMode;
}
if (random_bool()) {
pa->poly_edge = random_bool();
flags |= CPPolyEdge;
}
if (random_bool()) {
pa->poly_mode = random_bool();
flags |= CPPolyMode;
}
if (random_bool()) {
pa->component_alpha = random_bool();
flags |= CPComponentAlpha;
}
return flags;
}
#endif
|