Imported Upstream version 1.15.1
[deb_xorg-server.git] / render / picturestr.h
CommitLineData
a09e091a
JB
1/*
2 * Copyright © 2000 SuSE, Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of SuSE not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. SuSE makes no representations about the
11 * suitability of this software for any purpose. It is provided "as is"
12 * without express or implied warranty.
13 *
14 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
16 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 *
21 * Author: Keith Packard, SuSE, Inc.
22 */
23
24#ifndef _PICTURESTR_H_
25#define _PICTURESTR_H_
26
27#include "scrnintstr.h"
28#include "glyphstr.h"
29#include "resource.h"
30#include "privates.h"
31
32typedef struct _DirectFormat {
33 CARD16 red, redMask;
34 CARD16 green, greenMask;
35 CARD16 blue, blueMask;
36 CARD16 alpha, alphaMask;
37} DirectFormatRec;
38
39typedef struct _IndexFormat {
40 VisualID vid;
41 ColormapPtr pColormap;
42 int nvalues;
43 xIndexValue *pValues;
44 void *devPrivate;
45} IndexFormatRec;
46
47typedef struct _PictFormat {
48 CARD32 id;
49 CARD32 format; /* except bpp */
50 unsigned char type;
51 unsigned char depth;
52 DirectFormatRec direct;
53 IndexFormatRec index;
54} PictFormatRec;
55
56typedef struct pixman_vector PictVector, *PictVectorPtr;
57typedef struct pixman_transform PictTransform, *PictTransformPtr;
58
59#define pict_f_vector pixman_f_vector
60#define pict_f_transform pixman_f_transform
61
62#define PICT_GRADIENT_STOPTABLE_SIZE 1024
63#define SourcePictTypeSolidFill 0
64#define SourcePictTypeLinear 1
65#define SourcePictTypeRadial 2
66#define SourcePictTypeConical 3
67
68typedef struct _PictSolidFill {
69 unsigned int type;
70 CARD32 color;
71} PictSolidFill, *PictSolidFillPtr;
72
73typedef struct _PictGradientStop {
74 xFixed x;
75 xRenderColor color;
76} PictGradientStop, *PictGradientStopPtr;
77
78typedef struct _PictGradient {
79 unsigned int type;
80 int nstops;
81 PictGradientStopPtr stops;
82} PictGradient, *PictGradientPtr;
83
84typedef struct _PictLinearGradient {
85 unsigned int type;
86 int nstops;
87 PictGradientStopPtr stops;
88 xPointFixed p1;
89 xPointFixed p2;
90} PictLinearGradient, *PictLinearGradientPtr;
91
92typedef struct _PictCircle {
93 xFixed x;
94 xFixed y;
95 xFixed radius;
96} PictCircle, *PictCirclePtr;
97
98typedef struct _PictRadialGradient {
99 unsigned int type;
100 int nstops;
101 PictGradientStopPtr stops;
102 PictCircle c1;
103 PictCircle c2;
104} PictRadialGradient, *PictRadialGradientPtr;
105
106typedef struct _PictConicalGradient {
107 unsigned int type;
108 int nstops;
109 PictGradientStopPtr stops;
110 xPointFixed center;
111 xFixed angle;
112} PictConicalGradient, *PictConicalGradientPtr;
113
114typedef union _SourcePict {
115 unsigned int type;
116 PictSolidFill solidFill;
117 PictGradient gradient;
118 PictLinearGradient linear;
119 PictRadialGradient radial;
120 PictConicalGradient conical;
121} SourcePict, *SourcePictPtr;
122
123typedef struct _Picture {
124 DrawablePtr pDrawable;
125 PictFormatPtr pFormat;
126 PictFormatShort format; /* PICT_FORMAT */
127 int refcnt;
128 CARD32 id;
129 unsigned int repeat:1;
130 unsigned int graphicsExposures:1;
131 unsigned int subWindowMode:1;
132 unsigned int polyEdge:1;
133 unsigned int polyMode:1;
134 unsigned int freeCompClip:1;
135 unsigned int clientClipType:2;
136 unsigned int componentAlpha:1;
137 unsigned int repeatType:2;
138 unsigned int filter:3;
139 unsigned int stateChanges:CPLastBit;
140 unsigned int unused:18 - CPLastBit;
141
142 PicturePtr pNext; /* chain on same drawable */
143
144 PicturePtr alphaMap;
145 DDXPointRec alphaOrigin;
146
147 DDXPointRec clipOrigin;
148 pointer clientClip;
149
150 unsigned long serialNumber;
151
152 RegionPtr pCompositeClip;
153
154 PrivateRec *devPrivates;
155
156 PictTransform *transform;
157
158 SourcePictPtr pSourcePict;
159 xFixed *filter_params;
160 int filter_nparams;
161} PictureRec;
162
163typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id,
164 xFixed * params, int nparams,
165 int *width, int *height);
166typedef struct {
167 char *name;
168 int id;
169 PictFilterValidateParamsProcPtr ValidateParams;
170 int width, height;
171} PictFilterRec, *PictFilterPtr;
172
173#define PictFilterNearest 0
174#define PictFilterBilinear 1
175
176#define PictFilterFast 2
177#define PictFilterGood 3
178#define PictFilterBest 4
179
180#define PictFilterConvolution 5
181/* if you add an 8th filter, expand the filter bitfield above */
182
183typedef struct {
184 char *alias;
185 int alias_id;
186 int filter_id;
187} PictFilterAliasRec, *PictFilterAliasPtr;
188
189typedef int (*CreatePictureProcPtr) (PicturePtr pPicture);
190typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture);
191typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture,
192 int clipType, pointer value, int n);
193typedef void (*DestroyPictureClipProcPtr) (PicturePtr pPicture);
194
195typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture,
196 PictTransform * transform);
197
198typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture,
199 int filter,
200 xFixed * params, int nparams);
201
202typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture);
203
204typedef void (*ChangePictureProcPtr) (PicturePtr pPicture, Mask mask);
205typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture, Mask mask);
206typedef void (*CompositeProcPtr) (CARD8 op,
207 PicturePtr pSrc,
208 PicturePtr pMask,
209 PicturePtr pDst,
210 INT16 xSrc,
211 INT16 ySrc,
212 INT16 xMask,
213 INT16 yMask,
214 INT16 xDst,
215 INT16 yDst, CARD16 width, CARD16 height);
216
217typedef void (*GlyphsProcPtr) (CARD8 op,
218 PicturePtr pSrc,
219 PicturePtr pDst,
220 PictFormatPtr maskFormat,
221 INT16 xSrc,
222 INT16 ySrc,
223 int nlists,
224 GlyphListPtr lists, GlyphPtr * glyphs);
225
226typedef void (*CompositeRectsProcPtr) (CARD8 op,
227 PicturePtr pDst,
228 xRenderColor * color,
229 int nRect, xRectangle *rects);
230
231typedef void (*RasterizeTrapezoidProcPtr) (PicturePtr pMask,
232 xTrapezoid * trap,
233 int x_off, int y_off);
234
235typedef void (*TrapezoidsProcPtr) (CARD8 op,
236 PicturePtr pSrc,
237 PicturePtr pDst,
238 PictFormatPtr maskFormat,
239 INT16 xSrc,
240 INT16 ySrc, int ntrap, xTrapezoid * traps);
241
242typedef void (*TrianglesProcPtr) (CARD8 op,
243 PicturePtr pSrc,
244 PicturePtr pDst,
245 PictFormatPtr maskFormat,
246 INT16 xSrc,
247 INT16 ySrc, int ntri, xTriangle * tris);
248
249typedef void (*TriStripProcPtr) (CARD8 op,
250 PicturePtr pSrc,
251 PicturePtr pDst,
252 PictFormatPtr maskFormat,
253 INT16 xSrc,
254 INT16 ySrc, int npoint, xPointFixed * points);
255
256typedef void (*TriFanProcPtr) (CARD8 op,
257 PicturePtr pSrc,
258 PicturePtr pDst,
259 PictFormatPtr maskFormat,
260 INT16 xSrc,
261 INT16 ySrc, int npoint, xPointFixed * points);
262
263typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen, PictFormatPtr pFormat);
264
265typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen, PictFormatPtr pFormat);
266
267typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen,
268 PictFormatPtr pFormat,
269 int ndef, xColorItem * pdef);
270
271typedef void (*AddTrapsProcPtr) (PicturePtr pPicture,
272 INT16 xOff,
273 INT16 yOff, int ntrap, xTrap * traps);
274
275typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture,
276 INT16 xOff,
277 INT16 yOff, int ntri, xTriangle * tris);
278
279typedef Bool (*RealizeGlyphProcPtr) (ScreenPtr pScreen, GlyphPtr glyph);
280
281typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen, GlyphPtr glyph);
282
283typedef struct _PictureScreen {
284 PictFormatPtr formats;
285 PictFormatPtr fallback;
286 int nformats;
287
288 CreatePictureProcPtr CreatePicture;
289 DestroyPictureProcPtr DestroyPicture;
290 ChangePictureClipProcPtr ChangePictureClip;
291 DestroyPictureClipProcPtr DestroyPictureClip;
292
293 ChangePictureProcPtr ChangePicture;
294 ValidatePictureProcPtr ValidatePicture;
295
296 CompositeProcPtr Composite;
297 GlyphsProcPtr Glyphs; /* unused */
298 CompositeRectsProcPtr CompositeRects;
299
300 DestroyWindowProcPtr DestroyWindow;
301 CloseScreenProcPtr CloseScreen;
302
303 StoreColorsProcPtr StoreColors;
304
305 InitIndexedProcPtr InitIndexed;
306 CloseIndexedProcPtr CloseIndexed;
307 UpdateIndexedProcPtr UpdateIndexed;
308
309 int subpixel;
310
311 PictFilterPtr filters;
312 int nfilters;
313 PictFilterAliasPtr filterAliases;
314 int nfilterAliases;
315
316 /**
317 * Called immediately after a picture's transform is changed through the
318 * SetPictureTransform request. Not called for source-only pictures.
319 */
320 ChangePictureTransformProcPtr ChangePictureTransform;
321
322 /**
323 * Called immediately after a picture's transform is changed through the
324 * SetPictureFilter request. Not called for source-only pictures.
325 */
326 ChangePictureFilterProcPtr ChangePictureFilter;
327
328 DestroyPictureFilterProcPtr DestroyPictureFilter;
329
330 TrapezoidsProcPtr Trapezoids;
331 TrianglesProcPtr Triangles;
332
333 RasterizeTrapezoidProcPtr RasterizeTrapezoid;
334
335 AddTrianglesProcPtr AddTriangles;
336
337 AddTrapsProcPtr AddTraps;
338
339 RealizeGlyphProcPtr RealizeGlyph;
340 UnrealizeGlyphProcPtr UnrealizeGlyph;
341
342#define PICTURE_SCREEN_VERSION 2
343 TriStripProcPtr TriStrip;
344 TriFanProcPtr TriFan;
345} PictureScreenRec, *PictureScreenPtr;
346
347extern _X_EXPORT DevPrivateKeyRec PictureScreenPrivateKeyRec;
348
349#define PictureScreenPrivateKey (&PictureScreenPrivateKeyRec)
350
351extern _X_EXPORT DevPrivateKeyRec PictureWindowPrivateKeyRec;
352
353#define PictureWindowPrivateKey (&PictureWindowPrivateKeyRec)
354
355extern _X_EXPORT RESTYPE PictureType;
356extern _X_EXPORT RESTYPE PictFormatType;
357extern _X_EXPORT RESTYPE GlyphSetType;
358
359#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey))
360#define GetPictureScreenIfSet(s) (dixPrivateKeyRegistered(PictureScreenPrivateKey) ? GetPictureScreen(s) : NULL)
361#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p)
362#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey))
363#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
364
365#define VERIFY_PICTURE(pPicture, pid, client, mode) {\
366 int tmprc = dixLookupResourceByType((pointer)&(pPicture), pid,\
367 PictureType, client, mode);\
368 if (tmprc != Success)\
369 return tmprc;\
370}
371
372#define VERIFY_ALPHA(pPicture, pid, client, mode) {\
373 if (pid == None) \
374 pPicture = 0; \
375 else { \
376 VERIFY_PICTURE(pPicture, pid, client, mode); \
377 } \
378} \
379
380extern _X_EXPORT PictFormatPtr
381 PictureWindowFormat(WindowPtr pWindow);
382
383extern _X_EXPORT Bool
384 PictureDestroyWindow(WindowPtr pWindow);
385
386extern _X_EXPORT Bool
387 PictureCloseScreen(ScreenPtr pScreen);
388
389extern _X_EXPORT void
390 PictureStoreColors(ColormapPtr pColormap, int ndef, xColorItem * pdef);
391
392extern _X_EXPORT Bool
393 PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format);
394
395extern _X_EXPORT Bool
396 PictureSetSubpixelOrder(ScreenPtr pScreen, int subpixel);
397
398extern _X_EXPORT int
399 PictureGetSubpixelOrder(ScreenPtr pScreen);
400
401extern _X_EXPORT PictFormatPtr
402PictureCreateDefaultFormats(ScreenPtr pScreen, int *nformatp);
403
404extern _X_EXPORT PictFormatPtr
405PictureMatchVisual(ScreenPtr pScreen, int depth, VisualPtr pVisual);
406
407extern _X_EXPORT PictFormatPtr
408PictureMatchFormat(ScreenPtr pScreen, int depth, CARD32 format);
409
410extern _X_EXPORT Bool
411 PictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
412
413extern _X_EXPORT int
414 PictureGetFilterId(const char *filter, int len, Bool makeit);
415
416extern _X_EXPORT char *PictureGetFilterName(int id);
417
418extern _X_EXPORT int
419
420PictureAddFilter(ScreenPtr pScreen,
421 const char *filter,
422 PictFilterValidateParamsProcPtr ValidateParams,
423 int width, int height);
424
425extern _X_EXPORT Bool
426
427PictureSetFilterAlias(ScreenPtr pScreen, const char *filter, const char *alias);
428
429extern _X_EXPORT Bool
430 PictureSetDefaultFilters(ScreenPtr pScreen);
431
432extern _X_EXPORT void
433 PictureResetFilters(ScreenPtr pScreen);
434
435extern _X_EXPORT PictFilterPtr
436PictureFindFilter(ScreenPtr pScreen, char *name, int len);
437
438extern _X_EXPORT int
439
440SetPicturePictFilter(PicturePtr pPicture, PictFilterPtr pFilter,
441 xFixed * params, int nparams);
442
443extern _X_EXPORT int
444
445SetPictureFilter(PicturePtr pPicture, char *name, int len,
446 xFixed * params, int nparams);
447
448extern _X_EXPORT Bool
449 PictureFinishInit(void);
450
451extern _X_EXPORT void
452 SetPictureToDefaults(PicturePtr pPicture);
453
454extern _X_EXPORT PicturePtr
455CreatePicture(Picture pid,
456 DrawablePtr pDrawable,
457 PictFormatPtr pFormat,
458 Mask mask, XID *list, ClientPtr client, int *error);
459
460extern _X_EXPORT int
461
462ChangePicture(PicturePtr pPicture,
463 Mask vmask, XID *vlist, DevUnion *ulist, ClientPtr client);
464
465extern _X_EXPORT int
466
467SetPictureClipRects(PicturePtr pPicture,
468 int xOrigin, int yOrigin, int nRect, xRectangle *rects);
469
470extern _X_EXPORT int
471
472SetPictureClipRegion(PicturePtr pPicture,
473 int xOrigin, int yOrigin, RegionPtr pRegion);
474
475extern _X_EXPORT int
476 SetPictureTransform(PicturePtr pPicture, PictTransform * transform);
477
478extern _X_EXPORT void
479 CopyPicture(PicturePtr pSrc, Mask mask, PicturePtr pDst);
480
481extern _X_EXPORT void
482 ValidatePicture(PicturePtr pPicture);
483
484extern _X_EXPORT int
485 FreePicture(pointer pPicture, XID pid);
486
487extern _X_EXPORT int
488 FreePictFormat(pointer pPictFormat, XID pid);
489
490extern _X_EXPORT void
491
492CompositePicture(CARD8 op,
493 PicturePtr pSrc,
494 PicturePtr pMask,
495 PicturePtr pDst,
496 INT16 xSrc,
497 INT16 ySrc,
498 INT16 xMask,
499 INT16 yMask,
500 INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
501
502extern _X_EXPORT void
503
504CompositeGlyphs(CARD8 op,
505 PicturePtr pSrc,
506 PicturePtr pDst,
507 PictFormatPtr maskFormat,
508 INT16 xSrc,
509 INT16 ySrc, int nlist, GlyphListPtr lists, GlyphPtr * glyphs);
510
511extern _X_EXPORT void
512
513CompositeRects(CARD8 op,
514 PicturePtr pDst,
515 xRenderColor * color, int nRect, xRectangle *rects);
516
517extern _X_EXPORT void
518
519CompositeTrapezoids(CARD8 op,
520 PicturePtr pSrc,
521 PicturePtr pDst,
522 PictFormatPtr maskFormat,
523 INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps);
524
525extern _X_EXPORT void
526
527CompositeTriangles(CARD8 op,
528 PicturePtr pSrc,
529 PicturePtr pDst,
530 PictFormatPtr maskFormat,
531 INT16 xSrc,
532 INT16 ySrc, int ntriangles, xTriangle * triangles);
533
534extern _X_EXPORT void
535
536CompositeTriStrip(CARD8 op,
537 PicturePtr pSrc,
538 PicturePtr pDst,
539 PictFormatPtr maskFormat,
540 INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
541
542extern _X_EXPORT void
543
544CompositeTriFan(CARD8 op,
545 PicturePtr pSrc,
546 PicturePtr pDst,
547 PictFormatPtr maskFormat,
548 INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
549
550Bool
551 AnimCurInit(ScreenPtr pScreen);
552
553int
554
555AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
556 CursorPtr *ppCursor, ClientPtr client, XID cid);
557
558extern _X_EXPORT void
559
560AddTraps(PicturePtr pPicture,
561 INT16 xOff, INT16 yOff, int ntraps, xTrap * traps);
562
563extern _X_EXPORT PicturePtr
564CreateSolidPicture(Picture pid, xRenderColor * color, int *error);
565
566extern _X_EXPORT PicturePtr
567CreateLinearGradientPicture(Picture pid,
568 xPointFixed * p1,
569 xPointFixed * p2,
570 int nStops,
571 xFixed * stops, xRenderColor * colors, int *error);
572
573extern _X_EXPORT PicturePtr
574CreateRadialGradientPicture(Picture pid,
575 xPointFixed * inner,
576 xPointFixed * outer,
577 xFixed innerRadius,
578 xFixed outerRadius,
579 int nStops,
580 xFixed * stops, xRenderColor * colors, int *error);
581
582extern _X_EXPORT PicturePtr
583CreateConicalGradientPicture(Picture pid,
584 xPointFixed * center,
585 xFixed angle,
586 int nStops,
587 xFixed * stops, xRenderColor * colors, int *error);
588
589#ifdef PANORAMIX
590extern _X_EXPORT void PanoramiXRenderInit(void);
591extern _X_EXPORT void PanoramiXRenderReset(void);
592#endif
593
594/*
595 * matrix.c
596 */
597
598extern _X_EXPORT void
599
600PictTransform_from_xRenderTransform(PictTransformPtr pict,
601 xRenderTransform * render);
602
603extern _X_EXPORT void
604
605xRenderTransform_from_PictTransform(xRenderTransform * render,
606 PictTransformPtr pict);
607
608extern _X_EXPORT Bool
609 PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector);
610
611extern _X_EXPORT Bool
612 PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector);
613
614#endif /* _PICTURESTR_H_ */