summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-10-11 17:41:03 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-10-11 17:41:03 +0000
commit8ad1076dc2afda8ed37e5a9f6a757583eba90375 (patch)
tree30bc52e2db6e089972d441a53c070e8377cb684d /src/mesa/swrast
parent9e84910749744efcba06670f622cc00d279f26f1 (diff)
Another round of glRead/DrawBuffer() clean-ups and simplifications.
Replaced ctx->Color._DriverDrawBuffer with swrast->CurrentBuffer. Replaced ctx->Pixel._DriverReadBuffer with ctx->Pixel._ReadSrcMask. swrast->Driver.SetBuffer() takes FRONT/BACK_LEFT/RIGHT_BIT values now. Added tokens and code for GL_AUX buffers, for completeness.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_alphabuf.c19
-rw-r--r--src/mesa/swrast/s_buffers.c33
-rw-r--r--src/mesa/swrast/s_context.h3
-rw-r--r--src/mesa/swrast/s_span.c32
-rw-r--r--src/mesa/swrast/swrast.h20
5 files changed, 40 insertions, 67 deletions
diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c
index 2eab878a23..4bf3368cb2 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.12 2002/10/04 19:10:12 brianp Exp $ */
+/* $Id: s_alphabuf.c,v 1.13 2002/10/11 17:41:06 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,7 @@
#include "context.h"
#include "mem.h"
+#include "s_context.h"
#include "s_alphabuf.h"
@@ -171,22 +172,24 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
static INLINE
GLchan *get_alpha_buffer( GLcontext *ctx )
{
- switch (ctx->Color._DriverDrawBuffer) {
- case GL_FRONT_LEFT:
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ switch (swrast->CurrentBuffer) {
+ case FRONT_LEFT_BIT:
return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
break;
- case GL_BACK_LEFT:
+ case BACK_LEFT_BIT:
return (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
break;
- case GL_FRONT_RIGHT:
+ case FRONT_RIGHT_BIT:
return (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
break;
- case GL_BACK_RIGHT:
+ case BACK_RIGHT_BIT:
return (GLchan *) ctx->DrawBuffer->BackRightAlpha;
break;
default:
- _mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()");
- return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
+ _mesa_problem(ctx, "Bad CurrentBuffer in get_alpha_buffer()");
+ return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
}
}
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c
index 1b07eb0bef..102d53ac7f 100644
--- a/src/mesa/swrast/s_buffers.c
+++ b/src/mesa/swrast/s_buffers.c
@@ -1,4 +1,4 @@
-/* $Id: s_buffers.c,v 1.13 2002/10/04 19:10:12 brianp Exp $ */
+/* $Id: s_buffers.c,v 1.14 2002/10/11 17:41:06 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -166,18 +166,7 @@ clear_color_buffers(GLcontext *ctx)
/* loop over four possible dest color buffers */
for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
if (bufferBit & ctx->Color._DrawDestMask) {
- if (bufferBit == FRONT_LEFT_BIT) {
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
- }
- else if (bufferBit == FRONT_RIGHT_BIT) {
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
- }
- else if (bufferBit == BACK_LEFT_BIT) {
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT);
- }
- else {
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
- }
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
if (colorMask != 0xffffffff) {
clear_color_buffer_with_masking(ctx);
@@ -274,10 +263,9 @@ _swrast_use_read_buffer( GLcontext *ctx )
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* Do this so the software-emulated alpha plane span functions work! */
- ctx->Color._DriverDrawBuffer = ctx->Pixel._DriverReadBuffer;
+ swrast->CurrentBuffer = ctx->Pixel._ReadSrcMask;
/* Tell the device driver where to read/write spans */
- (*swrast->Driver.SetBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel._DriverReadBuffer );
+ (*swrast->Driver.SetBuffer)( ctx, ctx->ReadBuffer, swrast->CurrentBuffer );
}
@@ -302,17 +290,16 @@ _swrast_use_draw_buffer( GLcontext *ctx )
*/
if (ctx->Color._DrawDestMask & FRONT_LEFT_BIT)
- ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT;
+ swrast->CurrentBuffer = FRONT_LEFT_BIT;
else if (ctx->Color._DrawDestMask & BACK_LEFT_BIT)
- ctx->Color._DriverDrawBuffer = GL_BACK_LEFT;
+ swrast->CurrentBuffer = BACK_LEFT_BIT;
else if (ctx->Color._DrawDestMask & FRONT_RIGHT_BIT)
- ctx->Color._DriverDrawBuffer = GL_FRONT_RIGHT;
+ swrast->CurrentBuffer = FRONT_RIGHT_BIT;
else if (ctx->Color._DrawDestMask & BACK_RIGHT_BIT)
- ctx->Color._DriverDrawBuffer = GL_BACK_RIGHT;
+ swrast->CurrentBuffer = BACK_RIGHT_BIT;
else
/* glDrawBuffer(GL_NONE) */
- ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT; /* always have this */
+ swrast->CurrentBuffer = FRONT_LEFT_BIT; /* we always have this buffer */
- (*swrast->Driver.SetBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color._DriverDrawBuffer );
+ (*swrast->Driver.SetBuffer)( ctx, ctx->DrawBuffer, swrast->CurrentBuffer );
}
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index ecf173adbc..8493ad4264 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -1,4 +1,4 @@
-/* $Id: s_context.h,v 1.20 2002/10/04 17:37:47 brianp Exp $ */
+/* $Id: s_context.h,v 1.21 2002/10/11 17:41:06 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -138,6 +138,7 @@ typedef struct
GLuint NewState;
GLuint StateChanges;
GLenum Primitive; /* current primitive being drawn (ala glBegin) */
+ GLuint CurrentBuffer; /* exactly one of FRONT_LEFT_BIT, BACK_LEFT_BIT, etc*/
/** Mechanism to allow driver (like X11) to register further
* software rasterization routines.
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index b134890a3b..2628a7af3e 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,4 +1,4 @@
-/* $Id: s_span.c,v 1.48 2002/10/02 23:24:04 brianp Exp $ */
+/* $Id: s_span.c,v 1.49 2002/10/11 17:41:06 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -618,14 +618,9 @@ multi_write_index_span( GLcontext *ctx, struct sw_span *span )
GLuint indexTmp[MAX_WIDTH];
ASSERT(span->end < MAX_WIDTH);
- if (bufferBit == FRONT_LEFT_BIT)
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
- else if (bufferBit == FRONT_RIGHT_BIT)
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
- else if (bufferBit == BACK_LEFT_BIT)
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT);
- else
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
+ /* Set the current read/draw buffer */
+ swrast->CurrentBuffer = bufferBit;
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
/* make copy of incoming indexes */
MEMCPY( indexTmp, span->array->index, span->end * sizeof(GLuint) );
@@ -680,22 +675,9 @@ multi_write_rgba_span( GLcontext *ctx, struct sw_span *span )
GLchan rgbaTmp[MAX_WIDTH][4];
ASSERT(span->end < MAX_WIDTH);
- if (bufferBit == FRONT_LEFT_BIT) {
- ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT;
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
- }
- else if (bufferBit == FRONT_RIGHT_BIT) {
- ctx->Color._DriverDrawBuffer = GL_FRONT_RIGHT;
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
- }
- else if (bufferBit == BACK_LEFT_BIT) {
- ctx->Color._DriverDrawBuffer = GL_BACK_LEFT;
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT);
- }
- else {
- ctx->Color._DriverDrawBuffer = GL_BACK_RIGHT;
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
- }
+ /* Set the current read/draw buffer */
+ swrast->CurrentBuffer = bufferBit;
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
/* make copy of incoming colors */
MEMCPY( rgbaTmp, span->array->rgba, 4 * span->end * sizeof(GLchan) );
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 1cb55a9d8c..43c9aea8dc 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,4 +1,4 @@
-/* $Id: swrast.h,v 1.29 2002/10/04 17:37:47 brianp Exp $ */
+/* $Id: swrast.h,v 1.30 2002/10/11 17:41:06 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -390,23 +390,23 @@ _swrast_copy_texsubimage3d(GLcontext *ctx,
-/* The driver interface for the software rasterizer. Unless otherwise
- * noted, all functions are mandatory.
+/* The driver interface for the software rasterizer.
+ * Unless otherwise noted, all functions are mandatory.
*/
struct swrast_device_driver {
- void (*SetBuffer)( GLcontext *ctx, GLframebuffer *buffer,
- GLenum colorBuffer );
+ void (*SetBuffer)( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit);
/*
* Specifies the current buffer for span/pixel writing/reading.
* buffer indicates which window to write to / read from. Normally,
* this'll be the buffer currently bound to the context, but it doesn't
* have to be!
- * colorBuffer indicates which color buffer, one of:
- * GL_FRONT_LEFT - this buffer always exists
- * GL_BACK_LEFT - when double buffering
- * GL_FRONT_RIGHT - when using stereo
- * GL_BACK_RIGHT - when using stereo and double buffering
+ * bufferBit indicates which color buffer, one of:
+ * FRONT_LEFT_BIT - this buffer always exists
+ * BACK_LEFT_BIT - when double buffering
+ * FRONT_RIGHT_BIT - when using stereo
+ * BACK_RIGHT_BIT - when using stereo and double buffering
+ * AUXn_BIT - if aux buffers are implemented
*/