Bug 1075305 - WebGL2 - convert BaseTexFormat() to use strong GL types.; r=bjacob
authorDan Glastonbury <dglastonbury@mozilla.com>
Tue, 30 Sep 2014 14:03:29 +1000
changeset 208812 138e0dba47e8bf8ca972d3ff59628cd41b54509f
parent 208811 08943f32886a07c5500bd8bf269663c658a52c77
child 208813 4fe8ca5b1c15709ccfe573d3d472e129b441dec4
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbjacob
bugs1075305
milestone35.0a1
Bug 1075305 - WebGL2 - convert BaseTexFormat() to use strong GL types.; r=bjacob
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextValidate.cpp
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1068,17 +1068,17 @@ protected:
 
     virtual bool IsWebGL2() const = 0;
 
     bool InitWebGL2();
 
 
     // -------------------------------------------------------------------------
     // Validation functions (implemented in WebGLContextValidate.cpp)
-    GLenum BaseTexFormat(GLenum internalFormat) const;
+    TexFormat BaseTexFormat(TexInternalFormat internalFormat) const;
 
     bool CreateOffscreenGL(bool forceEnabled);
     bool InitAndValidateGL();
     bool ResizeBackbuffer(uint32_t width, uint32_t height);
     bool ValidateBlendEquationEnum(GLenum cap, const char *info);
     bool ValidateBlendFuncDstEnum(GLenum mode, const char *info);
     bool ValidateBlendFuncSrcEnum(GLenum mode, const char *info);
     bool ValidateBlendFuncEnumsCompatibility(GLenum sfactor, GLenum dfactor, const char *info);
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -243,90 +243,90 @@ WebGLProgram::UpdateInfo()
 }
 
 /**
  * Return the simple base format for a given internal format.
  *
  * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE,
  * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA), or GL_NONE if invalid enum.
  */
-GLenum
-WebGLContext::BaseTexFormat(GLenum internalFormat) const
+TexFormat
+WebGLContext::BaseTexFormat(TexInternalFormat internalFormat) const
 {
     if (internalFormat == LOCAL_GL_ALPHA ||
         internalFormat == LOCAL_GL_LUMINANCE ||
         internalFormat == LOCAL_GL_LUMINANCE_ALPHA ||
         internalFormat == LOCAL_GL_RGB ||
         internalFormat == LOCAL_GL_RGBA)
     {
-        return internalFormat;
+        return TexFormat(internalFormat.get());
     }
 
     if (IsExtensionEnabled(WebGLExtensionID::EXT_sRGB)) {
         if (internalFormat == LOCAL_GL_SRGB)
-            return LOCAL_GL_RGB;
+            return TexFormat(LOCAL_GL_RGB);
 
         if (internalFormat == LOCAL_GL_SRGB_ALPHA)
-            return LOCAL_GL_RGBA;
+            return TexFormat(LOCAL_GL_RGBA);
     }
 
     if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_atc)) {
         if (internalFormat == LOCAL_GL_ATC_RGB)
-            return LOCAL_GL_RGB;
+            return TexFormat(LOCAL_GL_RGB);
 
         if (internalFormat == LOCAL_GL_ATC_RGBA_EXPLICIT_ALPHA ||
             internalFormat == LOCAL_GL_ATC_RGBA_INTERPOLATED_ALPHA)
         {
-            return LOCAL_GL_RGBA;
+            return TexFormat(LOCAL_GL_RGBA);
         }
     }
 
     if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_etc1)) {
         if (internalFormat == LOCAL_GL_ETC1_RGB8_OES)
-            return LOCAL_GL_RGB;
+            return TexFormat(LOCAL_GL_RGB);
     }
 
     if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_pvrtc)) {
         if (internalFormat == LOCAL_GL_COMPRESSED_RGB_PVRTC_2BPPV1 ||
             internalFormat == LOCAL_GL_COMPRESSED_RGB_PVRTC_4BPPV1)
         {
-            return LOCAL_GL_RGB;
+            return TexFormat(LOCAL_GL_RGB);
         }
 
         if (internalFormat == LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1 ||
             internalFormat == LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1)
         {
-            return LOCAL_GL_RGBA;
+            return TexFormat(LOCAL_GL_RGBA);
         }
     }
 
     if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_s3tc)) {
         if (internalFormat == LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
-            return LOCAL_GL_RGB;
+            return TexFormat(LOCAL_GL_RGB);
 
         if (internalFormat == LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
             internalFormat == LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||
             internalFormat == LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
         {
-            return LOCAL_GL_RGBA;
+            return TexFormat(LOCAL_GL_RGBA);
         }
     }
 
     if (IsExtensionEnabled(WebGLExtensionID::WEBGL_depth_texture)) {
         if (internalFormat == LOCAL_GL_DEPTH_COMPONENT ||
             internalFormat == LOCAL_GL_DEPTH_COMPONENT16 ||
             internalFormat == LOCAL_GL_DEPTH_COMPONENT32)
         {
-            return LOCAL_GL_DEPTH_COMPONENT;
+            return TexFormat(LOCAL_GL_DEPTH_COMPONENT);
         }
 
         if (internalFormat == LOCAL_GL_DEPTH_STENCIL ||
             internalFormat == LOCAL_GL_DEPTH24_STENCIL8)
         {
-            return LOCAL_GL_DEPTH_STENCIL;
+            return TexFormat(LOCAL_GL_DEPTH_STENCIL);
         }
     }
 
     MOZ_ASSERT(false, "Unhandled internalFormat");
     return LOCAL_GL_NONE;
 }
 
 bool WebGLContext::ValidateBlendEquationEnum(GLenum mode, const char *info)