additional preprocessor checks for stdint.h, inttypes.h, etc
[mesa.git] / include / GL / xmesa_xf86.h
index 2be3efe78d184b2afe7cfba92226dab6ccefc4fb..10f93c3ab6276905f288cdfc70e48b4d85646d72 100644 (file)
@@ -30,16 +30,28 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  * Authors:
  *   Kevin E. Martin <kevin@precisioninsight.com>
  *
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/include/GL/xmesa_xf86.h,v 1.4 2000/02/25 20:31:11 brianp Exp $
+ * When we're building the XMesa driver for use in the X server (as the
+ * indirect render) we include this file when building the xm_*.c files.
+ * We need to define some types and macros differently when building
+ * in the Xserver vs. stand-alone Mesa.
  */
 
 #ifndef _XMESA_XF86_H_
 #define _XMESA_XF86_H_
 
+#include "GL/glxtokens.h"
 #include "scrnintstr.h"
 #include "pixmapstr.h"
+#include "gcstruct.h"
+#include "servermd.h"
 
-typedef struct _XMesaImageRec XMesaImage;
+
+typedef struct _XMesaImageRec {
+    int width, height;
+    char *data;
+    int bytes_per_line; /* Padded to 32 bits */
+    int bits_per_pixel;
+} XMesaImage;
 
 typedef ScreenRec   XMesaDisplay;
 typedef PixmapPtr   XMesaPixmap;
@@ -67,25 +79,6 @@ do { \
     dixChangeGC(NullClient, __gc, __mask, NULL, __v); \
 } while (0)
 
-#define XMesaSetDashes(__d,__gc,__do,__dl,__n) \
-do { \
-    (void) __d; \
-    SetDashes(__gc, __do, __n, (unsigned char *)__dl); \
-} while (0)
-
-#define XMesaSetLineAttributes(__d,__gc,__lw,__ls,__cs,__js) \
-do { \
-    CARD32 __v[4]; \
-    (void) __d; \
-    __v[0] = __lw; \
-    __v[1] = __ls; \
-    __v[2] = __cs; \
-    __v[3] = __js; \
-    dixChangeGC(NullClient, __gc, \
-               GCLineWidth|GCLineStyle|GCCapStyle|GCJoinStyle, \
-               __v, NULL); \
-} while (0)
-
 #define XMesaSetForeground(d,gc,v) XMesaSetGeneric(d,gc,v,GCForeground)
 #define XMesaSetBackground(d,gc,v) XMesaSetGeneric(d,gc,v,GCBackground)
 #define XMesaSetPlaneMask(d,gc,v)  XMesaSetGeneric(d,gc,v,GCPlaneMask)
@@ -93,7 +86,6 @@ do { \
 #define XMesaSetFillStyle(d,gc,v)  XMesaSetGeneric(d,gc,v,GCFillStyle)
 
 #define XMesaSetTile(d,gc,v)       XMesaSetGenericPtr(d,gc,v,GCTile)
-#define XMesaSetStipple(d,gc,v)    XMesaSetGenericPtr(d,gc,v,GCStipple)
 
 #define XMesaDrawPoint(__d,__b,__gc,__x,__y) \
 do { \
@@ -112,36 +104,55 @@ do { \
     (*gc->ops->PolyPoint)(__b, __gc, __m, __n, __p); \
 } while (0)
 
-#define XMesaDrawLine(__d,__b,__gc,__x0,__y0,__x1,__y1) \
+#define XMesaDrawLine(__d, __b, __gc, __x0, __y0, __x1, __y1) \
 do { \
     XMesaPoint __p[2]; \
     (void) __d; \
-    ValidateGC(__b, __gc); \
     __p[0].x = __x0; \
     __p[0].y = __y0; \
     __p[1].x = __x1; \
     __p[1].y = __y1; \
-    (*__gc->ops->Polylines)(__b, __gc, CoordModeOrigin, 2, __p); \
+    ValidateGC(__b, __gc); \
+    (*gc->ops->PolyLines)(__b, __gc, CoordModeOrigin, 2, __p); \
 } while (0)
 
 #define XMesaFillRectangle(__d,__b,__gc,__x,__y,__w,__h) \
 do { \
     xRectangle __r[1]; \
     (void) __d; \
-    ValidateGC(__b, __gc); \
+    ValidateGC((DrawablePtr)__b, __gc); \
     __r[0].x = __x; \
     __r[0].y = __y; \
     __r[0].width = __w; \
     __r[0].height = __h; \
-    (*__gc->ops->PolyFillRect)(__b, __gc, 1, __r); \
+    (*__gc->ops->PolyFillRect)((DrawablePtr)__b, __gc, 1, __r); \
 } while (0)
 
+static _X_INLINE XMesaImage *XMesaGetImage(XMesaDisplay *dpy, PixmapPtr p, int x,
+                                       int y, unsigned int width,
+                                       unsigned int height,
+                                       unsigned long plane_mask, int format)
+{
+    XMesaImage *img = Xcalloc(sizeof(*img));
+
+    img->width = p->drawable.width;
+    img->height = p->drawable.height;
+    img->bits_per_pixel = p->drawable.bitsPerPixel;
+    img->bytes_per_line = PixmapBytePad(width, p->drawable.depth);
+    img->data = malloc(height * img->bytes_per_line);
+
+    /* Assumes: Images are always in ZPixmap format */
+    (*p->drawable.pScreen->GetImage)(&p->drawable, x, y, width, height,
+                                    plane_mask, ZPixmap, img->data);
+
+    return img;
+}
+
 #define XMesaPutImage(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h) \
 do { \
     /* Assumes: Images are always in ZPixmap format */ \
     (void) __d; \
-    if (__sx || __sy) /* The non-trivial case */ \
-       XMesaPutImageHelper(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h); \
+    ASSERT(!__sx && !__sy); /* The SubImage case */     \
     ValidateGC(__b, __gc); \
     (*__gc->ops->PutImage)(__b, __gc, ((XMesaDrawable)(__b))->depth, \
                           __x, __y, __w, __h, 0, ZPixmap, \
@@ -156,16 +167,16 @@ do { \
                           __sx, __sy, __w, __h, __x, __y); \
 } while (0)
 
-#define XMesaFillPolygon(__d,__b,__gc,__p,__n,__s,__m) \
-do { \
-    (void) __d; \
-    ValidateGC(__b, __gc); \
-    (*__gc->ops->FillPolygon)(__b, __gc, __s, __m, __n, __p); \
-} while (0)
 
 /* CreatePixmap returns a PixmapPtr; so, it cannot be inside braces */
+#ifdef CREATE_PIXMAP_USAGE_SCRATCH
+#define XMesaCreatePixmap(__d,__b,__w,__h,__depth) \
+  (*__d->CreatePixmap)(__d, __w, __h, __depth, 0)
+#else
 #define XMesaCreatePixmap(__d,__b,__w,__h,__depth) \
     (*__d->CreatePixmap)(__d, __w, __h, __depth)
+#endif
+
 #define XMesaFreePixmap(__d,__b) \
     (*__d->DestroyPixmap)(__b)
 
@@ -175,12 +186,11 @@ do { \
     FreeScratchGC(__gc); \
 } while (0)
 
-#define GET_COLORMAP_SIZE(__v)  __v->visinfo->ColormapEntries
-#define GET_REDMASK(__v)        __v->visinfo->redMask
-#define GET_GREENMASK(__v)      __v->visinfo->greenMask
-#define GET_BLUEMASK(__v)       __v->visinfo->blueMask
-#define GET_VISUAL_CLASS(__v)   __v->visinfo->class
-#define GET_VISUAL_DEPTH(__v)   __v->visinfo->nplanes
+#define GET_COLORMAP_SIZE(__v)  __v->ColormapEntries
+#define GET_REDMASK(__v)        __v->mesa_visual.redMask
+#define GET_GREENMASK(__v)      __v->mesa_visual.greenMask
+#define GET_BLUEMASK(__v)       __v->mesa_visual.blueMask
+#define GET_VISUAL_DEPTH(__v)   __v->nplanes
 #define GET_BLACK_PIXEL(__v)    __v->display->blackPixel
 #define CHECK_BYTE_ORDER(__v)   GL_TRUE
 #define CHECK_FOR_HPCR(__v)     GL_FALSE