const struct gl_pixelstore_attrib *dstPacking,
GLbitfield transferOps)
{
- GLfloat luminance[MAX_WIDTH];
+ GLfloat *luminance;
const GLint comps = _mesa_components_in_format(dstFormat);
const GLboolean intDstFormat = _mesa_is_integer_format(dstFormat);
GLuint i;
+ if (dstFormat == GL_LUMINANCE ||
+ dstFormat == GL_LUMINANCE_ALPHA ||
+ dstFormat == GL_LUMINANCE_INTEGER_EXT ||
+ dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) {
+ luminance = (GLfloat *) malloc(n * sizeof(GLfloat));
+ if (!luminance) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
+ return;
+ }
+ }
+ else {
+ luminance = NULL;
+ }
+
/* XXX
* This test should probably go away. Have the caller set/clear the
* IMAGE_CLAMP_BIT as needed.
}
}
}
+
+ free(luminance);
}
/*
* Extract image data and convert to RGBA floats
*/
- assert(n <= MAX_WIDTH);
if (srcFormat == GL_COLOR_INDEX) {
- GLuint indexes[MAX_WIDTH];
+ GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+
+ if (!indexes) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
+ return;
+ }
+
extract_uint_indexes(n, indexes, srcFormat, srcType, source,
srcPacking);
for (i = 0; i < n; i++) {
dest[i] = (GLchan) (indexes[i] & 0xff);
}
+ free(indexes);
free(rgba);
return;
}
* with color indexes.
*/
transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT);
+
+ free(indexes);
}
else {
/* non-color index data */
/*
* Extract image data and convert to RGBA floats
*/
- assert(n <= MAX_WIDTH);
if (srcFormat == GL_COLOR_INDEX) {
- GLuint indexes[MAX_WIDTH];
+ GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+
+ if (!indexes) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
+ free(rgba);
+ return;
+ }
+
extract_uint_indexes(n, indexes, srcFormat, srcType, source,
srcPacking);
for (i = 0; i < n; i++) {
dest[i] = (GLchan) (indexes[i] & 0xff);
}
+ free(indexes);
free(rgba);
return;
}
*/
transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT);
- free(rgba);
+ free(indexes);
}
else {
/* non-color index data */
dst += dstComponents;
}
}
+
+ free(rgba);
}
}
return;
}
- ASSERT(n <= MAX_WIDTH);
-
ASSERT(dstFormat == GL_ALPHA ||
dstFormat == GL_LUMINANCE ||
dstFormat == GL_LUMINANCE_ALPHA ||
/*
* Extract image data and convert to RGBA floats
*/
- assert(n <= MAX_WIDTH);
extract_float_rgba(n, rgba, srcFormat, srcType, source,
srcPacking->SwapBytes);
* transferOps - the pixel transfer operations to apply
*/
void
-_mesa_unpack_index_span( const struct gl_context *ctx, GLuint n,
+_mesa_unpack_index_span( struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking,
/*
* general solution
*/
- GLuint indexes[MAX_WIDTH];
- assert(n <= MAX_WIDTH);
+ GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+
+ if (!indexes) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
+ return;
+ }
extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source,
srcPacking);
default:
_mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span");
}
+
+ free(indexes);
}
}
void
-_mesa_pack_index_span( const struct gl_context *ctx, GLuint n,
+_mesa_pack_index_span( struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest, const GLuint *source,
const struct gl_pixelstore_attrib *dstPacking,
GLbitfield transferOps )
{
- GLuint indexes[MAX_WIDTH];
+ GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
- ASSERT(n <= MAX_WIDTH);
+ if (!indexes) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
+ return;
+ }
transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT);
default:
_mesa_problem(ctx, "bad type in _mesa_pack_index_span");
}
+
+ free(indexes);
}
* transferOps - apply offset/bias/lookup ops?
*/
void
-_mesa_unpack_stencil_span( const struct gl_context *ctx, GLuint n,
+_mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking,
/*
* general solution
*/
- GLuint indexes[MAX_WIDTH];
- assert(n <= MAX_WIDTH);
+ GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+
+ if (!indexes) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil unpacking");
+ return;
+ }
extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source,
srcPacking);
default:
_mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span");
}
+
+ free(indexes);
}
}
void
-_mesa_pack_stencil_span( const struct gl_context *ctx, GLuint n,
+_mesa_pack_stencil_span( struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest, const GLstencil *source,
const struct gl_pixelstore_attrib *dstPacking )
{
- GLstencil stencil[MAX_WIDTH];
+ GLstencil *stencil = (GLstencil *) malloc(n * sizeof(GLstencil));
- ASSERT(n <= MAX_WIDTH);
+ if (!stencil) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil packing");
+ return;
+ }
if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset ||
ctx->Pixel.MapStencilFlag) {
default:
_mesa_problem(ctx, "bad type in _mesa_pack_index_span");
}
+
+ free(stencil);
}
#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \
* (ignored for GLfloat).
*/
void
-_mesa_unpack_depth_span( const struct gl_context *ctx, GLuint n,
+_mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest, GLuint depthMax,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking )
{
- GLfloat depthTemp[MAX_WIDTH], *depthValues;
+ GLfloat *depthTemp, *depthValues;
GLboolean needClamp = GL_FALSE;
/* Look for special cases first.
/* general case path follows */
+ depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat));
+ if (!depthTemp) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
+ return;
+ }
+
if (dstType == GL_FLOAT) {
depthValues = (GLfloat *) dest;
}
break;
default:
_mesa_problem(NULL, "bad type in _mesa_unpack_depth_span()");
+ free(depthTemp);
return;
}
ASSERT(dstType == GL_FLOAT);
/*ASSERT(depthMax == 1.0F);*/
}
+
+ free(depthTemp);
}
* Pack an array of depth values. The values are floats in [0,1].
*/
void
-_mesa_pack_depth_span( const struct gl_context *ctx, GLuint n, GLvoid *dest,
+_mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest,
GLenum dstType, const GLfloat *depthSpan,
const struct gl_pixelstore_attrib *dstPacking )
{
- GLfloat depthCopy[MAX_WIDTH];
-
- ASSERT(n <= MAX_WIDTH);
+ GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat));
+ if (!depthCopy) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
+ return;
+ }
if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) {
memcpy(depthCopy, depthSpan, n * sizeof(GLfloat));
default:
_mesa_problem(ctx, "bad type in _mesa_pack_depth_span");
}
+
+ free(depthCopy);
}
* Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8.
*/
void
-_mesa_pack_depth_stencil_span(const struct gl_context *ctx, GLuint n, GLuint *dest,
+_mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest,
const GLfloat *depthVals,
const GLstencil *stencilVals,
const struct gl_pixelstore_attrib *dstPacking)
{
- GLfloat depthCopy[MAX_WIDTH];
- GLstencil stencilCopy[MAX_WIDTH];
+ GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat));
+ GLstencil *stencilCopy = (GLstencil *) malloc(n * sizeof(GLstencil));
GLuint i;
- ASSERT(n <= MAX_WIDTH);
+ if (!depthCopy || !stencilCopy) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
+ free(depthCopy);
+ free(stencilCopy);
+ return;
+ }
if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) {
memcpy(depthCopy, depthVals, n * sizeof(GLfloat));
if (dstPacking->SwapBytes) {
_mesa_swap4(dest, n);
}
+
+ free(depthCopy);
+ free(stencilCopy);
}
GLbitfield transferOps);
extern void
-_mesa_unpack_index_span(const struct gl_context *ctx, GLuint n,
+_mesa_unpack_index_span(struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking,
extern void
-_mesa_pack_index_span(const struct gl_context *ctx, GLuint n,
+_mesa_pack_index_span(struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest, const GLuint *source,
const struct gl_pixelstore_attrib *dstPacking,
GLbitfield transferOps);
extern void
-_mesa_unpack_stencil_span(const struct gl_context *ctx, GLuint n,
+_mesa_unpack_stencil_span(struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking,
GLbitfield transferOps);
extern void
-_mesa_pack_stencil_span(const struct gl_context *ctx, GLuint n,
+_mesa_pack_stencil_span(struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest, const GLstencil *source,
const struct gl_pixelstore_attrib *dstPacking);
extern void
-_mesa_unpack_depth_span(const struct gl_context *ctx, GLuint n,
+_mesa_unpack_depth_span(struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest, GLuint depthMax,
GLenum srcType, const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking);
extern void
-_mesa_pack_depth_span(const struct gl_context *ctx, GLuint n, GLvoid *dest,
+_mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest,
GLenum dstType, const GLfloat *depthSpan,
const struct gl_pixelstore_attrib *dstPacking);
extern void
-_mesa_pack_depth_stencil_span(const struct gl_context *ctx,
+_mesa_pack_depth_stencil_span(struct gl_context *ctx,
GLuint n, GLuint *dest,
const GLfloat *depthVals,
const GLstencil *stencilVals,