X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fswrast%2Fs_zoom.c;h=a48eae19259c6b90d435a897b67f6b950cc73756;hb=71e64fc30b4f57bd93daf004bc04af7181391f4d;hp=1ab5911f2f1778d430ef507984a12b56f5d3fed6;hpb=4fe48b4e8568896cdbc822323aeec0a41c72ff2a;p=mesa.git diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 1ab5911f2f1..a48eae19259 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -22,10 +22,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "macros.h" -#include "imports.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/macros.h" +#include "main/imports.h" +#include "main/colormac.h" #include "s_context.h" #include "s_span.h" @@ -130,8 +130,8 @@ static void zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, const GLvoid *src, GLenum format ) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); SWspan zoomed; - SWspanarrays zoomed_arrays; /* this is big! */ GLint x0, x1, y0, y1; GLint zoomedWidth; @@ -140,6 +140,13 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, return; /* totally clipped */ } + if (!swrast->ZoomedArrays) { + /* allocate on demand */ + swrast->ZoomedArrays = (SWspanarrays *) CALLOC(sizeof(SWspanarrays)); + if (!swrast->ZoomedArrays) + return; + } + zoomedWidth = x1 - x0; ASSERT(zoomedWidth > 0); ASSERT(zoomedWidth <= MAX_WIDTH); @@ -148,21 +155,18 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, ASSERT((span->arrayMask & SPAN_XY) == 0); ASSERT(span->primitive == GL_BITMAP); - INIT_SPAN(zoomed, GL_BITMAP, 0, 0, 0); + INIT_SPAN(zoomed, GL_BITMAP); zoomed.x = x0; zoomed.end = zoomedWidth; - zoomed.array = &zoomed_arrays; - zoomed_arrays.ChanType = span->array->ChanType; - /* XXX temporary */ -#if CHAN_TYPE == GL_UNSIGNED_BYTE - zoomed_arrays.rgba = zoomed_arrays.rgba8; -#elif CHAN_TYPE == GL_UNSIGNED_SHORT - zoomed_arrays.rgba = zoomed_arrays.rgba16; -#else - zoomed_arrays.rgba = zoomed_arrays.attribs[FRAG_ATTRIB_COL0]; -#endif - - /* copy attribute info (XXX copy all attribs?) */ + zoomed.array = swrast->ZoomedArrays; + zoomed.array->ChanType = span->array->ChanType; + if (zoomed.array->ChanType == GL_UNSIGNED_BYTE) + zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->rgba8; + else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) + zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->rgba16; + else + zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->attribs[FRAG_ATTRIB_COL0]; + COPY_4V(zoomed.attrStart[FRAG_ATTRIB_WPOS], span->attrStart[FRAG_ATTRIB_WPOS]); COPY_4V(zoomed.attrStepX[FRAG_ATTRIB_WPOS], span->attrStepX[FRAG_ATTRIB_WPOS]); COPY_4V(zoomed.attrStepY[FRAG_ATTRIB_WPOS], span->attrStepY[FRAG_ATTRIB_WPOS]); @@ -178,6 +182,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, /* we'll generate an array of colorss */ zoomed.interpMask = span->interpMask & ~SPAN_RGBA; zoomed.arrayMask |= SPAN_RGBA; + zoomed.arrayAttribs |= FRAG_BIT_COL0; /* we'll produce these values */ ASSERT(span->arrayMask & SPAN_RGBA); } else if (format == GL_COLOR_INDEX) {