added SPAN_W
[mesa.git] / src / mesa / swrast / s_alphabuf.c
index 4bf3368cb28daa18f91762eb9f1587d3a20d37ce..e0468a4c91f872907bc718672cbabf9ee198a44c 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: s_alphabuf.c,v 1.13 2002/10/11 17:41:06 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  6.1
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -32,8 +30,9 @@
 
 
 #include "glheader.h"
+#include "colormac.h"
 #include "context.h"
-#include "mem.h"
+#include "imports.h"
 
 #include "s_context.h"
 #include "s_alphabuf.h"
@@ -43,7 +42,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);
 
@@ -52,7 +51,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
    if (buffer->FrontLeftAlpha) {
       MESA_PBUFFER_FREE( buffer->FrontLeftAlpha );
    }
-   buffer->FrontLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
+   buffer->FrontLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
    if (!buffer->FrontLeftAlpha) {
       /* out of memory */
       _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -63,7 +62,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
       if (buffer->BackLeftAlpha) {
          MESA_PBUFFER_FREE( buffer->BackLeftAlpha );
       }
-      buffer->BackLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
+      buffer->BackLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
       if (!buffer->BackLeftAlpha) {
          /* out of memory */
          _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -75,7 +74,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
       if (buffer->FrontRightAlpha) {
          MESA_PBUFFER_FREE( buffer->FrontRightAlpha );
       }
-      buffer->FrontRightAlpha = MESA_PBUFFER_ALLOC( bytes );
+      buffer->FrontRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
       if (!buffer->FrontRightAlpha) {
          /* out of memory */
          _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -86,7 +85,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
          if (buffer->BackRightAlpha) {
             MESA_PBUFFER_FREE( buffer->BackRightAlpha );
          }
-         buffer->BackRightAlpha = MESA_PBUFFER_ALLOC( bytes );
+         buffer->BackRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
          if (!buffer->BackRightAlpha) {
             /* out of memory */
             _mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -101,11 +100,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]);
 
@@ -114,16 +115,16 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
       if (bufferBit & ctx->Color._DrawDestMask) {
          GLchan *buffer;
          if (bufferBit == FRONT_LEFT_BIT) {
-            buffer = (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
+            buffer = ctx->DrawBuffer->FrontLeftAlpha;
          }
          else if (bufferBit == FRONT_RIGHT_BIT) {
-            buffer = (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
+            buffer = ctx->DrawBuffer->FrontRightAlpha;
          }
          else if (bufferBit == BACK_LEFT_BIT) {
-            buffer = (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
+            buffer = ctx->DrawBuffer->BackLeftAlpha;
          }
          else {
-            buffer = (GLchan *) ctx->DrawBuffer->BackRightAlpha;
+            buffer = ctx->DrawBuffer->BackRightAlpha;
          }
 
          if (ctx->Scissor.Enabled) {
@@ -176,16 +177,16 @@ GLchan *get_alpha_buffer( GLcontext *ctx )
 
    switch (swrast->CurrentBuffer) {
    case FRONT_LEFT_BIT:
-      return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
+      return ctx->DrawBuffer->FrontLeftAlpha;
       break;
    case BACK_LEFT_BIT:
-      return (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
+      return ctx->DrawBuffer->BackLeftAlpha;
       break;
    case FRONT_RIGHT_BIT:
-      return (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
+      return ctx->DrawBuffer->FrontRightAlpha;
       break;
    case BACK_RIGHT_BIT:
-      return (GLchan *) ctx->DrawBuffer->BackRightAlpha;
+      return ctx->DrawBuffer->BackRightAlpha;
       break;
    default:
       _mesa_problem(ctx, "Bad CurrentBuffer in get_alpha_buffer()");
@@ -195,7 +196,7 @@ GLchan *get_alpha_buffer( GLcontext *ctx )
 
 
 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;
@@ -221,7 +222,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;
@@ -247,7 +248,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[] )
 {
@@ -274,7 +275,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[] )
 {
@@ -302,7 +303,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;
@@ -317,7 +318,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[] )
 {