picturestr.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*
  2. *
  3. * Copyright © 2000 SuSE, Inc.
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software and its
  6. * documentation for any purpose is hereby granted without fee, provided that
  7. * the above copyright notice appear in all copies and that both that
  8. * copyright notice and this permission notice appear in supporting
  9. * documentation, and that the name of SuSE not be used in advertising or
  10. * publicity pertaining to distribution of the software without specific,
  11. * written prior permission. SuSE makes no representations about the
  12. * suitability of this software for any purpose. It is provided "as is"
  13. * without express or implied warranty.
  14. *
  15. * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  17. * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  18. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  19. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  20. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21. *
  22. * Author: Keith Packard, SuSE, Inc.
  23. */
  24. #ifndef _PICTURESTR_H_
  25. #define _PICTURESTR_H_
  26. #include "glyphstr.h"
  27. #include "scrnintstr.h"
  28. #include "resource.h"
  29. typedef struct _DirectFormat {
  30. CARD16 red, redMask;
  31. CARD16 green, greenMask;
  32. CARD16 blue, blueMask;
  33. CARD16 alpha, alphaMask;
  34. } DirectFormatRec;
  35. typedef struct _IndexFormat {
  36. VisualID vid;
  37. ColormapPtr pColormap;
  38. int nvalues;
  39. xIndexValue *pValues;
  40. void *devPrivate;
  41. } IndexFormatRec;
  42. typedef struct _PictFormat {
  43. CARD32 id;
  44. CARD32 format; /* except bpp */
  45. unsigned char type;
  46. unsigned char depth;
  47. DirectFormatRec direct;
  48. IndexFormatRec index;
  49. } PictFormatRec;
  50. typedef struct _PictVector {
  51. xFixed vector[3];
  52. } PictVector, *PictVectorPtr;
  53. typedef struct _PictTransform {
  54. xFixed matrix[3][3];
  55. } PictTransform, *PictTransformPtr;
  56. #define PICT_GRADIENT_STOPTABLE_SIZE 1024
  57. #define SourcePictTypeSolidFill 0
  58. #define SourcePictTypeLinear 1
  59. #define SourcePictTypeRadial 2
  60. #define SourcePictTypeConical 3
  61. typedef struct _PictSolidFill {
  62. unsigned int type;
  63. CARD32 color;
  64. } PictSolidFill, *PictSolidFillPtr;
  65. typedef struct _PictGradientStop {
  66. xFixed x;
  67. xRenderColor color;
  68. } PictGradientStop, *PictGradientStopPtr;
  69. typedef struct _PictGradient {
  70. unsigned int type;
  71. int nstops;
  72. PictGradientStopPtr stops;
  73. CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
  74. } PictGradient, *PictGradientPtr;
  75. typedef struct _PictLinearGradient {
  76. unsigned int type;
  77. int nstops;
  78. PictGradientStopPtr stops;
  79. CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
  80. xPointFixed p1;
  81. xPointFixed p2;
  82. } PictLinearGradient, *PictLinearGradientPtr;
  83. typedef struct _PictRadialGradient {
  84. unsigned int type;
  85. int nstops;
  86. PictGradientStopPtr stops;
  87. CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
  88. double fx;
  89. double fy;
  90. double dx;
  91. double dy;
  92. double a;
  93. double m;
  94. double b;
  95. } PictRadialGradient, *PictRadialGradientPtr;
  96. typedef struct _PictConicalGradient {
  97. unsigned int type;
  98. int nstops;
  99. PictGradientStopPtr stops;
  100. CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
  101. xPointFixed center;
  102. xFixed angle;
  103. } PictConicalGradient, *PictConicalGradientPtr;
  104. typedef union _SourcePict {
  105. unsigned int type;
  106. PictSolidFill solidFill;
  107. PictGradient gradient;
  108. PictLinearGradient linear;
  109. PictRadialGradient radial;
  110. PictConicalGradient conical;
  111. } SourcePict, *SourcePictPtr;
  112. typedef struct _Picture {
  113. DrawablePtr pDrawable;
  114. PictFormatPtr pFormat;
  115. PictFormatShort format; /* PICT_FORMAT */
  116. int refcnt;
  117. CARD32 id;
  118. PicturePtr pNext; /* chain on same drawable */
  119. unsigned int repeat:1;
  120. unsigned int graphicsExposures:1;
  121. unsigned int subWindowMode:1;
  122. unsigned int polyEdge:1;
  123. unsigned int polyMode:1;
  124. unsigned int freeCompClip:1;
  125. unsigned int clientClipType:2;
  126. unsigned int componentAlpha:1;
  127. unsigned int repeatType:2;
  128. unsigned int unused:21;
  129. PicturePtr alphaMap;
  130. DDXPointRec alphaOrigin;
  131. DDXPointRec clipOrigin;
  132. pointer clientClip;
  133. Atom dither;
  134. unsigned long stateChanges;
  135. unsigned long serialNumber;
  136. RegionPtr pCompositeClip;
  137. DevUnion *devPrivates;
  138. PictTransform *transform;
  139. int filter;
  140. xFixed *filter_params;
  141. int filter_nparams;
  142. SourcePictPtr pSourcePict;
  143. } PictureRec;
  144. typedef Bool (*PictFilterValidateParamsProcPtr) (PicturePtr pPicture, int id,
  145. xFixed * params, int nparams);
  146. typedef struct {
  147. char *name;
  148. int id;
  149. PictFilterValidateParamsProcPtr ValidateParams;
  150. } PictFilterRec, *PictFilterPtr;
  151. #define PictFilterNearest 0
  152. #define PictFilterBilinear 1
  153. #define PictFilterFast 2
  154. #define PictFilterGood 3
  155. #define PictFilterBest 4
  156. #define PictFilterConvolution 5
  157. typedef struct {
  158. char *alias;
  159. int alias_id;
  160. int filter_id;
  161. } PictFilterAliasRec, *PictFilterAliasPtr;
  162. typedef int (*CreatePictureProcPtr) (PicturePtr pPicture);
  163. typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture);
  164. typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture,
  165. int clipType, pointer value, int n);
  166. typedef void (*DestroyPictureClipProcPtr) (PicturePtr pPicture);
  167. typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture,
  168. PictTransform * transform);
  169. typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture,
  170. int filter,
  171. xFixed * params, int nparams);
  172. typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture);
  173. typedef void (*ChangePictureProcPtr) (PicturePtr pPicture, Mask mask);
  174. typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture, Mask mask);
  175. typedef void (*CompositeProcPtr) (CARD8 op,
  176. PicturePtr pSrc,
  177. PicturePtr pMask,
  178. PicturePtr pDst,
  179. INT16 xSrc,
  180. INT16 ySrc,
  181. INT16 xMask,
  182. INT16 yMask,
  183. INT16 xDst,
  184. INT16 yDst, CARD16 width, CARD16 height);
  185. typedef void (*GlyphsProcPtr) (CARD8 op,
  186. PicturePtr pSrc,
  187. PicturePtr pDst,
  188. PictFormatPtr maskFormat,
  189. INT16 xSrc,
  190. INT16 ySrc,
  191. int nlists,
  192. GlyphListPtr lists, GlyphPtr * glyphs);
  193. typedef void (*CompositeRectsProcPtr) (CARD8 op,
  194. PicturePtr pDst,
  195. xRenderColor * color,
  196. int nRect, xRectangle *rects);
  197. typedef void (*RasterizeTrapezoidProcPtr) (PicturePtr pMask,
  198. xTrapezoid * trap,
  199. int x_off, int y_off);
  200. typedef void (*TrapezoidsProcPtr) (CARD8 op,
  201. PicturePtr pSrc,
  202. PicturePtr pDst,
  203. PictFormatPtr maskFormat,
  204. INT16 xSrc,
  205. INT16 ySrc, int ntrap, xTrapezoid * traps);
  206. typedef void (*TrianglesProcPtr) (CARD8 op,
  207. PicturePtr pSrc,
  208. PicturePtr pDst,
  209. PictFormatPtr maskFormat,
  210. INT16 xSrc,
  211. INT16 ySrc, int ntri, xTriangle * tris);
  212. typedef void (*TriStripProcPtr) (CARD8 op,
  213. PicturePtr pSrc,
  214. PicturePtr pDst,
  215. PictFormatPtr maskFormat,
  216. INT16 xSrc,
  217. INT16 ySrc, int npoint, xPointFixed * points);
  218. typedef void (*TriFanProcPtr) (CARD8 op,
  219. PicturePtr pSrc,
  220. PicturePtr pDst,
  221. PictFormatPtr maskFormat,
  222. INT16 xSrc,
  223. INT16 ySrc, int npoint, xPointFixed * points);
  224. typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen, PictFormatPtr pFormat);
  225. typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen, PictFormatPtr pFormat);
  226. typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen,
  227. PictFormatPtr pFormat,
  228. int ndef, xColorItem * pdef);
  229. typedef void (*AddTrapsProcPtr) (PicturePtr pPicture,
  230. INT16 xOff,
  231. INT16 yOff, int ntrap, xTrap * traps);
  232. typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture,
  233. INT16 xOff,
  234. INT16 yOff, int ntri, xTriangle * tris);
  235. typedef Bool (*RealizeGlyphProcPtr) (ScreenPtr pScreen, GlyphPtr glyph);
  236. typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen, GlyphPtr glyph);
  237. typedef struct _PictureScreen {
  238. int totalPictureSize;
  239. unsigned int *PicturePrivateSizes;
  240. int PicturePrivateLen;
  241. PictFormatPtr formats;
  242. PictFormatPtr fallback;
  243. int nformats;
  244. CreatePictureProcPtr CreatePicture;
  245. DestroyPictureProcPtr DestroyPicture;
  246. ChangePictureClipProcPtr ChangePictureClip;
  247. DestroyPictureClipProcPtr DestroyPictureClip;
  248. ChangePictureProcPtr ChangePicture;
  249. ValidatePictureProcPtr ValidatePicture;
  250. CompositeProcPtr Composite;
  251. GlyphsProcPtr Glyphs;
  252. CompositeRectsProcPtr CompositeRects;
  253. DestroyWindowProcPtr DestroyWindow;
  254. CloseScreenProcPtr CloseScreen;
  255. StoreColorsProcPtr StoreColors;
  256. InitIndexedProcPtr InitIndexed;
  257. CloseIndexedProcPtr CloseIndexed;
  258. UpdateIndexedProcPtr UpdateIndexed;
  259. int subpixel;
  260. PictFilterPtr filters;
  261. int nfilters;
  262. PictFilterAliasPtr filterAliases;
  263. int nfilterAliases;
  264. /**
  265. * Called immediately after a picture's transform is changed through the
  266. * SetPictureTransform request. Not called for source-only pictures.
  267. */
  268. ChangePictureTransformProcPtr ChangePictureTransform;
  269. /**
  270. * Called immediately after a picture's transform is changed through the
  271. * SetPictureFilter request. Not called for source-only pictures.
  272. */
  273. ChangePictureFilterProcPtr ChangePictureFilter;
  274. DestroyPictureFilterProcPtr DestroyPictureFilter;
  275. TrapezoidsProcPtr Trapezoids;
  276. TrianglesProcPtr Triangles;
  277. TriStripProcPtr TriStrip;
  278. TriFanProcPtr TriFan;
  279. RasterizeTrapezoidProcPtr RasterizeTrapezoid;
  280. AddTrianglesProcPtr AddTriangles;
  281. AddTrapsProcPtr AddTraps;
  282. int totalGlyphPrivateSize;
  283. unsigned int *glyphPrivateSizes;
  284. int glyphPrivateLen;
  285. int glyphPrivateOffset;
  286. RealizeGlyphProcPtr RealizeGlyph;
  287. UnrealizeGlyphProcPtr UnrealizeGlyph;
  288. } PictureScreenRec, *PictureScreenPtr;
  289. extern int PictureScreenPrivateIndex;
  290. extern int PictureWindowPrivateIndex;
  291. extern RESTYPE PictureType;
  292. extern RESTYPE PictFormatType;
  293. extern RESTYPE GlyphSetType;
  294. #define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
  295. #define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
  296. #define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
  297. #define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
  298. #define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
  299. #define GetGlyphPrivatesForScreen(glyph, s) \
  300. ((glyph)->devPrivates + (GetPictureScreen (s))->glyphPrivateOffset)
  301. #define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
  302. pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
  303. if (!pPicture) { \
  304. client->errorValue = pid; \
  305. return err; \
  306. } \
  307. }
  308. #define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\
  309. if (pid == None) \
  310. pPicture = 0; \
  311. else { \
  312. VERIFY_PICTURE(pPicture, pid, client, mode, err); \
  313. } \
  314. } \
  315. void
  316. ResetPicturePrivateIndex(void);
  317. Bool
  318. PictureDestroyWindow(WindowPtr pWindow);
  319. Bool
  320. PictureCloseScreen(int Index, ScreenPtr pScreen);
  321. void
  322. PictureStoreColors(ColormapPtr pColormap, int ndef, xColorItem * pdef);
  323. Bool
  324. PictureInitIndexedFormats(ScreenPtr pScreen);
  325. Bool
  326. PictureSetSubpixelOrder(ScreenPtr pScreen, int subpixel);
  327. int
  328. PictureGetSubpixelOrder(ScreenPtr pScreen);
  329. PictFormatPtr PictureCreateDefaultFormats(ScreenPtr pScreen, int *nformatp);
  330. PictFormatPtr
  331. PictureMatchVisual(ScreenPtr pScreen, int depth, VisualPtr pVisual);
  332. PictFormatPtr PictureMatchFormat(ScreenPtr pScreen, int depth, CARD32 format);
  333. Bool
  334. PictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
  335. int
  336. PictureGetFilterId(char *filter, int len, Bool makeit);
  337. char *PictureGetFilterName(int id);
  338. int
  339. PictureAddFilter(ScreenPtr pScreen,
  340. char *filter, PictFilterValidateParamsProcPtr ValidateParams);
  341. Bool
  342. PictureSetFilterAlias(ScreenPtr pScreen, char *filter, char *alias);
  343. Bool
  344. PictureSetDefaultFilters(ScreenPtr pScreen);
  345. void
  346. PictureResetFilters(ScreenPtr pScreen);
  347. PictFilterPtr PictureFindFilter(ScreenPtr pScreen, char *name, int len);
  348. int
  349. SetPictureFilter(PicturePtr pPicture, char *name, int len, xFixed * params,
  350. int nparams);
  351. Bool
  352. PictureFinishInit(void);
  353. void
  354. SetPictureToDefaults(PicturePtr pPicture);
  355. PicturePtr AllocatePicture(ScreenPtr pScreen);
  356. #if 0
  357. Bool
  358. miPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
  359. #endif
  360. PicturePtr
  361. CreatePicture(Picture pid,
  362. DrawablePtr pDrawable,
  363. PictFormatPtr pFormat,
  364. Mask mask, XID *list, ClientPtr client, int *error);
  365. int
  366. ChangePicture(PicturePtr pPicture,
  367. Mask vmask, XID *vlist, DevUnion *ulist, ClientPtr client);
  368. int
  369. SetPictureClipRects(PicturePtr pPicture,
  370. int xOrigin, int yOrigin, int nRect, xRectangle *rects);
  371. int
  372. SetPictureClipRegion(PicturePtr pPicture,
  373. int xOrigin, int yOrigin, RegionPtr pRegion);
  374. int
  375. SetPictureTransform(PicturePtr pPicture, PictTransform * transform);
  376. void
  377. ValidatePicture(PicturePtr pPicture);
  378. int
  379. FreePicture(pointer pPicture, XID pid);
  380. int
  381. FreePictFormat(pointer pPictFormat, XID pid);
  382. void
  383. CompositePicture(CARD8 op,
  384. PicturePtr pSrc,
  385. PicturePtr pMask,
  386. PicturePtr pDst,
  387. INT16 xSrc,
  388. INT16 ySrc,
  389. INT16 xMask,
  390. INT16 yMask,
  391. INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
  392. void
  393. CompositeGlyphs(CARD8 op,
  394. PicturePtr pSrc,
  395. PicturePtr pDst,
  396. PictFormatPtr maskFormat,
  397. INT16 xSrc,
  398. INT16 ySrc, int nlist, GlyphListPtr lists, GlyphPtr * glyphs);
  399. void
  400. CompositeRects(CARD8 op,
  401. PicturePtr pDst,
  402. xRenderColor * color, int nRect, xRectangle *rects);
  403. void
  404. CompositeTrapezoids(CARD8 op,
  405. PicturePtr pSrc,
  406. PicturePtr pDst,
  407. PictFormatPtr maskFormat,
  408. INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps);
  409. void
  410. CompositeTriangles(CARD8 op,
  411. PicturePtr pSrc,
  412. PicturePtr pDst,
  413. PictFormatPtr maskFormat,
  414. INT16 xSrc,
  415. INT16 ySrc, int ntriangles, xTriangle * triangles);
  416. void
  417. CompositeTriStrip(CARD8 op,
  418. PicturePtr pSrc,
  419. PicturePtr pDst,
  420. PictFormatPtr maskFormat,
  421. INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
  422. void
  423. CompositeTriFan(CARD8 op,
  424. PicturePtr pSrc,
  425. PicturePtr pDst,
  426. PictFormatPtr maskFormat,
  427. INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
  428. Bool
  429. PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector);
  430. Bool
  431. PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector);
  432. void RenderExtensionInit(void);
  433. Bool
  434. AnimCurInit(ScreenPtr pScreen);
  435. int
  436. AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
  437. CursorPtr *ppCursor);
  438. void
  439. AddTraps(PicturePtr pPicture,
  440. INT16 xOff, INT16 yOff, int ntraps, xTrap * traps);
  441. PicturePtr CreateSolidPicture(Picture pid, xRenderColor * color, int *error);
  442. PicturePtr
  443. CreateLinearGradientPicture(Picture pid,
  444. xPointFixed * p1,
  445. xPointFixed * p2,
  446. int nStops,
  447. xFixed * stops, xRenderColor * colors, int *error);
  448. PicturePtr
  449. CreateRadialGradientPicture(Picture pid,
  450. xPointFixed * inner,
  451. xPointFixed * outer,
  452. xFixed innerRadius,
  453. xFixed outerRadius,
  454. int nStops,
  455. xFixed * stops, xRenderColor * colors, int *error);
  456. PicturePtr
  457. CreateConicalGradientPicture(Picture pid,
  458. xPointFixed * center,
  459. xFixed angle,
  460. int nStops,
  461. xFixed * stops, xRenderColor * colors, int *error);
  462. #endif /* _PICTURESTR_H_ */