From 844585be4c392d7e06a8954e56c3756cafa74a39 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Mar 2004 17:17:25 +0000 Subject: [PATCH] use Driver.WriteMonoRGBAPixels() when possible (Dan Schikore) --- src/mesa/swrast/s_span.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 13248fd..d164ad9 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -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], -- 2.7.4