Bug 924191 - Use MOZ_BEGIN_ENUM_CLASS for the WebGLTexelFormat enum - r=jgilbert
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 11 Oct 2013 09:16:43 -0400
changeset 164282 32cd027a960db4acfc1357818974aab2c530506d
parent 164281 110789fb8722a8fe2988bcba2f55cfb272aea01f
child 164283 447425c70633f8c889425ddc8f4f46443e520f64
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs924191
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924191 - Use MOZ_BEGIN_ENUM_CLASS for the WebGLTexelFormat enum - r=jgilbert
content/canvas/src/WebGLContext.h
content/canvas/src/WebGLContextGL.cpp
content/canvas/src/WebGLTexelConversions.cpp
content/canvas/src/WebGLTexelConversions.h
content/canvas/src/WebGLTypes.h
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -79,18 +79,16 @@ class ImageData;
 struct WebGLContextAttributes;
 template<typename> struct Nullable;
 }
 
 namespace gfx {
 class SourceSurface;
 }
 
-using WebGLTexelConversions::WebGLTexelFormat;
-
 WebGLTexelFormat GetWebGLTexelFormat(GLenum format, GLenum type);
 
 struct WebGLContextOptions {
     // these are defaults
     WebGLContextOptions();
 
     bool operator==(const WebGLContextOptions& other) const {
         return
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -2657,26 +2657,26 @@ WebGLContext::SurfaceFromElementResultTo
 
     gfxImageSurface* surf = static_cast<gfxImageSurface*>(res.mSurface.get());
 
     res.mSurface.forget();
     *imageOut = surf;
 
     switch (surf->Format()) {
         case gfxImageFormatARGB32:
-            *format = WebGLTexelConversions::BGRA8; // careful, our ARGB means BGRA
+            *format = WebGLTexelFormat::BGRA8; // careful, our ARGB means BGRA
             break;
         case gfxImageFormatRGB24:
-            *format = WebGLTexelConversions::BGRX8; // careful, our RGB24 is not tightly packed. Whence BGRX8.
+            *format = WebGLTexelFormat::BGRX8; // careful, our RGB24 is not tightly packed. Whence BGRX8.
             break;
         case gfxImageFormatA8:
-            *format = WebGLTexelConversions::A8;
+            *format = WebGLTexelFormat::A8;
             break;
         case gfxImageFormatRGB16_565:
-            *format = WebGLTexelConversions::RGB565;
+            *format = WebGLTexelFormat::RGB565;
             break;
         default:
             NS_ASSERTION(false, "Unsupported image format. Unimplemented.");
             return NS_ERROR_NOT_IMPLEMENTED;
     }
 
     return NS_OK;
 }
@@ -3749,17 +3749,17 @@ WebGLContext::TexImage2D_base(GLenum tar
         }
     }
 
     uint32_t dstTexelSize = 0;
     if (!ValidateTexFormatAndType(format, type, jsArrayType, &dstTexelSize, "texImage2D"))
         return;
 
     WebGLTexelFormat dstFormat = GetWebGLTexelFormat(format, type);
-    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelConversions::Auto ? dstFormat : srcFormat;
+    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelFormat::Auto ? dstFormat : srcFormat;
 
     uint32_t srcTexelSize = WebGLTexelConversions::TexelBytesForFormat(actualSrcFormat);
 
     CheckedUint32 checked_neededByteLength = 
         GetImageSize(height, width, srcTexelSize, mPixelStoreUnpackAlignment);
 
     CheckedUint32 checked_plainRowSize = CheckedUint32(width) * srcTexelSize;
 
@@ -3847,17 +3847,17 @@ WebGLContext::TexImage2D(GLenum target, 
 {
     if (IsContextLost())
         return;
 
     return TexImage2D_base(target, level, internalformat, width, height, 0, border, format, type,
                            pixels.IsNull() ? 0 : pixels.Value().Data(),
                            pixels.IsNull() ? 0 : pixels.Value().Length(),
                            pixels.IsNull() ? -1 : (int)JS_GetArrayBufferViewType(pixels.Value().Obj()),
-                           WebGLTexelConversions::Auto, false);
+                           WebGLTexelFormat::Auto, false);
 }
 
 void
 WebGLContext::TexImage2D(GLenum target, GLint level,
                          GLenum internalformat, GLenum format,
                          GLenum type, ImageData* pixels, ErrorResult& rv)
 {
     if (IsContextLost())
@@ -3867,17 +3867,17 @@ WebGLContext::TexImage2D(GLenum target, 
         // Spec says to generate an INVALID_VALUE error
         return ErrorInvalidValue("texImage2D: null ImageData");
     }
     
     Uint8ClampedArray arr(pixels->GetDataObject());
     return TexImage2D_base(target, level, internalformat, pixels->Width(),
                            pixels->Height(), 4*pixels->Width(), 0,
                            format, type, arr.Data(), arr.Length(), -1,
-                           WebGLTexelConversions::RGBA8, false);
+                           WebGLTexelFormat::RGBA8, false);
 }
 
 
 void
 WebGLContext::TexSubImage2D_base(GLenum target, GLint level,
                                  GLint xoffset, GLint yoffset,
                                  GLsizei width, GLsizei height, GLsizei srcStrideOrZero,
                                  GLenum format, GLenum type,
@@ -3913,17 +3913,17 @@ WebGLContext::TexSubImage2D_base(GLenum 
         return ErrorInvalidOperation("texSubImage2D: format");
     }
 
     uint32_t dstTexelSize = 0;
     if (!ValidateTexFormatAndType(format, type, jsArrayType, &dstTexelSize, "texSubImage2D"))
         return;
 
     WebGLTexelFormat dstFormat = GetWebGLTexelFormat(format, type);
-    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelConversions::Auto ? dstFormat : srcFormat;
+    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelFormat::Auto ? dstFormat : srcFormat;
 
     uint32_t srcTexelSize = WebGLTexelConversions::TexelBytesForFormat(actualSrcFormat);
 
     if (width == 0 || height == 0)
         return; // ES 2.0 says it has no effect, we better return right now
 
     CheckedUint32 checked_neededByteLength = 
         GetImageSize(height, width, srcTexelSize, mPixelStoreUnpackAlignment);
@@ -4003,17 +4003,17 @@ WebGLContext::TexSubImage2D(GLenum targe
 
     if (pixels.IsNull())
         return ErrorInvalidValue("texSubImage2D: pixels must not be null!");
 
     return TexSubImage2D_base(target, level, xoffset, yoffset,
                               width, height, 0, format, type,
                               pixels.Value().Data(), pixels.Value().Length(),
                               JS_GetArrayBufferViewType(pixels.Value().Obj()),
-                              WebGLTexelConversions::Auto, false);
+                              WebGLTexelFormat::Auto, false);
 }
 
 void
 WebGLContext::TexSubImage2D(GLenum target, GLint level,
                             GLint xoffset, GLint yoffset,
                             GLenum format, GLenum type, ImageData* pixels,
                             ErrorResult& rv)
 {
@@ -4024,17 +4024,17 @@ WebGLContext::TexSubImage2D(GLenum targe
         return ErrorInvalidValue("texSubImage2D: pixels must not be null!");
 
     Uint8ClampedArray arr(pixels->GetDataObject());
     return TexSubImage2D_base(target, level, xoffset, yoffset,
                               pixels->Width(), pixels->Height(),
                               4*pixels->Width(), format, type,
                               arr.Data(), arr.Length(),
                               -1,
-                              WebGLTexelConversions::RGBA8, false);
+                              WebGLTexelFormat::RGBA8, false);
 }
 
 bool
 WebGLContext::LoseContext()
 {
     if (IsContextLost())
         return false;
 
@@ -4128,76 +4128,76 @@ BaseTypeAndSizeFromUniformType(GLenum uT
 
 WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum format, GLenum type)
 {
     //
     // WEBGL_depth_texture
     if (format == LOCAL_GL_DEPTH_COMPONENT) {
         switch (type) {
             case LOCAL_GL_UNSIGNED_SHORT:
-                return WebGLTexelConversions::D16;
+                return WebGLTexelFormat::D16;
             case LOCAL_GL_UNSIGNED_INT:
-                return WebGLTexelConversions::D32;
+                return WebGLTexelFormat::D32;
             default:
                 MOZ_CRASH("Invalid WebGL texture format/type?");
         }
     } else if (format == LOCAL_GL_DEPTH_STENCIL) {
         switch (type) {
             case LOCAL_GL_UNSIGNED_INT_24_8_EXT:
-                return WebGLTexelConversions::D24S8;
+                return WebGLTexelFormat::D24S8;
             default:
                 MOZ_CRASH("Invalid WebGL texture format/type?");
         }
     }
 
 
     if (type == LOCAL_GL_UNSIGNED_BYTE) {
         switch (format) {
             case LOCAL_GL_RGBA:
-                return WebGLTexelConversions::RGBA8;
+                return WebGLTexelFormat::RGBA8;
             case LOCAL_GL_RGB:
-                return WebGLTexelConversions::RGB8;
+                return WebGLTexelFormat::RGB8;
             case LOCAL_GL_ALPHA:
-                return WebGLTexelConversions::A8;
+                return WebGLTexelFormat::A8;
             case LOCAL_GL_LUMINANCE:
-                return WebGLTexelConversions::R8;
+                return WebGLTexelFormat::R8;
             case LOCAL_GL_LUMINANCE_ALPHA:
-                return WebGLTexelConversions::RA8;
+                return WebGLTexelFormat::RA8;
             default:
                 MOZ_ASSERT(false, "Coding mistake?! Should never reach this point.");
-                return WebGLTexelConversions::BadFormat;
+                return WebGLTexelFormat::BadFormat;
         }
     } else if (type == LOCAL_GL_FLOAT) {
         // OES_texture_float
         switch (format) {
             case LOCAL_GL_RGBA:
-                return WebGLTexelConversions::RGBA32F;
+                return WebGLTexelFormat::RGBA32F;
             case LOCAL_GL_RGB:
-                return WebGLTexelConversions::RGB32F;
+                return WebGLTexelFormat::RGB32F;
             case LOCAL_GL_ALPHA:
-                return WebGLTexelConversions::A32F;
+                return WebGLTexelFormat::A32F;
             case LOCAL_GL_LUMINANCE:
-                return WebGLTexelConversions::R32F;
+                return WebGLTexelFormat::R32F;
             case LOCAL_GL_LUMINANCE_ALPHA:
-                return WebGLTexelConversions::RA32F;
+                return WebGLTexelFormat::RA32F;
             default:
                 MOZ_ASSERT(false, "Coding mistake?! Should never reach this point.");
-                return WebGLTexelConversions::BadFormat;
+                return WebGLTexelFormat::BadFormat;
         }
     } else {
         switch (type) {
             case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
-                return WebGLTexelConversions::RGBA4444;
+                return WebGLTexelFormat::RGBA4444;
             case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
-                return WebGLTexelConversions::RGBA5551;
+                return WebGLTexelFormat::RGBA5551;
             case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
-                return WebGLTexelConversions::RGB565;
+                return WebGLTexelFormat::RGB565;
             default:
                 MOZ_ASSERT(false, "Coding mistake?! Should never reach this point.");
-                return WebGLTexelConversions::BadFormat;
+                return WebGLTexelFormat::BadFormat;
         }
     }
 }
 
 GLenum
 InternalFormatForFormatAndType(GLenum format, GLenum type, bool isGLES2)
 {
     // ES2 requires that format == internalformat; floating-point is
--- a/content/canvas/src/WebGLTexelConversions.cpp
+++ b/content/canvas/src/WebGLTexelConversions.cpp
@@ -32,54 +32,54 @@ class WebGLImageConverter
     bool mAlreadyRun;
     bool mSuccess;
 
     /*
      * Returns sizeof(texel)/sizeof(type). The point is that we will iterate over
      * texels with typed pointers and this value will tell us by how much we need
      * to increment these pointers to advance to the next texel.
      */
-    template<int Format>
+    template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format>
     static size_t NumElementsPerTexelForFormat() {
         switch (Format) {
-            case R8:
-            case A8:
-            case R32F:
-            case A32F:
-            case RGBA5551:
-            case RGBA4444:
-            case RGB565:
+            case WebGLTexelFormat::R8:
+            case WebGLTexelFormat::A8:
+            case WebGLTexelFormat::R32F:
+            case WebGLTexelFormat::A32F:
+            case WebGLTexelFormat::RGBA5551:
+            case WebGLTexelFormat::RGBA4444:
+            case WebGLTexelFormat::RGB565:
                 return 1;
-            case RA8:
-            case RA32F:
+            case WebGLTexelFormat::RA8:
+            case WebGLTexelFormat::RA32F:
                 return 2;
-            case RGB8:
-            case RGB32F:
+            case WebGLTexelFormat::RGB8:
+            case WebGLTexelFormat::RGB32F:
                 return 3;
-            case RGBA8:
-            case BGRA8:
-            case BGRX8:
-            case RGBA32F:
+            case WebGLTexelFormat::RGBA8:
+            case WebGLTexelFormat::BGRA8:
+            case WebGLTexelFormat::BGRX8:
+            case WebGLTexelFormat::RGBA32F:
                 return 4;
             default:
                 MOZ_ASSERT(false, "Unknown texel format. Coding mistake?");
                 return 0;
         }
     }
 
     /*
      * This is the completely format-specific templatized conversion function,
      * that will be instantiated hundreds of times for all different combinations.
      * It is important to avoid generating useless code here. In particular, many
      * instantiations of this function template will never be called, so we try
      * to return immediately in these cases to allow the compiler to avoid generating
      * useless code.
      */
-    template<WebGLTexelFormat SrcFormat,
-             WebGLTexelFormat DstFormat,
+    template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) SrcFormat,
+             MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) DstFormat,
              WebGLTexelPremultiplicationOp PremultiplicationOp>
     void run()
     {
         // check for never-called cases. We early-return to allow the compiler
         // to avoid generating this code. It would be tempting to abort() instead,
         // as returning early does leave the destination surface with uninitialized
         // data, but that would not allow the compiler to avoid generating this code.
         // So instead, we return early, so Success() will return false, and the caller
@@ -93,21 +93,21 @@ class WebGLImageConverter
             return;
         }
 
         // Only textures uploaded from DOM elements or ImageData can allow DstFormat != SrcFormat.
         // DOM elements can only give BGRA8, BGRX8, A8, RGB565 formats. See DOMElementToImageSurface.
         // ImageData is always RGBA8. So all other SrcFormat will always satisfy DstFormat==SrcFormat,
         // so we can avoid compiling the code for all the unreachable paths.
         const bool CanSrcFormatComeFromDOMElementOrImageData
-            = SrcFormat == BGRA8 ||
-              SrcFormat == BGRX8 ||
-              SrcFormat == A8 ||
-              SrcFormat == RGB565 ||
-              SrcFormat == RGBA8;
+            = SrcFormat == WebGLTexelFormat::BGRA8 ||
+              SrcFormat == WebGLTexelFormat::BGRX8 ||
+              SrcFormat == WebGLTexelFormat::A8 ||
+              SrcFormat == WebGLTexelFormat::RGB565 ||
+              SrcFormat == WebGLTexelFormat::RGBA8;
         if (!CanSrcFormatComeFromDOMElementOrImageData &&
             SrcFormat != DstFormat)
         {
             return;
         }
 
         // Likewise, only textures uploaded from DOM elements or ImageData can possibly have to be unpremultiplied.
         if (!CanSrcFormatComeFromDOMElementOrImageData &&
@@ -141,19 +141,19 @@ class WebGLImageConverter
 
         typedef
             typename DataTypeForFormat<SrcFormat>::Type
             SrcType;
         typedef
             typename DataTypeForFormat<DstFormat>::Type
             DstType;
 
-        const int IntermediateSrcFormat
+        const MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) IntermediateSrcFormat
             = IntermediateFormat<SrcFormat>::Value;
-        const int IntermediateDstFormat
+        const MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) IntermediateDstFormat
             = IntermediateFormat<DstFormat>::Value;
         typedef
             typename DataTypeForFormat<IntermediateSrcFormat>::Type
             IntermediateSrcType;
         typedef
             typename DataTypeForFormat<IntermediateDstFormat>::Type
             IntermediateDstType;
 
@@ -208,17 +208,18 @@ class WebGLImageConverter
             srcRowStart += srcStrideInElements;
             dstRowStart += dstStrideInElements;
         }
 
         mSuccess = true;
         return;
     }
 
-    template<WebGLTexelFormat SrcFormat, WebGLTexelFormat DstFormat>
+    template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) SrcFormat,
+             MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) DstFormat>
     void run(WebGLTexelPremultiplicationOp premultiplicationOp)
     {
         #define WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(PremultiplicationOp) \
             case PremultiplicationOp: \
                 return run<SrcFormat, DstFormat, PremultiplicationOp>();
 
         switch (premultiplicationOp) {
             WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(NoPremultiplicationOp)
@@ -226,38 +227,38 @@ class WebGLImageConverter
             WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(Unpremultiply)
             default:
                 MOZ_ASSERT(false, "unhandled case. Coding mistake?");
         }
 
         #undef WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP
     }
 
-    template<WebGLTexelFormat SrcFormat>
+    template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) SrcFormat>
     void run(WebGLTexelFormat dstFormat,
              WebGLTexelPremultiplicationOp premultiplicationOp)
     {
         #define WEBGLIMAGECONVERTER_CASE_DSTFORMAT(DstFormat) \
             case DstFormat: \
                 return run<SrcFormat, DstFormat>(premultiplicationOp);
 
         switch (dstFormat) {
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(R8)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(A8)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(R32F)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(A32F)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RA8)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RA32F)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGB8)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGB565)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGB32F)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGBA8)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGBA5551)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGBA4444)
-            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(RGBA32F)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::R8)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::A8)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::R32F)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::A32F)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RA8)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RA32F)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB8)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB565)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB32F)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA8)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA5551)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA4444)
+            WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA32F)
             default:
                 MOZ_ASSERT(false, "unhandled case. Coding mistake?");
         }
 
         #undef WEBGLIMAGECONVERTER_CASE_DSTFORMAT
     }
 
 public:
@@ -266,31 +267,31 @@ public:
              WebGLTexelFormat dstFormat,
              WebGLTexelPremultiplicationOp premultiplicationOp)
     {
         #define WEBGLIMAGECONVERTER_CASE_SRCFORMAT(SrcFormat) \
             case SrcFormat: \
                 return run<SrcFormat>(dstFormat, premultiplicationOp);
 
         switch (srcFormat) {
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(R8)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(A8)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(R32F)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(A32F)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RA8)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RA32F)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGB8)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(BGRX8) // source format only
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGB565)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGB32F)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGBA8)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(BGRA8)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGBA5551)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGBA4444)
-            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(RGBA32F)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::R8)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::A8)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::R32F)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::A32F)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RA8)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RA32F)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGB8)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::BGRX8) // source format only
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGB565)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGB32F)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA8)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::BGRA8)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA5551)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA4444)
+            WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA32F)
             default:
                 MOZ_ASSERT(false, "unhandled case. Coding mistake?");
         }
 
         #undef WEBGLIMAGECONVERTER_CASE_SRCFORMAT
     }
 
     WebGLImageConverter(size_t width, size_t height,
--- a/content/canvas/src/WebGLTexelConversions.h
+++ b/content/canvas/src/WebGLTexelConversions.h
@@ -49,609 +49,619 @@ namespace WebGLTexelConversions {
 
 enum WebGLTexelPremultiplicationOp
 {
     NoPremultiplicationOp,
     Premultiply,
     Unpremultiply
 };
 
-template<int Format>
+// remove this as soon as B2G and Windows use newer compilers
+#ifdef MOZ_HAVE_CXX11_STRONG_ENUMS
+#define MOZ_ENUM_CLASS_INTEGER_TYPE(X) X
+#else
+#define MOZ_ENUM_CLASS_INTEGER_TYPE(X) X::Enum
+#endif
+
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format>
 struct IsFloatFormat
 {
     static const bool Value =
-        Format == RGBA32F ||
-        Format == RGB32F ||
-        Format == RA32F ||
-        Format == R32F ||
-        Format == A32F;
+        Format == WebGLTexelFormat::RGBA32F ||
+        Format == WebGLTexelFormat::RGB32F ||
+        Format == WebGLTexelFormat::RA32F ||
+        Format == WebGLTexelFormat::R32F ||
+        Format == WebGLTexelFormat::A32F;
 };
 
-template<int Format>
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format>
 struct Is16bppFormat
 {
     static const bool Value =
-        Format == RGBA4444 ||
-        Format == RGBA5551 ||
-        Format == RGB565;
+        Format == WebGLTexelFormat::RGBA4444 ||
+        Format == WebGLTexelFormat::RGBA5551 ||
+        Format == WebGLTexelFormat::RGB565;
 };
 
-template<int Format,
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format,
          bool IsFloat = IsFloatFormat<Format>::Value,
          bool Is16bpp = Is16bppFormat<Format>::Value>
 struct DataTypeForFormat
 {
     typedef uint8_t Type;
 };
 
-template<int Format>
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format>
 struct DataTypeForFormat<Format, true, false>
 {
     typedef float Type;
 };
 
-template<int Format>
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format>
 struct DataTypeForFormat<Format, false, true>
 {
     typedef uint16_t Type;
 };
 
-template<int Format>
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format>
 struct IntermediateFormat
 {
-    static const int Value = IsFloatFormat<Format>::Value ? RGBA32F : RGBA8;
+    static const MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Value
+        = IsFloatFormat<Format>::Value
+          ? WebGLTexelFormat::RGBA32F
+          : WebGLTexelFormat::RGBA8;
 };
 
-inline size_t TexelBytesForFormat(int format) {
+inline size_t TexelBytesForFormat(WebGLTexelFormat format) {
     switch (format) {
-        case WebGLTexelConversions::R8:
-        case WebGLTexelConversions::A8:
+        case WebGLTexelFormat::R8:
+        case WebGLTexelFormat::A8:
             return 1;
-        case WebGLTexelConversions::RA8:
-        case WebGLTexelConversions::RGBA5551:
-        case WebGLTexelConversions::RGBA4444:
-        case WebGLTexelConversions::RGB565:
-        case WebGLTexelConversions::D16:
+        case WebGLTexelFormat::RA8:
+        case WebGLTexelFormat::RGBA5551:
+        case WebGLTexelFormat::RGBA4444:
+        case WebGLTexelFormat::RGB565:
+        case WebGLTexelFormat::D16:
             return 2;
-        case WebGLTexelConversions::RGB8:
+        case WebGLTexelFormat::RGB8:
             return 3;
-        case WebGLTexelConversions::RGBA8:
-        case WebGLTexelConversions::BGRA8:
-        case WebGLTexelConversions::BGRX8:
-        case WebGLTexelConversions::R32F:
-        case WebGLTexelConversions::A32F:
-        case WebGLTexelConversions::D32:
-        case WebGLTexelConversions::D24S8:
+        case WebGLTexelFormat::RGBA8:
+        case WebGLTexelFormat::BGRA8:
+        case WebGLTexelFormat::BGRX8:
+        case WebGLTexelFormat::R32F:
+        case WebGLTexelFormat::A32F:
+        case WebGLTexelFormat::D32:
+        case WebGLTexelFormat::D24S8:
             return 4;
-        case WebGLTexelConversions::RA32F:
+        case WebGLTexelFormat::RA32F:
             return 8;
-        case WebGLTexelConversions::RGB32F:
+        case WebGLTexelFormat::RGB32F:
             return 12;
-        case WebGLTexelConversions::RGBA32F:
+        case WebGLTexelFormat::RGBA32F:
             return 16;
         default:
             MOZ_ASSERT(false, "Unknown texel format. Coding mistake?");
             return 0;
     }
 }
 
-FORCE_INLINE bool HasAlpha(int format) {
-    return format == A8 ||
-           format == A32F ||
-           format == RA8 ||
-           format == RA32F ||
-           format == RGBA8 ||
-           format == BGRA8 ||
-           format == RGBA32F ||
-           format == RGBA4444 ||
-           format == RGBA5551;
+FORCE_INLINE bool HasAlpha(WebGLTexelFormat format) {
+    return format == WebGLTexelFormat::A8 ||
+           format == WebGLTexelFormat::A32F ||
+           format == WebGLTexelFormat::RA8 ||
+           format == WebGLTexelFormat::RA32F ||
+           format == WebGLTexelFormat::RGBA8 ||
+           format == WebGLTexelFormat::BGRA8 ||
+           format == WebGLTexelFormat::RGBA32F ||
+           format == WebGLTexelFormat::RGBA4444 ||
+           format == WebGLTexelFormat::RGBA5551;
 }
 
-FORCE_INLINE bool HasColor(int format) {
-    return format == R8 ||
-           format == R32F ||
-           format == RA8 ||
-           format == RA32F ||
-           format == RGB8 ||
-           format == BGRX8 ||
-           format == RGB565 ||
-           format == RGB32F ||
-           format == RGBA8 ||
-           format == BGRA8 ||
-           format == RGBA32F ||
-           format == RGBA4444 ||
-           format == RGBA5551;
+FORCE_INLINE bool HasColor(WebGLTexelFormat format) {
+    return format == WebGLTexelFormat::R8 ||
+           format == WebGLTexelFormat::R32F ||
+           format == WebGLTexelFormat::RA8 ||
+           format == WebGLTexelFormat::RA32F ||
+           format == WebGLTexelFormat::RGB8 ||
+           format == WebGLTexelFormat::BGRX8 ||
+           format == WebGLTexelFormat::RGB565 ||
+           format == WebGLTexelFormat::RGB32F ||
+           format == WebGLTexelFormat::RGBA8 ||
+           format == WebGLTexelFormat::BGRA8 ||
+           format == WebGLTexelFormat::RGBA32F ||
+           format == WebGLTexelFormat::RGBA4444 ||
+           format == WebGLTexelFormat::RGBA5551;
 }
 
 
 /****** BEGIN CODE SHARED WITH WEBKIT ******/
 
 // the pack/unpack functions here are originally from this file:
 //   http://trac.webkit.org/browser/trunk/WebCore/platform/graphics/GraphicsContext3D.cpp
 
 //----------------------------------------------------------------------
 // Pixel unpacking routines.
 
-template<int Format, typename SrcType, typename DstType>
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format, typename SrcType, typename DstType>
 FORCE_INLINE void
 unpack(const SrcType* __restrict src,
        DstType* __restrict dst)
 {
     MOZ_ASSERT(false, "Unimplemented texture format conversion");
 }
 
 template<> FORCE_INLINE void
-unpack<RGBA8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::RGBA8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
     dst[3] = src[3];
 }
 
 template<> FORCE_INLINE void
-unpack<RGB8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::RGB8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
     dst[3] = 0xFF;
 }
 
 template<> FORCE_INLINE void
-unpack<BGRA8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::BGRA8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[2];
     dst[1] = src[1];
     dst[2] = src[0];
     dst[3] = src[3];
 }
 
 template<> FORCE_INLINE void
-unpack<BGRX8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::BGRX8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[2];
     dst[1] = src[1];
     dst[2] = src[0];
     dst[3] = 0xFF;
 }
 
 template<> FORCE_INLINE void
-unpack<RGBA5551, uint16_t, uint8_t>(const uint16_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::RGBA5551, uint16_t, uint8_t>(const uint16_t* __restrict src, uint8_t* __restrict dst)
 {
     uint16_t packedValue = src[0];
     uint8_t r = (packedValue >> 11) & 0x1F;
     uint8_t g = (packedValue >> 6) & 0x1F;
     uint8_t b = (packedValue >> 1) & 0x1F;
     dst[0] = (r << 3) | (r & 0x7);
     dst[1] = (g << 3) | (g & 0x7);
     dst[2] = (b << 3) | (b & 0x7);
     dst[3] = (packedValue & 0x1) ? 0xFF : 0;
 }
 
 template<> FORCE_INLINE void
-unpack<RGBA4444, uint16_t, uint8_t>(const uint16_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::RGBA4444, uint16_t, uint8_t>(const uint16_t* __restrict src, uint8_t* __restrict dst)
 {
     uint16_t packedValue = src[0];
     uint8_t r = (packedValue >> 12) & 0x0F;
     uint8_t g = (packedValue >> 8) & 0x0F;
     uint8_t b = (packedValue >> 4) & 0x0F;
     uint8_t a = packedValue & 0x0F;
     dst[0] = (r << 4) | r;
     dst[1] = (g << 4) | g;
     dst[2] = (b << 4) | b;
     dst[3] = (a << 4) | a;
 }
 
 template<> FORCE_INLINE void
-unpack<RGB565, uint16_t, uint8_t>(const uint16_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::RGB565, uint16_t, uint8_t>(const uint16_t* __restrict src, uint8_t* __restrict dst)
 {
     uint16_t packedValue = src[0];
     uint8_t r = (packedValue >> 11) & 0x1F;
     uint8_t g = (packedValue >> 5) & 0x3F;
     uint8_t b = packedValue & 0x1F;
     dst[0] = (r << 3) | (r & 0x7);
     dst[1] = (g << 2) | (g & 0x3);
     dst[2] = (b << 3) | (b & 0x7);
     dst[3] = 0xFF;
 }
 
 template<> FORCE_INLINE void
-unpack<R8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::R8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[0];
     dst[2] = src[0];
     dst[3] = 0xFF;
 }
 
 template<> FORCE_INLINE void
-unpack<RA8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::RA8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[0];
     dst[2] = src[0];
     dst[3] = src[1];
 }
 
 template<> FORCE_INLINE void
-unpack<A8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+unpack<WebGLTexelFormat::A8, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = 0;
     dst[1] = 0;
     dst[2] = 0;
     dst[3] = src[0];
 }
 
 template<> FORCE_INLINE void
-unpack<RGBA32F, float, float>(const float* __restrict src, float* __restrict dst)
+unpack<WebGLTexelFormat::RGBA32F, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
     dst[3] = src[3];
 }
 
 template<> FORCE_INLINE void
-unpack<RGB32F, float, float>(const float* __restrict src, float* __restrict dst)
+unpack<WebGLTexelFormat::RGB32F, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
     dst[3] = 1.0f;
 }
 
 template<> FORCE_INLINE void
-unpack<R32F, float, float>(const float* __restrict src, float* __restrict dst)
+unpack<WebGLTexelFormat::R32F, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[0];
     dst[2] = src[0];
     dst[3] = 1.0f;
 }
 
 template<> FORCE_INLINE void
-unpack<RA32F, float, float>(const float* __restrict src, float* __restrict dst)
+unpack<WebGLTexelFormat::RA32F, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[0];
     dst[2] = src[0];
     dst[3] = src[1];
 }
 
 template<> FORCE_INLINE void
-unpack<A32F, float, float>(const float* __restrict src, float* __restrict dst)
+unpack<WebGLTexelFormat::A32F, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = 0;
     dst[1] = 0;
     dst[2] = 0;
     dst[3] = src[0];
 }
 
 //----------------------------------------------------------------------
 // Pixel packing routines.
 //
 
-template<int Format, int PremultiplicationOp, typename SrcType, typename DstType>
+template<MOZ_ENUM_CLASS_INTEGER_TYPE(WebGLTexelFormat) Format, int PremultiplicationOp, typename SrcType, typename DstType>
 FORCE_INLINE void
 pack(const SrcType* __restrict src,
      DstType* __restrict dst)
 {
     MOZ_ASSERT(false, "Unimplemented texture format conversion");
 }
 
 template<> FORCE_INLINE void
-pack<A8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::A8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<A8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::A8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<A8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::A8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<R8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::R8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
 }
 
 template<> FORCE_INLINE void
-pack<R8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::R8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] / 255.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     dst[0] = srcR;
 }
 
 template<> FORCE_INLINE void
-pack<R8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::R8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     dst[0] = srcR;
 }
 
 template<> FORCE_INLINE void
-pack<RA8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RA8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<RA8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RA8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] / 255.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     dst[0] = srcR;
     dst[1] = src[3];
 }
 
 // FIXME: this routine is lossy and must be removed.
 template<> FORCE_INLINE void
-pack<RA8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RA8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     dst[0] = srcR;
     dst[1] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<RGB8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RGB8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
 }
 
 template<> FORCE_INLINE void
-pack<RGB8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RGB8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] / 255.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     dst[0] = srcR;
     dst[1] = srcG;
     dst[2] = srcB;
 }
 
 template<> FORCE_INLINE void
-pack<RGB8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RGB8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     dst[0] = srcR;
     dst[1] = srcG;
     dst[2] = srcB;
 }
 
 template<> FORCE_INLINE void
-pack<RGBA8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA8, NoPremultiplicationOp, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
     dst[3] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<RGBA8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA8, Premultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] / 255.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     dst[0] = srcR;
     dst[1] = srcG;
     dst[2] = srcB;
     dst[3] = src[3];
 }
 
 // FIXME: this routine is lossy and must be removed.
 template<> FORCE_INLINE void
-pack<RGBA8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA8, Unpremultiply, uint8_t, uint8_t>(const uint8_t* __restrict src, uint8_t* __restrict dst)
 {
     float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     dst[0] = srcR;
     dst[1] = srcG;
     dst[2] = srcB;
     dst[3] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<RGBA4444, NoPremultiplicationOp, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA4444, NoPremultiplicationOp, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     *dst = ( ((src[0] & 0xF0) << 8)
            | ((src[1] & 0xF0) << 4)
            | (src[2] & 0xF0)
            | (src[3] >> 4) );
 }
 
 template<> FORCE_INLINE void
-pack<RGBA4444, Premultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA4444, Premultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     float scaleFactor = src[3] / 255.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     *dst = ( ((srcR & 0xF0) << 8)
            | ((srcG & 0xF0) << 4)
            | (srcB & 0xF0)
            | (src[3] >> 4));
 }
 
 // FIXME: this routine is lossy and must be removed.
 template<> FORCE_INLINE void
-pack<RGBA4444, Unpremultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA4444, Unpremultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     *dst = ( ((srcR & 0xF0) << 8)
            | ((srcG & 0xF0) << 4)
            | (srcB & 0xF0)
            | (src[3] >> 4));
 }
 
 template<> FORCE_INLINE void
-pack<RGBA5551, NoPremultiplicationOp, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA5551, NoPremultiplicationOp, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     *dst = ( ((src[0] & 0xF8) << 8)
            | ((src[1] & 0xF8) << 3)
            | ((src[2] & 0xF8) >> 2)
            | (src[3] >> 7));
 }
 
 template<> FORCE_INLINE void
-pack<RGBA5551, Premultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA5551, Premultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     float scaleFactor = src[3] / 255.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     *dst = ( ((srcR & 0xF8) << 8)
            | ((srcG & 0xF8) << 3)
            | ((srcB & 0xF8) >> 2)
            | (src[3] >> 7));
 }
 
 // FIXME: this routine is lossy and must be removed.
 template<> FORCE_INLINE void
-pack<RGBA5551, Unpremultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGBA5551, Unpremultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     *dst = ( ((srcR & 0xF8) << 8)
            | ((srcG & 0xF8) << 3)
            | ((srcB & 0xF8) >> 2)
            | (src[3] >> 7));
 }
 
 template<> FORCE_INLINE void
-pack<RGB565, NoPremultiplicationOp, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGB565, NoPremultiplicationOp, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     *dst = ( ((src[0] & 0xF8) << 8)
            | ((src[1] & 0xFC) << 3)
            | ((src[2] & 0xF8) >> 3));
 }
 
 template<> FORCE_INLINE void
-pack<RGB565, Premultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGB565, Premultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     float scaleFactor = src[3] / 255.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     *dst = ( ((srcR & 0xF8) << 8)
            | ((srcG & 0xFC) << 3)
            | ((srcB & 0xF8) >> 3));
 }
 
 // FIXME: this routine is lossy and must be removed.
 template<> FORCE_INLINE void
-pack<RGB565, Unpremultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
+pack<WebGLTexelFormat::RGB565, Unpremultiply, uint8_t, uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst)
 {
     float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f;
     uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
     uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
     uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
     *dst = ( ((srcR & 0xF8) << 8)
            | ((srcG & 0xFC) << 3)
            | ((srcB & 0xF8) >> 3));
 }
 
 template<> FORCE_INLINE void
-pack<RGB32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::RGB32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
 }
 
 template<> FORCE_INLINE void
-pack<RGB32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::RGB32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
 {
     float scaleFactor = src[3];
     dst[0] = src[0] * scaleFactor;
     dst[1] = src[1] * scaleFactor;
     dst[2] = src[2] * scaleFactor;
 }
 
 template<> FORCE_INLINE void
-pack<RGBA32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::RGBA32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[1];
     dst[2] = src[2];
     dst[3] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<RGBA32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::RGBA32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
 {
     float scaleFactor = src[3];
     dst[0] = src[0] * scaleFactor;
     dst[1] = src[1] * scaleFactor;
     dst[2] = src[2] * scaleFactor;
     dst[3] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<A32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::A32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<A32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::A32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<R32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::R32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
 }
 
 template<> FORCE_INLINE void
-pack<R32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::R32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
 {
     float scaleFactor = src[3];
     dst[0] = src[0] * scaleFactor;
 }
 
 template<> FORCE_INLINE void
-pack<RA32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::RA32F, NoPremultiplicationOp, float, float>(const float* __restrict src, float* __restrict dst)
 {
     dst[0] = src[0];
     dst[1] = src[3];
 }
 
 template<> FORCE_INLINE void
-pack<RA32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
+pack<WebGLTexelFormat::RA32F, Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
 {
     float scaleFactor = src[3];
     dst[0] = src[0] * scaleFactor;
     dst[1] = scaleFactor;
 }
 
 /****** END CODE SHARED WITH WEBKIT ******/
 
--- a/content/canvas/src/WebGLTypes.h
+++ b/content/canvas/src/WebGLTypes.h
@@ -82,28 +82,25 @@ MOZ_END_ENUM_CLASS(WebGLVertexAttrib0Sta
  *   and it is the state that texture images are in after a texImage2D call with null data.
  */
 MOZ_BEGIN_ENUM_CLASS(WebGLImageDataStatus, int)
     NoImageData,
     UninitializedImageData,
     InitializedImageData
 MOZ_END_ENUM_CLASS(WebGLImageDataStatus)
 
-namespace WebGLTexelConversions {
-
 /*
  * The formats that may participate, either as source or destination formats,
  * in WebGL texture conversions. This includes:
  *  - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444
  *  - additional formats provided by extensions, e.g. RGB32F
  *  - additional source formats, depending on browser details, used when uploading
  *    textures from DOM elements. See gfxImageSurface::Format().
  */
-enum WebGLTexelFormat
-{
+MOZ_BEGIN_ENUM_CLASS(WebGLTexelFormat, int)
     // dummy error code returned by GetWebGLTexelFormat in error cases,
     // after assertion failure (so this never happens in debug builds)
     BadFormat,
     // dummy pseudo-format meaning "use the other format".
     // For example, if SrcFormat=Auto and DstFormat=RGB8, then the source
     // is implicitly treated as being RGB8 itself.
     Auto,
     // 1-channel formats
@@ -123,15 +120,13 @@ enum WebGLTexelFormat
     RGB565,
     RGB32F, // used for OES_texture_float extension
     // 4-channel formats
     RGBA8,
     BGRA8, // used for DOM elements
     RGBA5551,
     RGBA4444,
     RGBA32F // used for OES_texture_float extension
-};
-
-} // end namespace WebGLTexelConversions
+MOZ_END_ENUM_CLASS(WebGLTexelFormat)
 
 } // namespace mozilla
 
 #endif