Removed all RCS / CVS tags (Id, Header, Date, etc.) from everything.
[mesa.git] / src / mesa / swrast / s_alphabuf.c
index b303c0fc76c061b4a5601c8510310de5e7ec080e..c74ab45a44c5f896d5632e421799a546911b2957 100644 (file)
@@ -1,8 +1,7 @@
-/* $Id: s_alphabuf.c,v 1.11 2002/07/09 01:22:52 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  4.0.2
+ * Version:  5.0.1
  *
  * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
  *
 
 
 #include "glheader.h"
+#include "colormac.h"
 #include "context.h"
-#include "mem.h"
+#include "imports.h"
 
+#include "s_context.h"
 #include "s_alphabuf.h"
 
 
@@ -42,7 +43,7 @@
  * Allocate a new front and back alpha buffer.
  */
 void
-_mesa_alloc_alpha_buffers( GLframebuffer *buffer )
+_swrast_alloc_alpha_buffers( GLframebuffer *buffer )
 {
    const GLint bytes = buffer->Width * buffer->Height * sizeof(GLchan);
 
@@ -51,7 +52,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
    if (buffer->FrontLeftAlpha) {
       MESA_PBUFFER_FREE( buffer->FrontLeftAlpha );
    }
-   buffer->FrontLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+   buffer->FrontLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
    if (!buffer->FrontLeftAlpha) {
       /* out of memory */
       _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -62,7 +63,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
       if (buffer->BackLeftAlpha) {
          MESA_PBUFFER_FREE( buffer->BackLeftAlpha );
       }
-      buffer->BackLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+      buffer->BackLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
       if (!buffer->BackLeftAlpha) {
          /* out of memory */
          _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -74,7 +75,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
       if (buffer->FrontRightAlpha) {
          MESA_PBUFFER_FREE( buffer->FrontRightAlpha );
       }
-      buffer->FrontRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+      buffer->FrontRightAlpha = MESA_PBUFFER_ALLOC( bytes );
       if (!buffer->FrontRightAlpha) {
          /* out of memory */
          _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -85,7 +86,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
          if (buffer->BackRightAlpha) {
             MESA_PBUFFER_FREE( buffer->BackRightAlpha );
          }
-         buffer->BackRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+         buffer->BackRightAlpha = MESA_PBUFFER_ALLOC( bytes );
          if (!buffer->BackRightAlpha) {
             /* out of memory */
             _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -100,11 +101,13 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
  * Clear all the alpha buffers
  */
 void
-_mesa_clear_alpha_buffers( GLcontext *ctx )
+_swrast_clear_alpha_buffers( GLcontext *ctx )
 {
-   const GLchan aclear = ctx->Color.ClearColor[3];
+   GLchan aclear;
    GLuint bufferBit;
 
+   CLAMPED_FLOAT_TO_CHAN(aclear, ctx->Color.ClearColor[3]);
+
    ASSERT(ctx->DrawBuffer->UseSoftwareAlphaBuffers);
    ASSERT(ctx->Color.ColorMask[ACOMP]);
 
@@ -113,16 +116,16 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
       if (bufferBit & ctx->Color._DrawDestMask) {
          GLchan *buffer;
          if (bufferBit == FRONT_LEFT_BIT) {
-            buffer = ctx->DrawBuffer->FrontLeftAlpha;
+            buffer = (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
          }
          else if (bufferBit == FRONT_RIGHT_BIT) {
-            buffer = ctx->DrawBuffer->FrontRightAlpha;
+            buffer = (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
          }
          else if (bufferBit == BACK_LEFT_BIT) {
-            buffer = ctx->DrawBuffer->BackLeftAlpha;
+            buffer = (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
          }
          else {
-            buffer = ctx->DrawBuffer->BackRightAlpha;
+            buffer = (GLchan *) ctx->DrawBuffer->BackRightAlpha;
          }
 
          if (ctx->Scissor.Enabled) {
@@ -171,28 +174,30 @@ _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;
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+   switch (swrast->CurrentBuffer) {
+   case FRONT_LEFT_BIT:
+      return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
       break;
-   case GL_BACK_LEFT:
-      return ctx->DrawBuffer->BackLeftAlpha;
+   case BACK_LEFT_BIT:
+      return (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
       break;
-   case GL_FRONT_RIGHT:
-      return ctx->DrawBuffer->FrontRightAlpha;
+   case FRONT_RIGHT_BIT:
+      return (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
       break;
-   case GL_BACK_RIGHT:
-      return ctx->DrawBuffer->BackRightAlpha;
+   case BACK_RIGHT_BIT:
+      return (GLchan *) ctx->DrawBuffer->BackRightAlpha;
       break;
    default:
-      _mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()");
-      return ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
+      _mesa_problem(ctx, "Bad CurrentBuffer in get_alpha_buffer()");
+      return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
    }
 }
 
 
 void
-_mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
+_swrast_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
                         CONST GLchan rgba[][4], const GLubyte mask[] )
 {
    GLchan *buffer, *aptr;
@@ -218,7 +223,7 @@ _mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
 
 
 void
-_mesa_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
+_swrast_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
                              GLchan alpha, const GLubyte mask[] )
 {
    GLchan *buffer, *aptr;
@@ -244,7 +249,7 @@ _mesa_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
 
 
 void
-_mesa_write_alpha_pixels( GLcontext *ctx,
+_swrast_write_alpha_pixels( GLcontext *ctx,
                           GLuint n, const GLint x[], const GLint y[],
                           CONST GLchan rgba[][4], const GLubyte mask[] )
 {
@@ -271,7 +276,7 @@ _mesa_write_alpha_pixels( GLcontext *ctx,
 
 
 void
-_mesa_write_mono_alpha_pixels( GLcontext *ctx,
+_swrast_write_mono_alpha_pixels( GLcontext *ctx,
                                GLuint n, const GLint x[], const GLint y[],
                                GLchan alpha, const GLubyte mask[] )
 {
@@ -299,7 +304,7 @@ _mesa_write_mono_alpha_pixels( GLcontext *ctx,
 
 
 void
-_mesa_read_alpha_span( GLcontext *ctx,
+_swrast_read_alpha_span( GLcontext *ctx,
                        GLuint n, GLint x, GLint y, GLchan rgba[][4] )
 {
    const GLchan *buffer, *aptr;
@@ -314,7 +319,7 @@ _mesa_read_alpha_span( GLcontext *ctx,
 
 
 void
-_mesa_read_alpha_pixels( GLcontext *ctx,
+_swrast_read_alpha_pixels( GLcontext *ctx,
                          GLuint n, const GLint x[], const GLint y[],
                          GLchan rgba[][4], const GLubyte mask[] )
 {