diff options
author | Brian Paul <[email protected]> | 2009-08-07 09:03:49 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-08-07 09:50:38 -0600 |
commit | 3335b847bf1e1ee9e77600bd7122eb56ffbc8c07 (patch) | |
tree | 5e5271146d6c6c090bafa5d581d2a12ddb95f594 /src | |
parent | 28cfd37bb3c5dfa70715d91bd523e93dfedd3981 (diff) |
mesa: do error checking on glCopyPixels() type parameter
Plus, move some other error checks before state validation and update
some comments.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/drawpix.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index 6682b5e725c..ec8a45cb94e 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -27,6 +27,7 @@ #include "bufferobj.h" #include "context.h" #include "drawpix.h" +#include "enums.h" #include "feedback.h" #include "framebuffer.h" #include "image.h" @@ -62,7 +63,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, } if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) { - /* found an error */ + /* the error was already recorded */ return; } @@ -73,7 +74,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, } if (!ctx->Current.RasterPosValid) { - return; + return; /* no-op, not an error */ } if (ctx->RenderMode == GL_RENDER) { @@ -126,6 +127,17 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + if (width < 0 || height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)"); + return; + } + + if (type != GL_COLOR && type != GL_DEPTH && type != GL_STENCIL) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels(type=%s)", + _mesa_lookup_enum_by_nr(type)); + return; + } + if (ctx->NewState) { _mesa_update_state(ctx); } @@ -136,11 +148,6 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, return; } - if (width < 0 || height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)"); - return; - } - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, @@ -156,7 +163,7 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, } if (!ctx->Current.RasterPosValid || width ==0 || height == 0) { - return; + return; /* no-op, not an error */ } if (ctx->RenderMode == GL_RENDER) { |