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