summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-06-16 10:03:05 -0600
committerBrian Paul <[email protected]>2008-06-16 10:03:05 -0600
commitec2d0decbd739df99cac4baba57fe0005bf4894d (patch)
tree050ef6df739104ecc8062d4a22454bc435c4f21d
parentbbce58802d9bf94eadbb0d0c0211a0768f8302aa (diff)
mesa: allocate pixel zoom arrays on heap, not stack
Fixes stack overflow on Windows.
-rw-r--r--src/mesa/swrast/s_context.c2
-rw-r--r--src/mesa/swrast/s_context.h1
-rw-r--r--src/mesa/swrast/s_zoom.c27
3 files changed, 20 insertions, 10 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 8e6b28bb4c6..eab9ff3a9e7 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -832,6 +832,8 @@ _swrast_DestroyContext( GLcontext *ctx )
}
FREE( swrast->SpanArrays );
+ if (swrast->ZoomedArrays)
+ FREE( swrast->ZoomedArrays );
FREE( swrast->TexelBuffer );
FREE( swrast );
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 3dcc3ed16e2..a511d1c9a17 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -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.
diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c
index 9f1a4c6f0a7..4473078b78a 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"),
@@ -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]);