summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_alphabuf.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-07-09 01:22:50 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-07-09 01:22:50 +0000
commit3b4fbbc129c711a5aec8d653d5c6eb2e195f947c (patch)
treeececa2d3a08ab45afd2068d9cabf5609a0c374d1 /src/mesa/swrast/s_alphabuf.c
parentb4338e58879a4f2eabf8af09f9dfa7adf6e9f9f2 (diff)
Overhaul of glRead/DrawBuffer() code. Now, swrast->Driver.SetBuffer()
indicates the read AND draw color buffer for all software rasterization. Lots of related clean-ups. See RELNOTES-4.1 for details.
Diffstat (limited to 'src/mesa/swrast/s_alphabuf.c')
-rw-r--r--src/mesa/swrast/s_alphabuf.c87
1 files changed, 55 insertions, 32 deletions
diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c
index 56c4d552da..b303c0fc76 100644
--- a/src/mesa/swrast/s_alphabuf.c
+++ b/src/mesa/swrast/s_alphabuf.c
@@ -1,4 +1,4 @@
-/* $Id: s_alphabuf.c,v 1.10 2002/03/19 16:47:05 brianp Exp $ */
+/* $Id: s_alphabuf.c,v 1.11 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -38,20 +38,12 @@
#include "s_alphabuf.h"
-#define ALPHA_DRAW_ADDR(X,Y) \
- (ctx->DrawBuffer->Alpha + (Y) * ctx->DrawBuffer->Width + (X))
-
-#define ALPHA_READ_ADDR(X,Y) \
- (ctx->ReadBuffer->Alpha + (Y) * ctx->ReadBuffer->Width + (X))
-
-
/*
* Allocate a new front and back alpha buffer.
*/
void
_mesa_alloc_alpha_buffers( GLframebuffer *buffer )
{
- GET_CURRENT_CONTEXT(ctx);
const GLint bytes = buffer->Width * buffer->Height * sizeof(GLchan);
ASSERT(buffer->UseSoftwareAlphaBuffers);
@@ -101,17 +93,6 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
}
}
}
-
- if (ctx) {
- if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT)
- buffer->Alpha = buffer->FrontLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)
- buffer->Alpha = buffer->BackLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT)
- buffer->Alpha = buffer->FrontRightAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT)
- buffer->Alpha = buffer->BackRightAlpha;
- }
}
@@ -129,7 +110,7 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
/* loop over four possible alpha buffers */
for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
- if (bufferBit & ctx->Color.DrawDestMask) {
+ if (bufferBit & ctx->Color._DrawDestMask) {
GLchan *buffer;
if (bufferBit == FRONT_LEFT_BIT) {
buffer = ctx->DrawBuffer->FrontLeftAlpha;
@@ -187,13 +168,39 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
+static INLINE
+GLchan *get_alpha_buffer( GLcontext *ctx )
+{
+ switch (ctx->Color._DriverDrawBuffer) {
+ case GL_FRONT_LEFT:
+ return ctx->DrawBuffer->FrontLeftAlpha;
+ break;
+ case GL_BACK_LEFT:
+ return ctx->DrawBuffer->BackLeftAlpha;
+ break;
+ case GL_FRONT_RIGHT:
+ return ctx->DrawBuffer->FrontRightAlpha;
+ break;
+ case GL_BACK_RIGHT:
+ return ctx->DrawBuffer->BackRightAlpha;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()");
+ return ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
+ }
+}
+
+
void
_mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
CONST GLchan rgba[][4], const GLubyte mask[] )
{
- GLchan *aptr = ALPHA_DRAW_ADDR( x, y );
+ GLchan *buffer, *aptr;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+ aptr = buffer + y * ctx->DrawBuffer->Width + x;
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -214,9 +221,12 @@ void
_mesa_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLchan alpha, const GLubyte mask[] )
{
- GLchan *aptr = ALPHA_DRAW_ADDR( x, y );
+ GLchan *buffer, *aptr;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+ aptr = buffer + y * ctx->DrawBuffer->Width + x;
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -238,19 +248,22 @@ _mesa_write_alpha_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
CONST GLchan rgba[][4], const GLubyte mask[] )
{
+ GLchan *buffer;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = rgba[i][ACOMP];
}
}
}
else {
for (i=0;i<n;i++) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = rgba[i][ACOMP];
}
}
@@ -262,19 +275,22 @@ _mesa_write_mono_alpha_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan alpha, const GLubyte mask[] )
{
+ GLchan *buffer;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = alpha;
}
}
}
else {
for (i=0;i<n;i++) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = alpha;
}
}
@@ -286,11 +302,14 @@ void
_mesa_read_alpha_span( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLchan rgba[][4] )
{
- GLchan *aptr = ALPHA_READ_ADDR( x, y );
+ const GLchan *buffer, *aptr;
GLuint i;
- for (i=0;i<n;i++) {
+
+ buffer = get_alpha_buffer(ctx);
+ aptr = buffer + y * ctx->DrawBuffer->Width + x;
+
+ for (i = 0; i < n; i++)
rgba[i][ACOMP] = *aptr++;
- }
}
@@ -299,10 +318,14 @@ _mesa_read_alpha_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
+ const GLchan *buffer;
GLuint i;
- for (i=0;i<n;i++) {
+
+ buffer = get_alpha_buffer(ctx);
+
+ for (i = 0; i < n; i++) {
if (mask[i]) {
- GLchan *aptr = ALPHA_READ_ADDR( x[i], y[i] );
+ const GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
rgba[i][ACOMP] = *aptr;
}
}