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
|
#include <X11/Xlib.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xrender.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
static char glyphdata[4096] =
{
};
static GlyphSet
make_glyphs (Display *dpy)
{
GlyphSet glyphset;
Glyph gid = 1;
XGlyphInfo glyphinfo;
int i;
for (i = 0; i < sizeof (glyphdata); ++i)
{
glyphdata[i] = i & 0x07;
}
glyphinfo.width = 64;
glyphinfo.height = 64;
glyphinfo.x = 0;
glyphinfo.y = 0;
glyphinfo.xOff = 0;
glyphinfo.yOff = 0;
glyphset = XRenderCreateGlyphSet (
dpy, XRenderFindStandardFormat (dpy, PictStandardA8));
XRenderAddGlyphs (
dpy, glyphset, &gid, &glyphinfo, 1, glyphdata, 64 * 64);
return glyphset;
}
int
main ()
{
Display *dpy = XOpenDisplay (NULL);
Window window;
Damage damage;
int devent, derror;
int revent, rerror;
Picture dst;
Picture src;
XRenderPictureAttributes attr;
XTrapezoid traps[1] =
{
{
10 << 16, 40 << 16,
{ { 0 << 16, 0 << 16 }, { 10 << 16, 50 << 16 } },
{ { 150 << 16, 0 << 16 }, { 160 << 16, 50 << 16 } },
}
};
XRenderColor color =
{
0x8080, 0xffff, 0x3232, 0xefef
};
window = XCreateSimpleWindow (
dpy, DefaultRootWindow (dpy), 100, 100,
300, 300, 0, 0, 0);
XDamageQueryExtension (dpy, &devent, &derror);
XRenderQueryExtension (dpy, &revent, &rerror);
damage = XDamageCreate (dpy, window, XDamageReportRawRectangles);
XMapWindow (dpy, window);
src = XRenderCreateSolidFill (dpy, &color);
dst = XRenderCreatePicture (
dpy, window, XRenderFindStandardFormat (dpy, PictStandardRGB24),
0, &attr);
for (;;)
{
XEvent event;
char c = 1;
int dstx = rand() % 300;
int dsty = rand() % 300;
XSync (dpy, False);
#if 0
while (XPending (dpy))
{
XNextEvent (dpy, &event);
if (event.type == devent + XDamageNotify)
printf ("Got damage\n");
}
#endif
XRenderCompositeTrapezoids (dpy, PictOpOver, src, dst, NULL,
0, 0, traps, 1);
usleep (70000);
}
return 0;
}
|