If using PF_8A8B8G8R, be sure alpha is correctly handled.
authorBrian <brian@nostromo.localnet.net>
Mon, 2 Apr 2007 00:28:28 +0000 (18:28 -0600)
committerBrian <brian@nostromo.localnet.net>
Mon, 2 Apr 2007 00:28:28 +0000 (18:28 -0600)
src/mesa/drivers/x11/xm_line.c
src/mesa/drivers/x11/xm_tri.c

index c31054251599db1a0c9c0f4fff32e7f71c85416f..8537256d2e21090f95df5c982c02d75bb02ab01a 100644 (file)
@@ -147,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)
@@ -164,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)
@@ -331,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
@@ -354,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
@@ -581,13 +581,11 @@ static swrast_line_func
 get_line_func(GLcontext *ctx)
 {
 #if CHAN_BITS == 8
-   XMesaContext xmesa = XMESA_CONTEXT(ctx);
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
-   int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
-   struct xmesa_renderbuffer *xrb;
-
-   if (CHAN_BITS != 8)
-      return NULL;
+   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)
@@ -598,6 +596,7 @@ 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][0]->Wrapped);
 
index 289ce11be62b335a50b2241b56039b3c8843965a..2110e63551a538e0790820ed7e3c2ce969dd2690 100644 (file)
@@ -96,6 +96,7 @@
 #define INTERP_Z 1
 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
 #define INTERP_RGB 1
+#define INTERP_ALPHA 1
 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
 #define PIXEL_TYPE GLuint
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
    for (i = 0; i < span.end; i++) {                            \
       const DEPTH_TYPE z = FixedToDepth(span.z);               \
       if (z < zRow[i]) {                                       \
-         pRow[i] = PACK_8B8G8R(FixedToInt(span.red),           \
-            FixedToInt(span.green), FixedToInt(span.blue));    \
+         pRow[i] = PACK_8A8B8G8R(FixedToInt(span.red),         \
+            FixedToInt(span.green), FixedToInt(span.blue),     \
+            FixedToInt(span.alpha));                           \
          zRow[i] = z;                                          \
       }                                                                \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
+      span.alpha += span.alphaStep;                            \
       span.z += span.zStep;                                    \
    }
 
 #define INTERP_Z 1
 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
 #define INTERP_RGB 1
+#define INTERP_ALPHA 1
 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
 #define PIXEL_TYPE GLuint
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
    for (i = 0; i < span.end; i++) {                            \
       const DEPTH_TYPE z = FixedToDepth(span.z);               \
       if (z < zRow[i]) {                                       \
-         pRow[i] = PACK_8R8G8B(FixedToInt(span.red),           \
-            FixedToInt(span.green), FixedToInt(span.blue));    \
+         pRow[i] = PACK_8A8R8G8B(FixedToInt(span.red),         \
+            FixedToInt(span.green), FixedToInt(span.blue),     \
+            FixedToInt(span.alpha));                           \
          zRow[i] = z;                                          \
       }                                                                \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
+      span.alpha += span.alphaStep;                            \
       span.z += span.zStep;                                    \
    }
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                     \
    GET_XRB(xrb);                                       \
-   GLuint p = PACK_8B8G8R( v2->color[0], v2->color[1], v2->color[2] );
+   GLuint p = PACK_8A8B8G8R( v2->color[0], v2->color[1],\
+                             v2->color[2], v2->color[3]);
 #define RENDER_SPAN( span )                            \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                     \
    GET_XRB(xrb);                                       \
-   GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
+   GLuint p = PACK_8A8R8G8B(v2->color[0], v2->color[1],        \
+                            v2->color[2], v2->color[3]);
 #define RENDER_SPAN( span )                            \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
  */
 #define NAME smooth_8A8B8G8R_triangle
 #define INTERP_RGB 1
+#define INTERP_ALPHA 1
 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
 #define PIXEL_TYPE GLuint
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define RENDER_SPAN( span )                                    \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
-      pRow[i] = PACK_8B8G8R(FixedToInt(span.red),              \
-         FixedToInt(span.green), FixedToInt(span.blue) );      \
+      pRow[i] = PACK_8A8B8G8R(FixedToInt(span.red),            \
+         FixedToInt(span.green), FixedToInt(span.blue),                \
+         FixedToInt(span.alpha));                              \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
+      span.alpha += span.alphaStep;                            \
    }
 #include "swrast/s_tritemp.h"
 
  */
 #define NAME smooth_8A8R8G8B_triangle
 #define INTERP_RGB 1
+#define INTERP_ALPHA 1
 #define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
 #define PIXEL_TYPE GLuint
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define RENDER_SPAN( span )                                    \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
-      pRow[i] = PACK_8R8G8B(FixedToInt(span.red),              \
-         FixedToInt(span.green), FixedToInt(span.blue) );      \
+      pRow[i] = PACK_8A8R8G8B(FixedToInt(span.red),            \
+         FixedToInt(span.green), FixedToInt(span.blue),                \
+         FixedToInt(span.alpha));                              \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
+      span.alpha += span.alphaStep;                            \
    }
 #include "swrast/s_tritemp.h"
 
@@ -1419,6 +1433,7 @@ static const char *triFuncName = NULL;
 #define USE(triFunc)                   \
 do {                                   \
     triFuncName = #triFunc;            \
+    printf("%s\n", triFuncName);\
     return triFunc;                    \
 } while (0)
 
@@ -1436,16 +1451,17 @@ do {                                   \
 static swrast_tri_func
 get_triangle_func(GLcontext *ctx)
 {
+#if CHAN_BITS == 8
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    XMesaContext xmesa = XMESA_CONTEXT(ctx);
-   int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
-   struct xmesa_renderbuffer *xrb;
+   XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+   const int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+   const struct xmesa_renderbuffer *xrb;
 
 #ifdef DEBUG
    triFuncName = NULL;
 #endif
 
-#if CHAN_BITS == 8
    /* trivial fallback tests */
    if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
         & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
@@ -1461,6 +1477,8 @@ get_triangle_func(GLcontext *ctx)
    if (ctx->Polygon.CullFlag && 
        ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
       return (swrast_tri_func) NULL;
+   if (xmbuf->swAlpha)
+      return (swrast_tri_func) NULL;
 
    xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);