mesa: Allow glGetTexParameter of GL_TEXTURE_SRGB_DECODE_EXT
[mesa.git] / src / mesa / main / pixelstore.c
index b16d27a4ea5eaa62a9160db4cee879a181cb0059..e56d5049fbe7aa0e90c15745398f8321578eeeca 100644 (file)
@@ -32,6 +32,7 @@
 #include "bufferobj.h"
 #include "context.h"
 #include "pixelstore.h"
+#include "mfeatures.h"
 #include "mtypes.h"
 
 
@@ -44,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;
@@ -66,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;
@@ -76,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;
@@ -86,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;
@@ -96,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;
@@ -116,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;
@@ -127,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)
@@ -135,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)
@@ -143,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;
@@ -153,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;
@@ -164,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;
@@ -174,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;
@@ -184,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;
@@ -203,23 +234,22 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
         ctx->Unpack.Alignment = param;
         break;
-      case GL_UNPACK_CLIENT_STORAGE_APPLE:
-         if (param == (GLint)ctx->Unpack.ClientStorage)
-            return;
-         FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
-         ctx->Unpack.ClientStorage = param ? GL_TRUE : GL_FALSE;
-         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;
 }
 
 
 void GLAPIENTRY
 _mesa_PixelStoref( GLenum pname, GLfloat param )
 {
-   _mesa_PixelStorei( pname, (GLint) param );
+   _mesa_PixelStorei( pname, IROUND(param) );
 }
 
 
@@ -239,12 +269,9 @@ _mesa_init_pixelstore( struct gl_context *ctx )
    ctx->Pack.SkipImages = 0;
    ctx->Pack.SwapBytes = GL_FALSE;
    ctx->Pack.LsbFirst = GL_FALSE;
-   ctx->Pack.ClientStorage = GL_FALSE;
    ctx->Pack.Invert = GL_FALSE;
-#if FEATURE_EXT_pixel_buffer_object
    _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj,
                                  ctx->Shared->NullBufferObj);
-#endif
    ctx->Unpack.Alignment = 4;
    ctx->Unpack.RowLength = 0;
    ctx->Unpack.ImageHeight = 0;
@@ -253,12 +280,9 @@ _mesa_init_pixelstore( struct gl_context *ctx )
    ctx->Unpack.SkipImages = 0;
    ctx->Unpack.SwapBytes = GL_FALSE;
    ctx->Unpack.LsbFirst = GL_FALSE;
-   ctx->Unpack.ClientStorage = GL_FALSE;
    ctx->Unpack.Invert = GL_FALSE;
-#if FEATURE_EXT_pixel_buffer_object
    _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj,
                                  ctx->Shared->NullBufferObj);
-#endif
 
    /*
     * _mesa_unpack_image() returns image data in this format.  When we
@@ -274,10 +298,7 @@ _mesa_init_pixelstore( struct gl_context *ctx )
    ctx->DefaultPacking.SkipImages = 0;
    ctx->DefaultPacking.SwapBytes = GL_FALSE;
    ctx->DefaultPacking.LsbFirst = GL_FALSE;
-   ctx->DefaultPacking.ClientStorage = GL_FALSE;
    ctx->DefaultPacking.Invert = GL_FALSE;
-#if FEATURE_EXT_pixel_buffer_object
    _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj,
                                  ctx->Shared->NullBufferObj);
-#endif
 }