diff options
author | Brian <[email protected]> | 2007-04-01 18:28:28 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-04-01 18:28:28 -0600 |
commit | 0683e4ce4bbbe381cbf59122aaef4ae3671d45e9 (patch) | |
tree | b67764fc5d1b3376d1099efe530f6ac65a71fd01 /src/mesa | |
parent | ec42af9263bfba71074396f3850d5264083a5632 (diff) |
If using PF_8A8B8G8R, be sure alpha is correctly handled.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/x11/xm_line.c | 19 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_tri.c | 44 |
2 files changed, 40 insertions, 23 deletions
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c index c3105425159..8537256d2e2 100644 --- a/src/mesa/drivers/x11/xm_line.c +++ b/src/mesa/drivers/x11/xm_line.c @@ -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); diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index 289ce11be62..2110e63551a 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -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) @@ -106,13 +107,15 @@ 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; \ } @@ -127,6 +130,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) @@ -138,13 +142,15 @@ 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; \ } @@ -473,7 +479,8 @@ #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++) { \ @@ -499,7 +506,8 @@ #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++) { \ @@ -798,6 +806,7 @@ */ #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) @@ -806,11 +815,13 @@ #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" @@ -821,6 +832,7 @@ */ #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) @@ -829,11 +841,13 @@ #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); |