1 module x11.extensions.Xrender;
2 
3 version(Posix):
4 
5 /*
6  *
7  * Copyright © 2000 SuSE, Inc.
8  *
9  * Permission to use, copy, modify, distribute, and sell this software and its
10  * documentation for any purpose is hereby granted without fee, provided that
11  * the above copyright notice appear in all copies and that both that
12  * copyright notice and this permission notice appear in supporting
13  * documentation, and that the name of SuSE not be used in advertising or
14  * publicity pertaining to distribution of the software without specific,
15  * written prior permission.  SuSE makes no representations about the
16  * suitability of this software for any purpose.  It is provided "as is"
17  * without express or implied warranty.
18  *
19  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
21  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
23  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
24  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25  *
26  * Author:  Keith Packard, SuSE, Inc.
27  */
28 
29 import x11.X;
30 import x11.Xlib;
31 import x11.Xutil;
32 
33 import x11.extensions.render;
34 
35 extern (C) nothrow:
36 
37 struct XRenderDirectFormat{
38 	short   red;
39 	short   redMask;
40 	short   green;
41 	short   greenMask;
42 	short   blue;
43 	short   blueMask;
44 	short   alpha;
45 	short   alphaMask;
46 }
47 
48 struct XRenderPictFormat{
49 	PictFormat		id;
50 	int			type;
51 	int			depth;
52 	XRenderDirectFormat	direct;
53 	Colormap		colormap;
54 }
55 
56 enum PictFormatID        = (1 << 0);
57 enum PictFormatType      = (1 << 1);
58 enum PictFormatDepth     = (1 << 2);
59 enum PictFormatRed       = (1 << 3);
60 enum PictFormatRedMask   = (1 << 4);
61 enum PictFormatGreen     = (1 << 5);
62 enum PictFormatGreenMask = (1 << 6);
63 enum PictFormatBlue      = (1 << 7);
64 enum PictFormatBlueMask  = (1 << 8);
65 enum PictFormatAlpha     = (1 << 9);
66 enum PictFormatAlphaMask = (1 << 10);
67 enum PictFormatColormap  = (1 << 11);
68 
69 struct XRenderPictureAttributes {
70 	int 		repeat;
71 	Picture		alpha_map;
72 	int			alpha_x_origin;
73 	int			alpha_y_origin;
74 	int			clip_x_origin;
75 	int			clip_y_origin;
76 	Pixmap		clip_mask;
77 	Bool		graphics_exposures;
78 	int			subwindow_mode;
79 	int			poly_edge;
80 	int			poly_mode;
81 	Atom		dither;
82 	Bool		component_alpha;
83 }
84 
85 struct XRenderColor{
86 	ushort   red;
87 	ushort   green;
88 	ushort   blue;
89 	ushort   alpha;
90 }
91 
92 struct XGlyphInfo {
93 	ushort  width;
94 	ushort  height;
95 	short	    x;
96 	short	    y;
97 	short	    xOff;
98 	short	    yOff;
99 }
100 
101 struct XGlyphElt8 {
102 	GlyphSet		    glyphset;
103 	const char	    *chars;
104 	int			    nchars;
105 	int			    xOff;
106 	int			    yOff;
107 }
108 
109 struct XGlyphElt16 {
110 	GlyphSet        glyphset;
111 	const ushort*   chars;
112 	int			    nchars;
113 	int			    xOff;
114 	int			    yOff;
115 }
116 
117 struct XGlyphElt32 {
118 	GlyphSet		glyphset;
119 	const uint*     chars;
120 	int			    nchars;
121 	int			    xOff;
122 	int			    yOff;
123 }
124 
125 alias double	XDouble;
126 
127 struct XPointDouble {
128 	XDouble  x, y;
129 }
130 
131 XFixed XDoubleToFixed(T)(T f) {
132 	return (cast(XFixed)(f * 65536));
133 }
134 
135 XDouble XFixedToDouble(T)(T f) {
136 	return (cast(XDouble)(f * 65536));
137 }
138 
139 alias int XFixed;
140 
141 struct XPointFixed {
142 	XFixed  x, y;
143 }
144 
145 struct XLineFixed {
146 	XPointFixed	p1, p2;
147 }
148 
149 struct XTriangle {
150 	XPointFixed	p1, p2, p3;
151 }
152 
153 struct XCircle {
154 	XFixed x;
155 	XFixed y;
156 	XFixed radius;
157 }
158 
159 struct XTrapezoid {
160 	XFixed  top, bottom;
161 	XLineFixed	left, right;
162 }
163 
164 struct XTransform {
165 	XFixed[3][3]  matrix;
166 }
167 
168 struct XFilters {
169 	int	    nfilter;
170 	char    **filter;
171 	int	    nalias;
172 	short   *alias_;
173 }
174 
175 struct XIndexValue {
176 	ulong    pixel;
177 	ushort   red, green, blue, alpha;
178 }
179 
180 struct XAnimCursor {
181 	Cursor	    cursor;
182 	ulong   delay;
183 }
184 
185 struct XSpanFix {
186 	XFixed	    left, right, y;
187 }
188 
189 struct XTrap {
190 	XSpanFix	    top, bottom;
191 }
192 
193 struct XLinearGradient {
194 	XPointFixed p1;
195 	XPointFixed p2;
196 }
197 
198 struct XRadialGradient {
199 	XCircle inner;
200 	XCircle outer;
201 }
202 
203 struct XConicalGradient {
204 	XPointFixed center;
205 	XFixed angle; /* in degrees */
206 }
207 
208 
209 Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
210 
211 Status XRenderQueryVersion (Display *dpy,
212 		int     *major_versionp,
213 		int     *minor_versionp);
214 
215 Status XRenderQueryFormats (Display *dpy);
216 
217 int XRenderQuerySubpixelOrder (Display *dpy, int screen);
218 
219 Bool XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel);
220 
221 XRenderPictFormat *
222 	XRenderFindVisualFormat (Display *dpy, const Visual *visual);
223 
224 XRenderPictFormat *
225 	XRenderFindFormat (Display			*dpy,
226 			ulong		mask,
227 			const XRenderPictFormat	*templ,
228 			int				count);
229 
230 enum PictStandardARGB32 = 0;
231 enum PictStandardRGB24  = 1;
232 enum PictStandardA8	    = 2;
233 enum PictStandardA4	    = 3;
234 enum PictStandardA1	    = 4;
235 enum PictStandardNUM    = 5;
236 
237 XRenderPictFormat *
238 	XRenderFindStandardFormat (Display		*dpy,
239 			int			format);
240 
241 XIndexValue *
242 	XRenderQueryPictIndexValues(Display			*dpy,
243 			const XRenderPictFormat	*format,
244 			int				*num);
245 
246 Picture
247 	XRenderCreatePicture (Display				*dpy,
248 			Drawable				drawable,
249 			const XRenderPictFormat		*format,
250 			ulong			valuemask,
251 			const XRenderPictureAttributes	*attributes);
252 
253 void
254 	XRenderChangePicture (Display				*dpy,
255 			Picture				picture,
256 			ulong			valuemask,
257 			const XRenderPictureAttributes  *attributes);
258 
259 void
260 	XRenderSetPictureClipRectangles (Display	    *dpy,
261 			Picture	    picture,
262 			int		    xOrigin,
263 			int		    yOrigin,
264 			const XRectangle *rects,
265 			int		    n);
266 
267 void
268 	XRenderSetPictureClipRegion (Display	    *dpy,
269 			Picture	    picture,
270 			Region	    r);
271 
272 void
273 	XRenderSetPictureTransform (Display	    *dpy,
274 			Picture	    picture,
275 			XTransform	    *transform);
276 
277 void
278 	XRenderFreePicture (Display                   *dpy,
279 			Picture                   picture);
280 
281 void
282 	XRenderComposite (Display   *dpy,
283 			int	    op,
284 			Picture   src,
285 			Picture   mask,
286 			Picture   dst,
287 			int	    src_x,
288 			int	    src_y,
289 			int	    mask_x,
290 			int	    mask_y,
291 			int	    dst_x,
292 			int	    dst_y,
293 			uint	width,
294 			uint	height);
295 
296 GlyphSet
297 	XRenderCreateGlyphSet (Display *dpy, const XRenderPictFormat *format);
298 
299 GlyphSet
300 	XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing);
301 
302 void
303 	XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset);
304 
305 void
306 	XRenderAddGlyphs (Display		*dpy,
307 			GlyphSet		glyphset,
308 			const Glyph		*gids,
309 			const XGlyphInfo	*glyphs,
310 			int			nglyphs,
311 			const char		*images,
312 			int			nbyte_images);
313 
314 void
315 	XRenderFreeGlyphs (Display	    *dpy,
316 			GlyphSet	    glyphset,
317 			const Glyph    *gids,
318 			int		    nglyphs);
319 
320 void
321 	XRenderCompositeString8 (Display		    *dpy,
322 			int			    op,
323 			Picture		    src,
324 			Picture		    dst,
325 			const XRenderPictFormat  *maskFormat,
326 			GlyphSet		    glyphset,
327 			int			    xSrc,
328 			int			    ySrc,
329 			int			    xDst,
330 			int			    yDst,
331 			const char		    *string,
332 			int			    nchar);
333 
334 void
335 	XRenderCompositeString16 (Display		    *dpy,
336 			int			    op,
337 			Picture		    src,
338 			Picture		    dst,
339 			const XRenderPictFormat *maskFormat,
340 			GlyphSet		    glyphset,
341 			int			    xSrc,
342 			int			    ySrc,
343 			int			    xDst,
344 			int			    yDst,
345 			const ushort    *string,
346 			int			    nchar);
347 
348 void
349 	XRenderCompositeString32 (Display		    *dpy,
350 			int			    op,
351 			Picture		    src,
352 			Picture		    dst,
353 			const XRenderPictFormat *maskFormat,
354 			GlyphSet		    glyphset,
355 			int			    xSrc,
356 			int			    ySrc,
357 			int			    xDst,
358 			int			    yDst,
359 			const uint	    *string,
360 			int			    nchar);
361 
362 void
363 	XRenderCompositeText8 (Display			    *dpy,
364 			int			    op,
365 			Picture			    src,
366 			Picture			    dst,
367 			const XRenderPictFormat    *maskFormat,
368 			int			    xSrc,
369 			int			    ySrc,
370 			int			    xDst,
371 			int			    yDst,
372 			const XGlyphElt8	    *elts,
373 			int			    nelt);
374 
375 void
376 	XRenderCompositeText16 (Display			    *dpy,
377 			int			    op,
378 			Picture			    src,
379 			Picture			    dst,
380 			const XRenderPictFormat   *maskFormat,
381 			int			    xSrc,
382 			int			    ySrc,
383 			int			    xDst,
384 			int			    yDst,
385 			const XGlyphElt16	    *elts,
386 			int			    nelt);
387 
388 void
389 	XRenderCompositeText32 (Display			    *dpy,
390 			int			    op,
391 			Picture			    src,
392 			Picture			    dst,
393 			const XRenderPictFormat   *maskFormat,
394 			int			    xSrc,
395 			int			    ySrc,
396 			int			    xDst,
397 			int			    yDst,
398 			const XGlyphElt32	    *elts,
399 			int			    nelt);
400 
401 void
402 	XRenderFillRectangle (Display		    *dpy,
403 			int		    op,
404 			Picture		    dst,
405 			const XRenderColor  *color,
406 			int		    x,
407 			int		    y,
408 			uint	    width,
409 			uint	    height);
410 
411 void
412 	XRenderFillRectangles (Display		    *dpy,
413 			int		    op,
414 			Picture		    dst,
415 			const XRenderColor *color,
416 			const XRectangle   *rectangles,
417 			int		    n_rects);
418 
419 void
420 	XRenderCompositeTrapezoids (Display		*dpy,
421 			int			op,
422 			Picture		src,
423 			Picture		dst,
424 			const XRenderPictFormat	*maskFormat,
425 			int			xSrc,
426 			int			ySrc,
427 			const XTrapezoid	*traps,
428 			int			ntrap);
429 
430 void
431 	XRenderCompositeTriangles (Display		*dpy,
432 			int			op,
433 			Picture		src,
434 			Picture		dst,
435 			const XRenderPictFormat	*maskFormat,
436 			int			xSrc,
437 			int			ySrc,
438 			const XTriangle	*triangles,
439 			int			ntriangle);
440 
441 void
442 	XRenderCompositeTriStrip (Display		*dpy,
443 			int			op,
444 			Picture		src,
445 			Picture		dst,
446 			const XRenderPictFormat	*maskFormat,
447 			int			xSrc,
448 			int			ySrc,
449 			const XPointFixed	*points,
450 			int			npoint);
451 
452 void
453 	XRenderCompositeTriFan (Display			*dpy,
454 			int			op,
455 			Picture			src,
456 			Picture			dst,
457 			const XRenderPictFormat	*maskFormat,
458 			int			xSrc,
459 			int			ySrc,
460 			const XPointFixed	*points,
461 			int			npoint);
462 
463 void
464 	XRenderCompositeDoublePoly (Display		    *dpy,
465 			int			    op,
466 			Picture		    src,
467 			Picture		    dst,
468 			const XRenderPictFormat	*maskFormat,
469 			int			    xSrc,
470 			int			    ySrc,
471 			int			    xDst,
472 			int			    yDst,
473 			const XPointDouble    *fpoints,
474 			int			    npoints,
475 			int			    winding);
476 Status
477 	XRenderParseColor(Display	*dpy,
478 			char		*spec,
479 			XRenderColor	*def);
480 
481 Cursor
482 	XRenderCreateCursor (Display	    *dpy,
483 			Picture	    source,
484 			uint   x,
485 			uint   y);
486 
487 XFilters *
488 	XRenderQueryFilters (Display *dpy, Drawable drawable);
489 
490 void
491 	XRenderSetPictureFilter (Display    *dpy,
492 			Picture    picture,
493 			const char *filter,
494 			XFixed	    *params,
495 			int	    nparams);
496 
497 Cursor
498 	XRenderCreateAnimCursor (Display	*dpy,
499 			int		ncursor,
500 			XAnimCursor	*cursors);
501 
502 
503 void
504 	XRenderAddTraps (Display	    *dpy,
505 			Picture	    picture,
506 			int		    xOff,
507 			int		    yOff,
508 			const XTrap	    *traps,
509 			int		    ntrap);
510 
511 Picture XRenderCreateSolidFill (Display *dpy,
512 		const XRenderColor *color);
513 
514 Picture XRenderCreateLinearGradient (Display *dpy,
515 		const XLinearGradient *gradient,
516 		const XFixed *stops,
517 		const XRenderColor *colors,
518 		int nstops);
519 
520 Picture XRenderCreateRadialGradient (Display *dpy,
521 		const XRadialGradient *gradient,
522 		const XFixed *stops,
523 		const XRenderColor *colors,
524 		int nstops);
525 
526 Picture XRenderCreateConicalGradient (Display *dpy,
527 		const XConicalGradient *gradient,
528 		const XFixed *stops,
529 		const XRenderColor *colors,
530 		int nstops);