summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-01-21 18:12:34 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-01-21 18:12:34 +0000
commit2ef866d1fc0a5cc5ef8543d65744dfd4da4dbbaf (patch)
tree835adeb2048e8c54afcea9fb7f1d29dc7f1c05ed
parent674012f083dde5a58742a74a6b4adf266ea17ed7 (diff)
Klaus's latest patches and some clean-up
-rw-r--r--src/mesa/swrast/s_alpha.c89
-rw-r--r--src/mesa/swrast/s_alpha.h13
-rw-r--r--src/mesa/swrast/s_depth.c10
-rw-r--r--src/mesa/swrast/s_fog.c86
-rw-r--r--src/mesa/swrast/s_fog.h9
-rw-r--r--src/mesa/swrast/s_span.c107
-rw-r--r--src/mesa/swrast/s_span.h8
-rw-r--r--src/mesa/swrast/s_stencil.c4
-rw-r--r--src/mesa/swrast/s_triangle.c54
-rw-r--r--src/mesa/swrast/s_zoom.c124
-rw-r--r--src/mesa/swrast/s_zoom.h8
-rw-r--r--src/mesa/swrast/swrast.h45
12 files changed, 384 insertions, 173 deletions
diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c
index c0d76fd9e1..7aa47f230f 100644
--- a/src/mesa/swrast/s_alpha.c
+++ b/src/mesa/swrast/s_alpha.c
@@ -1,10 +1,10 @@
-/* $Id: s_alpha.c,v 1.4 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_alpha.c,v 1.5 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -34,7 +34,84 @@
#include "s_alpha.h"
+/*
+ * Apply the alpha test to a span of pixels.
+ * In: rgba - array of pixels
+ * In/Out: span -
+ * Return: 0 = all pixels in the span failed the alpha test.
+ * 1 = one or more pixels passed the alpha test.
+ */
+GLint
+_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span,
+ CONST GLchan rgba[][4])
+{
+ GLuint i;
+ const GLchan ref = ctx->Color.AlphaRef;
+ GLubyte *mask = span->mask;
+
+ ASSERT (span->filledMask == GL_TRUE);
+ ASSERT (span->filledAlpha == GL_TRUE);
+
+ SW_SPAN_SET_FLAG(span->testedAlpha);
+
+
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Color.AlphaFunc) {
+ case GL_LESS:
+ for (i=span->start; i<span->end; i++) {
+ mask[i] &= (rgba[i][ACOMP] < ref);
+ }
+ break;
+ case GL_LEQUAL:
+ for (i=span->start; i<span->end; i++)
+ mask[i] &= (rgba[i][ACOMP] <= ref);
+ break;
+ case GL_GEQUAL:
+ for (i=span->start; i<span->end; i++) {
+ mask[i] &= (rgba[i][ACOMP] >= ref);
+ }
+ break;
+ case GL_GREATER:
+ for (i=span->start; i<span->end; i++) {
+ mask[i] &= (rgba[i][ACOMP] > ref);
+ }
+ break;
+ case GL_NOTEQUAL:
+ for (i=span->start; i<span->end; i++) {
+ mask[i] &= (rgba[i][ACOMP] != ref);
+ }
+ break;
+ case GL_EQUAL:
+ for (i=span->start; i<span->end; i++) {
+ mask[i] &= (rgba[i][ACOMP] == ref);
+ }
+ break;
+ case GL_ALWAYS:
+ /* do nothing */
+ return 1;
+ case GL_NEVER:
+ /* caller should check for zero! */
+ return 0;
+ default:
+ _mesa_problem( ctx, "Invalid alpha test in gl_alpha_test" );
+ return 0;
+ }
+
+ while ((span->start <= span->end) &&
+ (mask[span->start] == 0))
+ span->start ++;
+
+ while ((span->end >= span->start) &&
+ (mask[span->end] == 0))
+ span->end --;
+ span->writeAll = GL_FALSE;
+
+ if (span->start >= span->end)
+ return 0;
+ else
+ return 1;
+}
/*
@@ -46,11 +123,11 @@
* 1 = one or more pixels passed the alpha test.
*/
GLint
-_mesa_alpha_test( const GLcontext *ctx,
- GLuint n, CONST GLchan rgba[][4], GLubyte mask[] )
+_old_alpha_test( const GLcontext *ctx,
+ GLuint n, CONST GLchan rgba[][4], GLubyte mask[] )
{
GLuint i;
- GLchan ref = ctx->Color.AlphaRef;
+ const GLchan ref = ctx->Color.AlphaRef;
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Color.AlphaFunc) {
diff --git a/src/mesa/swrast/s_alpha.h b/src/mesa/swrast/s_alpha.h
index 5338df58ae..ed60a9b552 100644
--- a/src/mesa/swrast/s_alpha.h
+++ b/src/mesa/swrast/s_alpha.h
@@ -1,4 +1,4 @@
-/* $Id: s_alpha.h,v 1.3 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_alpha.h,v 1.4 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,9 +34,14 @@
extern GLint
-_mesa_alpha_test( const GLcontext *ctx, GLuint n,
- CONST GLchan rgba[][4], GLubyte mask[] );
+_old_alpha_test( const GLcontext *ctx, GLuint n,
+ CONST GLchan rgba[][4], GLubyte mask[] );
+extern GLint
+_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span,
+ CONST GLchan rgba[][4]);
+
+#endif
+
-#endif
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index b892ffabb3..5a7fc4b4ed 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1,10 +1,10 @@
-/* $Id: s_depth.c,v 1.10 2001/12/17 04:54:35 brianp Exp $ */
+/* $Id: s_depth.c,v 1.11 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -587,7 +587,7 @@ _mesa_depth_test_span( GLcontext *ctx, struct sw_span *span)
ASSERT(swrast->Driver.WriteDepthSpan);
(*swrast->Driver.WriteDepthSpan)(ctx, span->end, span->x, span->y, zbuffer, span->mask);
if (passed < span->end)
- span->write_all = GL_FALSE;
+ span->writeAll = GL_FALSE;
return passed;
}
else {
@@ -602,7 +602,7 @@ _mesa_depth_test_span( GLcontext *ctx, struct sw_span *span)
passed = depth_test_span32(ctx, span->end, span->x, span->y, zptr, span->depth, span->mask);
}
if (passed < span->end)
- span->write_all = GL_FALSE;
+ span->writeAll = GL_FALSE;
return passed;
}
}
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 4441141bdd..5a8ac878cd 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -1,4 +1,4 @@
-/* $Id: s_fog.c,v 1.16 2001/12/18 04:06:46 brianp Exp $ */
+/* $Id: s_fog.c,v 1.17 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -38,7 +38,7 @@
-/*
+/**
* Used to convert current raster distance to a fog factor in [0,1].
*/
GLfloat
@@ -70,7 +70,7 @@ _mesa_z_to_fogfactor(GLcontext *ctx, GLfloat z)
-/*
+/**
* Apply fog to a span of RGBA pixels.
* Input: ctx -
* span - where span->fog and span->fogStep have to be set.
@@ -102,7 +102,40 @@ _mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
}
}
-/*
+
+/**
+ * Apply fog given in an array to RGBA pixels.
+ * Input: ctx -
+ * span -
+ * fog - array of fog factors in [0,1]
+ * red, green, blue, alpha - pixel colors
+ * Output: red, green, blue, alpha - fogged pixel colors
+ */
+void
+_mesa_fog_rgba_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
+ const GLfloat fog[], GLchan rgba[][4] )
+{
+ GLuint i;
+ GLchan rFog, gFog, bFog;
+
+ ASSERT(fog != NULL);
+ ASSERT(ctx->Fog.Enabled);
+ ASSERT(span->filledColor == GL_TRUE);
+
+ UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
+ UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
+ UNCLAMPED_FLOAT_TO_CHAN(bFog, ctx->Fog.Color[BCOMP]);
+
+ for (i = span->start; i < span->end; i++) {
+ const GLfloat f = fog[i];
+ const GLfloat g = 1.0F - f;
+ rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + g * rFog);
+ rgba[i][GCOMP] = (GLchan) (f * rgba[i][GCOMP] + g * gFog);
+ rgba[i][BCOMP] = (GLchan) (f * rgba[i][BCOMP] + g * bFog);
+ }
+}
+
+/**
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
* fog - array of fog factors in [0,1]
@@ -132,7 +165,7 @@ _old_fog_rgba_pixels( const GLcontext *ctx,
}
-/*
+/**
* Apply fog to a span of color index pixels.
* Input: ctx -
* span - where span->fog and span->fogStep have to be set.
@@ -158,7 +191,33 @@ _mesa_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
}
}
-/*
+
+/**
+ * Apply fog given in an array to a span of color index pixels.
+ * Input: ctx -
+ * span -
+ * fog - array of fog factors in [0,1]
+ * index - pixel color indexes
+ * Output: index - fogged pixel color indexes
+ */
+void
+_mesa_fog_ci_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
+ const GLfloat fog[], GLuint index[] )
+{
+ GLuint idx = (GLuint) ctx->Fog.Index;
+ GLuint i;
+
+ ASSERT(fog != NULL);
+ ASSERT(ctx->Fog.Enabled);
+ ASSERT(span->filledColor == GL_TRUE);
+
+ for (i = span->start; i < span->end; i++) {
+ const GLfloat f = CLAMP(fog[i], 0.0F, 1.0F);
+ index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * idx);
+ }
+}
+
+/**
* Apply fog to an array of color index pixels.
* Input: n - number of pixels
* fog - array of fog factors in [0,1]
@@ -180,7 +239,7 @@ _old_fog_ci_pixels( const GLcontext *ctx,
-/*
+/**
* Calculate fog factors (in [0,1]) from window z values
* Input: n - number of pixels
* z - array of integer depth values
@@ -321,7 +380,7 @@ compute_fog_factors_from_z( const GLcontext *ctx,
}
-/*
+/**
* Apply fog to a span of RGBA pixels.
* Input: ctx -
* span - where span->depth has to be filled.
@@ -341,10 +400,11 @@ _mesa_depth_fog_rgba_pixels(const GLcontext *ctx, struct sw_span *span,
ASSERT(span->filledColor == GL_TRUE);
compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact );
- _old_fog_rgba_pixels( ctx, span->end, fogFact, rgba );
+ _mesa_fog_rgba_pixels_with_array( ctx, span, fogFact, rgba );
}
-/*
+
+/**
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
* z - array of integer depth values
@@ -362,7 +422,7 @@ _old_depth_fog_rgba_pixels( const GLcontext *ctx,
}
-/*
+/**
* Apply fog to a span of color index pixels.
* Input: ctx -
* span - where span->depth has to be filled.
@@ -382,11 +442,11 @@ _mesa_depth_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
ASSERT(span->filledColor == GL_TRUE);
compute_fog_factors_from_z(ctx, span->end, span->depth, fogFact );
- _old_fog_ci_pixels( ctx, span->end, fogFact, index );
+ _mesa_fog_ci_pixels_with_array( ctx, span, fogFact, index );
}
-/*
+/**
* Apply fog to an array of color index pixels.
* Input: n - number of pixels
* z - array of integer depth values
diff --git a/src/mesa/swrast/s_fog.h b/src/mesa/swrast/s_fog.h
index 8db6495d01..10f1b923b3 100644
--- a/src/mesa/swrast/s_fog.h
+++ b/src/mesa/swrast/s_fog.h
@@ -1,4 +1,4 @@
-/* $Id: s_fog.h,v 1.6 2001/12/17 04:54:35 brianp Exp $ */
+/* $Id: s_fog.h,v 1.7 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,11 +44,18 @@ _old_fog_rgba_pixels( const GLcontext *ctx,
extern void
_mesa_fog_rgba_pixels( const GLcontext *ctx, struct sw_span *span,
GLchan rgba[][4]);
+extern void
+_mesa_fog_rgba_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
+ const GLfloat fog[], GLchan rgba[][4] );
+
extern void
_mesa_fog_ci_pixels( const GLcontext *ctx, struct sw_span *span,
GLuint indx[]);
extern void
+_mesa_fog_ci_pixels_with_array( const GLcontext *ctx, struct sw_span *span,
+ const GLfloat fog[], GLuint index[] );
+extern void
_old_fog_ci_pixels( const GLcontext *ctx,
GLuint n, const GLfloat fog[],
GLuint indx[] );
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index c00dd9f6b2..fce8d33c97 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.22 2002/01/16 16:00:03 brianp Exp $ */
+/* $Id: s_span.c,v 1.23 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -105,7 +105,7 @@ stipple_polygon_span( GLcontext *ctx, struct sw_span *span)
m = highbit;
}
}
- span->write_all = GL_FALSE;
+ span->writeAll = GL_FALSE;
}
@@ -179,7 +179,7 @@ clip_span( GLcontext *ctx, struct sw_span *span)
}
else {
/* partially off left side */
- span->write_all = GL_FALSE;
+ span->writeAll = GL_FALSE;
BZERO(span->mask, -x * sizeof(GLubyte));
return GL_TRUE;
}
@@ -488,7 +488,7 @@ _old_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
/* Do the alpha test */
if (ctx->Color.AlphaEnabled) {
- if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
+ if (_old_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
return;
}
write_all = GL_FALSE;
@@ -575,7 +575,7 @@ _old_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
*/
void
_mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
- GLenum primitive )
+ const GLfloat fog[MAX_WIDTH], GLenum primitive)
{
const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT;
GLuint indexBackup[MAX_WIDTH];
@@ -659,8 +659,9 @@ _mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
}
if (ctx->Fog.Enabled) {
- /* Is this the right 'if' ?? */
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ if (fog != NULL && !swrast->_PreferPixelFog)
+ _mesa_fog_ci_pixels_with_array( ctx, span, fog, index);
+ else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels( ctx, span, index);
else
_mesa_depth_fog_ci_pixels( ctx, span, index);
@@ -791,7 +792,6 @@ _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
}
if (ctx->Fog.Enabled) {
- /* Is this the right 'if' ?? */
if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels( ctx, span, indexes );
else
@@ -853,7 +853,7 @@ _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
*/
void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
- GLenum primitive )
+ const GLfloat fog[MAX_WIDTH], GLenum primitive)
{
const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT |
LOGIC_OP_BIT | TEXTURE_BIT;
@@ -898,10 +898,9 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* Do the alpha test */
if (ctx->Color.AlphaEnabled) {
- if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4]) rgba, span->mask ) == 0) {
+ if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba) == 0) {
return;
}
- span->write_all = GL_FALSE;
}
/* I have to think where to put this!! */
@@ -943,8 +942,9 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- /* Is this the right 'if' ?? */
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ if (fog != NULL && !swrast->_PreferPixelFog)
+ _mesa_fog_rgba_pixels_with_array( ctx, span, fog, rgba);
+ else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, span, rgba );
else
_mesa_depth_fog_rgba_pixels( ctx, span, rgba );
@@ -986,12 +986,12 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
/* write pixels */
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba,
- span->write_all ? ((const GLubyte *) NULL) : span->mask );
+ span->writeAll ? ((const GLubyte *) NULL) : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba,
- span->write_all ? ((const GLubyte *) NULL) : span->mask );
+ span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
}
@@ -1036,13 +1036,13 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* Do the alpha test */
if (ctx->Color.AlphaEnabled) {
+ SW_SPAN_SET_FLAG(span->filledAlpha);
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = color[ACOMP];
}
- if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4])rgba, span->mask ) == 0) {
+ if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4])rgba) == 0) {
return;
}
- span->write_all = GL_FALSE;
}
/* I have to think where to put this!! */
@@ -1103,8 +1103,7 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- /* Is this the right 'if' ?? */
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, span, rgba );
else
_mesa_depth_fog_rgba_pixels( ctx, span, rgba );
@@ -1144,11 +1143,11 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
/* write pixels */
(*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba,
- span->write_all ? ((const GLubyte *) NULL) : span->mask );
+ span->writeAll ? ((const GLubyte *) NULL) : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, span->end, span->x, span->y,
(const GLchan (*)[4]) rgba,
- span->write_all ? ((const GLubyte *) NULL) : span->mask );
+ span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
}
@@ -1170,8 +1169,9 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
else {
(*swrast->Driver.WriteMonoRGBASpan)( ctx, span->end, span->x, span->y, color, span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
- _mesa_write_mono_alpha_span( ctx, span->end, span->x, span->y, (GLchan) color[ACOMP],
- span->write_all ? ((const GLubyte *) NULL) : span->mask );
+ _mesa_write_mono_alpha_span( ctx, span->end, span->x, span->y,
+ (GLchan) color[ACOMP],
+ span->writeAll ? ((const GLubyte *) NULL) : span->mask );
}
}
}
@@ -1219,7 +1219,7 @@ add_colors(CONST struct sw_span *span, GLchan rgba[][4])
*/
void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[], GLenum primitive )
+ const GLfloat fog[MAX_WIDTH], GLenum primitive )
{
const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
GLchan rgbaBackup[MAX_WIDTH][4];
@@ -1265,10 +1265,9 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
_swrast_texture_fragments( ctx, 0, span, rgba );
/* Do the alpha test */
- if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4]) rgba, span->mask ) == 0) {
+ if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba ) == 0) {
return;
}
- span->write_all = GL_FALSE;
}
if (ctx->Stencil.Enabled) {
@@ -1301,9 +1300,10 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- /* Is this the right 'if' ?? */
- if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
- _old_fog_rgba_pixels( ctx, span->end, fog, rgba );
+ if (fog != NULL && !swrast->_PreferPixelFog)
+ _mesa_fog_rgba_pixels_with_array( ctx, span, fog, rgba);
+ else if ((span->activeMask & SPAN_FOG) && !swrast->_PreferPixelFog)
+ _mesa_fog_rgba_pixels( ctx, span, rgba );
else
_mesa_depth_fog_rgba_pixels(ctx, span, rgba);
}
@@ -1337,14 +1337,15 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
}
- (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba,
- span->write_all ? NULL : span->mask );
+ (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
+ (const GLchan (*)[4]) rgba,
+ span->writeAll ? NULL : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
- _mesa_write_alpha_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba,
- span->write_all ? NULL : span->mask );
+ _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
+ (const GLchan (*)[4]) rgba,
+ span->writeAll ? NULL : span->mask );
}
}
-
}
@@ -1391,10 +1392,9 @@ masked_texture_span( GLcontext *ctx, struct sw_span *span)
/* Texture with alpha test */
if (ctx->Color.AlphaEnabled) {
/* Do the alpha test */
- if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4]) rgba, span->mask ) == 0) {
+ if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4]) rgba ) == 0) {
return;
}
- span->write_all = GL_FALSE;
/* Depth test usually in 'rasterize_span' but if alpha test
needed, we have to wait for that test before depth test can
@@ -1459,11 +1459,13 @@ masked_texture_span( GLcontext *ctx, struct sw_span *span)
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
}
- (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba,
- span->write_all ? NULL : span->mask );
+ (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
+ (const GLchan (*)[4]) rgba,
+ span->writeAll ? NULL : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
- _mesa_write_alpha_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba,
- span->write_all ? NULL : span->mask );
+ _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
+ (const GLchan (*)[4]) rgba,
+ span->writeAll ? NULL : span->mask );
}
}
}
@@ -1500,10 +1502,10 @@ masked_multitexture_span( GLcontext *ctx, struct sw_span *span)
/* Texture with alpha test */
if (ctx->Color.AlphaEnabled) {
/* Do the alpha test */
- if (_mesa_alpha_test( ctx, span->end, (const GLchan (*)[4])rgba, span->mask ) == 0) {
+ if (_mesa_alpha_test( ctx, span, (const GLchan (*)[4])rgba ) == 0) {
return;
}
- span->write_all = GL_FALSE;
+
/* Depth test usually in 'rasterize_span' but if alpha test
needed, we have to wait for that test before depth test can
be done. */
@@ -1550,7 +1552,8 @@ masked_multitexture_span( GLcontext *ctx, struct sw_span *span)
#endif
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
- multi_write_rgba_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4]) rgba, span->mask );
+ multi_write_rgba_span( ctx, span->end, span->x, span->y,
+ (const GLchan (*)[4]) rgba, span->mask );
}
else {
/* normal: write to exactly one buffer */
@@ -1570,11 +1573,13 @@ masked_multitexture_span( GLcontext *ctx, struct sw_span *span)
_mesa_mask_rgba_span( ctx, span->end, span->x, span->y, rgba );
}
- (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba,
- span->write_all ? NULL : span->mask );
+ (*swrast->Driver.WriteRGBASpan)( ctx, span->end, span->x, span->y,
+ (const GLchan (*)[4])rgba,
+ span->writeAll ? NULL : span->mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
- _mesa_write_alpha_span( ctx, span->end, span->x, span->y, (const GLchan (*)[4])rgba,
- span->write_all ? NULL : span->mask );
+ _mesa_write_alpha_span( ctx, span->end, span->x, span->y,
+ (const GLchan (*)[4])rgba,
+ span->writeAll ? NULL : span->mask );
}
}
}
@@ -1655,8 +1660,8 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
}
if (span->activeMask & SPAN_RGBA) {
- ASSERT(span->filledColor == GL_FALSE);
SW_SPAN_SET_FLAG(span->filledColor);
+ SW_SPAN_SET_FLAG(span->filledAlpha);
if (span->activeMask & SPAN_FLAT) {
GLuint i;
GLchan color[4];
@@ -1696,7 +1701,7 @@ _mesa_rasterize_span(GLcontext *ctx, struct sw_span *span)
}
if (span->activeMask & SPAN_SPEC) {
- SW_SPAN_SET_FLAG(span->filledSpecular);
+ SW_SPAN_SET_FLAG(span->filledSpecular);
if (span->activeMask & SPAN_FLAT) {
const GLchan r = FixedToChan(span->specRed);
const GLchan g = FixedToChan(span->specGreen);
@@ -1993,7 +1998,7 @@ _old_write_texture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
(CONST GLchan (*)[4]) rgba, rgba );
/* Do the alpha test */
- if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
+ if (_old_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) {
return;
}
write_all = GL_FALSE;
@@ -2149,7 +2154,7 @@ _old_write_multitexture_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
(CONST GLchan (*)[4]) rgbaIn, rgba );
/* Do the alpha test */
- if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4])rgba, mask ) == 0) {
+ if (_old_alpha_test( ctx, n, (const GLchan (*)[4])rgba, mask ) == 0) {
return;
}
write_all = GL_FALSE;
diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h
index 326d02415a..ce67c6c761 100644
--- a/src/mesa/swrast/s_span.h
+++ b/src/mesa/swrast/s_span.h
@@ -1,4 +1,4 @@
-/* $Id: s_span.h,v 1.10 2002/01/16 16:00:04 brianp Exp $ */
+/* $Id: s_span.h,v 1.11 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -47,7 +47,7 @@ _old_write_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
void
_mesa_write_index_span( GLcontext *ctx, struct sw_span *span,
- GLenum primitive);
+ const GLfloat fog[MAX_WIDTH], GLenum primitive);
extern void
_mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
@@ -55,7 +55,7 @@ _mesa_write_monoindex_span( GLcontext *ctx, struct sw_span *span,
extern void
_mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span,
- GLenum primitive );
+ const GLfloat fog[MAX_WIDTH], GLenum primitive);
extern void
_mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
@@ -63,7 +63,7 @@ _mesa_write_monocolor_span( GLcontext *ctx, struct sw_span *span,
extern void
_mesa_write_texture_span( GLcontext *ctx, struct sw_span *span,
- const GLfloat fog[], GLenum primitive );
+ const GLfloat fog[MAX_WIDTH], GLenum primitive );
extern void
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index a28721bbc1..6e69fc8d70 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.c,v 1.14 2002/01/08 14:56:51 brianp Exp $ */
+/* $Id: s_stencil.c,v 1.15 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -586,7 +586,7 @@ _mesa_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
span->y, stencil, span->mask );
}
- span->write_all = GL_FALSE;
+ span->writeAll = GL_FALSE;
return result;
}
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index f4c1643d6b..06d1c31308 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.47 2002/01/16 16:00:04 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.48 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -107,7 +107,7 @@ static void smooth_ci_triangle( GLcontext *ctx,
span.color.index[i] = FixedToInt(span.index); \
span.index += span.indexStep; \
} \
- _mesa_write_index_span(ctx, &span, GL_POLYGON);
+ _mesa_write_index_span(ctx, &span, NULL, GL_POLYGON);
#include "s_tritemp.h"
}
@@ -155,6 +155,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
#define RENDER_SPAN( span ) \
GLuint i; \
SW_SPAN_SET_FLAG(span.filledColor); \
+ SW_SPAN_SET_FLAG(span.filledAlpha); \
for (i = 0; i < span.end; i++) { \
span.color.rgba[i][RCOMP] = FixedToChan(span.red); \
span.color.rgba[i][GCOMP] = FixedToChan(span.green); \
@@ -165,7 +166,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
span.blue += span.blueStep; \
span.alpha += span.alphaStep; \
} \
- _mesa_write_rgba_span(ctx, &span, GL_POLYGON);
+ _mesa_write_rgba_span(ctx, &span, NULL, GL_POLYGON);
#include "s_tritemp.h"
@@ -192,7 +193,7 @@ static void simple_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \
SWcontext *swrast = SWRAST_CONTEXT(ctx); \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
- GLint b = obj->BaseLevel; \
+ const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
const GLint twidth_log2 = obj->Image[b]->WidthLog2; \
@@ -221,7 +222,8 @@ static void simple_textured_triangle( GLcontext *ctx,
span.intTex[1] += span.intTexStep[1]; \
} \
(*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \
- (CONST GLchan (*)[3]) span.color.rgb, NULL );
+ (CONST GLchan (*)[3]) span.color.rgb, \
+ NULL );
#include "s_tritemp.h"
}
@@ -248,13 +250,13 @@ static void simple_z_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \
SWcontext *swrast = SWRAST_CONTEXT(ctx); \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
- GLint b = obj->BaseLevel; \
- GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
- GLfloat theight = (GLfloat) obj->Image[b]->Height; \
- GLint twidth_log2 = obj->Image[b]->WidthLog2; \
+ const GLint b = obj->BaseLevel; \
+ const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
+ const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
+ const GLint twidth_log2 = obj->Image[b]->WidthLog2; \
const GLchan *texture = (const GLchan *) obj->Image[b]->Data; \
- GLint smask = obj->Image[b]->Width - 1; \
- GLint tmask = obj->Image[b]->Height - 1; \
+ const GLint smask = obj->Image[b]->Width - 1; \
+ const GLint tmask = obj->Image[b]->Height - 1; \
if (!texture) { \
/* this shouldn't happen */ \
return; \
@@ -286,7 +288,8 @@ static void simple_z_textured_triangle( GLcontext *ctx,
span.z += span.zStep; \
} \
(*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \
- (CONST GLchan (*)[3]) span.color.rgb, span.mask );
+ (CONST GLchan (*)[3]) span.color.rgb, \
+ span.mask );
#include "s_tritemp.h"
}
@@ -552,7 +555,7 @@ affine_span(GLcontext *ctx, struct sw_span *span,
}
break;
}
- _mesa_write_rgba_span(ctx, span, GL_POLYGON);
+ _mesa_write_rgba_span(ctx, span, NULL, GL_POLYGON);
#undef SPAN_NEAREST
#undef SPAN_LINEAR
@@ -581,9 +584,9 @@ static void affine_textured_triangle( GLcontext *ctx,
struct affine_info info; \
struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
struct gl_texture_object *obj = unit->Current2D; \
- GLint b = obj->BaseLevel; \
- GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
- GLfloat theight = (GLfloat) obj->Image[b]->Height; \
+ const GLint b = obj->BaseLevel; \
+ const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
+ const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
info.texture = (const GLchan *) obj->Image[b]->Data; \
info.twidth_log2 = obj->Image[b]->WidthLog2; \
info.smask = obj->Image[b]->Width - 1; \
@@ -824,7 +827,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
break;
}
- _mesa_write_rgba_span(ctx, span, GL_POLYGON);
+ _mesa_write_rgba_span(ctx, span, NULL, GL_POLYGON);
#undef SPAN_NEAREST
@@ -852,9 +855,9 @@ static void persp_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \
struct persp_info info; \
- struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
- struct gl_texture_object *obj = unit->Current2D; \
- GLint b = obj->BaseLevel; \
+ const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
+ const struct gl_texture_object *obj = unit->Current2D; \
+ const GLint b = obj->BaseLevel; \
info.texture = (const GLchan *) obj->Image[b]->Data; \
info.twidth_log2 = obj->Image[b]->WidthLog2; \
info.smask = obj->Image[b]->Width - 1; \
@@ -932,22 +935,20 @@ static void general_textured_triangle( GLcontext *ctx,
(void) fixedToDepthShift;
#define RENDER_SPAN( span ) \
- GLfloat fogSpan[MAX_WIDTH]; \
GLuint i; \
SW_SPAN_SET_FLAG(span.filledColor); \
+ SW_SPAN_SET_FLAG(span.filledAlpha); \
SW_SPAN_SET_FLAG(span.filledTex[0]); \
/* NOTE: we could just call rasterize_span() here instead */ \
for (i = 0; i < span.end; i++) { \
GLdouble invQ = span.tex[0][3] ? (1.0 / span.tex[0][3]) : 1.0; \
span.depth[i] = FixedToDepth(span.z); \
span.z += span.zStep; \
- fogSpan[i] = span.fog; \
- span.fog += span.fogStep; \
span.color.rgba[i][RCOMP] = FixedToChan(span.red); \
span.color.rgba[i][GCOMP] = FixedToChan(span.green); \
span.color.rgba[i][BCOMP] = FixedToChan(span.blue); \
span.color.rgba[i][ACOMP] = FixedToChan(span.alpha); \
- span.red += span.redStep; \
+ span.red += span.redStep; \
span.green += span.greenStep; \
span.blue += span.blueStep; \
span.alpha += span.alphaStep; \
@@ -959,8 +960,7 @@ static void general_textured_triangle( GLcontext *ctx,
span.tex[0][2] += span.texStep[0][2]; \
span.tex[0][3] += span.texStep[0][3]; \
} \
- _mesa_write_texture_span( ctx, &span, fogSpan, \
- GL_POLYGON );
+ _mesa_write_texture_span( ctx, &span, NULL, GL_POLYGON );
#include "s_tritemp.h"
}
@@ -1124,7 +1124,7 @@ static void occlusion_zless_triangle( GLcontext *ctx,
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
- GLdepth z = FixedToDepth(span.z); \
+ GLdepth z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
ctx->OcclusionResult = GL_TRUE; \
return; \
diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c
index b331be1306..26567fa3c8 100644
--- a/src/mesa/swrast/s_zoom.c
+++ b/src/mesa/swrast/s_zoom.c
@@ -1,10 +1,10 @@
-/* $Id: s_zoom.c,v 1.7 2001/12/17 04:54:35 brianp Exp $ */
+/* $Id: s_zoom.c,v 1.8 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -26,6 +26,8 @@
#include "glheader.h"
#include "macros.h"
+#include "mem.h"
+#include "colormac.h"
#include "s_context.h"
#include "s_span.h"
@@ -33,6 +35,36 @@
#include "s_zoom.h"
+#ifdef DEBUG
+
+#define SAVE_SPAN(span) struct sw_span tmp_span = (span);
+
+#define RESTORE_SPAN(span) \
+{ \
+ GLint i; \
+ for (i=tmp_span.start; i<tmp_span.end; i++) { \
+ if (tmp_span.color.rgba[i][RCOMP] != \
+ (span).color.rgba[i][RCOMP] || \
+ tmp_span.color.rgba[i][GCOMP] != \
+ (span).color.rgba[i][GCOMP] || \
+ tmp_span.color.rgba[i][BCOMP] != \
+ (span).color.rgba[i][BCOMP]) { \
+ fprintf(stderr, "glZoom: Color-span changed in subfunction."); \
+ } \
+ if (tmp_span.depth[i] != (span).depth[i]) { \
+ fprintf(stderr, "glZoom: Depth-span changed in subfunction."); \
+ } \
+ } \
+ (span) = tmp_span; \
+}
+
+#else /* DEBUG not defined */
+
+#define SAVE_SPAN(span) GLint start = (span).start, end = (span).end;
+#define RESTORE_SPAN(span) (span).start = start, (span).end = end; \
+ (span).writeAll = GL_TRUE;
+
+#endif /* DEBUG */
/*
* Write a span of pixels to the frame buffer while applying a pixel zoom.
@@ -49,25 +81,31 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
const GLfloat *fog,
CONST GLchan rgba[][4], GLint y0 )
{
- GLint m;
- GLint r0, r1, row, r;
- GLint i, j, skipcol;
- GLchan zrgba[MAX_WIDTH][4]; /* zoomed pixel colors */
- GLdepth zdepth[MAX_WIDTH]; /* zoomed depth values */
+ GLint r0, r1, row;
+ GLint i, j;
+ struct sw_span dstspan;
GLfloat zfog[MAX_WIDTH]; /* zoomed fog values */
- GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
- const GLuint *srcRGBA32 = (const GLuint *) rgba;
- GLuint *dstRGBA32 = (GLuint *) zrgba;
+ const GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
+
+ SW_SPAN_RESET (dstspan);
/* compute width of output row */
- m = (GLint) ABSF( n * ctx->Pixel.ZoomX );
- if (m==0) {
+ dstspan.end = (GLint) ABSF( n * ctx->Pixel.ZoomX );
+ if (dstspan.end == 0) {
return;
}
+ /*here ok or better latter? like it was before */
+ else if (dstspan.end > maxwidth) {
+ dstspan.end = maxwidth;
+ }
+
if (ctx->Pixel.ZoomX<0.0) {
/* adjust x coordinate for left/right mirroring */
- x = x - m;
+ dstspan.x = x - dstspan.end;
}
+ else
+ dstspan.x = x;
+
/* compute which rows to draw */
row = y-y0;
@@ -93,47 +131,53 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
}
/* check if left edge is outside window */
- skipcol = 0;
- if (x<0) {
- skipcol = -x;
- m += x;
+ if (dstspan.x < 0) {
+ dstspan.start = -x;
}
+
/* make sure span isn't too long or short */
- if (m>maxwidth) {
+ /* if (m>maxwidth) {
m = maxwidth;
- }
- else if (m<=0) {
+ }*/
+
+ if (dstspan.end <= dstspan.start) {
return;
}
- ASSERT( m <= MAX_WIDTH );
+ ASSERT( dstspan.end <= MAX_WIDTH );
/* zoom the span horizontally */
if (ctx->Pixel.ZoomX==-1.0F) {
+ SW_SPAN_SET_FLAG(dstspan.filledColor);
+ SW_SPAN_SET_FLAG(dstspan.filledAlpha);
+ SW_SPAN_SET_FLAG(dstspan.filledDepth);
/* n==m */
- for (j=0;j<m;j++) {
- i = n - (j+skipcol) - 1;
- dstRGBA32[j] = srcRGBA32[i];
- zdepth[j] = z[i];
+ for (j=dstspan.start; j<dstspan.end; j++) {
+ i = n - j - 1;
+ COPY_CHAN4(dstspan.color.rgba[j], rgba[i]);
+ dstspan.depth[j] = z[i];
}
if (fog && ctx->Fog.Enabled) {
- for (j=0;j<m;j++) {
- i = n - (j+skipcol) - 1;
+ for (j=dstspan.start; j<dstspan.end; j++) {
+ i = n - j - 1;
zfog[j] = fog[i];
}
}
}
else {
- GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
- for (j=0;j<m;j++) {
- i = (GLint) ((j+skipcol) * xscale);
+ const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
+ SW_SPAN_SET_FLAG(dstspan.filledColor);
+ SW_SPAN_SET_FLAG(dstspan.filledAlpha);
+ SW_SPAN_SET_FLAG(dstspan.filledDepth);
+ for (j=dstspan.start; j<dstspan.end; j++) {
+ i = (GLint) (j * xscale);
if (i<0) i = n + i - 1;
- dstRGBA32[j] = srcRGBA32[i];
- zdepth[j] = z[i];
+ COPY_CHAN4(dstspan.color.rgba[j], rgba[i]);
+ dstspan.depth[j] = z[i];
}
if (fog && ctx->Fog.Enabled) {
- for (j=0;j<m;j++) {
- i = (GLint) ((j+skipcol) * xscale);
+ for (j=dstspan.start; j<dstspan.end; j++) {
+ i = (GLint) (j * xscale);
if (i<0) i = n + i - 1;
zfog[j] = fog[i];
}
@@ -141,9 +185,13 @@ _mesa_write_zoomed_rgba_span( GLcontext *ctx,
}
/* write the span */
- for (r=r0; r<r1; r++) {
- _old_write_rgba_span( ctx, m, x+skipcol, r, zdepth,
- (fog ? zfog : 0), zrgba, NULL, GL_BITMAP );
+ for (dstspan.y = r0; dstspan.y < r1; dstspan.y++) {
+ SAVE_SPAN(dstspan);
+ _mesa_write_rgba_span(ctx, &dstspan, (fog ? zfog : NULL), GL_BITMAP);
+ RESTORE_SPAN(dstspan);
+ /* problem here: "dstspan" can change inside
+ "_mesa_write_rgba_span". Best solution: make copy "tmpspan"
+ and give to function, but too slow */
}
}
diff --git a/src/mesa/swrast/s_zoom.h b/src/mesa/swrast/s_zoom.h
index 940970d7ab..2891d305e7 100644
--- a/src/mesa/swrast/s_zoom.h
+++ b/src/mesa/swrast/s_zoom.h
@@ -1,10 +1,10 @@
-/* $Id: s_zoom.h,v 1.5 2001/05/03 22:13:32 brianp Exp $ */
+/* $Id: s_zoom.h,v 1.6 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -30,7 +30,7 @@
#include "mtypes.h"
-
+#include "swrast.h"
extern void
_mesa_write_zoomed_rgba_span( GLcontext *ctx,
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index edc78b19b3..5ee58bfcf1 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,4 +1,4 @@
-/* $Id: swrast.h,v 1.14 2002/01/10 16:54:29 brianp Exp $ */
+/* $Id: swrast.h,v 1.15 2002/01/21 18:12:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,7 +33,6 @@
#include "mtypes.h"
-
/* The software rasterizer now uses this format for vertices. Thus a
* 'RasterSetup' stage or other translation is required between the
* tnl module and the swrast rasterization functions. This serves to
@@ -98,9 +97,15 @@ typedef struct {
struct sw_span {
GLint x, y;
- GLuint start, end; /* start=first pixel in span, end=last pixel in span*/
- /* only end is used until now.(end was before called count) */
+
+ /* only need to process pixels between start <= i < end */
+ GLuint start, end;
+
+ /* This flag indicates that only a part of the span is visible */
+ GLboolean writeAll;
+
GLuint activeMask; /* OR of the SPAN_* flags */
+
#if CHAN_TYPE == GL_FLOAT
GLfloat red, redStep;
GLfloat green, greenStep;
@@ -127,29 +132,33 @@ struct sw_span {
GLfloat rho[MAX_TEXTURE_UNITS];
GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS];
- GLboolean write_all; /* This flag indicates that only a part of */
- /*the span is visible. */
-#ifdef DEBUG
- GLboolean filledDepth, filledMask, filledAlpha;
- GLboolean filledColor, filledSpecular;
- GLboolean filledLambda[MAX_TEXTURE_UNITS], filledTex[MAX_TEXTURE_UNITS];
- GLboolean testedDepth, testedAlpha;
-#endif
- /* The interpolated fragment values */
+ /**
+ * Arrays of fragment values. These will either be computed from the
+ * x/xStep values above or loadd from glDrawPixels, etc.
+ */
GLdepth depth[MAX_WIDTH];
union {
GLchan rgb[MAX_WIDTH][3];
GLchan rgba[MAX_WIDTH][4];
GLuint index[MAX_WIDTH];
} color;
- GLchan specular[MAX_WIDTH][4];
- GLint itexcoords[MAX_WIDTH][2]; /* s, t */
- GLfloat texcoords[MAX_TEXTURE_UNITS][MAX_WIDTH][4]; /* s, t, r */
+ GLchan specular[MAX_WIDTH][4];
+ GLint itexcoords[MAX_WIDTH][2]; /* Integer texture (s, t) */
+ /* Texture (s,t,r). 4th component only used for pixel texture */
+ GLfloat texcoords[MAX_TEXTURE_UNITS][MAX_WIDTH][4];
GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH];
GLfloat coverage[MAX_WIDTH];
GLubyte mask[MAX_WIDTH];
+
+#ifdef DEBUG
+ GLboolean filledDepth, filledMask, filledAlpha;
+ GLboolean filledColor, filledSpecular;
+ GLboolean filledLambda[MAX_TEXTURE_UNITS], filledTex[MAX_TEXTURE_UNITS];
+ GLboolean testedDepth, testedAlpha;
+#endif
};
+
#ifdef DEBUG
#define SW_SPAN_SET_FLAG(flag) {ASSERT((flag) == GL_FALSE);(flag) = GL_TRUE;}
#define SW_SPAN_RESET(span) { \
@@ -160,10 +169,10 @@ struct sw_span {
MAX_TEXTURE_UNITS*sizeof(GLboolean)); \
MEMSET((span).filledLambda, GL_FALSE, \
MAX_TEXTURE_UNITS*sizeof(GLboolean)); \
- (span).start = 0; (span).write_all = GL_TRUE;}
+ (span).start = 0; (span).writeAll = GL_TRUE;}
#else
#define SW_SPAN_SET_FLAG(flag) ;
-#define SW_SPAN_RESET(span) {(span).start = 0;(span).write_all = GL_TRUE;}
+#define SW_SPAN_RESET(span) {(span).start = 0;(span).writeAll = GL_TRUE;}
#endif
struct swrast_device_driver;