r300/compiler: implement SGT+SLE opcodes
[mesa.git] / src / mesa / drivers / x11 / xm_line.c
index 8e99943007bf181ecde3ef555578aa8c771c7ccf..f643b6d3a763371ce973362e7e8d55b750784daf 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -31,9 +31,9 @@
 
 
 #include "glxheader.h"
-#include "depth.h"
-#include "macros.h"
-#include "mtypes.h"
+#include "main/depth.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
 #include "xmesaP.h"
 
 /* Internal swrast includes:
@@ -69,7 +69,7 @@ static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
                                                  color[2], color[3],
                                                  xmesa->pixelformat);
       XMesaSetForeground( dpy, gc, pixel );
-      x =                         (GLint) vert->win[0];
+      x = (GLint) vert->win[0];
       y = YFLIP( xrb, (GLint) vert->win[1] );
       XMesaDrawPoint( dpy, buffer, gc, x, y);
    }
@@ -117,8 +117,11 @@ void xmesa_choose_point( GLcontext *ctx )
 /**********************************************************************/
 
 
+#if CHAN_BITS == 8
+
+
 #define GET_XRB(XRB)  struct xmesa_renderbuffer *XRB = \
-   (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped
+   xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped)
 
 
 /*
@@ -144,7 +147,7 @@ void xmesa_choose_point( GLcontext *ctx )
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    const GLubyte *color = vert1->color;                                \
-   GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
+   GLuint pixel = PACK_8A8B8G8R(color[0], color[1], color[2], color[3]);
 #define PIXEL_TYPE GLuint
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
@@ -161,7 +164,7 @@ void xmesa_choose_point( GLcontext *ctx )
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    const GLubyte *color = vert1->color;                                \
-   GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
+   GLuint pixel = PACK_8A8R8G8B(color[0], color[1], color[2], color[3]);
 #define PIXEL_TYPE GLuint
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
@@ -328,7 +331,7 @@ void xmesa_choose_point( GLcontext *ctx )
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    const GLubyte *color = vert1->color;                                \
-   GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
+   GLuint pixel = PACK_8A8B8G8R(color[0], color[1], color[2], color[3]);
 #define INTERP_Z 1
 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
 #define PIXEL_TYPE GLuint
@@ -351,7 +354,7 @@ void xmesa_choose_point( GLcontext *ctx )
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    const GLubyte *color = vert1->color;                                \
-   GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
+   GLuint pixel = PACK_8A8R8G8B(color[0], color[1], color[2], color[3]);
 #define INTERP_Z 1
 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
 #define PIXEL_TYPE GLuint
@@ -533,6 +536,7 @@ void xmesa_choose_point( GLcontext *ctx )
 
 
 
+
 #ifndef XFree86Server
 /**
  * Draw fast, XOR line with XDrawLine in front color buffer.
@@ -547,16 +551,15 @@ xor_line(GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1)
    XMesaContext xmesa = XMESA_CONTEXT(ctx);
    XMesaDisplay *dpy = xmesa->xm_visual->display;
    XMesaGC gc = xmesa->xm_buffer->gc;
-   struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
-      ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+   GET_XRB(xrb);
    unsigned long pixel = xmesa_color_to_pixel(ctx,
                                               vert1->color[0], vert1->color[1],
                                               vert1->color[2], vert1->color[3],
                                               xmesa->pixelformat);
-   int x0 = (int) vert0->win[0];
-   int y0 = YFLIP(xrb, (GLint) vert0->win[1]);
-   int x1 = (int) vert1->win[0];
-   int y1 = YFLIP(xrb, (GLint) vert1->win[1]);
+   int x0 =            (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][0];
+   int y0 = YFLIP(xrb, (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][1]);
+   int x1 =            (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][0];
+   int y1 = YFLIP(xrb, (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][1]);
    XMesaSetForeground(dpy, gc, pixel);
    XMesaSetFunction(dpy, gc, GXxor);
    XSetLineAttributes(dpy, gc, (int) ctx->Line.Width,
@@ -567,6 +570,9 @@ xor_line(GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1)
 #endif /* XFree86Server */
 
 
+#endif /* CHAN_BITS == 8 */
+
+
 /**
  * Return pointer to line drawing function, or NULL if we should use a
  * swrast fallback.
@@ -574,14 +580,15 @@ xor_line(GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1)
 static swrast_line_func
 get_line_func(GLcontext *ctx)
 {
-   XMesaContext xmesa = XMESA_CONTEXT(ctx);
+#if CHAN_BITS == 8
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
-   int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
-   struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
-      ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+   XMesaContext xmesa = XMESA_CONTEXT(ctx);
+   XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+   const int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+   const struct xmesa_renderbuffer *xrb;
 
-   if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
-        & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
+   if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) &&
+       (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT))
       return (swrast_line_func) NULL;
    if (ctx->RenderMode != GL_RENDER)      return (swrast_line_func) NULL;
    if (ctx->Line.SmoothFlag)              return (swrast_line_func) NULL;
@@ -589,6 +596,9 @@ get_line_func(GLcontext *ctx)
    if (ctx->Light.ShadeModel != GL_FLAT)  return (swrast_line_func) NULL;
    if (ctx->Line.StippleFlag)             return (swrast_line_func) NULL;
    if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
+   if (xmbuf->swAlpha)                    return (swrast_line_func) NULL;
+
+   xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
 
    if (xrb->ximage
        && swrast->_RasterMask==DEPTH_BIT
@@ -651,8 +661,8 @@ get_line_func(GLcontext *ctx)
    }
 
 #ifndef XFree86Server
-   if (ctx->DrawBuffer->_NumColorDrawBuffers[0] == 1
-       && ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT
+   if (ctx->DrawBuffer->_NumColorDrawBuffers == 1
+       && ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT
        && swrast->_RasterMask == LOGIC_OP_BIT
        && ctx->Color.LogicOp == GL_XOR
        && !ctx->Line.StippleFlag
@@ -661,6 +671,7 @@ get_line_func(GLcontext *ctx)
    }
 #endif /* XFree86Server */
 
+#endif /* CHAN_BITS == 8 */
    return (swrast_line_func) NULL;
 }