Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xmesa_xf86.h 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /**************************************************************************
  2. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
  3. All Rights Reserved.
  4. Permission is hereby granted, free of charge, to any person obtaining a
  5. copy of this software and associated documentation files (the
  6. "Software"), to deal in the Software without restriction, including
  7. without limitation the rights to use, copy, modify, merge, publish,
  8. distribute, sub license, and/or sell copies of the Software, and to
  9. permit persons to whom the Software is furnished to do so, subject to
  10. the following conditions:
  11. The above copyright notice and this permission notice (including the
  12. next paragraph) shall be included in all copies or substantial portions
  13. of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  17. IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
  18. ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  19. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  20. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. **************************************************************************/
  22. /*
  23. * Authors:
  24. * Kevin E. Martin <kevin@precisioninsight.com>
  25. *
  26. * When we're building the XMesa driver for use in the X server (as the
  27. * indirect render) we include this file when building the xm_*.c files.
  28. * We need to define some types and macros differently when building
  29. * in the Xserver vs. stand-alone Mesa.
  30. */
  31. #ifndef _XMESA_XF86_H_
  32. #define _XMESA_XF86_H_
  33. #include "GL/glxtokens.h"
  34. #include "scrnintstr.h"
  35. #include "pixmapstr.h"
  36. #include "gcstruct.h"
  37. #include "servermd.h"
  38. typedef struct _XMesaImageRec {
  39. int width, height;
  40. char *data;
  41. int bytes_per_line; /* Padded to 32 bits */
  42. int bits_per_pixel;
  43. } XMesaImage;
  44. typedef ScreenRec XMesaDisplay;
  45. typedef PixmapPtr XMesaPixmap;
  46. typedef ColormapPtr XMesaColormap;
  47. typedef DrawablePtr XMesaDrawable;
  48. typedef WindowPtr XMesaWindow;
  49. typedef GCPtr XMesaGC;
  50. typedef VisualPtr XMesaVisualInfo;
  51. typedef DDXPointRec XMesaPoint;
  52. typedef xColorItem XMesaColor;
  53. #define XMesaSetGeneric(__d,__gc,__val,__mask) \
  54. do { \
  55. CARD32 __v[1]; \
  56. (void) __d; \
  57. __v[0] = __val; \
  58. dixChangeGC(NullClient, __gc, __mask, __v, NULL); \
  59. } while (0)
  60. #define XMesaSetGenericPtr(__d,__gc,__pval,__mask) \
  61. do { \
  62. ChangeGCVal __v[1]; \
  63. (void) __d; \
  64. __v[0].ptr = __pval; \
  65. dixChangeGC(NullClient, __gc, __mask, NULL, __v); \
  66. } while (0)
  67. #define XMesaSetForeground(d,gc,v) XMesaSetGeneric(d,gc,v,GCForeground)
  68. #define XMesaSetBackground(d,gc,v) XMesaSetGeneric(d,gc,v,GCBackground)
  69. #define XMesaSetPlaneMask(d,gc,v) XMesaSetGeneric(d,gc,v,GCPlaneMask)
  70. #define XMesaSetFunction(d,gc,v) XMesaSetGeneric(d,gc,v,GCFunction)
  71. #define XMesaSetFillStyle(d,gc,v) XMesaSetGeneric(d,gc,v,GCFillStyle)
  72. #define XMesaSetTile(d,gc,v) XMesaSetGenericPtr(d,gc,v,GCTile)
  73. #define XMesaDrawPoint(__d,__b,__gc,__x,__y) \
  74. do { \
  75. XMesaPoint __p[1]; \
  76. (void) __d; \
  77. __p[0].x = __x; \
  78. __p[0].y = __y; \
  79. ValidateGC(__b, __gc); \
  80. (*gc->ops->PolyPoint)(__b, __gc, CoordModeOrigin, 1, __p); \
  81. } while (0)
  82. #define XMesaDrawPoints(__d,__b,__gc,__p,__n,__m) \
  83. do { \
  84. (void) __d; \
  85. ValidateGC(__b, __gc); \
  86. (*gc->ops->PolyPoint)(__b, __gc, __m, __n, __p); \
  87. } while (0)
  88. #define XMesaDrawLine(__d, __b, __gc, __x0, __y0, __x1, __y1) \
  89. do { \
  90. XMesaPoint __p[2]; \
  91. (void) __d; \
  92. __p[0].x = __x0; \
  93. __p[0].y = __y0; \
  94. __p[1].x = __x1; \
  95. __p[1].y = __y1; \
  96. ValidateGC(__b, __gc); \
  97. (*gc->ops->PolyLines)(__b, __gc, CoordModeOrigin, 2, __p); \
  98. } while (0)
  99. #define XMesaFillRectangle(__d,__b,__gc,__x,__y,__w,__h) \
  100. do { \
  101. xRectangle __r[1]; \
  102. (void) __d; \
  103. ValidateGC((DrawablePtr)__b, __gc); \
  104. __r[0].x = __x; \
  105. __r[0].y = __y; \
  106. __r[0].width = __w; \
  107. __r[0].height = __h; \
  108. (*__gc->ops->PolyFillRect)((DrawablePtr)__b, __gc, 1, __r); \
  109. } while (0)
  110. static _X_INLINE XMesaImage *XMesaGetImage(XMesaDisplay *dpy, PixmapPtr p, int x,
  111. int y, unsigned int width,
  112. unsigned int height,
  113. unsigned long plane_mask, int format)
  114. {
  115. XMesaImage *img = Xcalloc(sizeof(*img));
  116. img->width = p->drawable.width;
  117. img->height = p->drawable.height;
  118. img->bits_per_pixel = p->drawable.bitsPerPixel;
  119. img->bytes_per_line = PixmapBytePad(width, p->drawable.depth);
  120. img->data = malloc(height * img->bytes_per_line);
  121. /* Assumes: Images are always in ZPixmap format */
  122. (*p->drawable.pScreen->GetImage)(&p->drawable, x, y, width, height,
  123. plane_mask, ZPixmap, img->data);
  124. return img;
  125. }
  126. #define XMesaPutImage(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h) \
  127. do { \
  128. /* Assumes: Images are always in ZPixmap format */ \
  129. (void) __d; \
  130. ASSERT(!__sx && !__sy); /* The SubImage case */ \
  131. ValidateGC(__b, __gc); \
  132. (*__gc->ops->PutImage)(__b, __gc, ((XMesaDrawable)(__b))->depth, \
  133. __x, __y, __w, __h, 0, ZPixmap, \
  134. ((XMesaImage *)(__i))->data); \
  135. } while (0)
  136. #define XMesaCopyArea(__d,__sb,__db,__gc,__sx,__sy,__w,__h,__x,__y) \
  137. do { \
  138. (void) __d; \
  139. ValidateGC(__db, __gc); \
  140. (*__gc->ops->CopyArea)((DrawablePtr)__sb, __db, __gc, \
  141. __sx, __sy, __w, __h, __x, __y); \
  142. } while (0)
  143. /* CreatePixmap returns a PixmapPtr; so, it cannot be inside braces */
  144. #define XMesaCreatePixmap(__d,__b,__w,__h,__depth) \
  145. (*__d->CreatePixmap)(__d, __w, __h, __depth)
  146. #define XMesaFreePixmap(__d,__b) \
  147. (*__d->DestroyPixmap)(__b)
  148. #define XMesaFreeGC(__d,__gc) \
  149. do { \
  150. (void) __d; \
  151. FreeScratchGC(__gc); \
  152. } while (0)
  153. #define GET_COLORMAP_SIZE(__v) __v->ColormapEntries
  154. #define GET_REDMASK(__v) __v->mesa_visual.redMask
  155. #define GET_GREENMASK(__v) __v->mesa_visual.greenMask
  156. #define GET_BLUEMASK(__v) __v->mesa_visual.blueMask
  157. #define GET_VISUAL_DEPTH(__v) __v->nplanes
  158. #define GET_BLACK_PIXEL(__v) __v->display->blackPixel
  159. #define CHECK_BYTE_ORDER(__v) GL_TRUE
  160. #define CHECK_FOR_HPCR(__v) GL_FALSE
  161. #endif