swrast: Fix fixed-function fragment processing
[mesa.git] / src / mesa / swrast / s_lines.c
index cff36042cbbf18b8225a805a3aa09a8dba76fb23..ee997b08a7b1c5c285a49da050dcf89063928b0e 100644 (file)
@@ -38,7 +38,7 @@
  * Init the mask[] array to implement a line stipple.
  */
 static void
-compute_stipple_mask( GLcontext *ctx, GLuint len, GLubyte mask[] )
+compute_stipple_mask( struct gl_context *ctx, GLuint len, GLubyte mask[] )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLuint i;
@@ -60,7 +60,7 @@ compute_stipple_mask( GLcontext *ctx, GLuint len, GLubyte mask[] )
  * To draw a wide line we can simply redraw the span N times, side by side.
  */
 static void
-draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
+draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor )
 {
    const GLint width = (GLint) CLAMP(ctx->Line.Width,
                                      ctx->Const.MinLineWidth,
@@ -87,10 +87,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
             for (i = 0; i < span->end; i++)
                y[i]++;
          }
-         if (ctx->Visual.rgbMode)
-            _swrast_write_rgba_span(ctx, span);
-         else
-            _swrast_write_index_span(ctx, span);
+        _swrast_write_rgba_span(ctx, span);
       }
    }
    else {
@@ -106,10 +103,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
             for (i = 0; i < span->end; i++)
                x[i]++;
          }
-         if (ctx->Visual.rgbMode)
-            _swrast_write_rgba_span(ctx, span);
-         else
-            _swrast_write_index_span(ctx, span);
+        _swrast_write_rgba_span(ctx, span);
       }
    }
 }
@@ -120,12 +114,6 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
 /*****                    Rasterization                           *****/
 /**********************************************************************/
 
-/* Simple color index line (no stipple, width=1, no Z, no fog, no tex)*/
-#define NAME simple_no_z_ci_line
-#define INTERP_INDEX
-#define RENDER_SPAN(span) _swrast_write_index_span(ctx, &span)
-#include "s_linetemp.h"
-
 /* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/
 #define NAME simple_no_z_rgba_line
 #define INTERP_RGBA
@@ -133,25 +121,6 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
 #include "s_linetemp.h"
 
 
-/* Z, fog, wide, stipple color index line */
-#define NAME ci_line
-#define INTERP_INDEX
-#define INTERP_Z
-#define INTERP_ATTRIBS /* for fog */
-#define RENDER_SPAN(span)                                      \
-   if (ctx->Line.StippleFlag) {                                        \
-      span.arrayMask |= SPAN_MASK;                             \
-      compute_stipple_mask(ctx, span.end, span.array->mask);    \
-   }                                                           \
-   if (ctx->Line.Width > 1.0) {                                        \
-      draw_wide_line(ctx, &span, (GLboolean)(dx > dy));                \
-   }                                                           \
-   else {                                                      \
-      _swrast_write_index_span(ctx, &span);                    \
-   }
-#include "s_linetemp.h"
-
-
 /* Z, fog, wide, stipple RGBA line */
 #define NAME rgba_line
 #define INTERP_RGBA
@@ -191,7 +160,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
 
 
 void
-_swrast_add_spec_terms_line(GLcontext *ctx,
+_swrast_add_spec_terms_line(struct gl_context *ctx,
                             const SWvertex *v0, const SWvertex *v1)
 {
    SWvertex *ncv0 = (SWvertex *)v0;
@@ -253,10 +222,9 @@ do {                                    \
  * tests to this code.
  */
 void
-_swrast_choose_line( GLcontext *ctx )
+_swrast_choose_line( struct gl_context *ctx )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
-   const GLboolean rgbmode = ctx->Visual.rgbMode;
    GLboolean specular = (ctx->Fog.ColorSumEnabled ||
                          (ctx->Light.Enabled &&
                           ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
@@ -268,7 +236,7 @@ _swrast_choose_line( GLcontext *ctx )
          ASSERT(swrast->Line);
       }
       else if (ctx->Texture._EnabledCoordUnits
-               || ctx->FragmentProgram._Current
+               || _swrast_use_fragment_program(ctx)
                || swrast->_FogEnabled
                || specular) {
          USE(general_line);
@@ -277,23 +245,17 @@ _swrast_choose_line( GLcontext *ctx )
                || ctx->Line.Width != 1.0
                || ctx->Line.StippleFlag) {
          /* no texture, but Z, fog, width>1, stipple, etc. */
-         if (rgbmode)
 #if CHAN_BITS == 32
-            USE(general_line);
+         USE(general_line);
 #else
-            USE(rgba_line);
+         USE(rgba_line);
 #endif
-         else
-            USE(ci_line);
       }
       else {
          ASSERT(!ctx->Depth.Test);
          ASSERT(ctx->Line.Width == 1.0);
          /* simple lines */
-         if (rgbmode)
-            USE(simple_no_z_rgba_line);
-         else
-            USE(simple_no_z_ci_line);
+         USE(simple_no_z_rgba_line);
       }
    }
    else if (ctx->RenderMode == GL_FEEDBACK) {