diff options
author | marha <marha@users.sourceforge.net> | 2012-02-09 08:46:41 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-02-09 08:46:41 +0100 |
commit | 535951cba015f2a2b63292e0ca983d0d6e736b71 (patch) | |
tree | 8c0e0364a27f250e926abe165b82ca12e5a841bf /mesalib/src/mesa/main/readpix.c | |
parent | ebb6162f9cbc1af0fac0b670b5aa38c8bb7a7446 (diff) | |
parent | 474621addc25cb22865c54b70ffbec07c82eb04c (diff) | |
download | vcxsrv-535951cba015f2a2b63292e0ca983d0d6e736b71.tar.gz vcxsrv-535951cba015f2a2b63292e0ca983d0d6e736b71.tar.bz2 vcxsrv-535951cba015f2a2b63292e0ca983d0d6e736b71.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/main/readpix.c')
-rw-r--r-- | mesalib/src/mesa/main/readpix.c | 160 |
1 files changed, 7 insertions, 153 deletions
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index 908a55e70..48708a6eb 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -575,162 +575,13 @@ _mesa_readpixels(struct gl_context *ctx, } -/** - * Do error checking of the format/type parameters to glReadPixels and - * glDrawPixels. - * \param drawing if GL_TRUE do checking for DrawPixels, else do checking - * for ReadPixels. - * \return GL_TRUE if error detected, GL_FALSE if no errors - */ -GLboolean -_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, - GLenum type, GLboolean drawing) -{ - const char *readDraw = drawing ? "Draw" : "Read"; - const GLboolean reading = !drawing; - - /* state validation should have already been done */ - ASSERT(ctx->NewState == 0x0); - - if (ctx->Extensions.EXT_packed_depth_stencil - && type == GL_UNSIGNED_INT_24_8_EXT - && format != GL_DEPTH_STENCIL_EXT) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); - return GL_TRUE; - } - - if (ctx->Extensions.ARB_depth_buffer_float - && type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV - && format != GL_DEPTH_STENCIL_EXT) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); - return GL_TRUE; - } - - /* basic combinations test */ - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "gl%sPixels(format or type)", readDraw); - return GL_TRUE; - } - - /* additional checks */ - switch (format) { - case GL_RG: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - if (!drawing) { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - } - break; - case GL_COLOR_INDEX: - if (drawing) { - if (ctx->PixelMaps.ItoR.Size == 0 || - ctx->PixelMaps.ItoG.Size == 0 || - ctx->PixelMaps.ItoB.Size == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(drawing color index pixels into RGB buffer)"); - return GL_TRUE; - } - } - else { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - /* We no longer support CI-mode color buffers so trying to read - * GL_COLOR_INDEX pixels is always an error. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(color buffer is RGB)"); - return GL_TRUE; - } - break; - case GL_STENCIL_INDEX: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (reading && !_mesa_source_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no stencil buffer)", readDraw); - return GL_TRUE; - } - break; - case GL_DEPTH_COMPONENT: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no depth buffer)", readDraw); - return GL_TRUE; - } - break; - case GL_DEPTH_STENCIL_EXT: - /* Check validity of the type first. */ - switch (type) { - case GL_UNSIGNED_INT_24_8_EXT: - if (!ctx->Extensions.EXT_packed_depth_stencil) { - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); - return GL_TRUE; - } - break; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - if (!ctx->Extensions.ARB_depth_buffer_float) { - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); - return GL_TRUE; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); - return GL_TRUE; - } - if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (reading && !_mesa_source_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no depth or stencil buffer)", readDraw); - return GL_TRUE; - } - break; - default: - /* this should have been caught in _mesa_is_legal_format_type() */ - _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw); - return GL_TRUE; - } - - /* no errors */ - return GL_FALSE; -} - - - void GLAPIENTRY _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *pixels ) { + GLenum err; + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -752,8 +603,11 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, if (ctx->NewState) _mesa_update_state(ctx); - if (_mesa_error_check_format_type(ctx, format, type, GL_FALSE)) { - /* found an error */ + err = _mesa_error_check_format_and_type(ctx, format, type); + if (err != GL_NO_ERROR) { + _mesa_error(ctx, err, "glReadPixels(invalid format %s and/or type %s)", + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type)); return; } |