use Driver.WriteMonoRGBAPixels() when possible (Dan Schikore)
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 24 Mar 2004 17:17:25 +0000 (17:17 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 24 Mar 2004 17:17:25 +0000 (17:17 +0000)
src/mesa/swrast/s_span.c

index 13248fd..d164ad9 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.1
  *
- * Copyright (C) 1999-2003  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"),
@@ -1118,14 +1118,32 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
       /* write pixels */
       if (span->arrayMask & SPAN_XY) {
          /* array of pixel coords */
-         /* XXX test for mono color */
-         (*swrast->Driver.WriteRGBAPixels)(ctx, span->end, span->array->x,
-             span->array->y, (const GLchan (*)[4]) span->array->rgba, span->array->mask);
-         if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
-            _swrast_write_alpha_pixels(ctx, span->end,
-                                     span->array->x, span->array->y,
-                                     (const GLchan (*)[4]) span->array->rgba,
-                                     span->array->mask);
+         if (monoColor) {
+            /* all pixels have same color */
+            GLchan color[4];
+            color[RCOMP] = FixedToChan(span->red);
+            color[GCOMP] = FixedToChan(span->green);
+            color[BCOMP] = FixedToChan(span->blue);
+            color[ACOMP] = FixedToChan(span->alpha);
+            (*swrast->Driver.WriteMonoRGBAPixels)(ctx, span->end,
+                     span->array->x, span->array->y, color, span->array->mask);
+            if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
+               _swrast_write_mono_alpha_pixels(ctx, span->end,
+                                              span->array->x, span->array->y,
+                                              color[ACOMP], span->array->mask);
+            }
+         }
+         else {
+            (*swrast->Driver.WriteRGBAPixels)(ctx, span->end,
+                                       span->array->x, span->array->y,
+                                       (const GLchan (*)[4]) span->array->rgba,
+                                       span->array->mask);
+            if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
+               _swrast_write_alpha_pixels(ctx, span->end,
+                                       span->array->x, span->array->y,
+                                       (const GLchan (*)[4]) span->array->rgba,
+                                       span->array->mask);
+            }
          }
       }
       else {
@@ -1138,7 +1156,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
             color[BCOMP] = FixedToChan(span->blue);
             color[ACOMP] = FixedToChan(span->alpha);
             (*swrast->Driver.WriteMonoRGBASpan)(ctx, span->end, span->x,
-                                                span->y, color, span->array->mask);
+                                           span->y, color, span->array->mask);
             if (swrast->_RasterMask & ALPHABUF_BIT) {
                _swrast_write_mono_alpha_span(ctx, span->end, span->x, span->y,
                       color[ACOMP],