Fix typo
[mesa.git] / src / mesa / swrast / s_stencil.c
index 8ce6c0ae5a3563566b09d5497d09e371d481916e..a69bd3c96c4c5e05fc14b7e5db857a575d4a55fc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.c,v 1.5 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_stencil.c,v 1.8 2001/03/03 20:33:30 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -219,7 +219,7 @@ static void apply_stencil_op( const GLcontext *ctx, GLenum oper,
         }
         break;
       default:
-         gl_problem(ctx, "Bad stencil op in apply_stencil_op");
+         _mesa_problem(ctx, "Bad stencil op in apply_stencil_op");
    }
 }
 
@@ -391,7 +391,7 @@ do_stencil_test( GLcontext *ctx, GLuint n, GLstencil stencil[],
         }
         break;
       default:
-         gl_problem(ctx, "Bad stencil func in gl_stencil_span");
+         _mesa_problem(ctx, "Bad stencil func in gl_stencil_span");
          return 0;
    }
 
@@ -697,7 +697,7 @@ apply_stencil_op_to_pixels( const GLcontext *ctx,
         }
         break;
       default:
-         gl_problem(ctx, "Bad stencilop in apply_stencil_op_to_pixels");
+         _mesa_problem(ctx, "Bad stencilop in apply_stencil_op_to_pixels");
    }
 }
 
@@ -875,7 +875,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint n,
         }
         break;
       default:
-         gl_problem(ctx, "Bad stencil func in gl_stencil_pixels");
+         _mesa_problem(ctx, "Bad stencil func in gl_stencil_pixels");
          return 0;
    }
 
@@ -916,47 +916,47 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
    if (ctx->Driver.WriteStencilPixels) {
       /*** Hardware stencil buffer ***/
       GLstencil stencil[PB_SIZE];
-      GLubyte mask[PB_SIZE];
+      GLubyte origMask[PB_SIZE];
 
       ASSERT(ctx->Driver.ReadStencilPixels);
       (*ctx->Driver.ReadStencilPixels)(ctx, n, x, y, stencil);
 
+      MEMCPY(origMask, mask, n * sizeof(GLubyte));
 
-      if (do_stencil_test( ctx, n, stencil, mask ) == GL_FALSE) {
-         /* all fragments failed the stencil test, we're done. */
-         return GL_FALSE;
-      }
+      (void) do_stencil_test(ctx, n, stencil, mask);
 
       if (ctx->Depth.Test == GL_FALSE) {
-         apply_stencil_op( ctx, ctx->Stencil.ZPassFunc, n, stencil, mask );
+         apply_stencil_op(ctx, ctx->Stencil.ZPassFunc, n, stencil, mask);
       }
       else {
-         GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE];
-         GLuint i;
-
-         MEMCPY(oldmask, mask, n * sizeof(GLubyte));
-
          _mesa_depth_test_pixels(ctx, n, x, y, z, mask);
 
-         for (i=0;i<n;i++) {
-            ASSERT(mask[i] == 0 || mask[i] == 1);
-            passmask[i] = oldmask[i] & mask[i];
-            failmask[i] = oldmask[i] & (mask[i] ^ 1);
-         }
-
          if (ctx->Stencil.ZFailFunc != GL_KEEP) {
-            apply_stencil_op( ctx, ctx->Stencil.ZFailFunc, n, stencil, failmask );
+            GLubyte failmask[PB_SIZE];
+            GLuint i;
+            for (i = 0; i < n; i++) {
+               ASSERT(mask[i] == 0 || mask[i] == 1);
+               failmask[i] = origMask[i] & (mask[i] ^ 1);
+            }
+            apply_stencil_op(ctx, ctx->Stencil.ZFailFunc,
+                             n, stencil, failmask);
          }
          if (ctx->Stencil.ZPassFunc != GL_KEEP) {
-            apply_stencil_op( ctx, ctx->Stencil.ZPassFunc, n, stencil, passmask );
+            GLubyte passmask[PB_SIZE];
+            GLuint i;
+            for (i = 0; i < n; i++) {
+               ASSERT(mask[i] == 0 || mask[i] == 1);
+               passmask[i] = origMask[i] & mask[i];
+            }
+            apply_stencil_op(ctx, ctx->Stencil.ZPassFunc,
+                             n, stencil, passmask);
          }
       }
 
       /* Write updated stencil values into hardware stencil buffer */
-      (ctx->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, mask );
+      (ctx->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, origMask);
 
       return GL_TRUE;
-
    }
    else {
       /*** Software stencil buffer ***/
@@ -966,9 +966,9 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
          return GL_FALSE;
       }
 
-
       if (ctx->Depth.Test==GL_FALSE) {
-         apply_stencil_op_to_pixels( ctx, n, x, y, ctx->Stencil.ZPassFunc, mask );
+         apply_stencil_op_to_pixels(ctx, n, x, y,
+                                    ctx->Stencil.ZPassFunc, mask);
       }
       else {
          GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE];
@@ -985,12 +985,12 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
          }
 
          if (ctx->Stencil.ZFailFunc != GL_KEEP) {
-            apply_stencil_op_to_pixels( ctx, n, x, y,
-                                        ctx->Stencil.ZFailFunc, failmask );
+            apply_stencil_op_to_pixels(ctx, n, x, y,
+                                       ctx->Stencil.ZFailFunc, failmask);
          }
          if (ctx->Stencil.ZPassFunc != GL_KEEP) {
-            apply_stencil_op_to_pixels( ctx, n, x, y,
-                                        ctx->Stencil.ZPassFunc, passmask );
+            apply_stencil_op_to_pixels(ctx, n, x, y,
+                                       ctx->Stencil.ZPassFunc, passmask);
          }
       }
 
@@ -1118,7 +1118,7 @@ _mesa_alloc_stencil_buffer( GLcontext *ctx )
    if (!ctx->DrawBuffer->Stencil) {
       /* out of memory */
 /*        _mesa_set_enable( ctx, GL_STENCIL_TEST, GL_FALSE ); */
-      gl_error( ctx, GL_OUT_OF_MEMORY, "_mesa_alloc_stencil_buffer" );
+      _mesa_error( ctx, GL_OUT_OF_MEMORY, "_mesa_alloc_stencil_buffer" );
    }
 }