mesa: allocate pixel zoom arrays on heap, not stack

Fixes stack overflow on Windows.
This commit is contained in:
Brian Paul 2008-06-16 10:03:05 -06:00
parent bbce58802d
commit ec2d0decbd
3 changed files with 20 additions and 10 deletions

View file

@ -832,6 +832,8 @@ _swrast_DestroyContext( GLcontext *ctx )
}
FREE( swrast->SpanArrays );
if (swrast->ZoomedArrays)
FREE( swrast->ZoomedArrays );
FREE( swrast->TexelBuffer );
FREE( swrast );

View file

@ -206,6 +206,7 @@ typedef struct
* on some systems.
*/
SWspanarrays *SpanArrays;
SWspanarrays *ZoomedArrays; /**< For pixel zooming */
/**
* Used to buffer N GL_POINTS, instead of rendering one by one.

View file

@ -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"),
@ -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);
@ -151,14 +158,14 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
INIT_SPAN(zoomed, GL_BITMAP);
zoomed.x = x0;
zoomed.end = zoomedWidth;
zoomed.array = &zoomed_arrays;
zoomed_arrays.ChanType = span->array->ChanType;
if (zoomed_arrays.ChanType == GL_UNSIGNED_BYTE)
zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba8;
else if (zoomed_arrays.ChanType == GL_UNSIGNED_SHORT)
zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba16;
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_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.attribs[FRAG_ATTRIB_COL0];
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]);