aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/pixelstore.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2012-07-27 12:11:32 -0700
committerIan Romanick <[email protected]>2012-08-29 15:09:35 -0700
commit4114dee99ecd848693302078597076ced9426f95 (patch)
tree93049afd2e0585aad7a4b8911dbb3c9c4b972cea /src/mesa/main/pixelstore.c
parent08be1d288f216232d3974f5997b266a8dd720928 (diff)
mesa/es: Validate glPixelStore pname in Mesa code rather than the ES wrapper
v2: Add proper core-profile and GLES3 filtering. Signed-off-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main/pixelstore.c')
-rw-r--r--src/mesa/main/pixelstore.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c
index 81474491dc5..d1e96aa8f57 100644
--- a/src/mesa/main/pixelstore.c
+++ b/src/mesa/main/pixelstore.c
@@ -45,18 +45,24 @@ _mesa_PixelStorei( GLenum pname, GLint param )
switch (pname) {
case GL_PACK_SWAP_BYTES:
+ if (!_mesa_is_desktop_gl(ctx))
+ goto invalid_enum_error;
if (param == (GLint)ctx->Pack.SwapBytes)
return;
FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE;
break;
case GL_PACK_LSB_FIRST:
+ if (!_mesa_is_desktop_gl(ctx))
+ goto invalid_enum_error;
if (param == (GLint)ctx->Pack.LsbFirst)
return;
FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE;
break;
case GL_PACK_ROW_LENGTH:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -67,6 +73,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Pack.RowLength = param;
break;
case GL_PACK_IMAGE_HEIGHT:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -77,6 +85,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Pack.ImageHeight = param;
break;
case GL_PACK_SKIP_PIXELS:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -87,6 +97,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Pack.SkipPixels = param;
break;
case GL_PACK_SKIP_ROWS:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -97,6 +109,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Pack.SkipRows = param;
break;
case GL_PACK_SKIP_IMAGES:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -117,6 +131,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Pack.Alignment = param;
break;
case GL_PACK_INVERT_MESA:
+ if (!_mesa_is_desktop_gl(ctx))
+ goto invalid_enum_error;
if (!ctx->Extensions.MESA_pack_invert) {
_mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" );
return;
@@ -128,6 +144,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
break;
case GL_UNPACK_SWAP_BYTES:
+ if (!_mesa_is_desktop_gl(ctx))
+ goto invalid_enum_error;
if (param == (GLint)ctx->Unpack.SwapBytes)
return;
if ((GLint)ctx->Unpack.SwapBytes == param)
@@ -136,6 +154,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE;
break;
case GL_UNPACK_LSB_FIRST:
+ if (!_mesa_is_desktop_gl(ctx))
+ goto invalid_enum_error;
if (param == (GLint)ctx->Unpack.LsbFirst)
return;
if ((GLint)ctx->Unpack.LsbFirst == param)
@@ -144,6 +164,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE;
break;
case GL_UNPACK_ROW_LENGTH:
+ if (ctx->API == API_OPENGLES)
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -154,6 +176,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Unpack.RowLength = param;
break;
case GL_UNPACK_IMAGE_HEIGHT:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -165,6 +189,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Unpack.ImageHeight = param;
break;
case GL_UNPACK_SKIP_PIXELS:
+ if (ctx->API == API_OPENGLES)
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -175,6 +201,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Unpack.SkipPixels = param;
break;
case GL_UNPACK_SKIP_ROWS:
+ if (ctx->API == API_OPENGLES)
+ goto invalid_enum_error;
if (param<0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -185,6 +213,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Unpack.SkipRows = param;
break;
case GL_UNPACK_SKIP_IMAGES:
+ if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+ goto invalid_enum_error;
if (param < 0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
return;
@@ -205,9 +235,14 @@ _mesa_PixelStorei( GLenum pname, GLint param )
ctx->Unpack.Alignment = param;
break;
default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
- return;
+ goto invalid_enum_error;
}
+
+ return;
+
+invalid_enum_error:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
+ return;
}