Bug 959380 - 2/5 - Make gfxImageFormat a typed enum - r=jrmuizel
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 23 Jan 2014 13:26:40 -0500
changeset 180947 cfecc1e799529437cf2657d0d0ff87617d6ef6df
parent 180946 52be855fdf89457c4ea1ba3e50af83752e99baea
child 180948 14829d658500244b55a1df02ed6b182f45d65237
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs959380
milestone29.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 959380 - 2/5 - Make gfxImageFormat a typed enum - r=jrmuizel find . -type f | grep -v \./obj | grep -v \.hg | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)gfxImageFormat\(ARGB32\|RGB24\|A8\|A1\|RGB16_565\|Unknown\)\($\|[^A-Za-z0-9_]\)/\1gfxImageFormat::\2\3/g'
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/DocumentRendererChild.cpp
content/canvas/src/DocumentRendererParent.cpp
content/canvas/src/ImageEncoder.cpp
content/canvas/src/WebGLContext.cpp
content/media/plugins/MediaPluginReader.cpp
content/media/webrtc/MediaEngineTabVideoSource.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
gfx/2d/FilterNodeSoftware.cpp
gfx/gl/GLReadTexImageHelper.cpp
gfx/gl/GLReadTexImageHelper.h
gfx/gl/GLScreenBuffer.cpp
gfx/gl/GLTextureImage.cpp
gfx/gl/GLTextureImage.h
gfx/gl/GLUploadHelpers.cpp
gfx/gl/TextureImageCGL.h
gfx/gl/TextureImageEGL.cpp
gfx/gl/TextureImageEGL.h
gfx/ipc/GfxMessageUtils.h
gfx/ipc/SharedDIBSurface.cpp
gfx/layers/CopyableCanvasLayer.cpp
gfx/layers/D3D9SurfaceImage.cpp
gfx/layers/GrallocImages.cpp
gfx/layers/ImageContainer.cpp
gfx/layers/Layers.cpp
gfx/layers/MacIOSurfaceImage.h
gfx/layers/basic/BasicLayerManager.cpp
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d10/ImageLayerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d10/ReadbackManagerD3D10.cpp
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/d3d9/ImageLayerD3D9.cpp
gfx/layers/d3d9/LayerManagerD3D9.cpp
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/d3d9/ThebesLayerD3D9.cpp
gfx/layers/ipc/ISurfaceAllocator.cpp
gfx/layers/ipc/LayersSurfaces.ipdlh
gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/ipc/SharedRGBImage.cpp
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/TextureHostOGL.cpp
gfx/tests/gtest/TestTextures.cpp
gfx/tests/gtest/gfxFontSelectionTest.cpp
gfx/tests/gtest/gfxSurfaceRefCountTest.cpp
gfx/tests/gtest/gfxTextRunPerfTest.cpp
gfx/tests/gtest/gfxWordCacheTest.cpp
gfx/thebes/gfx2DGlue.h
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxAlphaRecovery.cpp
gfx/thebes/gfxAlphaRecoverySSE2.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxBaseSharedMemorySurface.h
gfx/thebes/gfxBlur.cpp
gfx/thebes/gfxD2DSurface.cpp
gfx/thebes/gfxD2DSurface.h
gfx/thebes/gfxImageSurface.cpp
gfx/thebes/gfxOS2Platform.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxQtPlatform.cpp
gfx/thebes/gfxQuartzNativeDrawing.cpp
gfx/thebes/gfxTypes.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
gfx/thebes/gfxWindowsNativeDrawing.cpp
gfx/thebes/gfxWindowsSurface.cpp
gfx/thebes/gfxWindowsSurface.h
gfx/thebes/gfxXlibNativeRenderer.cpp
gfx/thebes/gfxXlibSurface.cpp
gfx/ycbcr/YCbCrUtils.cpp
image/decoders/nsGIFDecoder2.cpp
image/decoders/nsPNGDecoder.cpp
image/src/ClippedImage.cpp
image/src/FrameBlender.cpp
image/src/OrientedImage.cpp
image/src/RasterImage.cpp
image/src/VectorImage.cpp
image/src/imgFrame.cpp
image/src/imgTools.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsPresShell.cpp
layout/svg/nsSVGMaskFrame.cpp
widget/android/AndroidBridge.cpp
widget/android/AndroidGraphicBuffer.cpp
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaUtils.mm
widget/cocoa/nsDeviceContextSpecX.mm
widget/cocoa/nsDragService.mm
widget/gonk/Framebuffer.cpp
widget/gonk/nsWindow.cpp
widget/gtk/nsImageToPixbuf.cpp
widget/gtk/nsWindow.cpp
widget/os2/nsWindow.cpp
widget/qt/nsClipboard.cpp
widget/qt/nsNativeThemeQt.cpp
widget/qt/nsWindow.cpp
widget/shared/nsShmImage.cpp
widget/windows/TaskbarPreview.cpp
widget/windows/WinUtils.cpp
widget/windows/nsDragService.cpp
widget/windows/nsImageClipboard.cpp
widget/windows/nsWindow.cpp
widget/windows/nsWindowGfx.cpp
widget/xpwidgets/PuppetWidget.cpp
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -3896,17 +3896,17 @@ CanvasRenderingContext2D::PutImageData_e
   }
 
   uint32_t len = w * h * 4;
   if (aDataLen != len) {
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
 
   nsRefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfxIntSize(w, h),
-                                                          gfxImageFormatARGB32,
+                                                          gfxImageFormat::ARGB32,
                                                           false);
   if (!imgsurf || imgsurf->CairoStatus()) {
     return NS_ERROR_FAILURE;
   }
 
   uint8_t *src = aData;
   uint8_t *dst = imgsurf->Data();
 
--- a/content/canvas/src/DocumentRendererChild.cpp
+++ b/content/canvas/src/DocumentRendererChild.cpp
@@ -71,17 +71,17 @@ DocumentRendererChild::RenderDocument(ns
 
     // Draw directly into the output array.
     data.SetLength(renderSize.width * renderSize.height * 4);
 
     nsRefPtr<gfxImageSurface> surf =
         new gfxImageSurface(reinterpret_cast<uint8_t*>(data.BeginWriting()),
                             gfxIntSize(renderSize.width, renderSize.height),
                             4 * renderSize.width,
-                            gfxImageFormatARGB32);
+                            gfxImageFormat::ARGB32);
     nsRefPtr<gfxContext> ctx = new gfxContext(surf);
     ctx->SetMatrix(mozilla::gfx::ThebesMatrix(transform));
 
     nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
     shell->RenderDocument(documentRect, renderFlags, bgColor, ctx);
 
     return true;
 }
--- a/content/canvas/src/DocumentRendererParent.cpp
+++ b/content/canvas/src/DocumentRendererParent.cpp
@@ -27,17 +27,17 @@ void DocumentRendererParent::DrawToCanva
 {
     if (!mCanvas || !mCanvasContext)
         return;
 
     nsRefPtr<gfxImageSurface> surf =
         new gfxImageSurface(reinterpret_cast<uint8_t*>(const_cast<nsCString&>(aData).BeginWriting()),
                             gfxIntSize(aSize.width, aSize.height),
                             aSize.width * 4,
-                            gfxImageFormatARGB32);
+                            gfxImageFormat::ARGB32);
     nsRefPtr<gfxPattern> pat = new gfxPattern(surf);
 
     gfxRect rect(gfxPoint(0, 0), gfxSize(aSize.width, aSize.height));
     mCanvasContext->NewPath();
     mCanvasContext->PixelSnappedRectangleAndSetPattern(rect, pat);
     mCanvasContext->Fill();
 
     // get rid of the pattern surface ref, because aData is very
--- a/content/canvas/src/ImageEncoder.cpp
+++ b/content/canvas/src/ImageEncoder.cpp
@@ -279,17 +279,17 @@ ImageEncoder::ExtractDataInternal(const 
                                   getter_AddRefs(imgStream));
   } else {
     // no context, so we have to encode an empty image
     // note that if we didn't have a current context, the spec says we're
     // supposed to just return transparent black pixels of the canvas
     // dimensions.
     nsRefPtr<gfxImageSurface> emptyCanvas =
       new gfxImageSurface(gfxIntSize(aSize.width, aSize.height),
-                          gfxImageFormatARGB32);
+                          gfxImageFormat::ARGB32);
     if (emptyCanvas->CairoStatus()) {
       return NS_ERROR_INVALID_ARG;
     }
     rv = aEncoder->InitFromData(emptyCanvas->Data(),
                                 aSize.width * aSize.height * 4,
                                 aSize.width,
                                 aSize.height,
                                 aSize.width * 4,
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -616,17 +616,17 @@ WebGLContext::SetDimensions(int32_t widt
 
 NS_IMETHODIMP
 WebGLContext::Render(gfxContext *ctx, GraphicsFilter f, uint32_t aFlags)
 {
     if (!gl)
         return NS_OK;
 
     nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(gfxIntSize(mWidth, mHeight),
-                                                         gfxImageFormatARGB32);
+                                                         gfxImageFormat::ARGB32);
     if (surf->CairoStatus() != 0)
         return NS_ERROR_FAILURE;
 
     gl->MakeCurrent();
     ReadScreenIntoImageSurface(gl, surf);
 
     bool srcPremultAlpha = mOptions.premultipliedAlpha;
     bool dstPremultAlpha = aFlags & RenderFlagPremultAlpha;
@@ -744,17 +744,17 @@ void WebGLContext::LoseOldestWebGLContex
 void
 WebGLContext::GetImageBuffer(uint8_t** aImageBuffer, int32_t* aFormat)
 {
     *aImageBuffer = nullptr;
     *aFormat = 0;
 
     nsRefPtr<gfxImageSurface> imgsurf =
         new gfxImageSurface(gfxIntSize(mWidth, mHeight),
-                            gfxImageFormatARGB32);
+                            gfxImageFormat::ARGB32);
 
     if (!imgsurf || imgsurf->CairoStatus()) {
         return;
     }
 
     nsRefPtr<gfxContext> ctx = new gfxContext(imgsurf);
     if (!ctx || ctx->HasError()) {
         return;
--- a/content/media/plugins/MediaPluginReader.cpp
+++ b/content/media/plugins/MediaPluginReader.cpp
@@ -348,17 +348,17 @@ MediaPluginReader::ImageBufferCallback::
     return nullptr;
   }
 
   nsRefPtr<Image> image;
   switch(aColorFormat) {
     case MPAPI::RGB565:
       image = mozilla::layers::CreateSharedRGBImage(mImageContainer,
                                                     nsIntSize(aWidth, aHeight),
-                                                    gfxImageFormatRGB16_565);
+                                                    gfxImageFormat::RGB16_565);
       if (!image) {
         NS_WARNING("Could not create rgb image");
         return nullptr;
       }
 
       mImage = image;
       return image->AsSharedImage()->GetBuffer();
     case MPAPI::I420:
--- a/content/media/webrtc/MediaEngineTabVideoSource.cpp
+++ b/content/media/webrtc/MediaEngineTabVideoSource.cpp
@@ -233,17 +233,17 @@ MediaEngineTabVideoSource::Draw() {
   nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
   uint32_t renderDocFlags = (nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
                              nsIPresShell::RENDER_DOCUMENT_RELATIVE);
   nsRect r(nsPresContext::CSSPixelsToAppUnits(srcX / scale),
            nsPresContext::CSSPixelsToAppUnits(srcY / scale),
            nsPresContext::CSSPixelsToAppUnits(srcW / scale),
            nsPresContext::CSSPixelsToAppUnits(srcH / scale));
 
-  gfxImageFormat format = gfxImageFormatRGB24;
+  gfxImageFormat format = gfxImageFormat::RGB24;
   uint32_t stride = gfxASurface::FormatStrideForWidth(format, size.width);
 
   nsRefPtr<layers::ImageContainer> container = layers::LayerManager::CreateImageContainer();
   nsRefPtr<gfxASurface> surf;
   surf = new gfxImageSurface(static_cast<unsigned char*>(mData),
                              ThebesIntSize(size), stride, format);
   if (surf->CairoStatus() != 0) {
     return;
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -2502,17 +2502,17 @@ void nsPluginInstanceOwner::Paint(gfxCon
 #ifdef ANP_BITMAP_DRAWING_MODEL
   static nsRefPtr<gfxImageSurface> pluginSurface;
 
   if (pluginSurface == nullptr ||
       aFrameRect.width  != pluginSurface->Width() ||
       aFrameRect.height != pluginSurface->Height()) {
 
     pluginSurface = new gfxImageSurface(gfxIntSize(aFrameRect.width, aFrameRect.height), 
-                                        gfxImageFormatARGB32);
+                                        gfxImageFormat::ARGB32);
     if (!pluginSurface)
       return;
   }
 
   // Clears buffer.  I think this is needed.
   nsRefPtr<gfxContext> ctx = new gfxContext(pluginSurface);
   ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
   ctx->Paint();
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -2776,25 +2776,25 @@ PluginInstanceChild::CreateOptSurface(vo
     NS_ABORT_IF_FALSE(mSurfaceType != gfxSurfaceTypeMax,
                       "Need a valid surface type here");
     NS_ASSERTION(!mCurrentSurface, "mCurrentSurfaceActor can get out of sync.");
 
     nsRefPtr<gfxASurface> retsurf;
     // Use an opaque surface unless we're transparent and *don't* have
     // a background to source from.
     gfxImageFormat format =
-        (mIsTransparent && !mBackground) ? gfxImageFormatARGB32 :
-                                           gfxImageFormatRGB24;
+        (mIsTransparent && !mBackground) ? gfxImageFormat::ARGB32 :
+                                           gfxImageFormat::RGB24;
 
 #ifdef MOZ_X11
     Display* dpy = mWsInfo.display;
     Screen* screen = DefaultScreenOfDisplay(dpy);
-    if (format == gfxImageFormatRGB24 &&
+    if (format == gfxImageFormat::RGB24 &&
         DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
-        format = gfxImageFormatRGB16_565;
+        format = gfxImageFormat::RGB16_565;
     }
 
     if (mSurfaceType == gfxSurfaceTypeXlib) {
         if (!mIsTransparent  || mBackground) {
             Visual* defaultVisual = DefaultVisualOfScreen(screen);
             mCurrentSurface =
                 gfxXlibSurface::Create(screen, defaultVisual,
                                        gfxIntSize(mWindow.width,
@@ -3207,17 +3207,17 @@ PluginInstanceChild::PaintRectWithAlphaE
     // If |aSurface| can be used to paint and can have alpha values
     // recovered directly to it, do that to save a tmp surface and
     // copy.
     bool useSurfaceSubimageForBlack = false;
     if (gfxSurfaceTypeImage == aSurface->GetType()) {
         gfxImageSurface* surfaceAsImage =
             static_cast<gfxImageSurface*>(aSurface);
         useSurfaceSubimageForBlack =
-            (surfaceAsImage->Format() == gfxImageFormatARGB32);
+            (surfaceAsImage->Format() == gfxImageFormat::ARGB32);
         // If we're going to use a subimage, nudge the rect so that we
         // can use optimal alpha recovery.  If we're not using a
         // subimage, the temporaries should automatically get
         // fast-path alpha recovery so we don't need to do anything.
         if (useSurfaceSubimageForBlack) {
             rect =
                 gfxAlphaRecovery::AlignRectForSubimageRecovery(aRect,
                                                                surfaceAsImage);
@@ -3226,17 +3226,17 @@ PluginInstanceChild::PaintRectWithAlphaE
 
     nsRefPtr<gfxImageSurface> whiteImage;
     nsRefPtr<gfxImageSurface> blackImage;
     gfxRect targetRect(rect.x, rect.y, rect.width, rect.height);
     gfxIntSize targetSize(rect.width, rect.height);
     gfxPoint deviceOffset = -targetRect.TopLeft();
 
     // We always use a temporary "white image"
-    whiteImage = new gfxImageSurface(targetSize, gfxImageFormatRGB24);
+    whiteImage = new gfxImageSurface(targetSize, gfxImageFormat::RGB24);
     if (whiteImage->CairoStatus()) {
         return;
     }
 
 #ifdef XP_WIN
     // On windows, we need an HDC and so can't paint directly to
     // vanilla image surfaces.  Bifurcate this painting code so that
     // we don't accidentally attempt that.
@@ -3269,17 +3269,17 @@ PluginInstanceChild::PaintRectWithAlphaE
     whiteImage->SetDeviceOffset(deviceOffset);
     PaintRectToSurface(rect, whiteImage, gfxRGBA(1.0, 1.0, 1.0));
 
     if (useSurfaceSubimageForBlack) {
         gfxImageSurface *surface = static_cast<gfxImageSurface*>(aSurface);
         blackImage = surface->GetSubimage(targetRect);
     } else {
         blackImage = new gfxImageSurface(targetSize,
-                                         gfxImageFormatARGB32);
+                                         gfxImageFormat::ARGB32);
     }
 
     // Paint onto black background
     blackImage->SetDeviceOffset(deviceOffset);
     PaintRectToSurface(rect, blackImage, gfxRGBA(0.0, 0.0, 0.0));
 #endif
 
     NS_ABORT_IF_FALSE(whiteImage && blackImage, "Didn't paint enough!");
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -872,17 +872,17 @@ PluginInstanceParent::CreateBackground(c
 
 #elif defined(XP_WIN)
     // We have chosen to create an unsafe surface in which the plugin
     // can read from the region while we're writing to it.
     mBackground =
         gfxSharedImageSurface::CreateUnsafe(
             this,
             gfxIntSize(aSize.width, aSize.height),
-            gfxImageFormatRGB24);
+            gfxImageFormat::RGB24);
     return !!mBackground;
 #else
     return nullptr;
 #endif
 }
 
 void
 PluginInstanceParent::DestroyBackground()
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -23,17 +23,17 @@ namespace gfx {
 static void
 DumpAsPNG(SourceSurface* aSurface)
 {
   RefPtr<DataSourceSurface> dataSource = aSurface->GetDataSurface();
   IntSize size = dataSource->GetSize();
   nsRefPtr<gfxImageSurface> imageSurface =
     new gfxImageSurface(dataSource->GetData(), gfxIntSize(size.width, size.height),
                         dataSource->Stride(),
-                        aSurface->GetFormat() == SurfaceFormat::A8 ? gfxImageFormatA8 : gfxImageFormatARGB32);
+                        aSurface->GetFormat() == SurfaceFormat::A8 ? gfxImageFormat::A8 : gfxImageFormat::ARGB32);
   imageSurface->PrintAsDataURL();
 }
 } // namespace gfx
 } // namespace mozilla
 #endif
 
 namespace mozilla {
 namespace gfx {
--- a/gfx/gl/GLReadTexImageHelper.cpp
+++ b/gfx/gl/GLReadTexImageHelper.cpp
@@ -231,41 +231,41 @@ static void SwapRAndBComponents(DataSour
   }
 }
 
 void
 ReadPixelsIntoImageSurface(GLContext* gl, gfxImageSurface* dest) {
     gl->MakeCurrent();
     MOZ_ASSERT(dest->GetSize() != gfxIntSize(0, 0));
 
-    /* gfxImageFormatARGB32:
+    /* gfxImageFormat::ARGB32:
      * RGBA+UByte: be[RGBA], le[ABGR]
      * RGBA+UInt: le[RGBA]
      * BGRA+UInt: le[BGRA]
      * BGRA+UIntRev: le[ARGB]
      *
-     * gfxImageFormatRGB16_565:
+     * gfxImageFormat::RGB16_565:
      * RGB+UShort: le[rrrrrggg,gggbbbbb]
      */
-    bool hasAlpha = dest->Format() == gfxImageFormatARGB32;
+    bool hasAlpha = dest->Format() == gfxImageFormat::ARGB32;
 
     int destPixelSize;
     GLenum destFormat;
     GLenum destType;
 
     switch (dest->Format()) {
-        case gfxImageFormatRGB24: // XRGB
-        case gfxImageFormatARGB32:
+        case gfxImageFormat::RGB24: // XRGB
+        case gfxImageFormat::ARGB32:
             destPixelSize = 4;
             // Needs host (little) endian ARGB.
             destFormat = LOCAL_GL_BGRA;
             destType = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             break;
 
-        case gfxImageFormatRGB16_565:
+        case gfxImageFormat::RGB16_565:
             destPixelSize = 2;
             destFormat = LOCAL_GL_RGB;
             destType = LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV;
             break;
 
         default:
             MOZ_CRASH("Bad format.");
     }
@@ -374,17 +374,17 @@ ReadPixelsIntoImageSurface(GLContext* gl
         ctx.Paint();
     }
 
     // Check if GL is giving back 1.0 alpha for
     // RGBA reads to RGBA images from no-alpha buffers.
 #ifdef XP_MACOSX
     if (gl->WorkAroundDriverBugs() &&
         gl->Vendor() == gl::GLVendor::NVIDIA &&
-        dest->Format() == gfxImageFormatARGB32 &&
+        dest->Format() == gfxImageFormat::ARGB32 &&
         width && height)
     {
         GLint alphaBits = 0;
         gl->fGetIntegerv(LOCAL_GL_ALPHA_BITS, &alphaBits);
         if (!alphaBits) {
             const uint32_t alphaMask = gfxPackedPixelNoPreMultiply(0xff,0,0,0);
 
             dest->Flush();
@@ -498,17 +498,17 @@ GLReadTexImageHelper::ReadTexImage(GLuin
 
     MOZ_ASSERT(aTextureTarget == LOCAL_GL_TEXTURE_2D ||
                aTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL ||
                aTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB);
 
     mGL->MakeCurrent();
 
     /* Allocate resulting image surface */
-    nsRefPtr<gfxImageSurface> isurf = new gfxImageSurface(aSize, gfxImageFormatARGB32);
+    nsRefPtr<gfxImageSurface> isurf = new gfxImageSurface(aSize, gfxImageFormat::ARGB32);
     if (!isurf || isurf->CairoStatus()) {
         return nullptr;
     }
 
     GLint oldrb, oldfb, oldprog, oldTexUnit, oldTex;
     GLuint rb, fb;
 
     do {
--- a/gfx/gl/GLReadTexImageHelper.h
+++ b/gfx/gl/GLReadTexImageHelper.h
@@ -43,20 +43,20 @@ class GLReadTexImageHelper MOZ_FINAL
 
 public:
 
     GLReadTexImageHelper(GLContext* gl);
     ~GLReadTexImageHelper();
 
     /**
       * Read the image data contained in aTexture, and return it as an ImageSurface.
-      * If GL_RGBA is given as the format, a gfxImageFormatARGB32 surface is returned.
+      * If GL_RGBA is given as the format, a gfxImageFormat::ARGB32 surface is returned.
       * Not implemented yet:
-      * If GL_RGB is given as the format, a gfxImageFormatRGB24 surface is returned.
-      * If GL_LUMINANCE is given as the format, a gfxImageFormatA8 surface is returned.
+      * If GL_RGB is given as the format, a gfxImageFormat::RGB24 surface is returned.
+      * If GL_LUMINANCE is given as the format, a gfxImageFormat::A8 surface is returned.
       *
       * THIS IS EXPENSIVE.  It is ridiculously expensive.  Only do this
       * if you absolutely positively must, and never in any performance
       * critical path.
       *
       * NOTE: aShaderProgram is really mozilla::layers::ShaderProgramType. It is
       * passed as int to eliminate including LayerManagerOGLProgram.h here.
       */
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -479,18 +479,18 @@ GLScreenBuffer::CreateRead(SharedSurface
 }
 
 
 void
 GLScreenBuffer::Readback(SharedSurface_GL* src, gfxImageSurface* dest)
 {
     MOZ_ASSERT(src && dest);
     MOZ_ASSERT(ToIntSize(dest->GetSize()) == src->Size());
-    MOZ_ASSERT(dest->Format() == (src->HasAlpha() ? gfxImageFormatARGB32
-                                                  : gfxImageFormatRGB24));
+    MOZ_ASSERT(dest->Format() == (src->HasAlpha() ? gfxImageFormat::ARGB32
+                                                  : gfxImageFormat::RGB24));
 
     mGL->MakeCurrent();
 
     bool needsSwap = src != SharedSurf();
     if (needsSwap) {
         SharedSurf()->UnlockProd();
         src->LockProd();
     }
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -141,17 +141,17 @@ BasicTextureImage::BeginUpdate(nsIntRegi
     nsIntRect rgnSize = mUpdateRegion.GetBounds();
     if (!nsIntRect(nsIntPoint(0, 0), gfx::ThebesIntSize(mSize)).Contains(rgnSize)) {
         NS_ERROR("update outside of image");
         return nullptr;
     }
 
     ImageFormat format =
         (GetContentType() == GFX_CONTENT_COLOR) ?
-        gfxImageFormatRGB24 : gfxImageFormatARGB32;
+        gfxImageFormat::RGB24 : gfxImageFormat::ARGB32;
     mUpdateSurface =
         GetSurfaceForUpdate(gfxIntSize(rgnSize.width, rgnSize.height), format);
 
     if (!mUpdateSurface || mUpdateSurface->CairoStatus()) {
         mUpdateSurface = nullptr;
         return nullptr;
     }
 
@@ -283,17 +283,17 @@ TextureImage::TextureImage(const gfx::In
 {}
 
 BasicTextureImage::BasicTextureImage(GLuint aTexture,
                                      const nsIntSize& aSize,
                                      GLenum aWrapMode,
                                      ContentType aContentType,
                                      GLContext* aContext,
                                      TextureImage::Flags aFlags /* = TextureImage::NoFlags */,
-                                     TextureImage::ImageFormat aImageFormat /* = gfxImageFormatUnknown */)
+                                     TextureImage::ImageFormat aImageFormat /* = gfxImageFormat::Unknown */)
     : TextureImage(aSize, aWrapMode, aContentType, aFlags, aImageFormat)
     , mTexture(aTexture)
     , mTextureState(Created)
     , mGLContext(aContext)
     , mUpdateOffset(0, 0)
 {
 }
 
@@ -505,17 +505,17 @@ TiledTextureImage::BeginUpdate(nsIntRegi
     // each TextureImage tile
     GetUpdateRegion(aRegion);
     mUpdateRegion = aRegion;
     bounds = aRegion.GetBounds();
 
     // update covers multiple Images - create a temp surface to paint in
     gfxImageFormat format =
         (GetContentType() == GFX_CONTENT_COLOR) ?
-        gfxImageFormatRGB24 : gfxImageFormatARGB32;
+        gfxImageFormat::RGB24 : gfxImageFormat::ARGB32;
     mUpdateSurface = gfxPlatform::GetPlatform()->
         CreateOffscreenSurface(gfxIntSize(bounds.width, bounds.height), gfxASurface::ContentFromFormat(format));
     mUpdateSurface->SetDeviceOffset(gfxPoint(-bounds.x, -bounds.y));
 
     return mUpdateSurface;
 }
 
 void
--- a/gfx/gl/GLTextureImage.h
+++ b/gfx/gl/GLTextureImage.h
@@ -217,17 +217,17 @@ protected:
      * After the ctor, the TextureImage is invalid.  Implementations
      * must allocate resources successfully before returning the new
      * TextureImage from GLContext::CreateTextureImage().  That is,
      * clients must not be given partially-constructed TextureImages.
      */
     TextureImage(const nsIntSize& aSize,
                  GLenum aWrapMode, ContentType aContentType,
                  Flags aFlags = NoFlags,
-                 ImageFormat aImageFormat = gfxImageFormatUnknown)
+                 ImageFormat aImageFormat = gfxImageFormat::Unknown)
         : mSize(aSize.ToIntSize())
         , mWrapMode(aWrapMode)
         , mContentType(aContentType)
         , mImageFormat(aImageFormat)
         , mFilter(GraphicsFilter::FILTER_GOOD)
         , mFlags(aFlags)
     {}
 
@@ -263,24 +263,24 @@ public:
     virtual ~BasicTextureImage();
 
     BasicTextureImage(GLuint aTexture,
                       const nsIntSize& aSize,
                       GLenum aWrapMode,
                       ContentType aContentType,
                       GLContext* aContext,
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
-                      TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
+                      TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
     BasicTextureImage(GLuint aTexture,
                       const gfx::IntSize& aSize,
                       GLenum aWrapMode,
                       ContentType aContentType,
                       GLContext* aContext,
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
-                      TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
+                      TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
 
     virtual void BindTexture(GLenum aTextureUnit);
 
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
     virtual void EndUpdate();
     virtual bool DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0));
     virtual GLuint GetTextureID() { return mTexture; }
@@ -321,17 +321,17 @@ protected:
 class TiledTextureImage
     : public TextureImage
 {
 public:
     TiledTextureImage(GLContext* aGL,
                       gfx::IntSize aSize,
                       TextureImage::ContentType,
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
-                      TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
+                      TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
     ~TiledTextureImage();
     void DumpDiv();
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
     virtual void EndUpdate();
     virtual void Resize(const gfx::IntSize& aSize);
     virtual uint32_t GetTileCount();
     virtual void BeginTileIteration();
@@ -372,17 +372,17 @@ protected:
  * In doubt, use GLContext::CreateTextureImage instead.
  */
 already_AddRefed<TextureImage>
 CreateBasicTextureImage(GLContext* aGL,
                         const gfx::IntSize& aSize,
                         TextureImage::ContentType aContentType,
                         GLenum aWrapMode,
                         TextureImage::Flags aFlags,
-                        TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
+                        TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
 
 /**
   * Return a valid, allocated TextureImage of |aSize| with
   * |aContentType|.  If |aContentType| is COLOR, |aImageFormat| can be used
   * to hint at the preferred RGB format, however it is not necessarily
   * respected.  The TextureImage's texture is configured to use
   * |aWrapMode| (usually GL_CLAMP_TO_EDGE or GL_REPEAT) and by
   * default, GL_LINEAR filtering.  Specify
@@ -396,14 +396,14 @@ CreateBasicTextureImage(GLContext* aGL,
   * crashy) behavior.
   */
 already_AddRefed<TextureImage>
 CreateTextureImage(GLContext* gl,
                    const gfx::IntSize& aSize,
                    TextureImage::ContentType aContentType,
                    GLenum aWrapMode,
                    TextureImage::Flags aFlags = TextureImage::NoFlags,
-                   TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
+                   TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
 
 } // namespace gl
 } // namespace mozilla
 
 #endif /* GLTEXTUREIMAGE_H_ */
--- a/gfx/gl/GLUploadHelpers.cpp
+++ b/gfx/gl/GLUploadHelpers.cpp
@@ -26,25 +26,25 @@ DataOffset(const nsIntPoint &aPoint, int
   return data;
 }
 
 static gfxImageFormat
 ImageFormatForSurfaceFormat(gfx::SurfaceFormat aFormat)
 {
     switch (aFormat) {
         case gfx::SurfaceFormat::B8G8R8A8:
-            return gfxImageFormatARGB32;
+            return gfxImageFormat::ARGB32;
         case gfx::SurfaceFormat::B8G8R8X8:
-            return gfxImageFormatRGB24;
+            return gfxImageFormat::RGB24;
         case gfx::SurfaceFormat::R5G6B5:
-            return gfxImageFormatRGB16_565;
+            return gfxImageFormat::RGB16_565;
         case gfx::SurfaceFormat::A8:
-            return gfxImageFormatA8;
+            return gfxImageFormat::A8;
         default:
-            return gfxImageFormatUnknown;
+            return gfxImageFormat::Unknown;
     }
 }
 
 static GLint GetAddressAlignment(ptrdiff_t aAddress)
 {
     if (!(aAddress & 0x7)) {
        return 8;
     } else if (!(aAddress & 0x3)) {
@@ -412,48 +412,48 @@ UploadImageDataToTexture(GLContext* gl,
     GLenum internalFormat;
     GLenum type;
     int32_t pixelSize = gfxASurface::BytePerPixelFromFormat(aFormat);
     SurfaceFormat surfaceFormat;
 
     MOZ_ASSERT(gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA ||
                gl->GetPreferredARGB32Format() == LOCAL_GL_RGBA);
     switch (aFormat) {
-        case gfxImageFormatARGB32:
+        case gfxImageFormat::ARGB32:
             if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
               format = LOCAL_GL_BGRA;
               surfaceFormat = gfx::SurfaceFormat::R8G8B8A8;
               type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             } else {
               format = LOCAL_GL_RGBA;
               surfaceFormat = gfx::SurfaceFormat::B8G8R8A8;
               type = LOCAL_GL_UNSIGNED_BYTE;
             }
             internalFormat = LOCAL_GL_RGBA;
             break;
-        case gfxImageFormatRGB24:
+        case gfxImageFormat::RGB24:
             // Treat RGB24 surfaces as RGBA32 except for the surface
             // format used.
             if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
               format = LOCAL_GL_BGRA;
               surfaceFormat = gfx::SurfaceFormat::R8G8B8X8;
               type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             } else {
               format = LOCAL_GL_RGBA;
               surfaceFormat = gfx::SurfaceFormat::B8G8R8X8;
               type = LOCAL_GL_UNSIGNED_BYTE;
             }
             internalFormat = LOCAL_GL_RGBA;
             break;
-        case gfxImageFormatRGB16_565:
+        case gfxImageFormat::RGB16_565:
             internalFormat = format = LOCAL_GL_RGB;
             type = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
             surfaceFormat = gfx::SurfaceFormat::R5G6B5;
             break;
-        case gfxImageFormatA8:
+        case gfxImageFormat::A8:
             internalFormat = format = LOCAL_GL_LUMINANCE;
             type = LOCAL_GL_UNSIGNED_BYTE;
             // We don't have a specific luminance shader
             surfaceFormat = gfx::SurfaceFormat::A8;
             break;
         default:
             NS_ASSERTION(false, "Unhandled image surface format!");
             format = 0;
@@ -521,25 +521,25 @@ UploadSurfaceToTexture(GLContext* gl,
                        GLenum aTextureUnit,
                        GLenum aTextureTarget)
 {
 
     nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
     unsigned char* data = nullptr;
 
     if (!imageSurface ||
-        (imageSurface->Format() != gfxImageFormatARGB32 &&
-         imageSurface->Format() != gfxImageFormatRGB24 &&
-         imageSurface->Format() != gfxImageFormatRGB16_565 &&
-         imageSurface->Format() != gfxImageFormatA8)) {
+        (imageSurface->Format() != gfxImageFormat::ARGB32 &&
+         imageSurface->Format() != gfxImageFormat::RGB24 &&
+         imageSurface->Format() != gfxImageFormat::RGB16_565 &&
+         imageSurface->Format() != gfxImageFormat::A8)) {
         // We can't get suitable pixel data for the surface, make a copy
         nsIntRect bounds = aDstRegion.GetBounds();
         imageSurface =
           new gfxImageSurface(gfxIntSize(bounds.width, bounds.height),
-                              gfxImageFormatARGB32);
+                              gfxImageFormat::ARGB32);
 
         nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
 
         context->Translate(-gfxPoint(aSrcPoint.x, aSrcPoint.y));
         context->SetSource(aSurface);
         context->Paint();
         data = imageSurface->Data();
         NS_ASSERTION(!aPixelBuffer,
--- a/gfx/gl/TextureImageCGL.h
+++ b/gfx/gl/TextureImageCGL.h
@@ -21,17 +21,17 @@ class TextureImageCGL : public BasicText
 public:
 
     TextureImageCGL(GLuint aTexture,
                     const nsIntSize& aSize,
                     GLenum aWrapMode,
                     ContentType aContentType,
                     GLContext* aContext,
                     TextureImage::Flags aFlags = TextureImage::NoFlags,
-                    TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
+                    TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
 
     ~TextureImageCGL();
 
 protected:
     already_AddRefed<gfxASurface>
     GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt);
 
     bool FinishedSurfaceUpdate();
--- a/gfx/gl/TextureImageEGL.cpp
+++ b/gfx/gl/TextureImageEGL.cpp
@@ -13,39 +13,39 @@
 
 namespace mozilla {
 namespace gl {
 
 static GLenum
 GLFormatForImage(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-    case gfxImageFormatARGB32:
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::ARGB32:
+    case gfxImageFormat::RGB24:
         // Thebes only supports RGBX, not packed RGB.
         return LOCAL_GL_RGBA;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
         return LOCAL_GL_RGB;
-    case gfxImageFormatA8:
+    case gfxImageFormat::A8:
         return LOCAL_GL_LUMINANCE;
     default:
         NS_WARNING("Unknown GL format for Image format");
     }
     return 0;
 }
 
 static GLenum
 GLTypeForImage(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-    case gfxImageFormatARGB32:
-    case gfxImageFormatRGB24:
-    case gfxImageFormatA8:
+    case gfxImageFormat::ARGB32:
+    case gfxImageFormat::RGB24:
+    case gfxImageFormat::A8:
         return LOCAL_GL_UNSIGNED_BYTE;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
         return LOCAL_GL_UNSIGNED_SHORT_5_6_5;
     default:
         NS_WARNING("Unknown GL format for Image format");
     }
     return 0;
 }
 
 TextureImageEGL::TextureImageEGL(GLuint aTexture,
@@ -61,23 +61,23 @@ TextureImageEGL::TextureImageEGL(GLuint 
     , mUpdateFormat(aImageFormat)
     , mEGLImage(nullptr)
     , mTexture(aTexture)
     , mSurface(nullptr)
     , mConfig(nullptr)
     , mTextureState(aTextureState)
     , mBound(false)
 {
-    if (mUpdateFormat == gfxImageFormatUnknown) {
+    if (mUpdateFormat == gfxImageFormat::Unknown) {
         mUpdateFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(GetContentType());
     }
 
-    if (mUpdateFormat == gfxImageFormatRGB16_565) {
+    if (mUpdateFormat == gfxImageFormat::RGB16_565) {
         mTextureFormat = gfx::SurfaceFormat::R8G8B8X8;
-    } else if (mUpdateFormat == gfxImageFormatRGB24) {
+    } else if (mUpdateFormat == gfxImageFormat::RGB24) {
         // RGB24 means really RGBX for Thebes, which means we have to
         // use the right shader and ignore the uninitialized alpha
         // value.
         mTextureFormat = gfx::SurfaceFormat::B8G8R8X8;
     } else {
         mTextureFormat = gfx::SurfaceFormat::B8G8R8A8;
     }
 }
--- a/gfx/gl/TextureImageEGL.h
+++ b/gfx/gl/TextureImageEGL.h
@@ -17,17 +17,17 @@ class TextureImageEGL
 public:
     TextureImageEGL(GLuint aTexture,
                     const nsIntSize& aSize,
                     GLenum aWrapMode,
                     ContentType aContentType,
                     GLContext* aContext,
                     Flags aFlags = TextureImage::NoFlags,
                     TextureState aTextureState = Created,
-                    TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
+                    TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
 
     virtual ~TextureImageEGL();
 
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
 
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
 
     virtual void EndUpdate();
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -218,22 +218,30 @@ struct ParamTraits<mozilla::layers::Laye
 template <>
 struct ParamTraits<mozilla::layers::ScaleMode>
   : public EnumSerializer<mozilla::layers::ScaleMode,
                           mozilla::layers::SCALE_NONE,
                           mozilla::layers::SCALE_SENTINEL>
 {};
 
 template <>
+struct ParamTraits<gfxImageFormat>
+  : public TypedEnumSerializer<gfxImageFormat,
+                               gfxImageFormat::ARGB32,
+                               gfxImageFormat::Unknown>
+{};
+
+/*
+template <>
 struct ParamTraits<mozilla::PixelFormat>
   : public EnumSerializer<mozilla::PixelFormat,
-                          gfxImageFormatARGB32,
-                          gfxImageFormatUnknown>
+                          gfxImageFormat::ARGB32,
+                          gfxImageFormat::Unknown>
 {};
-
+*/
 
 template<>
 struct ParamTraits<gfxRGBA>
 {
   typedef gfxRGBA paramType;
 
   static void Write(Message* msg, const paramType& param)
   {
--- a/gfx/ipc/SharedDIBSurface.cpp
+++ b/gfx/ipc/SharedDIBSurface.cpp
@@ -40,17 +40,17 @@ SharedDIBSurface::Attach(Handle aHandle,
 
 void
 SharedDIBSurface::InitSurface(uint32_t aWidth, uint32_t aHeight,
                               bool aTransparent)
 {
   long stride = long(aWidth * kBytesPerPixel);
   unsigned char* data = reinterpret_cast<unsigned char*>(mSharedDIB.GetBits());
 
-  gfxImageFormat format = aTransparent ? gfxImageFormatARGB32 : gfxImageFormatRGB24;
+  gfxImageFormat format = aTransparent ? gfxImageFormat::ARGB32 : gfxImageFormat::RGB24;
 
   gfxImageSurface::InitWithData(data, gfxIntSize(aWidth, aHeight),
                                 stride, format);
 
   cairo_surface_set_user_data(mSurface, &SHAREDDIB_KEY, this, nullptr);
 }
 
 bool
--- a/gfx/layers/CopyableCanvasLayer.cpp
+++ b/gfx/layers/CopyableCanvasLayer.cpp
@@ -104,18 +104,18 @@ CopyableCanvasLayer::UpdateSurface(gfxAS
     SharedSurface* sharedSurf = mGLContext->RequestFrame();
     if (!sharedSurf) {
       NS_WARNING("Null frame received.");
       return;
     }
 
     IntSize readSize(sharedSurf->Size());
     gfxImageFormat format = (GetContentFlags() & CONTENT_OPAQUE)
-                            ? gfxImageFormatRGB24
-                            : gfxImageFormatARGB32;
+                            ? gfxImageFormat::RGB24
+                            : gfxImageFormat::ARGB32;
 
     if (aDestSurface) {
       resultSurf = aDestSurface;
     } else {
       resultSurf = GetTempSurface(readSize, format);
     }
     MOZ_ASSERT(resultSurf);
     if (resultSurf->CairoStatus() != 0) {
--- a/gfx/layers/D3D9SurfaceImage.cpp
+++ b/gfx/layers/D3D9SurfaceImage.cpp
@@ -118,17 +118,17 @@ D3D9SurfaceImage::GetSize()
 
 already_AddRefed<gfxASurface>
 D3D9SurfaceImage::DeprecatedGetAsSurface()
 {
   NS_ENSURE_TRUE(mTexture, nullptr);
 
   HRESULT hr;
   nsRefPtr<gfxImageSurface> surface =
-    new gfxImageSurface(gfx::ThebesIntSize(mSize), gfxImageFormatRGB24);
+    new gfxImageSurface(gfx::ThebesIntSize(mSize), gfxImageFormat::RGB24);
 
   if (!surface->CairoSurface() || surface->CairoStatus()) {
     NS_WARNING("Failed to created Cairo image surface for D3D9SurfaceImage.");
     return nullptr;
   }
 
   // Ensure that the texture is ready to be used.
   EnsureSynchronized();
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -228,17 +228,17 @@ GrallocImage::DeprecatedGetAsSurface()
   }
 
   if (!omxFormat) {
     NS_WARNING("Unknown color format");
     return nullptr;
   }
 
   nsRefPtr<gfxImageSurface> imageSurface =
-    new gfxImageSurface(gfx::ThebesIntSize(GetSize()), gfxImageFormatRGB16_565);
+    new gfxImageSurface(gfx::ThebesIntSize(GetSize()), gfxImageFormat::RGB16_565);
 
   uint32_t width = GetSize().width;
   uint32_t height = GetSize().height;
 
   if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
     // The Adreno hardware decoder aligns image dimensions to a multiple of 32,
     // so we have to account for that here
     uint32_t alignedWidth = ALIGN(width, 32);
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -317,18 +317,18 @@ ImageContainer::DeprecatedLockCurrentAsS
     } 
 
     if (mActiveImage->GetFormat() == REMOTE_IMAGE_BITMAP) {
       nsRefPtr<gfxImageSurface> newSurf =
         new gfxImageSurface(mRemoteData->mBitmap.mData,
                             ThebesIntSize(mRemoteData->mSize),
                             mRemoteData->mBitmap.mStride,
                             mRemoteData->mFormat == RemoteImageData::BGRX32 ?
-                                                   gfxImageFormatARGB32 :
-                                                   gfxImageFormatRGB24);
+                                                   gfxImageFormat::ARGB32 :
+                                                   gfxImageFormat::RGB24);
 
       *aSize = newSurf->GetSize().ToIntSize();
     
       return newSurf.forget();
     }
 
     *aSize = mActiveImage->GetSize();
     return mActiveImage->DeprecatedGetAsSurface();
@@ -364,18 +364,18 @@ ImageContainer::LockCurrentAsSourceSurfa
     }
 
     if (!mActiveImage) {
       return nullptr;
     }
 
     if (mActiveImage->GetFormat() == REMOTE_IMAGE_BITMAP) {
       gfxImageFormat fmt = mRemoteData->mFormat == RemoteImageData::BGRX32
-                           ? gfxImageFormatARGB32
-                           : gfxImageFormatRGB24;
+                           ? gfxImageFormat::ARGB32
+                           : gfxImageFormat::RGB24;
 
       RefPtr<gfx::DataSourceSurface> newSurf
         = gfx::Factory::CreateWrappingDataSourceSurface(mRemoteData->mBitmap.mData,
                                                         mRemoteData->mBitmap.mStride,
                                                         mRemoteData->mSize,
                                                         gfx::ImageFormatToSurfaceFormat(fmt));
       *aSize = newSurf->GetSize();
 
@@ -521,17 +521,17 @@ ImageContainer::EnsureActiveImage()
 #endif
   }
 }
 
 
 PlanarYCbCrImage::PlanarYCbCrImage(BufferRecycleBin *aRecycleBin)
   : Image(nullptr, PLANAR_YCBCR)
   , mBufferSize(0)
-  , mOffscreenFormat(gfxImageFormatUnknown)
+  , mOffscreenFormat(gfxImageFormat::Unknown)
   , mRecycleBin(aRecycleBin)
 {
 }
 
 PlanarYCbCrImage::~PlanarYCbCrImage()
 {
   if (mBuffer) {
     mRecycleBin->RecycleBuffer(mBuffer.forget(), mBufferSize);
@@ -603,17 +603,17 @@ void
 PlanarYCbCrImage::SetData(const Data &aData)
 {
   CopyData(aData);
 }
 
 gfxImageFormat
 PlanarYCbCrImage::GetOffscreenFormat()
 {
-  return mOffscreenFormat == gfxImageFormatUnknown ?
+  return mOffscreenFormat == gfxImageFormat::Unknown ?
     gfxPlatform::GetPlatform()->GetOffscreenFormat() :
     mOffscreenFormat;
 }
 
 void
 PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
 {
   mData = aData;
@@ -684,17 +684,17 @@ PlanarYCbCrImage::GetAsSourceSurface()
   return surface.forget();
 }
 
 already_AddRefed<gfxASurface>
 RemoteBitmapImage::DeprecatedGetAsSurface()
 {
   nsRefPtr<gfxImageSurface> newSurf =
     new gfxImageSurface(ThebesIntSize(mSize),
-    mFormat == RemoteImageData::BGRX32 ? gfxImageFormatRGB24 : gfxImageFormatARGB32);
+    mFormat == RemoteImageData::BGRX32 ? gfxImageFormat::RGB24 : gfxImageFormat::ARGB32);
 
   for (int y = 0; y < mSize.height; y++) {
     memcpy(newSurf->Data() + newSurf->Stride() * y,
            mData + mStride * y,
            mSize.width * 4);
   }
 
   return newSurf.forget();
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -118,17 +118,17 @@ LayerManager::CreateOptimalSurface(const
 {
   return gfxPlatform::GetPlatform()->
     CreateOffscreenSurface(gfx::ThebesIntSize(aSize), gfxASurface::ContentFromFormat(aFormat));
 }
 
 already_AddRefed<gfxASurface>
 LayerManager::CreateOptimalMaskSurface(const gfx::IntSize &aSize)
 {
-  return CreateOptimalSurface(aSize, gfxImageFormatA8);
+  return CreateOptimalSurface(aSize, gfxImageFormat::A8);
 }
 
 TemporaryRef<DrawTarget>
 LayerManager::CreateDrawTarget(const IntSize &aSize,
                                SurfaceFormat aFormat)
 {
   return gfxPlatform::GetPlatform()->
     CreateOffscreenCanvasDrawTarget(aSize, aFormat);
--- a/gfx/layers/MacIOSurfaceImage.h
+++ b/gfx/layers/MacIOSurfaceImage.h
@@ -32,17 +32,17 @@ public:
     mSurface->Lock();
     size_t bytesPerRow = mSurface->GetBytesPerRow();
     size_t ioWidth = mSurface->GetDevicePixelWidth();
     size_t ioHeight = mSurface->GetDevicePixelHeight();
 
     unsigned char* ioData = (unsigned char*)mSurface->GetBaseAddress();
 
     nsRefPtr<gfxImageSurface> imgSurface =
-      new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxImageFormatARGB32);
+      new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxImageFormat::ARGB32);
 
     for (size_t i = 0; i < ioHeight; i++) {
       memcpy(imgSurface->Data() + i * imgSurface->Stride(),
              ioData + i * bytesPerRow, ioWidth * 4);
     }
 
     mSurface->Unlock();
 
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -718,17 +718,17 @@ BasicLayerManager_Matrix3DToPixman(const
 
 static void
 PixmanTransform(const gfxImageSurface* aDest,
                 RefPtr<DataSourceSurface> aSrc,
                 const gfx3DMatrix& aTransform,
                 gfxPoint aDestOffset)
 {
   IntSize destSize = ToIntSize(aDest->GetSize());
-  pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormatARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
+  pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormat::ARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
                                                   destSize.width,
                                                   destSize.height,
                                                   (uint32_t*)aDest->Data(),
                                                   aDest->Stride());
 
   IntSize srcSize = aSrc->GetSize();
   pixman_image_t* src = pixman_image_create_bits(aSrc->GetFormat() == SurfaceFormat::B8G8R8A8 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
                                                  srcSize.width,
@@ -792,17 +792,17 @@ Transform3D(RefPtr<SourceSurface> aSourc
   aDestRect = aDest->GetClipExtents();
   aDestRect.IntersectRect(aDestRect, offsetRect);
   aDestRect.RoundOut();
 
   // Create a surface the size of the transformed object.
   nsRefPtr<gfxASurface> dest = aDest->CurrentSurface();
   nsRefPtr<gfxImageSurface> destImage = new gfxImageSurface(gfxIntSize(aDestRect.width,
                                                                        aDestRect.height),
-                                                            gfxImageFormatARGB32);
+                                                            gfxImageFormat::ARGB32);
   gfxPoint offset = aDestRect.TopLeft();
 
   // Include a translation to the correct origin.
   gfx3DMatrix translation = gfx3DMatrix::Translation(aBounds.x, aBounds.y, 0);
 
   // Transform the content and offset it such that the content begins at the origin.
   PixmanTransform(destImage, aSource->GetDataSurface(), translation * aTransform, offset);
 
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -203,17 +203,17 @@ CanvasLayerD3D10::UpdateSurface()
       return;
     }
 
     nsRefPtr<gfxImageSurface> dstSurface;
 
     dstSurface = new gfxImageSurface((unsigned char*)map.pData,
                                      gfxIntSize(mBounds.width, mBounds.height),
                                      map.RowPitch,
-                                     gfxImageFormatARGB32);
+                                     gfxImageFormat::ARGB32);
     nsRefPtr<gfxContext> ctx = new gfxContext(dstSurface);
     ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
     ctx->SetSource(mSurface);
     ctx->Paint();
     
     mTexture->Unmap(0);
     mSRView = mUploadSRView;
   }
--- a/gfx/layers/d3d10/ImageLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp
@@ -68,17 +68,17 @@ SurfaceToTexture(ID3D10Device *aDevice,
       }
     }
   }
 
   nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
 
   if (!imageSurface) {
     imageSurface = new gfxImageSurface(ThebesIntSize(aSize),
-                                       gfxImageFormatARGB32);
+                                       gfxImageFormat::ARGB32);
 
     nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
     context->SetSource(aSurface);
     context->SetOperator(gfxContext::OPERATOR_SOURCE);
     context->Paint();
   }
 
   return DataToTexture(aDevice, imageSurface->Data(), imageSurface->Stride(), aSize);
@@ -467,18 +467,18 @@ RemoteDXGITextureImage::DeprecatedGetAsS
   }
 
   device->CopyResource(softTexture, data->mTexture);
   keyedMutex->ReleaseSync(0);
 
   nsRefPtr<gfxImageSurface> surface =
     new gfxImageSurface(ThebesIntSize(mSize),
       mFormat == RemoteImageData::BGRX32 ?
-                 gfxImageFormatRGB24 :
-                 gfxImageFormatARGB32);
+                 gfxImageFormat::RGB24 :
+                 gfxImageFormat::ARGB32);
 
   if (!surface->CairoSurface() || surface->CairoStatus()) {
     NS_WARNING("Failed to created image surface for DXGI texture.");
     return nullptr;
   }
 
   D3D10_MAPPED_TEXTURE2D mapped;
   softTexture->Map(0, D3D10_MAP_READ, 0, &mapped);
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -449,18 +449,18 @@ static void ReleaseTexture(void *texture
 {
   static_cast<ID3D10Texture2D*>(texture)->Release();
 }
 
 already_AddRefed<gfxASurface>
 LayerManagerD3D10::CreateOptimalSurface(const IntSize &aSize,
                                         gfxImageFormat aFormat)
 {
-  if ((aFormat != gfxImageFormatRGB24 &&
-       aFormat != gfxImageFormatARGB32)) {
+  if ((aFormat != gfxImageFormat::RGB24 &&
+       aFormat != gfxImageFormat::ARGB32)) {
     return LayerManager::CreateOptimalSurface(aSize, aFormat);
   }
 
   nsRefPtr<ID3D10Texture2D> texture;
   
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, aSize.width, aSize.height, 1, 1);
   desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
   desc.MiscFlags = D3D10_RESOURCE_MISC_GDI_COMPATIBLE;
@@ -468,17 +468,17 @@ LayerManagerD3D10::CreateOptimalSurface(
   HRESULT hr = device()->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture));
 
   if (FAILED(hr)) {
     NS_WARNING("Failed to create new texture for CreateOptimalSurface!");
     return LayerManager::CreateOptimalSurface(aSize, aFormat);
   }
 
   nsRefPtr<gfxD2DSurface> surface =
-    new gfxD2DSurface(texture, aFormat == gfxImageFormatRGB24 ?
+    new gfxD2DSurface(texture, aFormat == gfxImageFormat::RGB24 ?
       GFX_CONTENT_COLOR : GFX_CONTENT_COLOR_ALPHA);
 
   if (!surface || surface->CairoStatus()) {
     return LayerManager::CreateOptimalSurface(aSize, aFormat);
   }
 
   surface->SetData(&gKeyD3D10Texture,
                    texture.forget().get(),
@@ -486,17 +486,17 @@ LayerManagerD3D10::CreateOptimalSurface(
 
   return surface.forget();
 }
 
 
 already_AddRefed<gfxASurface>
 LayerManagerD3D10::CreateOptimalMaskSurface(const IntSize &aSize)
 {
-  return CreateOptimalSurface(aSize, gfxImageFormatARGB32);
+  return CreateOptimalSurface(aSize, gfxImageFormat::ARGB32);
 }
 
 
 TemporaryRef<DrawTarget>
 LayerManagerD3D10::CreateDrawTarget(const IntSize &aSize,
                                     SurfaceFormat aFormat)
 {
   if ((aFormat != SurfaceFormat::B8G8R8A8 &&
@@ -767,17 +767,17 @@ LayerManagerD3D10::PaintToTarget()
 
   D3D10_MAPPED_TEXTURE2D map;
   readTexture->Map(0, D3D10_MAP_READ, 0, &map);
 
   nsRefPtr<gfxImageSurface> tmpSurface =
     new gfxImageSurface((unsigned char*)map.pData,
                         gfxIntSize(bbDesc.Width, bbDesc.Height),
                         map.RowPitch,
-                        gfxImageFormatARGB32);
+                        gfxImageFormat::ARGB32);
 
   mTarget->SetSource(tmpSurface);
   mTarget->SetOperator(gfxContext::OPERATOR_OVER);
   mTarget->Paint();
 
   readTexture->Unmap(0);
 }
 
--- a/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
+++ b/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
@@ -67,17 +67,17 @@ public:
       update->mLayer->GetSink()->SetUnknown(update->mSequenceCounter);
       return NS_OK;
     }
 
     nsRefPtr<gfxImageSurface> sourceSurface =
       new gfxImageSurface((unsigned char*)mappedTex.pData,
                           gfxIntSize(desc.Width, desc.Height),
                           mappedTex.RowPitch,
-                          gfxImageFormatRGB24);
+                          gfxImageFormat::RGB24);
 
     nsRefPtr<gfxContext> ctx =
       update->mLayer->GetSink()->BeginUpdate(update->mUpdateRect + offset,
                                              update->mSequenceCounter);
 
     if (ctx) {
       ctx->Translate(gfxPoint(offset.x, offset.y));
       ctx->SetSource(sourceSurface, gfxPoint(mTask->mOrigin.x,
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -693,27 +693,27 @@ DeprecatedTextureHostShmemD3D11::UpdateI
   nsRefPtr<gfxImageSurface> surf = openSurf.GetAsImage();
 
   gfx::IntSize size = gfx::ToIntSize(surf->GetSize());
 
   uint32_t bpp = 0;
 
   DXGI_FORMAT dxgiFormat;
   switch (surf->Format()) {
-  case gfxImageFormatRGB24:
+  case gfxImageFormat::RGB24:
     mFormat = SurfaceFormat::B8G8R8X8;
     dxgiFormat = DXGI_FORMAT_B8G8R8X8_UNORM;
     bpp = 4;
     break;
-  case gfxImageFormatARGB32:
+  case gfxImageFormat::ARGB32:
     mFormat = SurfaceFormat::B8G8R8A8;
     dxgiFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
     bpp = 4;
     break;
-  case gfxImageFormatA8:
+  case gfxImageFormat::A8:
     mFormat = SurfaceFormat::A8;
     dxgiFormat = DXGI_FORMAT_A8_UNORM;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -131,34 +131,34 @@ CanvasLayerD3D9::UpdateSurface()
     D3DLOCKED_RECT lockedRect = textureLock.GetLockRect();
 
     nsRefPtr<gfxImageSurface> sourceSurface;
 
     if (mSurface->GetType() == gfxSurfaceTypeWin32) {
       sourceSurface = mSurface->GetAsImageSurface();
     } else if (mSurface->GetType() == gfxSurfaceTypeImage) {
       sourceSurface = static_cast<gfxImageSurface*>(mSurface.get());
-      if (sourceSurface->Format() != gfxImageFormatARGB32 &&
-          sourceSurface->Format() != gfxImageFormatRGB24)
+      if (sourceSurface->Format() != gfxImageFormat::ARGB32 &&
+          sourceSurface->Format() != gfxImageFormat::RGB24)
       {
         return;
       }
     } else {
       sourceSurface = new gfxImageSurface(gfxIntSize(mBounds.width, mBounds.height),
-                                          gfxImageFormatARGB32);
+                                          gfxImageFormat::ARGB32);
       nsRefPtr<gfxContext> ctx = new gfxContext(sourceSurface);
       ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
       ctx->SetSource(mSurface);
       ctx->Paint();
     }
 
     uint8_t *startBits = sourceSurface->Data();
     uint32_t sourceStride = sourceSurface->Stride();
 
-    if (sourceSurface->Format() != gfxImageFormatARGB32) {
+    if (sourceSurface->Format() != gfxImageFormat::ARGB32) {
       mHasAlpha = false;
     } else {
       mHasAlpha = true;
     }
 
     for (int y = 0; y < mBounds.height; y++) {
       memcpy((uint8_t*)lockedRect.pBits + lockedRect.Pitch * y,
              startBits + sourceStride * y,
--- a/gfx/layers/d3d9/ImageLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp
@@ -22,17 +22,17 @@
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 static inline _D3DFORMAT
 D3dFormatForGfxFormat(gfxImageFormat aFormat)
 {
-  if (aFormat == gfxImageFormatA8) {
+  if (aFormat == gfxImageFormat::A8) {
     return D3DFMT_A8;
   }
 
   return D3DFMT_A8R8G8B8;
 }
 
 static already_AddRefed<IDirect3DTexture9>
 DataToTexture(IDirect3DDevice9 *aDevice,
@@ -136,17 +136,17 @@ SurfaceToTexture(IDirect3DDevice9 *aDevi
                  gfxASurface *aSurface,
                  const IntSize &aSize)
 {
 
   nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
 
   if (!imageSurface) {
     imageSurface = new gfxImageSurface(ThebesIntSize(aSize),
-                                       gfxImageFormatARGB32);
+                                       gfxImageFormat::ARGB32);
 
     nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
     context->SetSource(aSurface);
     context->SetOperator(gfxContext::OPERATOR_SOURCE);
     context->Paint();
   }
 
   return DataToTexture(aDevice, imageSurface->Data(), imageSurface->Stride(),
--- a/gfx/layers/d3d9/LayerManagerD3D9.cpp
+++ b/gfx/layers/d3d9/LayerManagerD3D9.cpp
@@ -342,17 +342,17 @@ LayerManagerD3D9::PaintToTarget()
 
   D3DLOCKED_RECT rect;
   destSurf->LockRect(&rect, nullptr, D3DLOCK_READONLY);
 
   nsRefPtr<gfxImageSurface> imageSurface =
     new gfxImageSurface((unsigned char*)rect.pBits,
                         gfxIntSize(desc.Width, desc.Height),
                         rect.Pitch,
-                        gfxImageFormatARGB32);
+                        gfxImageFormat::ARGB32);
 
   mTarget->SetSource(imageSurface);
   mTarget->SetOperator(gfxContext::OPERATOR_OVER);
   mTarget->Paint();
   destSurf->UnlockRect();
 }
 
 LayerD3D9::LayerD3D9(LayerManagerD3D9 *aManager)
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -327,27 +327,27 @@ DeprecatedTextureHostShmemD3D9::UpdateIm
   nsRefPtr<gfxImageSurface> surf = openSurf.GetAsImage();
 
   mSize = ToIntSize(surf->GetSize());
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   switch (surf->Format()) {
-  case gfxImageFormatRGB24:
+  case gfxImageFormat::RGB24:
     mFormat = SurfaceFormat::B8G8R8X8;
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageFormatARGB32:
+  case gfxImageFormat::ARGB32:
     mFormat = SurfaceFormat::B8G8R8A8;
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageFormatA8:
+  case gfxImageFormat::A8:
     mFormat = SurfaceFormat::A8;
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
@@ -661,27 +661,27 @@ DeprecatedTextureHostDIB::UpdateImpl(con
     dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aImage.get_SurfaceDescriptorDIB().surface()));
 
   mSize = ToIntSize(surf->GetSize());
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   switch (gfxPlatform::GetPlatform()->OptimalFormatForContent(surf->GetContentType())) {
-  case gfxImageFormatRGB24:
+  case gfxImageFormat::RGB24:
     mFormat = SurfaceFormat::B8G8R8X8;
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageFormatARGB32:
+  case gfxImageFormat::ARGB32:
     mFormat = SurfaceFormat::B8G8R8A8;
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageFormatA8:
+  case gfxImageFormat::A8:
     mFormat = SurfaceFormat::A8;
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
--- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp
@@ -445,17 +445,17 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion 
         ReportFailure(NS_LITERAL_CSTRING("Failed to create temporary texture in system memory."), hr);
         return;
       }
 
       // XXX - We may consider retaining a SYSTEMMEM texture texture the size
       // of our DEFAULT texture and then use UpdateTexture and add dirty rects
       // to update in a single call.
       nsRefPtr<gfxWindowsSurface> dest = new gfxWindowsSurface(
-          gfxIntSize(bounds.width, bounds.height), gfxImageFormatARGB32);
+          gfxIntSize(bounds.width, bounds.height), gfxImageFormat::ARGB32);
       // If the contents of this layer don't require component alpha in the
       // end of rendering, it's safe to enable Cleartype since all the Cleartype
       // glyphs must be over (or under) opaque pixels.
       dest->SetSubpixelAntialiasingEnabled(!(mContentFlags & CONTENT_COMPONENT_ALPHA));
       destinationSurface = dest.forget();
       break;
     }
 
@@ -534,17 +534,17 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion 
       }
 
       D3DLOCKED_RECT r = textureLock.GetLockRect();
 
       nsRefPtr<gfxImageSurface> imgSurface =
         new gfxImageSurface((unsigned char *)r.pBits,
                             bounds.Size(),
                             r.Pitch,
-                            gfxImageFormatARGB32);
+                            gfxImageFormat::ARGB32);
 
       if (destinationSurface) {
         nsRefPtr<gfxContext> context = new gfxContext(imgSurface);
         context->SetSource(destinationSurface);
         context->SetOperator(gfxContext::OPERATOR_SOURCE);
         context->Paint();
       }
 
--- a/gfx/layers/ipc/ISurfaceAllocator.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -95,17 +95,17 @@ ISurfaceAllocator::AllocSurfaceDescripto
     uint8_t *data = new (std::nothrow) uint8_t[stride * aSize.height];
     if (!data) {
       return false;
     }
     GfxMemoryImageReporter::DidAlloc(data);
 #ifdef XP_MACOSX
     // Workaround a bug in Quartz where drawing an a8 surface to another a8
     // surface with OPERATOR_SOURCE still requires the destination to be clear.
-    if (format == gfxImageFormatA8) {
+    if (format == gfxImageFormat::A8) {
       memset(data, 0, stride * aSize.height);
     }
 #endif
     *aBuffer = MemoryImage((uintptr_t)data, aSize, stride, format);
     return true;
   }
 
   nsRefPtr<gfxSharedImageSurface> buffer;
--- a/gfx/layers/ipc/LayersSurfaces.ipdlh
+++ b/gfx/layers/ipc/LayersSurfaces.ipdlh
@@ -13,16 +13,17 @@ using struct mozilla::layers::MagicGrall
 using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
 using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
 using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
 using mozilla::gl::SharedTextureHandle from "GLContextTypes.h";
 using mozilla::gl::SharedTextureShareType from "GLContextTypes.h";
 using mozilla::gfx::SurfaceStreamHandle from "SurfaceTypes.h";
 using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
+using gfxImageFormat from "gfxTypes.h";
 
 namespace mozilla {
 namespace layers {
 
 union MaybeMagicGrallocBufferHandle {
   MagicGrallocBufferHandle;
   null_t;
 };
@@ -132,25 +133,25 @@ struct YCbCrImage {
   Shmem data;
   uint64_t owner;
 };
 
 // XXX remove RGBImage (see bug 847914)
 struct RGBImage {
   Shmem data;
   nsIntRect picture;
-  uint32_t rgbFormat;
+  gfxImageFormat rgbFormat;
   uint64_t owner;
 };
 
 struct MemoryImage {
   uintptr_t data;
   IntSize size;
   uint32_t stride;
-  uint32_t format;
+  gfxImageFormat format;
 };
 
 /**
  * Used for shmem-backed YCbCr and (flavors of) RGBA textures
  */
 struct SurfaceDescriptorShmem {
   Shmem data;
   SurfaceFormat format;
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
@@ -146,41 +146,41 @@ MagicGrallocBufferHandle::MagicGrallocBu
 //-----------------------------------------------------------------------------
 // Parent process
 
 static gfxImageFormat
 ImageFormatForPixelFormat(android::PixelFormat aFormat)
 {
   switch (aFormat) {
   case PIXEL_FORMAT_RGBA_8888:
-    return gfxImageFormatARGB32;
+    return gfxImageFormat::ARGB32;
   case PIXEL_FORMAT_RGBX_8888:
-    return gfxImageFormatRGB24;
+    return gfxImageFormat::RGB24;
   case PIXEL_FORMAT_RGB_565:
-    return gfxImageFormatRGB16_565;
+    return gfxImageFormat::RGB16_565;
   default:
     MOZ_CRASH("Unknown gralloc pixel format");
   }
-  return gfxImageFormatARGB32;
+  return gfxImageFormat::ARGB32;
 }
 
 static android::PixelFormat
 PixelFormatForImageFormat(gfxImageFormat aFormat)
 {
   switch (aFormat) {
-  case gfxImageFormatARGB32:
+  case gfxImageFormat::ARGB32:
     return android::PIXEL_FORMAT_RGBA_8888;
-  case gfxImageFormatRGB24:
+  case gfxImageFormat::RGB24:
     return android::PIXEL_FORMAT_RGBX_8888;
-  case gfxImageFormatRGB16_565:
+  case gfxImageFormat::RGB16_565:
     return android::PIXEL_FORMAT_RGB_565;
   default:
     MOZ_CRASH("Unknown gralloc pixel format");
   }
-  return gfxImageFormatARGB32;
+  return gfxImageFormat::ARGB32;
 }
 
 static size_t
 BytesPerPixelForPixelFormat(android::PixelFormat aFormat)
 {
   switch (aFormat) {
   case PIXEL_FORMAT_RGBA_8888:
   case PIXEL_FORMAT_RGBX_8888:
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -680,23 +680,23 @@ ShadowLayerForwarder::GetDescriptorSurfa
   gfxASurface** aSurface)
 {
   gfxImageFormat format;
   if (PlatformGetDescriptorSurfaceImageFormat(aDescriptor, aMode, &format, aSurface)) {
     return format;
   }
 
   nsRefPtr<gfxASurface> surface = OpenDescriptor(aMode, aDescriptor);
-  NS_ENSURE_TRUE(surface, gfxImageFormatUnknown);
+  NS_ENSURE_TRUE(surface, gfxImageFormat::Unknown);
 
   nsRefPtr<gfxImageSurface> img = surface->GetAsImageSurface();
-  NS_ENSURE_TRUE(img, gfxImageFormatUnknown);
+  NS_ENSURE_TRUE(img, gfxImageFormat::Unknown);
 
   format = img->Format();
-  NS_ASSERTION(format != gfxImageFormatUnknown,
+  NS_ASSERTION(format != gfxImageFormat::Unknown,
                "ImageSurface RGB format should be known");
 
   *aSurface = surface.forget().get();
   return format;
 }
 
 /*static*/ void
 ShadowLayerForwarder::CloseDescriptor(const SurfaceDescriptor& aDescriptor)
@@ -809,17 +809,17 @@ AutoOpenSurface::ContentType()
 
 gfxImageFormat
 AutoOpenSurface::ImageFormat()
 {
   if (mSurface) {
     nsRefPtr<gfxImageSurface> img = mSurface->GetAsImageSurface();
     if (img) {
       gfxImageFormat format = img->Format();
-      NS_ASSERTION(format != gfxImageFormatUnknown,
+      NS_ASSERTION(format != gfxImageFormat::Unknown,
                    "ImageSurface RGB format should be known");
 
       return format;
     }
   }
 
   return ShadowLayerForwarder::GetDescriptorSurfaceImageFormat(
     mDescriptor, mMode, getter_AddRefs(mSurface));
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -446,17 +446,17 @@ private:
                            OpenMode aMode,
                            gfxASurface** aSurface);
   static bool
   PlatformGetDescriptorSurfaceSize(const SurfaceDescriptor& aDescriptor,
                                    OpenMode aMode,
                                    gfx::IntSize* aSize,
                                    gfxASurface** aSurface);
   // And again, for the image format.
-  // This function will return gfxImageFormatUnknown only if |aDescriptor|
+  // This function will return gfxImageFormat::Unknown only if |aDescriptor|
   // describes a non-ImageSurface.
   static gfxImageFormat
   GetDescriptorSurfaceImageFormat(const SurfaceDescriptor& aDescriptor,
                                   OpenMode aMode,
                                   gfxASurface** aSurface);
   static bool
   PlatformGetDescriptorSurfaceImageFormat(const SurfaceDescriptor& aDescriptor,
                                           OpenMode aMode,
--- a/gfx/layers/ipc/SharedRGBImage.cpp
+++ b/gfx/layers/ipc/SharedRGBImage.cpp
@@ -49,19 +49,19 @@ DeprecatedSharedRGBImage::~DeprecatedSha
   delete mShmem;
 }
 
 already_AddRefed<Image>
 CreateSharedRGBImage(ImageContainer *aImageContainer,
                      nsIntSize aSize,
                      gfxImageFormat aImageFormat)
 {
-  NS_ASSERTION(aImageFormat == gfxImageFormatARGB32 ||
-               aImageFormat == gfxImageFormatRGB24 ||
-               aImageFormat == gfxImageFormatRGB16_565,
+  NS_ASSERTION(aImageFormat == gfxImageFormat::ARGB32 ||
+               aImageFormat == gfxImageFormat::RGB24 ||
+               aImageFormat == gfxImageFormat::RGB16_565,
                "RGB formats supported only");
 
   if (!aImageContainer) {
     NS_WARNING("No ImageContainer to allocate DeprecatedSharedRGBImage");
     return nullptr;
   }
 
   ImageFormat format = SHARED_RGB;
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1502,17 +1502,17 @@ CompositorOGL::CopyToTarget(DrawTarget *
 
   DataSourceSurface::MappedSurface map;
   source->Map(DataSourceSurface::MapType::WRITE, &map);
   // XXX we should do this properly one day without using the gfxImageSurface
   nsRefPtr<gfxImageSurface> surf =
     new gfxImageSurface(map.mData,
                         gfxIntSize(width, height),
                         map.mStride,
-                        gfxImageFormatARGB32);
+                        gfxImageFormat::ARGB32);
   ReadPixelsIntoImageSurface(mGLContext, surf);
   source->Unmap();
 
   // Map from GL space to Cairo space and reverse the world transform.
   Matrix glToCairoTransform = ToMatrix(aTransform);
   glToCairoTransform.Invert();
   glToCairoTransform.Scale(1.0, -1.0);
   glToCairoTransform.Translate(0.0, -height);
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -745,17 +745,17 @@ TextureImageDeprecatedTextureHostOGL::Up
   AutoOpenSurface surf(OPEN_READ_ONLY, aImage);
   gfx::IntSize size = surf.Size();
   TextureImage::ImageFormat format = surf.ImageFormat();
 
   if (!mTexture ||
       (mTexture->GetSize() != size && !aOffset) ||
       mTexture->GetContentType() != surf.ContentType() ||
       (mTexture->GetImageFormat() != format &&
-       mTexture->GetImageFormat() != gfxImageFormatUnknown)) {
+       mTexture->GetImageFormat() != gfxImageFormat::Unknown)) {
 
     mTexture = CreateTextureImage(mGL,
                                   size,
                                   surf.ContentType(),
                                   WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                   FlagsToGLFlags(mFlags),
                                   format);
   }
@@ -1097,27 +1097,27 @@ YCbCrDeprecatedTextureHostOGL::UpdateImp
                                                     WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                     FlagsToGLFlags(mFlags));
   }
 
   RefPtr<gfxImageSurface> tempY =
     new gfxImageSurface(deserializer.GetYData(),
                         gfx::ThebesIntSize(gfxSize),
                         deserializer.GetYStride(),
-                        gfxImageFormatA8);
+                        gfxImageFormat::A8);
   RefPtr<gfxImageSurface> tempCb =
     new gfxImageSurface(deserializer.GetCbData(),
                         gfx::ThebesIntSize(gfxCbCrSize),
                         deserializer.GetCbCrStride(),
-                        gfxImageFormatA8);
+                        gfxImageFormat::A8);
   RefPtr<gfxImageSurface> tempCr =
     new gfxImageSurface(deserializer.GetCrData(),
                         gfx::ThebesIntSize(gfxCbCrSize),
                         deserializer.GetCbCrStride(),
-                        gfxImageFormatA8);
+                        gfxImageFormat::A8);
 
   nsIntRegion yRegion(nsIntRect(0, 0, gfxSize.width, gfxSize.height));
   nsIntRegion cbCrRegion(nsIntRect(0, 0, gfxCbCrSize.width, gfxCbCrSize.height));
 
   mYTexture->mTexImage->DirectUpdate(tempY, yRegion);
   mCbTexture->mTexImage->DirectUpdate(tempCb, cbCrRegion);
   mCrTexture->mTexImage->DirectUpdate(tempCr, cbCrRegion);
 }
@@ -1141,17 +1141,17 @@ TiledDeprecatedTextureHostOGL::BindTextu
   mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
 }
 
 static void
 GetFormatAndTileForImageFormat(gfxImageFormat aFormat,
                                GLenum& aOutFormat,
                                GLenum& aOutType)
 {
-  if (aFormat == gfxImageFormatRGB16_565) {
+  if (aFormat == gfxImageFormat::RGB16_565) {
     aOutFormat = LOCAL_GL_RGB;
     aOutType = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
   } else {
     aOutFormat = LOCAL_GL_RGBA;
     aOutType = LOCAL_GL_UNSIGNED_BYTE;
   }
 }
 
--- a/gfx/tests/gtest/TestTextures.cpp
+++ b/gfx/tests/gtest/TestTextures.cpp
@@ -204,19 +204,19 @@ void TestTextureClientYCbCr(TextureClien
 
   AssertYCbCrSurfacesEqual(&ycbcrData, &data);
   host->Unlock();
 }
 
 TEST(Layers, TextureSerialization) {
   // the test is run on all the following image formats
   gfxImageFormat formats[3] = {
-    gfxImageFormatARGB32,
-    gfxImageFormatRGB24,
-    gfxImageFormatA8,
+    gfxImageFormat::ARGB32,
+    gfxImageFormat::RGB24,
+    gfxImageFormat::A8,
   };
 
   for (int f = 0; f < 3; ++f) {
     RefPtr<gfxImageSurface> surface = new gfxImageSurface(gfxIntSize(400,300), formats[f]);
     SetupSurface(surface.get());
     AssertSurfacesEqual(surface, surface);
 
     RefPtr<TextureClient> client
@@ -226,19 +226,19 @@ TEST(Layers, TextureSerialization) {
 
     TestTextureClientSurface(client, surface);
 
     // XXX - Test more texture client types.
   }
 }
 
 TEST(Layers, TextureYCbCrSerialization) {
-  RefPtr<gfxImageSurface> ySurface = new gfxImageSurface(gfxIntSize(400,300), gfxImageFormatA8);
-  RefPtr<gfxImageSurface> cbSurface = new gfxImageSurface(gfxIntSize(200,150), gfxImageFormatA8);
-  RefPtr<gfxImageSurface> crSurface = new gfxImageSurface(gfxIntSize(200,150), gfxImageFormatA8);
+  RefPtr<gfxImageSurface> ySurface = new gfxImageSurface(gfxIntSize(400,300), gfxImageFormat::A8);
+  RefPtr<gfxImageSurface> cbSurface = new gfxImageSurface(gfxIntSize(200,150), gfxImageFormat::A8);
+  RefPtr<gfxImageSurface> crSurface = new gfxImageSurface(gfxIntSize(200,150), gfxImageFormat::A8);
   SetupSurface(ySurface.get());
   SetupSurface(cbSurface.get());
   SetupSurface(crSurface.get());
 
   PlanarYCbCrData clientData;
   clientData.mYChannel = ySurface->Data();
   clientData.mCbChannel = cbSurface->Data();
   clientData.mCrChannel = crSurface->Data();
--- a/gfx/tests/gtest/gfxFontSelectionTest.cpp
+++ b/gfx/tests/gtest/gfxFontSelectionTest.cpp
@@ -184,17 +184,17 @@ static already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
     surface = gfxPlatform::GetPlatform()->
         CreateOffscreenSurface(gfxIntSize(size, size),
-                               gfxASurface::ContentFromFormat(gfxImageFormatRGB24));
+                               gfxASurface::ContentFromFormat(gfxImageFormat::RGB24));
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     return ctx.forget();
 }
 
 TestEntry*
 AddTest (nsTArray<TestEntry>& testList,
          const char *utf8FamilyString,
          const gfxFontStyle& fontStyle,
--- a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp
+++ b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp
@@ -39,17 +39,17 @@ SurfaceDestroyNotifier (void *data) {
     *(int *)data = 1;
 }
 
 int
 TestNewSurface () {
     int failures = 0;
     int destroyed = 0;
 
-    nsRefPtr<gfxASurface> s = new gfxImageSurface (gfxIntSize(10, 10), gfxImageFormatARGB32);
+    nsRefPtr<gfxASurface> s = new gfxImageSurface (gfxIntSize(10, 10), gfxImageFormat::ARGB32);
     cairo_surface_t *cs = s->CairoSurface();
 
     cairo_surface_set_user_data (cs, &destruction_key, &destroyed, SurfaceDestroyNotifier);
 
     failures += CheckInt (GetASurfaceRefCount(s.get()), 1);
     failures += CheckInt (cairo_surface_get_reference_count(cs), 1);
     failures += CheckInt (destroyed, 0);
 
--- a/gfx/tests/gtest/gfxTextRunPerfTest.cpp
+++ b/gfx/tests/gtest/gfxTextRunPerfTest.cpp
@@ -36,17 +36,17 @@ static already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
     surface = gfxPlatform::GetPlatform()->
         CreateOffscreenSurface(gfxIntSize(size, size),
-                               gfxASurface::ContentFromFormat(gfxImageFormatRGB24));
+                               gfxASurface::ContentFromFormat(gfxImageFormat::RGB24));
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     return ctx.forget();
 }
 
 const char* lastFamilies = nullptr;
 
 static void
 RunTest (TestEntry *test, gfxContext *ctx) {
--- a/gfx/tests/gtest/gfxWordCacheTest.cpp
+++ b/gfx/tests/gtest/gfxWordCacheTest.cpp
@@ -77,17 +77,17 @@ static already_AddRefed<gfxContext>
 MakeContext ()
 {
    const int size = 200;
 
    nsRefPtr<gfxASurface> surface;
 
    surface = gfxPlatform::GetPlatform()->
        CreateOffscreenSurface(gfxIntSize(size, size),
-                              gfxASurface::ContentFromFormat(gfxImageFormatRGB24));
+                              gfxASurface::ContentFromFormat(gfxImageFormat::RGB24));
    nsRefPtr<gfxContext> ctx = new gfxContext(surface);
    return ctx.forget();
 }
 
 TEST(Gfx, WordCache) {
    gTextRuns = new FrameTextRunCache();
 
    nsRefPtr<gfxContext> ctx = MakeContext();
--- a/gfx/thebes/gfx2DGlue.h
+++ b/gfx/thebes/gfx2DGlue.h
@@ -204,41 +204,41 @@ inline JoinStyle ToJoinStyle(gfxContext:
   }
   MOZ_CRASH("Incomplete switch");
 }
 
 inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
   case SurfaceFormat::B8G8R8A8:
-    return gfxImageFormatARGB32;
+    return gfxImageFormat::ARGB32;
   case SurfaceFormat::B8G8R8X8:
-    return gfxImageFormatRGB24;
+    return gfxImageFormat::RGB24;
   case SurfaceFormat::R5G6B5:
-    return gfxImageFormatRGB16_565;
+    return gfxImageFormat::RGB16_565;
   case SurfaceFormat::A8:
-    return gfxImageFormatA8;
+    return gfxImageFormat::A8;
   default:
-    return gfxImageFormatUnknown;
+    return gfxImageFormat::Unknown;
   }
 }
 
 inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
 {
   switch (aFormat) {
-  case gfxImageFormatARGB32:
+  case gfxImageFormat::ARGB32:
     return SurfaceFormat::B8G8R8A8;
-  case gfxImageFormatRGB24:
+  case gfxImageFormat::RGB24:
     return SurfaceFormat::B8G8R8X8;
-  case gfxImageFormatRGB16_565:
+  case gfxImageFormat::RGB16_565:
     return SurfaceFormat::R5G6B5;
-  case gfxImageFormatA8:
+  case gfxImageFormat::A8:
     return SurfaceFormat::A8;
   default:
-  case gfxImageFormatUnknown:
+  case gfxImageFormat::Unknown:
     return SurfaceFormat::B8G8R8A8;
   }
 }
 
 inline gfxContentType ContentForFormat(const SurfaceFormat &aFormat)
 {
   switch (aFormat) {
   case SurfaceFormat::R5G6B5:
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -339,32 +339,32 @@ gfxASurface::CreateSimilarSurface(gfxCon
     cairo_surface_destroy(surface);
     return result.forget();
 }
 
 already_AddRefed<gfxImageSurface>
 gfxASurface::GetAsReadableARGB32ImageSurface()
 {
     nsRefPtr<gfxImageSurface> imgSurface = GetAsImageSurface();
-    if (!imgSurface || imgSurface->Format() != gfxImageFormatARGB32) {
+    if (!imgSurface || imgSurface->Format() != gfxImageFormat::ARGB32) {
       imgSurface = CopyToARGB32ImageSurface();
     }
     return imgSurface.forget();
 }
 
 already_AddRefed<gfxImageSurface>
 gfxASurface::CopyToARGB32ImageSurface()
 {
     if (!mSurface || !mSurfaceValid) {
       return nullptr;
     }
 
     const nsIntSize size = GetSize();
     nsRefPtr<gfxImageSurface> imgSurface =
-        new gfxImageSurface(size, gfxImageFormatARGB32);
+        new gfxImageSurface(size, gfxImageFormat::ARGB32);
 
     if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
         RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height));
         RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, this);
 
         dt->CopySurface(source, IntRect(0, 0, size.width, size.height), IntPoint());
     } else {
         gfxContext ctx(imgSurface);
@@ -427,17 +427,17 @@ gfxASurface::CheckSurfaceSize(const nsIn
 
     return true;
 }
 
 /* static */
 int32_t
 gfxASurface::FormatStrideForWidth(gfxImageFormat format, int32_t width)
 {
-    return cairo_format_stride_for_width((cairo_format_t)format, (int)width);
+    return cairo_format_stride_for_width((cairo_format_t)(int)format, (int)width);
 }
 
 nsresult
 gfxASurface::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName)
 {
     return NS_OK;
 }
 
@@ -464,26 +464,26 @@ gfxASurface::EndPage()
 {
     return NS_OK;
 }
 
 gfxContentType
 gfxASurface::ContentFromFormat(gfxImageFormat format)
 {
     switch (format) {
-        case gfxImageFormatARGB32:
+        case gfxImageFormat::ARGB32:
             return GFX_CONTENT_COLOR_ALPHA;
-        case gfxImageFormatRGB24:
-        case gfxImageFormatRGB16_565:
+        case gfxImageFormat::RGB24:
+        case gfxImageFormat::RGB16_565:
             return GFX_CONTENT_COLOR;
-        case gfxImageFormatA8:
-        case gfxImageFormatA1:
+        case gfxImageFormat::A8:
+        case gfxImageFormat::A1:
             return GFX_CONTENT_ALPHA;
 
-        case gfxImageFormatUnknown:
+        case gfxImageFormat::Unknown:
         default:
             return GFX_CONTENT_COLOR;
     }
 }
 
 void
 gfxASurface::SetSubpixelAntialiasingEnabled(bool aEnabled)
 {
@@ -512,22 +512,22 @@ gfxASurface::GetMemoryLocation() const
 {
     return GFX_MEMORY_IN_PROCESS_HEAP;
 }
 
 int32_t
 gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
 {
     switch (format) {
-        case gfxImageFormatARGB32:
-        case gfxImageFormatRGB24:
+        case gfxImageFormat::ARGB32:
+        case gfxImageFormat::RGB24:
             return 4;
-        case gfxImageFormatRGB16_565:
+        case gfxImageFormat::RGB16_565:
             return 2;
-        case gfxImageFormatA8:
+        case gfxImageFormat::A8:
             return 1;
         default:
             NS_WARNING("Unknown byte per pixel value for Image format");
     }
     return 0;
 }
 
 void
@@ -710,27 +710,27 @@ gfxASurface::SizeOfIncludingThis(MallocS
 {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
 }
 
 /* static */ uint8_t
 gfxASurface::BytesPerPixel(gfxImageFormat aImageFormat)
 {
   switch (aImageFormat) {
-    case gfxImageFormatARGB32:
+    case gfxImageFormat::ARGB32:
       return 4;
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::RGB24:
       return 4;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
       return 2;
-    case gfxImageFormatA8:
+    case gfxImageFormat::A8:
       return 1;
-    case gfxImageFormatA1:
+    case gfxImageFormat::A1:
       return 1; // Close enough
-    case gfxImageFormatUnknown:
+    case gfxImageFormat::Unknown:
     default:
       NS_NOTREACHED("Not really sure what you want me to say here");
       return 0;
   }
 }
 
 void
 gfxASurface::WriteAsPNG(const char* aFile)
@@ -770,26 +770,26 @@ gfxASurface::CopyAsDataURL()
  */
 void
 gfxASurface::WriteAsPNG_internal(FILE* aFile, bool aBinary)
 {
   nsRefPtr<gfxImageSurface> imgsurf = GetAsImageSurface();
   nsIntSize size;
 
   // FIXME/bug 831898: hack r5g6b5 for now.
-  if (!imgsurf || imgsurf->Format() == gfxImageFormatRGB16_565) {
+  if (!imgsurf || imgsurf->Format() == gfxImageFormat::RGB16_565) {
     size = GetSize();
     if (size.width == -1 && size.height == -1) {
       printf("Could not determine surface size\n");
       return;
     }
 
     imgsurf =
       new gfxImageSurface(nsIntSize(size.width, size.height),
-                          gfxImageFormatARGB32);
+                          gfxImageFormat::ARGB32);
 
     if (!imgsurf || imgsurf->CairoStatus()) {
       printf("Could not allocate image surface\n");
       return;
     }
 
     nsRefPtr<gfxContext> ctx = new gfxContext(imgsurf);
     if (!ctx || ctx->HasError()) {
--- a/gfx/thebes/gfxAlphaRecovery.cpp
+++ b/gfx/thebes/gfxAlphaRecovery.cpp
@@ -12,20 +12,20 @@
 
 /* static */ bool
 gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
                                const gfxImageSurface* whiteSurf)
 {
     gfxIntSize size = blackSurf->GetSize();
 
     if (size != whiteSurf->GetSize() ||
-        (blackSurf->Format() != gfxImageFormatARGB32 &&
-         blackSurf->Format() != gfxImageFormatRGB24) ||
-        (whiteSurf->Format() != gfxImageFormatARGB32 &&
-         whiteSurf->Format() != gfxImageFormatRGB24))
+        (blackSurf->Format() != gfxImageFormat::ARGB32 &&
+         blackSurf->Format() != gfxImageFormat::RGB24) ||
+        (whiteSurf->Format() != gfxImageFormat::ARGB32 &&
+         whiteSurf->Format() != gfxImageFormat::RGB24))
         return false;
 
 #ifdef MOZILLA_MAY_SUPPORT_SSE2
     if (mozilla::supports_sse2() &&
         RecoverAlphaSSE2(blackSurf, whiteSurf)) {
         return true;
     }
 #endif
--- a/gfx/thebes/gfxAlphaRecoverySSE2.cpp
+++ b/gfx/thebes/gfxAlphaRecoverySSE2.cpp
@@ -29,20 +29,20 @@ static uint32_t alphaMaski[] = { 0xff000
 
 bool
 gfxAlphaRecovery::RecoverAlphaSSE2(gfxImageSurface* blackSurf,
                                    const gfxImageSurface* whiteSurf)
 {
     gfxIntSize size = blackSurf->GetSize();
 
     if (size != whiteSurf->GetSize() ||
-        (blackSurf->Format() != gfxImageFormatARGB32 &&
-         blackSurf->Format() != gfxImageFormatRGB24) ||
-        (whiteSurf->Format() != gfxImageFormatARGB32 &&
-         whiteSurf->Format() != gfxImageFormatRGB24))
+        (blackSurf->Format() != gfxImageFormat::ARGB32 &&
+         blackSurf->Format() != gfxImageFormat::RGB24) ||
+        (whiteSurf->Format() != gfxImageFormat::ARGB32 &&
+         whiteSurf->Format() != gfxImageFormat::RGB24))
         return false;
 
     blackSurf->Flush();
     whiteSurf->Flush();
 
     unsigned char* blackData = blackSurf->Data();
     unsigned char* whiteData = whiteSurf->Data();
 
@@ -136,17 +136,17 @@ ByteAlignment(int32_t aAlignToLog2, int3
 {
     return (aX + aStride * aY) & ((1 << aAlignToLog2) - 1);
 }
 
 /*static*/ nsIntRect
 gfxAlphaRecovery::AlignRectForSubimageRecovery(const nsIntRect& aRect,
                                                gfxImageSurface* aSurface)
 {
-    NS_ASSERTION(gfxImageFormatARGB32 == aSurface->Format(),
+    NS_ASSERTION(gfxImageFormat::ARGB32 == aSurface->Format(),
                  "Thebes grew support for non-ARGB32 COLOR_ALPHA?");
     static const int32_t kByteAlignLog2 = GoodAlignmentLog2();
     static const int32_t bpp = 4;
     static const int32_t pixPerAlign = (1 << kByteAlignLog2) / bpp;
     //
     // We're going to create a subimage of the surface with size
     // <sw,sh> for alpha recovery, and want a SIMD fast-path.  The
     // rect <x,y, w,h> /needs/ to be redrawn, but it might not be
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -112,21 +112,21 @@ gfxAndroidPlatform::gfxAndroidPlatform()
 
     nsCOMPtr<nsIScreenManager> screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1");
     nsCOMPtr<nsIScreen> screen;
     screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
     mScreenDepth = 24;
     screen->GetColorDepth(&mScreenDepth);
 
     mOffscreenFormat = mScreenDepth == 16
-                       ? gfxImageFormatRGB16_565
-                       : gfxImageFormatRGB24;
+                       ? gfxImageFormat::RGB16_565
+                       : gfxImageFormat::RGB24;
 
     if (Preferences::GetBool("gfx.android.rgb16.force", false)) {
-        mOffscreenFormat = gfxImageFormatRGB16_565;
+        mOffscreenFormat = gfxImageFormat::RGB16_565;
     }
 
 }
 
 gfxAndroidPlatform::~gfxAndroidPlatform()
 {
     cairo_debug_reset_static_data();
 
--- a/gfx/thebes/gfxBaseSharedMemorySurface.h
+++ b/gfx/thebes/gfxBaseSharedMemorySurface.h
@@ -14,17 +14,17 @@
 #include "gfxImageSurface.h"
 #include "pratom.h"
 
 typedef struct _cairo_user_data_key cairo_user_data_key_t;
 
 struct SharedImageInfo {
     int32_t width;
     int32_t height;
-    int32_t format;
+    gfxImageFormat format;
     int32_t readCount;
 };
 
 inline SharedImageInfo*
 GetShmInfoPtr(const mozilla::ipc::Shmem& aShmem)
 {
     return reinterpret_cast<SharedImageInfo*>
         (aShmem.get<char>() + aShmem.Size<char>() - sizeof(SharedImageInfo));
--- a/gfx/thebes/gfxBlur.cpp
+++ b/gfx/thebes/gfxBlur.cpp
@@ -66,17 +66,17 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRe
         gfxPlatform::GetPlatform()->CreateDrawTargetForData(mData, size,
                                                             mBlur->GetStride(),
                                                             SurfaceFormat::A8);
     if (!dt) {
         nsRefPtr<gfxImageSurface> image =
             new gfxImageSurface(mData,
                                 gfxIntSize(size.width, size.height),
                                 mBlur->GetStride(),
-                                gfxImageFormatA8);
+                                gfxImageFormat::A8);
         dt = Factory::CreateDrawTargetForCairoSurface(image->CairoSurface(), size);
         if (!dt) {
             return nullptr;
         }
     }
 
     IntRect irect = mBlur->GetRect();
     gfxPoint topleft(irect.TopLeft().x, irect.TopLeft().y);
--- a/gfx/thebes/gfxD2DSurface.cpp
+++ b/gfx/thebes/gfxD2DSurface.cpp
@@ -37,17 +37,17 @@ gfxD2DSurface::gfxD2DSurface(cairo_surfa
     Init(csurf, true);
 }
 
 gfxD2DSurface::gfxD2DSurface(const gfxIntSize& size,
                              gfxImageFormat imageFormat)
 {
     Init(cairo_d2d_surface_create(
         gfxWindowsPlatform::GetPlatform()->GetD2DDevice(),
-        (cairo_format_t)imageFormat,
+        (cairo_format_t)(int)imageFormat,
         size.width, size.height));
 }
 
 gfxD2DSurface::~gfxD2DSurface()
 {
 }
 
 void
--- a/gfx/thebes/gfxD2DSurface.h
+++ b/gfx/thebes/gfxD2DSurface.h
@@ -16,17 +16,17 @@ struct nsIntRect;
 
 class gfxD2DSurface : public gfxASurface {
 public:
 
     gfxD2DSurface(HWND wnd,
                   gfxContentType aContent);
 
     gfxD2DSurface(const gfxIntSize& size,
-                  gfxImageFormat imageFormat = gfxImageFormatRGB24);
+                  gfxImageFormat imageFormat = gfxImageFormat::RGB24);
 
     gfxD2DSurface(HANDLE handle, gfxContentType aContent);
 
     gfxD2DSurface(ID3D10Texture2D *texture, gfxContentType aContent);
 
     gfxD2DSurface(cairo_surface_t *csurf);
 
     void MovePixels(const nsIntRect& aSourceRect,
--- a/gfx/thebes/gfxImageSurface.cpp
+++ b/gfx/thebes/gfxImageSurface.cpp
@@ -15,17 +15,17 @@
 #include "gfx2DGlue.h"
 #include <algorithm>
 
 using namespace mozilla::gfx;
 
 gfxImageSurface::gfxImageSurface()
   : mSize(0, 0),
     mOwnsData(false),
-    mFormat(gfxImageFormatUnknown),
+    mFormat(gfxImageFormat::Unknown),
     mStride(0)
 {
 }
 
 void
 gfxImageSurface::InitFromSurface(cairo_surface_t *csurf)
 {
     mSize.width = cairo_image_surface_get_width(csurf);
@@ -62,17 +62,17 @@ gfxImageSurface::InitWithData(unsigned c
     mFormat = aFormat;
     mStride = aStride;
 
     if (!CheckSurfaceSize(aSize))
         MakeInvalid();
 
     cairo_surface_t *surface =
         cairo_image_surface_create_for_data((unsigned char*)mData,
-                                            (cairo_format_t)mFormat,
+                                            (cairo_format_t)(int)mFormat,
                                             mSize.width,
                                             mSize.height,
                                             mStride);
 
     // cairo_image_surface_create_for_data can return a 'null' surface
     // in out of memory conditions. The gfxASurface::Init call checks
     // the surface it receives to see if there is an error with the
     // surface and handles it appropriately. That is why there is
@@ -131,17 +131,17 @@ gfxImageSurface::AllocateAndInit(long aS
         if (aClear)
             memset(mData, 0, aMinimalAllocation);
     }
 
     mOwnsData = true;
 
     cairo_surface_t *surface =
         cairo_image_surface_create_for_data((unsigned char*)mData,
-                                            (cairo_format_t)mFormat,
+                                            (cairo_format_t)(int)mFormat,
                                             mSize.width,
                                             mSize.height,
                                             mStride);
 
     Init(surface);
 
     if (mSurfaceValid) {
         RecordMemoryUsed(mSize.height * ComputeStride() +
@@ -174,25 +174,25 @@ gfxImageSurface::~gfxImageSurface()
         free(mData);
 }
 
 /*static*/ long
 gfxImageSurface::ComputeStride(const gfxIntSize& aSize, gfxImageFormat aFormat)
 {
     long stride;
 
-    if (aFormat == gfxImageFormatARGB32)
+    if (aFormat == gfxImageFormat::ARGB32)
         stride = aSize.width * 4;
-    else if (aFormat == gfxImageFormatRGB24)
+    else if (aFormat == gfxImageFormat::RGB24)
         stride = aSize.width * 4;
-    else if (aFormat == gfxImageFormatRGB16_565)
+    else if (aFormat == gfxImageFormat::RGB16_565)
         stride = aSize.width * 2;
-    else if (aFormat == gfxImageFormatA8)
+    else if (aFormat == gfxImageFormat::A8)
         stride = aSize.width;
-    else if (aFormat == gfxImageFormatA1) {
+    else if (aFormat == gfxImageFormat::A1) {
         stride = (aSize.width + 7) / 8;
     } else {
         NS_WARNING("Unknown format specified to gfxImageSurface!");
         stride = aSize.width * 4;
     }
 
     stride = ((stride + 3) / 4) * 4;
 
@@ -238,20 +238,20 @@ CopyForStride(unsigned char* aDest, unsi
     }
 }
 
 // helper function for the CopyFrom methods
 static bool
 FormatsAreCompatible(gfxImageFormat a1, gfxImageFormat a2)
 {
     if (a1 != a2 &&
-        !(a1 == gfxImageFormatARGB32 &&
-          a2 == gfxImageFormatRGB24) &&
-        !(a1 == gfxImageFormatRGB24 &&
-          a2 == gfxImageFormatARGB32)) {
+        !(a1 == gfxImageFormat::ARGB32 &&
+          a2 == gfxImageFormat::RGB24) &&
+        !(a1 == gfxImageFormat::RGB24 &&
+          a2 == gfxImageFormat::ARGB32)) {
         return false;
     }
 
     return true;
 }
 
 bool
 gfxImageSurface::CopyFrom (SourceSurface *aSurface)
@@ -325,19 +325,19 @@ gfxImageSurface::GetSubimage(const gfxRe
     MOZ_ASSERT(gfxRect(0, 0, mSize.width, mSize.height).Contains(r));
 
     gfxImageFormat format = Format();
 
     unsigned char* subData = Data() +
         (Stride() * (int)r.Y()) +
         (int)r.X() * gfxASurface::BytePerPixelFromFormat(Format());
 
-    if (format == gfxImageFormatARGB32 &&
+    if (format == gfxImageFormat::ARGB32 &&
         GetOpaqueRect().Contains(aRect)) {
-        format = gfxImageFormatRGB24;
+        format = gfxImageFormat::RGB24;
     }
 
     nsRefPtr<gfxSubimageSurface> image =
         new gfxSubimageSurface(this, subData,
                                gfxIntSize((int)r.Width(), (int)r.Height()),
                                format);
 
     return image.forget();
--- a/gfx/thebes/gfxOS2Platform.cpp
+++ b/gfx/thebes/gfxOS2Platform.cpp
@@ -53,17 +53,17 @@ gfxOS2Platform::CreateOffscreenSurface(c
                                        gfxContentType contentType)
 {
 #ifdef DEBUG_thebes_2
     printf("gfxOS2Platform::CreateOffscreenSurface(%d/%d, %d)\n",
            aSize.width, aSize.height, aImageFormat);
 #endif
     gfxASurface *newSurface = nullptr;
 
-    // we only ever seem to get aImageFormat=0 or gfxImageFormatARGB32 but
+    // we only ever seem to get aImageFormat=0 or gfxImageFormat::ARGB32 but
     // I don't really know if we need to differ between ARGB32 and RGB24 here
     if (contentType == GFX_CONTENT_COLOR_ALPHA ||
         contentType == GFX_CONTENT_COLOR)
     {
         newSurface = new gfxOS2Surface(aSize, OptimalFormatForContent(contentType));
     } else if (contentType == GFX_CONTENT_ALPHA) {
         newSurface = new gfxImageSurface(aSize, OptimalFormatForContent(contentType));
     } else {
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -798,26 +798,26 @@ gfxPlatform::GetSourceSurfaceForSurface(
       nsRefPtr<gfxContext> ctx = new gfxContext(imgSurface);
       ctx->SetSource(aSurface);
       ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
       ctx->Paint();
     }
 
     gfxImageFormat cairoFormat = imgSurface->Format();
     switch(cairoFormat) {
-      case gfxImageFormatARGB32:
+      case gfxImageFormat::ARGB32:
         format = SurfaceFormat::B8G8R8A8;
         break;
-      case gfxImageFormatRGB24:
+      case gfxImageFormat::RGB24:
         format = SurfaceFormat::B8G8R8X8;
         break;
-      case gfxImageFormatA8:
+      case gfxImageFormat::A8:
         format = SurfaceFormat::A8;
         break;
-      case gfxImageFormatRGB16_565:
+      case gfxImageFormat::RGB16_565:
         format = SurfaceFormat::R5G6B5;
         break;
       default:
         NS_RUNTIMEABORT("Invalid surface format!");
     }
 
     IntSize size = IntSize(imgSurface->GetSize().width, imgSurface->GetSize().height);
     srcBuffer = aTarget->CreateSourceSurfaceFromData(imgSurface->Data(),
@@ -1998,21 +1998,21 @@ gfxPlatform::GetScreenDepth() const
 }
 
 mozilla::gfx::SurfaceFormat
 gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
 {
   switch (aContent) {
   case GFX_CONTENT_COLOR:
     switch (GetOffscreenFormat()) {
-    case gfxImageFormatARGB32:
+    case gfxImageFormat::ARGB32:
       return mozilla::gfx::SurfaceFormat::B8G8R8A8;
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::RGB24:
       return mozilla::gfx::SurfaceFormat::B8G8R8X8;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
       return mozilla::gfx::SurfaceFormat::R5G6B5;
     default:
       NS_NOTREACHED("unknown gfxImageFormat for GFX_CONTENT_COLOR");
       return mozilla::gfx::SurfaceFormat::B8G8R8A8;
     }
   case GFX_CONTENT_ALPHA:
     return mozilla::gfx::SurfaceFormat::A8;
   case GFX_CONTENT_COLOR_ALPHA:
@@ -2025,22 +2025,22 @@ gfxPlatform::Optimal2DFormatForContent(g
 
 gfxImageFormat
 gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
 {
   switch (aContent) {
   case GFX_CONTENT_COLOR:
     return GetOffscreenFormat();
   case GFX_CONTENT_ALPHA:
-    return gfxImageFormatA8;
+    return gfxImageFormat::A8;
   case GFX_CONTENT_COLOR_ALPHA:
-    return gfxImageFormatARGB32;
+    return gfxImageFormat::ARGB32;
   default:
     NS_NOTREACHED("unknown gfxContentType");
-    return gfxImageFormatARGB32;
+    return gfxImageFormat::ARGB32;
   }
 }
 
 void
 gfxPlatform::OrientationSyncPrefsObserverChanged()
 {
   mOrientationSyncMillis = Preferences::GetUint("layers.orientation.sync.timeout", (uint32_t)0);
 }
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -590,17 +590,17 @@ public:
     gfxASurface* ScreenReferenceSurface() { return mScreenReferenceSurface; }
     mozilla::gfx::DrawTarget* ScreenReferenceDrawTarget() { return mScreenReferenceDrawTarget; }
 
     virtual mozilla::gfx::SurfaceFormat Optimal2DFormatForContent(gfxContentType aContent);
 
     virtual gfxImageFormat OptimalFormatForContent(gfxContentType aContent);
 
     virtual gfxImageFormat GetOffscreenFormat()
-    { return gfxImageFormatRGB24; }
+    { return gfxImageFormat::RGB24; }
 
     /**
      * Returns a logger if one is available and logging is enabled
      */
     static PRLogModuleInfo* GetLog(eGfxLog aWhichLog);
 
     bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
 
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -237,20 +237,20 @@ gfxPlatformGtk::GetDPI()
 }
 
 gfxImageFormat
 gfxPlatformGtk::GetOffscreenFormat()
 {
     // Make sure there is a screen
     GdkScreen *screen = gdk_screen_get_default();
     if (screen && gdk_visual_get_depth(gdk_visual_get_system()) == 16) {
-        return gfxImageFormatRGB16_565;
+        return gfxImageFormat::RGB16_565;
     }
 
-    return gfxImageFormatRGB24;
+    return gfxImageFormat::RGB24;
 }
 
 static int sDepth = 0;
 
 int
 gfxPlatformGtk::GetScreenDepth() const
 {
     if (!sDepth) {
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -367,18 +367,18 @@ gfxPlatformMac::CreateThebesSurfaceAlias
 {
   if (aTarget->GetType() == BackendType::COREGRAPHICS) {
     CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
     unsigned char* data = (unsigned char*)CGBitmapContextGetData(cg);
     size_t bpp = CGBitmapContextGetBitsPerPixel(cg);
     size_t stride = CGBitmapContextGetBytesPerRow(cg);
     gfxIntSize size(aTarget->GetSize().width, aTarget->GetSize().height);
     nsRefPtr<gfxImageSurface> imageSurface = new gfxImageSurface(data, size, stride, bpp == 2
-                                                                                     ? gfxImageFormatRGB16_565
-                                                                                     : gfxImageFormatARGB32);
+                                                                                     ? gfxImageFormat::RGB16_565
+                                                                                     : gfxImageFormat::ARGB32);
     // Here we should return a gfxQuartzImageSurface but quartz will assumes that image surfaces
     // don't change which wont create a proper alias to the draw target, therefore we have to
     // return a plain image surface.
     return imageSurface.forget();
   } else {
     return GetThebesSurfaceForDrawTarget(aTarget);
   }
 }
@@ -386,19 +386,19 @@ gfxPlatformMac::CreateThebesSurfaceAlias
 already_AddRefed<gfxASurface>
 gfxPlatformMac::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
 {
   if (aTarget->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
     RefPtr<SourceSurface> source = aTarget->Snapshot();
     RefPtr<DataSourceSurface> sourceData = source->GetDataSurface();
     unsigned char* data = sourceData->GetData();
     nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(data, ThebesIntSize(sourceData->GetSize()), sourceData->Stride(),
-                                                         gfxImageFormatARGB32);
+                                                         gfxImageFormat::ARGB32);
     // We could fix this by telling gfxImageSurface it owns data.
-    nsRefPtr<gfxImageSurface> cpy = new gfxImageSurface(ThebesIntSize(sourceData->GetSize()), gfxImageFormatARGB32);
+    nsRefPtr<gfxImageSurface> cpy = new gfxImageSurface(ThebesIntSize(sourceData->GetSize()), gfxImageFormat::ARGB32);
     cpy->CopyFrom(surf);
     return cpy.forget();
   } else if (aTarget->GetType() == BackendType::COREGRAPHICS) {
     CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
 
     //XXX: it would be nice to have an implicit conversion from IntSize to gfxIntSize
     IntSize intSize = aTarget->GetSize();
     gfxIntSize size(intSize.width, intSize.height);
--- a/gfx/thebes/gfxQtPlatform.cpp
+++ b/gfx/thebes/gfxQtPlatform.cpp
@@ -59,17 +59,17 @@ static QPaintEngine::Type sDefaultQtPain
 gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nullptr;
 static cairo_user_data_key_t cairo_qt_pixmap_key;
 static void do_qt_pixmap_unref (void *data)
 {
     QPixmap *pmap = (QPixmap*)data;
     delete pmap;
 }
 
-static gfxImageFormat sOffscreenFormat = gfxImageFormatRGB24;
+static gfxImageFormat sOffscreenFormat = gfxImageFormat::RGB24;
 
 gfxQtPlatform::gfxQtPlatform()
 {
     mPrefFonts.Init(50);
 
     if (!sFontconfigUtils)
         sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
 
@@ -97,17 +97,17 @@ gfxQtPlatform::gfxQtPlatform()
         default:
             mRenderMode = RENDER_QPAINTER;
     }
 
     // Qt doesn't provide a public API to detect the graphicssystem type. We hack
     // around this by checking what type of graphicssystem a test QPixmap uses.
     QPixmap pixmap(1, 1);
     if (pixmap.depth() == 16) {
-        sOffscreenFormat = gfxImageFormatRGB16_565;
+        sOffscreenFormat = gfxImageFormat::RGB16_565;
     }
     mScreenDepth = pixmap.depth();
 #if (QT_VERSION < QT_VERSION_CHECK(4,8,0))
     if (pixmap.paintEngine())
         sDefaultQtPaintEngineType = pixmap.paintEngine()->type();
 #endif
 }
 
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -108,17 +108,17 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
                                                              x0, y0));
 
         // bug 382049 - need to explicity set the composite operation to sourceOver
         CGContextSetCompositeOperation(mCGContext, kPrivateCGCompositeSourceOver);
     } else {
         nsIntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
                               NSToIntFloor(mNativeRect.height * mBackingScale));
         mQuartzSurface = new gfxQuartzSurface(backingSize,
-                                              gfxImageFormatARGB32);
+                                              gfxImageFormat::ARGB32);
         if (mQuartzSurface->CairoStatus())
             return nullptr;
         mSurfaceContext = new gfxContext(mQuartzSurface);
 
         // grab the CGContextRef
         mCGContext = cairo_quartz_get_cg_context_with_clip(mSurfaceContext->GetCairo());
         CGContextScaleCTM(mCGContext, mBackingScale, mBackingScale);
         CGContextTranslateCTM(mCGContext, -mNativeRect.X(), -mNativeRect.Y());
--- a/gfx/thebes/gfxTypes.h
+++ b/gfx/thebes/gfxTypes.h
@@ -40,28 +40,28 @@ typedef double gfxFloat;
  * @see nsLineLayout::NotifyOptionalBreakPosition
  */
 MOZ_BEGIN_ENUM_CLASS(gfxBreakPriority)
   eNoBreak       = 0,
   eWordWrapBreak,
   eNormalBreak
 MOZ_END_ENUM_CLASS(gfxBreakPriority)
 
-    /**
-     * The format for an image surface. For all formats with alpha data, 0
-     * means transparent, 1 or 255 means fully opaque.
-     */
-    enum gfxImageFormat {
-        gfxImageFormatARGB32, ///< ARGB data in native endianness, using premultiplied alpha
-        gfxImageFormatRGB24,  ///< xRGB data in native endianness
-        gfxImageFormatA8,     ///< Only an alpha channel
-        gfxImageFormatA1,     ///< Packed transparency information (one byte refers to 8 pixels)
-        gfxImageFormatRGB16_565,  ///< RGB_565 data in native endianness
-        gfxImageFormatUnknown
-    };
+/**
+  * The format for an image surface. For all formats with alpha data, 0
+  * means transparent, 1 or 255 means fully opaque.
+  */
+MOZ_BEGIN_ENUM_CLASS(gfxImageFormat)
+  ARGB32, ///< ARGB data in native endianness, using premultiplied alpha
+  RGB24,  ///< xRGB data in native endianness
+  A8,     ///< Only an alpha channel
+  A1,     ///< Packed transparency information (one byte refers to 8 pixels)
+  RGB16_565,  ///< RGB_565 data in native endianness
+  Unknown
+MOZ_END_ENUM_CLASS(gfxImageFormat)
 
     enum gfxSurfaceType {
         gfxSurfaceTypeImage,
         gfxSurfaceTypePDF,
         gfxSurfaceTypePS,
         gfxSurfaceTypeXlib,
         gfxSurfaceTypeXcb,
         gfxSurfaceTypeGlitz,           // unused, but needed for cairo parity
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -44,17 +44,17 @@ gfxUtils::PremultiplyImageSurface(gfxIma
                aSourceSurface->Height() == aDestSurface->Height() &&
                aSourceSurface->Stride() == aDestSurface->Stride(),
                "Source and destination surfaces don't have identical characteristics");
 
     MOZ_ASSERT(aSourceSurface->Stride() == aSourceSurface->Width() * 4,
                "Source surface stride isn't tightly packed");
 
     // Only premultiply ARGB32
-    if (aSourceSurface->Format() != gfxImageFormatARGB32) {
+    if (aSourceSurface->Format() != gfxImageFormat::ARGB32) {
         if (aDestSurface != aSourceSurface) {
             memcpy(aDestSurface->Data(), aSourceSurface->Data(),
                    aSourceSurface->Stride() * aSourceSurface->Height());
         }
         return;
     }
 
     uint8_t *src = aSourceSurface->Data();
@@ -94,17 +94,17 @@ gfxUtils::UnpremultiplyImageSurface(gfxI
         aDestSurface = aSourceSurface;
 
     MOZ_ASSERT(aSourceSurface->Format() == aDestSurface->Format() &&
                aSourceSurface->Width()  == aDestSurface->Width() &&
                aSourceSurface->Height() == aDestSurface->Height(),
                "Source and destination surfaces don't have identical characteristics");
 
     // Only premultiply ARGB32
-    if (aSourceSurface->Format() != gfxImageFormatARGB32) {
+    if (aSourceSurface->Format() != gfxImageFormat::ARGB32) {
         if (aDestSurface != aSourceSurface) {
             aDestSurface->CopyFrom(aSourceSurface);
         }
         return;
     }
 
     uint8_t *src = aSourceSurface->Data();
     uint8_t *dst = aDestSurface->Data();
@@ -149,17 +149,17 @@ gfxUtils::ConvertBGRAtoRGBA(gfxImageSurf
                aSourceSurface->Width()  == aDestSurface->Width() &&
                aSourceSurface->Height() == aDestSurface->Height() &&
                aSourceSurface->Stride() == aDestSurface->Stride(),
                "Source and destination surfaces don't have identical characteristics");
 
     MOZ_ASSERT(aSourceSurface->Stride() == aSourceSurface->Width() * 4,
                "Source surface stride isn't tightly packed");
 
-    MOZ_ASSERT(aSourceSurface->Format() == gfxImageFormatARGB32 || aSourceSurface->Format() == gfxImageFormatRGB24,
+    MOZ_ASSERT(aSourceSurface->Format() == gfxImageFormat::ARGB32 || aSourceSurface->Format() == gfxImageFormat::RGB24,
                "Surfaces must be ARGB32 or RGB24");
 
     uint8_t *src = aSourceSurface->Data();
     uint8_t *dst = aDestSurface->Data();
 
     uint32_t dim = aSourceSurface->Width() * aSourceSurface->Height();
     uint8_t *srcEnd = src + 4*dim;
 
@@ -486,21 +486,21 @@ gfxUtils::DrawPixelSnapped(gfxContext*  
 
     drawable->Draw(aContext, aFill, doTile, aFilter, userSpaceToImageSpace);
 }
 
 /* static */ int
 gfxUtils::ImageFormatToDepth(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-        case gfxImageFormatARGB32:
+        case gfxImageFormat::ARGB32:
             return 32;
-        case gfxImageFormatRGB24:
+        case gfxImageFormat::RGB24:
             return 24;
-        case gfxImageFormatRGB16_565:
+        case gfxImageFormat::RGB16_565:
             return 16;
         default:
             break;
     }
     return 0;
 }
 
 static void
@@ -695,17 +695,17 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize
                       aData.mCbCrSize.width,
                       aData.mCbCrSize.height);
 
   // 'prescale' is true if the scaling is to be done as part of the
   // YCbCr to RGB conversion rather than on the RGB data when rendered.
   bool prescale = aSuggestedSize.width > 0 && aSuggestedSize.height > 0 &&
                     ToIntSize(aSuggestedSize) != aData.mPicSize;
 
-  if (aSuggestedFormat == gfxImageFormatRGB16_565) {
+  if (aSuggestedFormat == gfxImageFormat::RGB16_565) {
 #if defined(HAVE_YCBCR_TO_RGB565)
     if (prescale &&
         !IsScaleYCbCrToRGB565Fast(aData.mPicX,
                                        aData.mPicY,
                                        aData.mPicSize.width,
                                        aData.mPicSize.height,
                                        aSuggestedSize.width,
                                        aSuggestedSize.height,
@@ -715,24 +715,24 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize
                                         aData.mPicY,
                                         aData.mPicSize.width,
                                         aData.mPicSize.height,
                                         yuvtype)) {
       prescale = false;
     }
 #else
     // yuv2rgb16 function not available
-    aSuggestedFormat = gfxImageFormatRGB24;
+    aSuggestedFormat = gfxImageFormat::RGB24;
 #endif
   }
-  else if (aSuggestedFormat != gfxImageFormatRGB24) {
+  else if (aSuggestedFormat != gfxImageFormat::RGB24) {
     // No other formats are currently supported.
-    aSuggestedFormat = gfxImageFormatRGB24;
+    aSuggestedFormat = gfxImageFormat::RGB24;
   }
-  if (aSuggestedFormat == gfxImageFormatRGB24) {
+  if (aSuggestedFormat == gfxImageFormat::RGB24) {
     /* ScaleYCbCrToRGB32 does not support a picture offset, nor 4:4:4 data.
        See bugs 639415 and 640073. */
     if (aData.mPicX != 0 || aData.mPicY != 0 || yuvtype == YV24)
       prescale = false;
   }
   if (!prescale) {
     ToIntSize(aSuggestedSize) = aData.mPicSize;
   }
@@ -755,17 +755,17 @@ gfxUtils::ConvertYCbCrToRGB(const Planar
     TypeFromSize(aData.mYSize.width,
                       aData.mYSize.height,
                       aData.mCbCrSize.width,
                       aData.mCbCrSize.height);
 
   // Convert from YCbCr to RGB now, scaling the image if needed.
   if (ToIntSize(aDestSize) != aData.mPicSize) {
 #if defined(HAVE_YCBCR_TO_RGB565)
-    if (aDestFormat == gfxImageFormatRGB16_565) {
+    if (aDestFormat == gfxImageFormat::RGB16_565) {
       ScaleYCbCrToRGB565(aData.mYChannel,
                               aData.mCbChannel,
                               aData.mCrChannel,
                               aDestBuffer,
                               aData.mPicX,
                               aData.mPicY,
                               aData.mPicSize.width,
                               aData.mPicSize.height,
@@ -789,30 +789,30 @@ gfxUtils::ConvertYCbCrToRGB(const Planar
                              aData.mYStride,
                              aData.mCbCrStride,
                              aStride,
                              yuvtype,
                              ROTATE_0,
                              FILTER_BILINEAR);
   } else { // no prescale
 #if defined(HAVE_YCBCR_TO_RGB565)
-    if (aDestFormat == gfxImageFormatRGB16_565) {
+    if (aDestFormat == gfxImageFormat::RGB16_565) {
       ConvertYCbCrToRGB565(aData.mYChannel,
                                 aData.mCbChannel,
                                 aData.mCrChannel,
                                 aDestBuffer,
                                 aData.mPicX,
                                 aData.mPicY,
                                 aData.mPicSize.width,
                                 aData.mPicSize.height,
                                 aData.mYStride,
                                 aData.mCbCrStride,
                                 aStride,
                                 yuvtype);
-    } else // aDestFormat != gfxImageFormatRGB16_565
+    } else // aDestFormat != gfxImageFormat::RGB16_565
 #endif
       ConvertYCbCrToRGB32(aData.mYChannel,
                                aData.mCbChannel,
                                aData.mCrChannel,
                                aDestBuffer,
                                aData.mPicX,
                                aData.mPicY,
                                aData.mPicSize.width,
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -24,17 +24,17 @@ class gfxUtils {
 public:
     /*
      * Premultiply or Unpremultiply aSourceSurface, writing the result
      * to aDestSurface or back into aSourceSurface if aDestSurface is null.
      *
      * If aDestSurface is given, it must have identical format, dimensions, and
      * stride as the source.
      *
-     * If the source is not gfxImageFormatARGB32, no operation is performed.  If
+     * If the source is not gfxImageFormat::ARGB32, no operation is performed.  If
      * aDestSurface is given, the data is copied over.
      */
     static void PremultiplyImageSurface(gfxImageSurface *aSourceSurface,
                                         gfxImageSurface *aDestSurface = nullptr);
     static void UnpremultiplyImageSurface(gfxImageSurface *aSurface,
                                           gfxImageSurface *aDestSurface = nullptr);
 
     static void ConvertBGRAtoRGBA(gfxImageSurface *aSourceSurface,
@@ -120,17 +120,17 @@ public:
      * Return the smallest power of kScaleResolution (2) greater than or equal to
      * aVal.
      */
     static gfxFloat ClampToScaleFactor(gfxFloat aVal);
 
     /**
      * Helper function for ConvertYCbCrToRGB that finds the
      * RGB buffer size and format for given YCbCrImage.
-     * @param aSuggestedFormat will be set to gfxImageFormatRGB24
+     * @param aSuggestedFormat will be set to gfxImageFormat::RGB24
      *   if the desired format is not supported.
      * @param aSuggestedSize will be set to the picture size from aData
      *   if either the suggested size was {0,0}
      *   or simultaneous scaling and conversion is not supported.
      */
     static void
     GetYCbCrToRGBDestFormatAndSize(const mozilla::layers::PlanarYCbCrData& aData,
                                    gfxImageFormat& aSuggestedFormat,
--- a/gfx/thebes/gfxWindowsNativeDrawing.cpp
+++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp
@@ -264,17 +264,17 @@ gfxWindowsNativeDrawing::PaintToContext(
         nsRefPtr<gfxImageSurface> white = mWhiteSurface->GetAsImageSurface();
         if (!gfxAlphaRecovery::RecoverAlpha(black, white)) {
             NS_ERROR("Alpha recovery failure");
             return;
         }
         nsRefPtr<gfxImageSurface> alphaSurface =
             new gfxImageSurface(black->Data(), black->GetSize(),
                                 black->Stride(),
-                                gfxImageFormatARGB32);
+                                gfxImageFormat::ARGB32);
 
         mContext->Save();
         mContext->Translate(mNativeRect.TopLeft());
         mContext->NewPath();
         mContext->Rectangle(gfxRect(gfxPoint(0.0, 0.0), mNativeRect.Size()));
 
         nsRefPtr<gfxPattern> pat = new gfxPattern(alphaSurface);
 
--- a/gfx/thebes/gfxWindowsSurface.cpp
+++ b/gfx/thebes/gfxWindowsSurface.cpp
@@ -50,17 +50,17 @@ gfxWindowsSurface::MakeInvalid(gfxIntSiz
 
 gfxWindowsSurface::gfxWindowsSurface(const gfxIntSize& realSize, gfxImageFormat imageFormat) :
     mOwnsDC(false), mForPrinting(false), mWnd(nullptr)
 {
     gfxIntSize size(realSize);
     if (!CheckSurfaceSize(size))
         MakeInvalid(size);
 
-    cairo_surface_t *surf = cairo_win32_surface_create_with_dib((cairo_format_t)imageFormat,
+    cairo_surface_t *surf = cairo_win32_surface_create_with_dib((cairo_format_t)(int)imageFormat,
                                                                 size.width, size.height);
 
     Init(surf);
 
     if (CairoStatus() == CAIRO_STATUS_SUCCESS) {
         mDC = cairo_win32_surface_get_dc(CairoSurface());
         RecordMemoryUsed(size.width * size.height * 4 + sizeof(gfxWindowsSurface));
     } else {
@@ -70,24 +70,24 @@ gfxWindowsSurface::gfxWindowsSurface(con
 
 gfxWindowsSurface::gfxWindowsSurface(HDC dc, const gfxIntSize& realSize, gfxImageFormat imageFormat) :
     mOwnsDC(false), mForPrinting(false), mWnd(nullptr)
 {
     gfxIntSize size(realSize);
     if (!CheckSurfaceSize(size))
         MakeInvalid(size);
 
-    cairo_surface_t *surf = cairo_win32_surface_create_with_ddb(dc, (cairo_format_t)imageFormat,
+    cairo_surface_t *surf = cairo_win32_surface_create_with_ddb(dc, (cairo_format_t)(int)imageFormat,
                                                                 size.width, size.height);
 
     Init(surf);
 
     if (mSurfaceValid) {
         // DDBs will generally only use 3 bytes per pixel when RGB24
-        int bytesPerPixel = ((imageFormat == gfxImageFormatRGB24) ? 3 : 4);
+        int bytesPerPixel = ((imageFormat == gfxImageFormat::RGB24) ? 3 : 4);
         RecordMemoryUsed(size.width * size.height * bytesPerPixel + sizeof(gfxWindowsSurface));
     }
 
     if (CairoStatus() == 0)
         mDC = cairo_win32_surface_get_dc(CairoSurface());
     else
         mDC = nullptr;
 }
@@ -130,17 +130,17 @@ gfxWindowsSurface::CreateSimilarSurface(
         // the new surface uses a DIB. cairo_surface_create_similar won't
         // use  a DIB for a GFX_CONTENT_COLOR surface if this surface doesn't
         // have a DIB (e.g. if we're a transparent window surface). But
         // we need a DIB to perform well if the new surface is composited into
         // a surface that's the result of create_similar(GFX_CONTENT_COLOR_ALPHA)
         // (e.g. a backbuffer for the window) --- that new surface *would*
         // have a DIB.
         surface =
-          cairo_win32_surface_create_with_dib(cairo_format_t(gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent)),
+          cairo_win32_surface_create_with_dib((cairo_format_t)(int)gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent),
                                               aSize.width, aSize.height);
     } else {
         surface =
           cairo_surface_create_similar(mSurface, cairo_content_t(aContent),
                                        aSize.width, aSize.height);
     }
 
     if (cairo_surface_status(surface)) {
--- a/gfx/thebes/gfxWindowsSurface.h
+++ b/gfx/thebes/gfxWindowsSurface.h
@@ -30,22 +30,22 @@ public:
     gfxWindowsSurface(HWND wnd, uint32_t flags = 0);
     gfxWindowsSurface(HDC dc, uint32_t flags = 0);
 
     // Create from a shared d3d9surface
     gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0);
 
     // Create a DIB surface
     gfxWindowsSurface(const gfxIntSize& size,
-                      gfxImageFormat imageFormat = gfxImageFormatRGB24);
+                      gfxImageFormat imageFormat = gfxImageFormat::RGB24);
 
     // Create a DDB surface; dc may be nullptr to use the screen DC
     gfxWindowsSurface(HDC dc,
                       const gfxIntSize& size,
-                      gfxImageFormat imageFormat = gfxImageFormatRGB24);
+                      gfxImageFormat imageFormat = gfxImageFormat::RGB24);
 
     gfxWindowsSurface(cairo_surface_t *csurf);
 
     virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
                                                                const gfxIntSize& aSize);
 
     void InitWithDC(uint32_t flags);
 
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -388,27 +388,27 @@ CreateTempXlibSurface (cairo_surface_t* 
     if (supportsAlternateVisual && !drawIsOpaque &&
         (screen != target_screen ||
          !(doCopyBackground || VisualHasAlpha(screen, visual)))) {
         // Try to find a visual with an alpha channel.
         Screen *visualScreen =
             supportsAlternateScreen ? target_screen : screen;
         Visual *argbVisual =
             gfxXlibSurface::FindVisual(visualScreen,
-                                       gfxImageFormatARGB32);
+                                       gfxImageFormat::ARGB32);
         if (argbVisual) {
             visual = argbVisual;
             screen = visualScreen;
         } else if (!doCopyBackground &&
                    gfxXlibSurface::DepthOfVisual(screen, visual) != 24) {
             // Will need to do alpha extraction; prefer a 24-bit visual.
             // No advantage in using the target screen.
             Visual *rgb24Visual =
                 gfxXlibSurface::FindVisual(screen,
-                                           gfxImageFormatRGB24);
+                                           gfxImageFormat::RGB24);
             if (rgb24Visual) {
                 visual = rgb24Visual;
             }
         }
     }
 
     Drawable drawable =
         (screen == target_screen && cairoTargetType == CAIRO_SURFACE_TYPE_XLIB) ?
@@ -597,26 +597,26 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
             ctx->SetSource(tmpSurf, offset);
             ctx->Paint();
         }
         cairo_surface_destroy(tempXlibSurface);
         return;
     }
     
     nsRefPtr<gfxImageSurface> blackImage =
-        CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormatARGB32);
+        CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::ARGB32);
     
     cairo_t* tmpCtx = cairo_create(tempXlibSurface);
     cairo_set_source_rgba(tmpCtx, 1.0, 1.0, 1.0, 1.0);
     cairo_set_operator(tmpCtx, CAIRO_OPERATOR_SOURCE);
     cairo_paint(tmpCtx);
     cairo_destroy(tmpCtx);
     DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft());
     nsRefPtr<gfxImageSurface> whiteImage =
-        CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormatRGB24);
+        CopyXlibSurfaceToImage(tempXlibSurface, size, gfxImageFormat::RGB24);
   
     if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS &&
         whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) {
         if (!gfxAlphaRecovery::RecoverAlpha(blackImage, whiteImage)) {
             cairo_surface_destroy(tempXlibSurface);
             return;
         }
 
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -496,36 +496,36 @@ gfxXlibSurface::DepthOfVisual(const Scre
     
 /* static */
 Visual*
 gfxXlibSurface::FindVisual(Screen *screen, gfxImageFormat format)
 {
     int depth;
     unsigned long red_mask, green_mask, blue_mask;
     switch (format) {
-        case gfxImageFormatARGB32:
+        case gfxImageFormat::ARGB32:
             depth = 32;
             red_mask = 0xff0000;
             green_mask = 0xff00;
             blue_mask = 0xff;
             break;
-        case gfxImageFormatRGB24:
+        case gfxImageFormat::RGB24:
             depth = 24;
             red_mask = 0xff0000;
             green_mask = 0xff00;
             blue_mask = 0xff;
             break;
-        case gfxImageFormatRGB16_565:
+        case gfxImageFormat::RGB16_565:
             depth = 16;
             red_mask = 0xf800;
             green_mask = 0x7e0;
             blue_mask = 0x1f;
             break;
-        case gfxImageFormatA8:
-        case gfxImageFormatA1:
+        case gfxImageFormat::A8:
+        case gfxImageFormat::A1:
         default:
             return nullptr;
     }
 
     for (int d = 0; d < screen->ndepths; d++) {
         const Depth& d_info = screen->depths[d];
         if (d_info.depth != depth)
             continue;
@@ -544,32 +544,32 @@ gfxXlibSurface::FindVisual(Screen *scree
     return nullptr;
 }
 
 /* static */
 XRenderPictFormat*
 gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
 {
     switch (format) {
-        case gfxImageFormatARGB32:
+        case gfxImageFormat::ARGB32:
             return XRenderFindStandardFormat (dpy, PictStandardARGB32);
-        case gfxImageFormatRGB24:
+        case gfxImageFormat::RGB24:
             return XRenderFindStandardFormat (dpy, PictStandardRGB24);
-        case gfxImageFormatRGB16_565: {
+        case gfxImageFormat::RGB16_565: {
             // PictStandardRGB16_565 is not standard Xrender format
             // we should try to find related visual
             // and find xrender format by visual
             Visual *visual = FindVisual(DefaultScreenOfDisplay(dpy), format);
             if (!visual)
                 return nullptr;
             return XRenderFindVisualFormat(dpy, visual);
         }
-        case gfxImageFormatA8:
+        case gfxImageFormat::A8:
             return XRenderFindStandardFormat (dpy, PictStandardA8);
-        case gfxImageFormatA1:
+        case gfxImageFormat::A1:
             return XRenderFindStandardFormat (dpy, PictStandardA1);
         default:
             break;
     }
 
     return nullptr;
 }
 
--- a/gfx/ycbcr/YCbCrUtils.cpp
+++ b/gfx/ycbcr/YCbCrUtils.cpp
@@ -130,17 +130,17 @@ ConvertYCbCrToRGB(const layers::PlanarYC
                            aData.mPicX,
                            aData.mPicY,
                            aData.mPicSize.width,
                            aData.mPicSize.height,
                            aData.mYStride,
                            aData.mCbCrStride,
                            aStride,
                            yuvtype);
-    } else // aDestFormat != gfxImageFormatRGB16_565
+    } else // aDestFormat != gfxImageFormat::RGB16_565
 #endif
       ConvertYCbCrToRGB32(aData.mYChannel, //
                           aData.mCbChannel,
                           aData.mCrChannel,
                           aDestBuffer,
                           aData.mPicX,
                           aData.mPicY,
                           aData.mPicSize.width,
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -156,19 +156,19 @@ void nsGIFDecoder2::BeginGIF()
   PostSize(mGIFStruct.screen_width, mGIFStruct.screen_height);
 }
 
 //******************************************************************************
 void nsGIFDecoder2::BeginImageFrame(uint16_t aDepth)
 {
   gfxImageFormat format;
   if (mGIFStruct.is_transparent)
-    format = gfxImageFormatARGB32;
+    format = gfxImageFormat::ARGB32;
   else
-    format = gfxImageFormatRGB24;
+    format = gfxImageFormat::RGB24;
 
   MOZ_ASSERT(HasSize());
 
   // Use correct format, RGB for first frame, PAL for following frames
   // and include transparency to allow for optimization of opaque images
   if (mGIFStruct.images_decoded) {
     // Image data is stored with original depth and palette
     NeedNewFrame(mGIFStruct.images_decoded, mGIFStruct.x_offset,
@@ -183,17 +183,17 @@ void nsGIFDecoder2::BeginImageFrame(uint
                                                                 mGIFStruct.width,
                                                                 mGIFStruct.height))) {
     // Regardless of depth of input, image is decoded into 24bit RGB
     NeedNewFrame(mGIFStruct.images_decoded, mGIFStruct.x_offset,
                  mGIFStruct.y_offset, mGIFStruct.width, mGIFStruct.height,
                  format);
   } else {
     // Our preallocated frame matches up, with the possible exception of alpha.
-    if (format == gfxImageFormatRGB24) {
+    if (format == gfxImageFormat::RGB24) {
       GetCurrentFrame()->SetHasNoAlpha();
     }
   }
 
   mCurrentFrame = mGIFStruct.images_decoded;
 }
 
 
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -143,17 +143,17 @@ void nsPNGDecoder::CreateFrame(png_uint_
   // Our first full frame is automatically created by the image decoding
   // infrastructure. Just use it as long as it matches up.
   MOZ_ASSERT(HasSize());
   if (mNumFrames != 0 ||
       !GetCurrentFrame()->GetRect().IsEqualEdges(nsIntRect(x_offset, y_offset, width, height))) {
     NeedNewFrame(mNumFrames, x_offset, y_offset, width, height, format);
   } else if (mNumFrames == 0) {
     // Our preallocated frame matches up, with the possible exception of alpha.
-    if (format == gfxImageFormatRGB24) {
+    if (format == gfxImageFormat::RGB24) {
       GetCurrentFrame()->SetHasNoAlpha();
     }
   }
 
   mFrameRect.x = x_offset;
   mFrameRect.y = y_offset;
   mFrameRect.width = width;
   mFrameRect.height = height;
@@ -622,19 +622,19 @@ nsPNGDecoder::info_callback(png_structp 
       }
     } else {
       alpha_bits = 8;
     }
   }
 #endif
 
   if (channels == 1 || channels == 3)
-    decoder->format = gfxImageFormatRGB24;
+    decoder->format = gfxImageFormat::RGB24;
   else if (channels == 2 || channels == 4)
-    decoder->format = gfxImageFormatARGB32;
+    decoder->format = gfxImageFormat::ARGB32;
 
 #ifdef PNG_APNG_SUPPORTED
   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_acTL))
     png_set_progressive_frame_fn(png_ptr, nsPNGDecoder::frame_info_callback,
                                  nullptr);
 
   if (png_get_first_frame_is_hidden(png_ptr, info_ptr)) {
     decoder->mFrameIsHidden = true;
@@ -738,17 +738,17 @@ nsPNGDecoder::row_callback(png_structp p
         }
         line = decoder->mCMSLine;
       } else {
         qcms_transform_data(decoder->mTransform, line, line, iwidth);
        }
      }
 
     switch (decoder->format) {
-      case gfxImageFormatRGB24:
+      case gfxImageFormat::RGB24:
       {
         // counter for while() loops below
         uint32_t idx = iwidth;
 
         // copy as bytes until source pointer is 32-bit-aligned
         for (; (NS_PTR_TO_UINT32(line) & 0x3) && idx; --idx) {
           *cptr32++ = gfxPackedPixel(0xFF, line[0], line[1], line[2]);
           line += 3;
@@ -765,17 +765,17 @@ nsPNGDecoder::row_callback(png_structp p
         // copy remaining pixel(s)
         while (idx--) {
           // 32-bit read of final pixel will exceed buffer, so read bytes
           *cptr32++ = gfxPackedPixel(0xFF, line[0], line[1], line[2]);
           line += 3;
         }
       }
       break;
-      case gfxImageFormatARGB32:
+      case gfxImageFormat::ARGB32:
       {
         if (!decoder->mDisablePremultipliedAlpha) {
           for (uint32_t x=width; x>0; --x) {
             *cptr32++ = gfxPackedPixel(line[3], line[0], line[1], line[2]);
             if (line[3] != 0xff)
               rowHasNoAlpha = false;
             line += 4;
           }
--- a/image/src/ClippedImage.cpp
+++ b/image/src/ClippedImage.cpp
@@ -254,17 +254,17 @@ ClippedImage::GetFrameInternal(const nsI
       new DrawSingleTileCallback(this, mClip, aViewportSize, aSVGContext, aWhichFrame, aFlags);
     nsRefPtr<gfxDrawable> drawable =
       new gfxCallbackDrawable(drawTileCallback, mClip.Size());
 
     // Actually draw. The callback will end up invoking DrawSingleTile.
     gfxRect imageRect(0, 0, mClip.width, mClip.height);
     gfxUtils::DrawPixelSnapped(ctx, drawable, gfxMatrix(),
                                imageRect, imageRect, imageRect, imageRect,
-                               gfxImageFormatARGB32,
+                               gfxImageFormat::ARGB32,
                                GraphicsFilter::FILTER_FAST);
 
     // Cache the resulting surface.
     mCachedSurface = new ClippedImageCachedSurface(target,
                                                    aViewportSize,
                                                    aSVGContext,
                                                    frameToDraw,
                                                    aFlags);
@@ -339,17 +339,17 @@ ClippedImage::Draw(gfxContext* aContext,
     nsRefPtr<gfxSurfaceDrawable> drawable =
       new gfxSurfaceDrawable(surface, gfxIntSize(mClip.width, mClip.height));
 
     // Draw.
     gfxRect imageRect(0, 0, mClip.width, mClip.height);
     gfxRect subimage(aSubimage.x, aSubimage.y, aSubimage.width, aSubimage.height);
     gfxUtils::DrawPixelSnapped(aContext, drawable, aUserSpaceToImageSpace,
                                subimage, sourceRect, imageRect, aFill,
-                               gfxImageFormatARGB32, aFilter);
+                               gfxImageFormat::ARGB32, aFilter);
 
     return NS_OK;
   }
 
   // Determine the appropriate subimage for the inner image.
   nsIntRect innerSubimage(aSubimage);
   innerSubimage.MoveBy(mClip.x, mClip.y);
   innerSubimage.Intersect(mClip);
--- a/image/src/FrameBlender.cpp
+++ b/image/src/FrameBlender.cpp
@@ -256,17 +256,17 @@ FrameBlender::DoBlend(nsIntRect* aDirtyR
   }
 
   bool needToBlankComposite = false;
 
   // Create the Compositing Frame
   if (!mAnim->compositingFrame) {
     mAnim->compositingFrame.SetFrame(new imgFrame());
     nsresult rv = mAnim->compositingFrame->Init(0, 0, mSize.width, mSize.height,
-                                                gfxImageFormatARGB32);
+                                                gfxImageFormat::ARGB32);
     if (NS_FAILED(rv)) {
       mAnim->compositingFrame.SetFrame(nullptr);
       return false;
     }
     mAnim->compositingFrame.LockAndGetData();
     needToBlankComposite = true;
   } else if (int32_t(aNextFrameIndex) != mAnim->lastCompositedFrameIndex+1) {
 
@@ -386,17 +386,17 @@ FrameBlender::DoBlend(nsIntRect* aDirtyR
   if ((nextFrameDisposalMethod == FrameBlender::kDisposeRestorePrevious) &&
       (prevFrameDisposalMethod != FrameBlender::kDisposeRestorePrevious)) {
     // We are storing the whole image.
     // It would be better if we just stored the area that nextFrame is going to
     // overwrite.
     if (!mAnim->compositingPrevFrame) {
       mAnim->compositingPrevFrame.SetFrame(new imgFrame());
       nsresult rv = mAnim->compositingPrevFrame->Init(0, 0, mSize.width, mSize.height,
-                                                      gfxImageFormatARGB32);
+                                                      gfxImageFormat::ARGB32);
       if (NS_FAILED(rv)) {
         mAnim->compositingPrevFrame.SetFrame(nullptr);
         return false;
       }
 
       mAnim->compositingPrevFrame.LockAndGetData();
     }
 
--- a/image/src/OrientedImage.cpp
+++ b/image/src/OrientedImage.cpp
@@ -96,20 +96,20 @@ OrientedImage::GetFrame(uint32_t aWhichF
   }
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   // Determine an appropriate format for the surface.
   gfx::SurfaceFormat surfaceFormat;
   gfxImageFormat imageFormat;
   if (InnerImage()->FrameIsOpaque(aWhichFrame)) {
     surfaceFormat = gfx::SurfaceFormat::B8G8R8X8;
-    imageFormat = gfxImageFormatARGB32;
+    imageFormat = gfxImageFormat::ARGB32;
   } else {
     surfaceFormat = gfx::SurfaceFormat::B8G8R8A8;
-    imageFormat = gfxImageFormatARGB32;
+    imageFormat = gfxImageFormat::ARGB32;
   }
 
   // Create a surface to draw into.
   mozilla::RefPtr<mozilla::gfx::DrawTarget> target;
   target = gfxPlatform::GetPlatform()->
     CreateOffscreenContentDrawTarget(gfx::IntSize(width, height), surfaceFormat);
 
   // Create our drawable.
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -321,17 +321,17 @@ public:
   ScaleRunner(RasterImage* aImage, const gfx::Size& aScale, imgFrame* aSrcFrame)
   {
     nsAutoPtr<ScaleRequest> request(new ScaleRequest(aImage, aScale, aSrcFrame));
 
     // Destination is unconditionally ARGB32 because that's what the scaler
     // outputs.
     request->dstFrame = new imgFrame();
     nsresult rv = request->dstFrame->Init(0, 0, request->dstSize.width, request->dstSize.height,
-                                          gfxImageFormatARGB32);
+                                          gfxImageFormat::ARGB32);
 
     if (NS_FAILED(rv) || !request->GetSurfaces(aSrcFrame)) {
       return;
     }
 
     aImage->ScalingStart(request);
 
     mScaleRequest = request;
@@ -859,17 +859,17 @@ RasterImage::CopyFrame(uint32_t aWhichFr
   nsRefPtr<gfxPattern> pattern;
   frame->GetPattern(getter_AddRefs(pattern));
   nsIntRect intframerect = frame->GetRect();
   gfxRect framerect(intframerect.x, intframerect.y, intframerect.width, intframerect.height);
 
   // Create a 32-bit image surface of our size, but draw using the frame's
   // rect, implicitly padding the frame out to the image's size.
   nsRefPtr<gfxImageSurface> imgsurface = new gfxImageSurface(gfxIntSize(mSize.width, mSize.height),
-                                                             gfxImageFormatARGB32);
+                                                             gfxImageFormat::ARGB32);
   gfxContext ctx(imgsurface);
   ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
   ctx.Rectangle(framerect);
   ctx.Translate(framerect.TopLeft());
   ctx.SetPattern(pattern);
   ctx.Fill();
 
   *_retval = imgsurface.forget().get();
@@ -2029,17 +2029,17 @@ RasterImage::InitDecoder(bool aDoSizeDec
   mDecoder->SetObserver(mDecodeRequest->mStatusTracker->GetDecoderObserver());
   mDecoder->SetSizeDecode(aDoSizeDecode);
   mDecoder->SetDecodeFlags(mFrameDecodeFlags);
   if (!aDoSizeDecode) {
     // We already have the size; tell the decoder so it can preallocate a
     // frame.  By default, we create an ARGB frame with no offset. If decoders
     // need a different type, they need to ask for it themselves.
     mDecoder->NeedNewFrame(0, 0, 0, mSize.width, mSize.height,
-                           gfxImageFormatARGB32);
+                           gfxImageFormat::ARGB32);
     mDecoder->AllocateFrame();
   }
   mDecoder->Init();
   CONTAINER_ENSURE_SUCCESS(mDecoder->GetDecoderError());
 
   if (!aDoSizeDecode) {
     Telemetry::GetHistogramById(Telemetry::IMAGE_DECODE_COUNT)->Subtract(mDecodeCount);
     mDecodeCount++;
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -672,17 +672,17 @@ VectorImage::GetFrame(uint32_t aWhichFra
 
   // Create a surface that we'll ultimately return
   // ---------------------------------------------
   // Make our surface the size of what will ultimately be drawn to it.
   // (either the full image size, or the restricted region)
   gfxIntSize surfaceSize(imageIntSize.width, imageIntSize.height);
 
   nsRefPtr<gfxImageSurface> surface =
-    new gfxImageSurface(surfaceSize, gfxImageFormatARGB32);
+    new gfxImageSurface(surfaceSize, gfxImageFormat::ARGB32);
   nsRefPtr<gfxContext> context = new gfxContext(surface);
 
   // Draw to our surface!
   // --------------------
   nsresult rv = Draw(context, GraphicsFilter::FILTER_NEAREST, gfxMatrix(),
                      gfxRect(gfxPoint(0,0), gfxIntSize(imageIntSize.width,
                                                        imageIntSize.height)),
                      nsIntRect(nsIntPoint(0,0), imageIntSize),
@@ -860,17 +860,17 @@ VectorImage::CreateDrawableAndShow(const
     return Show(svgDrawable, aParams);
 
   nsRefPtr<gfxContext> ctx = new gfxContext(target);
 
   // Actually draw. (We use FILTER_NEAREST since we never scale here.)
   gfxUtils::DrawPixelSnapped(ctx, svgDrawable, gfxMatrix(),
                              aParams.imageRect, aParams.imageRect,
                              aParams.imageRect, aParams.imageRect,
-                             gfxImageFormatARGB32,
+                             gfxImageFormat::ARGB32,
                              GraphicsFilter::FILTER_NEAREST, aParams.flags);
 
   // Attempt to cache the resulting surface.
   SurfaceCache::Insert(target,
                        ImageKey(this),
                        SurfaceKey(aParams.imageRect.Size(), aParams.scale,
                                   aParams.svgContext, aParams.animationTime,
                                   aParams.flags));
@@ -886,17 +886,17 @@ VectorImage::CreateDrawableAndShow(const
 void
 VectorImage::Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams)
 {
   MOZ_ASSERT(aDrawable, "Should have a gfxDrawable by now");
   gfxUtils::DrawPixelSnapped(aParams.context, aDrawable,
                              aParams.userSpaceToImageSpace,
                              aParams.subimage, aParams.sourceRect,
                              aParams.imageRect, aParams.fill,
-                             gfxImageFormatARGB32,
+                             gfxImageFormat::ARGB32,
                              aParams.filter, aParams.flags);
 
   MOZ_ASSERT(mRenderingObserver, "Should have a rendering observer by now");
   mRenderingObserver->ResumeHonoringInvalidations();
 }
 
 //******************************************************************************
 /* void requestDecode() */
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -231,22 +231,22 @@ nsresult imgFrame::Optimize()
     uint32_t firstPixel = * (uint32_t*) imgData;
     uint32_t pixelCount = mSize.width * mSize.height + 1;
 
     while (--pixelCount && *imgData++ == firstPixel)
       ;
 
     if (pixelCount == 0) {
       // all pixels were the same
-      if (mFormat == gfxImageFormatARGB32 ||
-          mFormat == gfxImageFormatRGB24)
+      if (mFormat == gfxImageFormat::ARGB32 ||
+          mFormat == gfxImageFormat::RGB24)
       {
         // Should already be premult if desired.
         gfxRGBA::PackedColorType inputType = gfxRGBA::PACKED_XRGB;
-        if (mFormat == gfxImageFormatARGB32)
+        if (mFormat == gfxImageFormat::ARGB32)
           inputType = gfxRGBA::PACKED_ARGB_PREMULTIPLIED;
 
         mSinglePixelColor = gfxRGBA(firstPixel, inputType);
 
         mSinglePixel = true;
 
         // blow away the older surfaces (if they exist), to release their memory
         mImageSurface = nullptr;
@@ -351,17 +351,17 @@ imgFrame::SurfaceForDrawing(bool        
   }
 
   gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height);
 
   if (aDoTile || mSinglePixel) {
     // Create a temporary surface.
     // Give this surface an alpha channel because there are
     // transparent pixels in the padding or undecoded area
-    gfxImageFormat format = gfxImageFormatARGB32;
+    gfxImageFormat format = gfxImageFormat::ARGB32;
     nsRefPtr<gfxASurface> surface =
       gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, gfxImageSurface::ContentFromFormat(format));
     if (!surface || surface->CairoStatus())
       return SurfaceWithFormat();
 
     // Fill 'available' with whatever we've got
     gfxContext tmpCtx(surface);
     tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
@@ -469,17 +469,17 @@ nsIntRect imgFrame::GetRect() const
 gfxImageFormat imgFrame::GetFormat() const
 {
   return mFormat;
 }
 
 bool imgFrame::GetNeedsBackground() const
 {
   // We need a background painted if we have alpha or we're incomplete.
-  return (mFormat == gfxImageFormatARGB32 || !ImageComplete());
+  return (mFormat == gfxImageFormat::ARGB32 || !ImageComplete());
 }
 
 uint32_t imgFrame::GetImageBytesPerRow() const
 {
   if (mImageSurface)
     return mImageSurface->Stride();
 
   if (mPaletteDepth)
@@ -519,17 +519,17 @@ uint8_t* imgFrame::GetImageData() const
 
 bool imgFrame::GetIsPaletted() const
 {
   return mPalettedImageData != nullptr;
 }
 
 bool imgFrame::GetHasAlpha() const
 {
-  return mFormat == gfxImageFormatARGB32;
+  return mFormat == gfxImageFormat::ARGB32;
 }
 
 void imgFrame::GetPaletteData(uint32_t **aPalette, uint32_t *length) const
 {
   NS_ABORT_IF_FALSE(mLockCount != 0, "Can't GetPaletteData unless frame is locked");
 
   if (!mPalettedImageData) {
     *aPalette = nullptr;
@@ -566,17 +566,17 @@ nsresult imgFrame::LockImageData()
 
   // Paletted images don't have surfaces, so there's nothing to do.
   if (mPalettedImageData)
     return NS_OK;
 
   if ((mOptSurface || mSinglePixel) && !mImageSurface) {
     // Recover the pixels
     mImageSurface = new gfxImageSurface(gfxIntSize(mSize.width, mSize.height),
-                                        gfxImageFormatARGB32);
+                                        gfxImageFormat::ARGB32);
     if (!mImageSurface || mImageSurface->CairoStatus())
       return NS_ERROR_OUT_OF_MEMORY;
 
     gfxContext context(mImageSurface);
     context.SetOperator(gfxContext::OPERATOR_SOURCE);
     if (mSinglePixel)
       context.SetDeviceColor(mSinglePixelColor);
     else
@@ -737,18 +737,18 @@ bool imgFrame::ImageComplete() const
 // A hint from the image decoders that this image has no alpha, even
 // though we created is ARGB32.  This changes our format to RGB24,
 // which in turn will cause us to Optimize() to RGB24.  Has no effect
 // after Optimize() is called, though in all cases it will be just a
 // performance win -- the pixels are still correct and have the A byte
 // set to 0xff.
 void imgFrame::SetHasNoAlpha()
 {
-  if (mFormat == gfxImageFormatARGB32) {
-      mFormat = gfxImageFormatRGB24;
+  if (mFormat == gfxImageFormat::ARGB32) {
+      mFormat = gfxImageFormat::RGB24;
       mFormatChanged = true;
       ThebesSurface()->SetOpaqueRect(gfxRect(0, 0, mSize.width, mSize.height));
   }
 }
 
 void imgFrame::SetAsNonPremult(bool aIsNonPremult)
 {
   mNonPremult = aIsNonPremult;
--- a/image/src/imgTools.cpp
+++ b/image/src/imgTools.cpp
@@ -141,17 +141,17 @@ NS_IMETHODIMP imgTools::EncodeScaledImag
   if (aScaledWidth == 0) {
     aScaledWidth = frameWidth;
   } else if (aScaledHeight == 0) {
     aScaledHeight = frameHeight;
   }
 
   // Create a temporary image surface
   nsRefPtr<gfxImageSurface> dest = new gfxImageSurface(gfxIntSize(aScaledWidth, aScaledHeight),
-                                                       gfxImageFormatARGB32);
+                                                       gfxImageFormat::ARGB32);
   if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
     RefPtr<DrawTarget> dt =
       gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(dest, IntSize(aScaledWidth, aScaledHeight));
     RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, frame);
 
     dt->DrawSurface(source,
                     Rect(0, 0, aScaledWidth, aScaledHeight),
                     Rect(0, 0, frameWidth, frameHeight),
@@ -215,17 +215,17 @@ NS_IMETHODIMP imgTools::EncodeCroppedIma
   }
 
   // Check that the given crop rectangle is within image bounds.
   NS_ENSURE_ARG(frameWidth >= aOffsetX + aWidth &&
                 frameHeight >= aOffsetY + aHeight);
 
   // Create a temporary image surface
   nsRefPtr<gfxImageSurface> dest = new gfxImageSurface(gfxIntSize(aWidth, aHeight),
-                                                       gfxImageFormatARGB32);
+                                                       gfxImageFormat::ARGB32);
   gfxContext ctx(dest);
 
   // Set translate
   ctx.Translate(gfxPoint(-aOffsetX, -aOffsetY));
 
   // Paint a scaled image
   ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
   ctx.SetSource(frame);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4341,17 +4341,17 @@ nsLayoutUtils::DrawPixelSnapped(nsRender
                    drawingParams.mSubimage.width, drawingParams.mSubimage.height);
 
   NS_ASSERTION(!sourceRect.Intersect(subimage).IsEmpty(),
                "We must be allowed to sample *some* source pixels!");
 
   gfxUtils::DrawPixelSnapped(ctx, aDrawable,
                              drawingParams.mUserSpaceToImageSpace, subimage,
                              sourceRect, imageRect, drawingParams.mFillRect,
-                             gfxImageFormatARGB32, aFilter);
+                             gfxImageFormat::ARGB32, aFilter);
 }
 
 /* static */ nsresult
 nsLayoutUtils::DrawSingleUnscaledImage(nsRenderingContext* aRenderingContext,
                                        imgIContainer*       aImage,
                                        GraphicsFilter       aGraphicsFilter,
                                        const nsPoint&       aDest,
                                        const nsRect*        aDirty,
@@ -4938,17 +4938,17 @@ nsLayoutUtils::SurfaceFromElement(HTMLCa
       // so that it can un-premultiply.
       RefPtr<DataSourceSurface> data = Factory::CreateDataSourceSurface(IntSize(size.width, size.height),
                                                                         SurfaceFormat::B8G8R8A8);
       memset(data->GetData(), 0, data->Stride() * size.height);
       result.mSourceSurface = data;
       nsRefPtr<gfxImageSurface> image = new gfxImageSurface(data->GetData(),
                                                             gfxIntSize(size.width, size.height),
                                                             data->Stride(),
-                                                            gfxImageFormatARGB32);
+                                                            gfxImageFormat::ARGB32);
       ctx = new gfxContext(image);
     }
     // XXX shouldn't use the external interface, but maybe we can layerify this
     uint32_t flags = premultAlpha ? HTMLCanvasElement::RenderFlagPremultAlpha : 0;
     rv = aElement->RenderContextsExternal(ctx, GraphicsFilter::FILTER_NEAREST, flags);
     if (NS_FAILED(rv))
       return result;
 
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -4862,17 +4862,17 @@ PresShell::PaintRangePaintInfo(nsTArray<
     // move aScreenRect to the position of the surface in screen coordinates
     aScreenRect->MoveTo(rootScreenRect.x + pixelArea.x, rootScreenRect.y + pixelArea.y);
   }
   aScreenRect->width = pixelArea.width;
   aScreenRect->height = pixelArea.height;
 
   nsRefPtr<gfxImageSurface> surface =
     new gfxImageSurface(gfxIntSize(pixelArea.width, pixelArea.height),
-                        gfxImageFormatARGB32);
+                        gfxImageFormat::ARGB32);
   if (surface->CairoStatus()) {
     return nullptr;
   }
 
   // clear the image
   gfxContext context(surface);
   context.SetOperator(gfxContext::OPERATOR_CLEAR);
   context.Rectangle(gfxRect(0, 0, pixelArea.width, pixelArea.height));
@@ -8853,24 +8853,24 @@ PresShell::CloneStyleSet(nsStyleSet* aSe
 static nsresult
 DumpToPNG(nsIPresShell* shell, nsAString& name) {
   int32_t width=1000, height=1000;
   nsRect r(0, 0, shell->GetPresContext()->DevPixelsToAppUnits(width),
                  shell->GetPresContext()->DevPixelsToAppUnits(height));
 
   nsRefPtr<gfxImageSurface> imgSurface =
      new gfxImageSurface(gfxIntSize(width, height),
-                         gfxImageFormatARGB32);
+                         gfxImageFormat::ARGB32);
 
   nsRefPtr<gfxContext> imgContext = new gfxContext(imgSurface);
 
   nsRefPtr<gfxASurface> surface = 
     gfxPlatform::GetPlatform()->
     CreateOffscreenSurface(gfxIntSize(width, height),
-      gfxASurface::ContentFromFormat(gfxImageFormatARGB32));
+      gfxASurface::ContentFromFormat(gfxImageFormat::ARGB32));
   NS_ENSURE_TRUE(surface, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<gfxContext> context = new gfxContext(surface);
 
   shell->RenderDocument(r, 0, NS_RGB(255, 255, 0), context);
 
   imgContext->DrawSurface(surface, gfxSize(width, height));
 
--- a/layout/svg/nsSVGMaskFrame.cpp
+++ b/layout/svg/nsSVGMaskFrame.cpp
@@ -208,17 +208,17 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsRende
   // 0 disables mask, < 0 is an error
   if (surfaceSize.width <= 0 || surfaceSize.height <= 0)
     return nullptr;
 
   if (resultOverflows)
     return nullptr;
 
   nsRefPtr<gfxImageSurface> image =
-    new gfxImageSurface(surfaceSize, gfxImageFormatARGB32);
+    new gfxImageSurface(surfaceSize, gfxImageFormat::ARGB32);
   if (!image || image->CairoStatus())
     return nullptr;
 
   // We would like to use gfxImageSurface::SetDeviceOffset() to position
   // 'image'. However, we need to set the same matrix on the temporary context
   // and pattern that we create below as is currently set on 'gfx'.
   // Unfortunately, any device offset set by SetDeviceOffset() is affected by
   // the transform passed to the SetMatrix() calls, so to avoid that we account
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -1751,18 +1751,18 @@ nsresult AndroidBridge::CaptureThumbnail
     uint32_t stride = bufW * (is24bit ? 4 : 2);
 
     void* data = env->GetDirectBufferAddress(buffer);
     if (!data)
         return NS_ERROR_FAILURE;
 
     nsRefPtr<gfxImageSurface> surf =
         new gfxImageSurface(static_cast<unsigned char*>(data), nsIntSize(bufW, bufH), stride,
-                            is24bit ? gfxImageFormatRGB24 :
-                                      gfxImageFormatRGB16_565);
+                            is24bit ? gfxImageFormat::RGB24 :
+                                      gfxImageFormat::RGB16_565);
     if (surf->CairoStatus() != 0) {
         ALOG_BRIDGE("Error creating gfxImageSurface");
         return NS_ERROR_FAILURE;
     }
 
     nsRefPtr<gfxContext> context;
     if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BackendType::CAIRO)) {
         RefPtr<DrawTarget> dt =
--- a/widget/android/AndroidGraphicBuffer.cpp
+++ b/widget/android/AndroidGraphicBuffer.cpp
@@ -386,19 +386,19 @@ AndroidGraphicBuffer::GetAndroidUsage(ui
 
   return flags;
 }
 
 uint32_t
 AndroidGraphicBuffer::GetAndroidFormat(gfxImageFormat aFormat)
 {
   switch (aFormat) {
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::RGB24:
       return HAL_PIXEL_FORMAT_RGBX_8888;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
       return HAL_PIXEL_FORMAT_RGB_565;
     default:
       return 0;
   }
 }
 
 bool
 AndroidGraphicBuffer::EnsureEGLImage()
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1062,20 +1062,20 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
     AutoLocalJNIFrame jniFrame;
 
     // We're paused, or we haven't been given a window-size yet, so do nothing
     if (sCompositorPaused || gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0) {
         return;
     }
 
     int bytesPerPixel = 2;
-    gfxImageFormat format = gfxImageFormatRGB16_565;
+    gfxImageFormat format = gfxImageFormat::RGB16_565;
     if (AndroidBridge::Bridge()->GetScreenDepth() == 24) {
         bytesPerPixel = 4;
-        format = gfxImageFormatRGB24;
+        format = gfxImageFormat::RGB24;
     }
 
     layers::renderTraceEventStart("Get surface", "424545");
     static unsigned char bits2[32 * 32 * 4];
     nsRefPtr<gfxImageSurface> targetSurface =
         new gfxImageSurface(bits2, gfxIntSize(32, 32), 32 * bytesPerPixel, format);
     layers::renderTraceEventEnd("Get surface", "424545");
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2029,17 +2029,17 @@ nsChildView::CreateCompositor()
     [(ChildView *)mView setUsingOMTCompositor:true];
   }
 }
 
 gfxASurface*
 nsChildView::GetThebesSurface()
 {
   if (!mTempThebesSurface) {
-    mTempThebesSurface = new gfxQuartzSurface(gfxSize(1, 1), gfxImageFormatARGB32);
+    mTempThebesSurface = new gfxQuartzSurface(gfxSize(1, 1), gfxImageFormat::ARGB32);
   }
 
   return mTempThebesSurface;
 }
 
 void
 nsChildView::NotifyDirtyRegion(const nsIntRegion& aDirtyRegion)
 {
--- a/widget/cocoa/nsCocoaUtils.mm
+++ b/widget/cocoa/nsCocoaUtils.mm
@@ -353,17 +353,17 @@ nsresult nsCocoaUtils::CreateNSImageFrom
   aImage->GetWidth(&width);
   aImage->GetHeight(&height);
 
   // Render a vector image at the correct resolution on a retina display
   if (aImage->GetType() == imgIContainer::TYPE_VECTOR && scaleFactor != 1.0f) {
     int scaledWidth = (int)ceilf(width * scaleFactor);
     int scaledHeight = (int)ceilf(height * scaleFactor);
 
-    frame = new gfxImageSurface(gfxIntSize(scaledWidth, scaledHeight), gfxImageFormatARGB32);
+    frame = new gfxImageSurface(gfxIntSize(scaledWidth, scaledHeight), gfxImageFormat::ARGB32);
     NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
 
     nsRefPtr<gfxContext> context = new gfxContext(frame);
     NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
 
     aImage->Draw(context, GraphicsFilter::FILTER_NEAREST, gfxMatrix(),
       gfxRect(0.0f, 0.0f, scaledWidth, scaledHeight),
       nsIntRect(0, 0, width, height),
--- a/widget/cocoa/nsDeviceContextSpecX.mm
+++ b/widget/cocoa/nsDeviceContextSpecX.mm
@@ -151,17 +151,17 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetS
 
     if (context) {
         // Initially, origin is at bottom-left corner of the paper.
         // Here, we translate it to top-left corner of the paper.
         CGContextTranslateCTM(context, 0, height);
         CGContextScaleCTM(context, 1.0, -1.0);
         newSurface = new gfxQuartzSurface(context, gfxSize(width, height), true);
     } else {
-        newSurface = new gfxQuartzSurface(gfxSize((int32_t)width, (int32_t)height), gfxImageFormatARGB32, true);
+        newSurface = new gfxQuartzSurface(gfxSize((int32_t)width, (int32_t)height), gfxImageFormat::ARGB32, true);
     }
 
     if (!newSurface)
         return NS_ERROR_FAILURE;
 
     *surface = newSurface;
     NS_ADDREF(*surface);
 
--- a/widget/cocoa/nsDragService.mm
+++ b/widget/cocoa/nsDragService.mm
@@ -157,17 +157,17 @@ nsDragService::ConstructDragImage(nsIDOM
 
   if (NS_FAILED(rv) || !surface)
     return nil;
 
   uint32_t width = aDragRect->width;
   uint32_t height = aDragRect->height;
 
   nsRefPtr<gfxImageSurface> imgSurface = new gfxImageSurface(
-    gfxIntSize(width, height), gfxImageFormatARGB32);
+    gfxIntSize(width, height), gfxImageFormat::ARGB32);
   if (!imgSurface)
     return nil;
 
   nsRefPtr<gfxContext> context = new gfxContext(imgSurface);
   if (!context)
     return nil;
 
   context->SetOperator(gfxContext::OPERATOR_SOURCE);
--- a/widget/gonk/Framebuffer.cpp
+++ b/widget/gonk/Framebuffer.cpp
@@ -104,17 +104,17 @@ Open()
     }
 
     sFd = fd.get();
     fd.forget();
 
     // The android porting doc requires a /dev/graphics/fb0 device
     // that's double buffered with r5g6b5 format.  Hence the
     // hard-coded numbers here.
-    gfxImageFormat format = gfxImageFormatRGB16_565;
+    gfxImageFormat format = gfxImageFormat::RGB16_565;
     int bytesPerPixel = gfxASurface::BytePerPixelFromFormat(format);
     if (!sScreenSize) {
         sScreenSize = new gfxIntSize(sVi.xres, sVi.yres);
     }
     long stride = fi.line_length;
     size_t numFrameBytes = stride * sScreenSize->height;
 
     sBuffers = new BufferVector(2);
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -163,17 +163,17 @@ nsWindow::nsWindow()
 
         property_get("ro.display.colorfill", propValue, "0");
 
         //Update sUsingHwc whenever layers.composer2d.enabled changes
         Preferences::AddBoolVarCache(&sUsingHwc, "layers.composer2d.enabled");
 
         if (sUsingOMTC) {
           sOMTCSurface = new gfxImageSurface(gfxIntSize(1, 1),
-                                             gfxImageFormatRGB24);
+                                             gfxImageFormat::RGB24);
         }
     }
 }
 
 nsWindow::~nsWindow()
 {
 }
 
@@ -606,17 +606,17 @@ gfxASurface *
 nsWindow::GetThebesSurface()
 {
     /* This is really a dummy surface; this is only used when doing reflow, because
      * we need a RenderingContext to measure text against.
      */
 
     // XXX this really wants to return already_AddRefed, but this only really gets used
     // on direct assignment to a gfxASurface
-    return new gfxImageSurface(gfxIntSize(5,5), gfxImageFormatRGB24);
+    return new gfxImageSurface(gfxIntSize(5,5), gfxImageFormat::RGB24);
 }
 
 void
 nsWindow::BringToTop()
 {
     if (!sTopWindows.IsEmpty()) {
         if (nsIWidgetListener* listener = sTopWindows[0]->GetWidgetListener())
             listener->WindowDeactivated();
--- a/widget/gtk/nsImageToPixbuf.cpp
+++ b/widget/gtk/nsImageToPixbuf.cpp
@@ -138,17 +138,17 @@ nsImageToPixbuf::SurfaceToPixbuf(gfxASur
     }
 
     nsRefPtr<gfxImageSurface> imgSurface;
     if (aSurface->GetType() == gfxSurfaceTypeImage) {
         imgSurface = static_cast<gfxImageSurface*>
                                 (static_cast<gfxASurface*>(aSurface));
     } else {
         imgSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight),
-					 gfxImageFormatARGB32);
+					 gfxImageFormat::ARGB32);
                                        
         if (!imgSurface)
             return nullptr;
 
         nsRefPtr<gfxContext> context = new gfxContext(imgSurface);
         if (!context)
             return nullptr;
 
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2292,17 +2292,17 @@ nsWindow::UpdateAlpha(gfxPattern* aPatte
       if (drawTarget) {
           drawTarget->FillRect(Rect(0, 0, aBoundsRect.width, aBoundsRect.height),
                                *aPattern->GetPattern(drawTarget),
                                DrawOptions(1.0, CompositionOp::OP_SOURCE));
       }
       UpdateTranslucentWindowAlphaInternal(aBoundsRect, imageBuffer, stride);
   } else {
       nsRefPtr<gfxImageSurface> img =
-          new gfxImageSurface(aBoundsRect.Size(), gfxImageFormatA8);
+          new gfxImageSurface(aBoundsRect.Size(), gfxImageFormat::A8);
       if (img && !img->CairoStatus()) {
           img->SetDeviceOffset(-aBoundsRect.TopLeft());
 
           nsRefPtr<gfxContext> imgCtx = new gfxContext(img);
           imgCtx->SetPattern(aPattern);
           imgCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
           imgCtx->Paint();
 
--- a/widget/os2/nsWindow.cpp
+++ b/widget/os2/nsWindow.cpp
@@ -1489,17 +1489,17 @@ HBITMAP nsWindow::CreateTransparencyMask
   // alloc and clear space to hold both the AND & XOR bitmaps
   uint8_t* mono = (uint8_t*)calloc(cbData, 2);
   if (!mono) {
     return 0;
   }
 
   // Non-alpha formats are already taken care of
   // by initializing the XOR and AND masks to zero
-  if (format == gfxImageFormatARGB32) {
+  if (format == gfxImageFormat::ARGB32) {
 
     // make the AND mask the inverse of the 8-bit alpha data
     int32_t* pSrc = (int32_t*)aImageData;
     for (uint32_t row = aHeight; row > 0; --row) {
       // Point to the right row in the AND mask
       uint8_t* pDst = mono + cbData + abpr * (row - 1);
       uint8_t mask = 0x80;
       for (uint32_t col = aWidth; col > 0; --col) {
--- a/widget/qt/nsClipboard.cpp
+++ b/widget/qt/nsClipboard.cpp
@@ -51,21 +51,21 @@ nsClipboard::nsClipboard() : nsIClipboar
 nsClipboard::~nsClipboard()
 {
 }
 
 static inline QImage::Format
 _gfximage_to_qformat(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-    case gfxImageFormatARGB32:
+    case gfxImageFormat::ARGB32:
         return QImage::Format_ARGB32_Premultiplied;
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::RGB24:
         return QImage::Format_ARGB32;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
         return QImage::Format_RGB16;
     default:
         return QImage::Format_Invalid;
     }
 }
 
 // nsClipboard::SetNativeClipboardData ie. Copy
 
--- a/widget/qt/nsNativeThemeQt.cpp
+++ b/widget/qt/nsNativeThemeQt.cpp
@@ -56,25 +56,25 @@ static inline QRect qRectInPixels(const 
                  NSAppUnitsToIntPixels(aRect.width, p2a),
                  NSAppUnitsToIntPixels(aRect.height, p2a));
 }
 
 static inline QImage::Format
 _qimage_from_gfximage_format (gfxImageFormat aFormat)
 {
     switch (aFormat) {
-    case gfxImageFormatARGB32:
+    case gfxImageFormat::ARGB32:
         return QImage::Format_ARGB32_Premultiplied;
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::RGB24:
         return QImage::Format_RGB32;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
         return QImage::Format_RGB16;
-    case gfxImageFormatA8:
+    case gfxImageFormat::A8:
         return QImage::Format_Indexed8;
-    case gfxImageFormatA1:
+    case gfxImageFormat::A1:
 #ifdef WORDS_BIGENDIAN
         return QImage::Format_Mono;
 #else
         return QImage::Format_MonoLSB;
 #endif
     default:
         return QImage::Format_Invalid;
     }
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -233,35 +233,35 @@ nsWindow::nsWindow()
 #endif
 }
 
 static inline gfxImageFormat
 _depth_to_gfximage_format(int32_t aDepth)
 {
     switch (aDepth) {
     case 32:
-        return gfxImageFormatARGB32;
+        return gfxImageFormat::ARGB32;
     case 24:
-        return gfxImageFormatRGB24;
+        return gfxImageFormat::RGB24;
     case 16:
-        return gfxImageFormatRGB16_565;
+        return gfxImageFormat::RGB16_565;
     default:
-        return gfxImageFormatUnknown;
+        return gfxImageFormat::Unknown;
     }
 }
 
 static inline QImage::Format
 _gfximage_to_qformat(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-    case gfxImageFormatARGB32:
+    case gfxImageFormat::ARGB32:
         return QImage::Format_ARGB32_Premultiplied;
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::RGB24:
         return QImage::Format_ARGB32;
-    case gfxImageFormatRGB16_565:
+    case gfxImageFormat::RGB16_565:
         return QImage::Format_RGB16;
     default:
         return QImage::Format_Invalid;
     }
 }
 
 static bool
 UpdateOffScreenBuffers(int aDepth, QSize aSize, QWidget* aWidget = nullptr)
@@ -278,18 +278,18 @@ UpdateOffScreenBuffers(int aDepth, QSize
     gBufferMaxSize.width = std::max(gBufferMaxSize.width, size.width);
     gBufferMaxSize.height = std::max(gBufferMaxSize.height, size.height);
 
     // Check if system depth has related gfxImage format
     gfxImageFormat format =
         _depth_to_gfximage_format(aDepth);
 
     // Use fallback RGB24 format, Qt will do conversion for us
-    if (format == gfxImageFormatUnknown)
-        format = gfxImageFormatRGB24;
+    if (format == gfxImageFormat::Unknown)
+        format = gfxImageFormat::RGB24;
 
 #ifdef MOZ_HAVE_SHMIMAGE
     if (aWidget) {
         if (gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType() ==
             gfxSurfaceTypeImage) {
             gShmImage = nsShmImage::Create(gBufferMaxSize,
                                            DefaultVisualOfScreen(gfxQtPlatform::GetXScreen(aWidget)),
                                            aDepth);
@@ -2690,17 +2690,17 @@ nsWindow::GetThebesSurface()
 
 #ifdef CAIRO_HAS_QT_SURFACE
     gfxQtPlatform::RenderMode renderMode = gfxQtPlatform::GetPlatform()->GetRenderMode();
     if (renderMode == gfxQtPlatform::RENDER_QPAINTER) {
         mThebesSurface = new gfxQPainterSurface(gfxIntSize(1, 1), GFX_CONTENT_COLOR);
     }
 #endif
     if (!mThebesSurface) {
-        gfxImageFormat imageFormat = gfxImageFormatRGB24;
+        gfxImageFormat imageFormat = gfxImageFormat::RGB24;
         mThebesSurface = new gfxImageSurface(gfxIntSize(1, 1), imageFormat);
     }
 
     return mThebesSurface;
 }
 
 NS_IMETHODIMP
 nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent,
--- a/widget/shared/nsShmImage.cpp
+++ b/widget/shared/nsShmImage.cpp
@@ -76,22 +76,22 @@ nsShmImage::Create(const gfxIntSize& aSi
     shm->mXAttached = true;
     shm->mSize = aSize;
     switch (shm->mImage->depth) {
     case 24:
         // Only xRGB is supported.
         if ((shm->mImage->red_mask == 0xff0000) &&
             (shm->mImage->green_mask == 0xff00) &&
             (shm->mImage->blue_mask == 0xff)) {
-            shm->mFormat = gfxImageFormatRGB24;
+            shm->mFormat = gfxImageFormat::RGB24;
             break;
         }
         goto unsupported;
     case 16:
-        shm->mFormat = gfxImageFormatRGB16_565; break;
+        shm->mFormat = gfxImageFormat::RGB16_565; break;
     unsupported:
     default:
         NS_WARNING("Unsupported XShm Image format!");
         gShmAvailable = false;
         return nullptr;
     }
     return shm.forget();
 }
--- a/widget/windows/TaskbarPreview.cpp
+++ b/widget/windows/TaskbarPreview.cpp
@@ -352,17 +352,17 @@ TaskbarPreview::UpdateTooltip() {
   if (FAILED(mTaskbar->SetThumbnailTooltip(PreviewWindow(), mTooltip.get())))
     return NS_ERROR_FAILURE;
   return NS_OK;
 }
 
 void
 TaskbarPreview::DrawBitmap(uint32_t width, uint32_t height, bool isPreview) {
   nsresult rv;
-  nsRefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(gfxIntSize(width, height), gfxImageFormatARGB32);
+  nsRefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(gfxIntSize(width, height), gfxImageFormat::ARGB32);
 
   nsCOMPtr<nsIDocShell> shell = do_QueryReferent(mDocShell);
 
   if (!shell)
     return;
 
   rv = GetRenderingContext(shell, surface, width, height);
   if (NS_FAILED(rv))
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -740,17 +740,17 @@ AsyncFaviconDataReady::OnComplete(nsIURI
     container->GetFrame(imgIContainer::FRAME_FIRST, 0);
   NS_ENSURE_TRUE(imgFrame, NS_ERROR_FAILURE);
 
   nsRefPtr<gfxImageSurface> imageSurface;
   gfxIntSize size;
   if (mURLShortcut) {
     imageSurface =
       new gfxImageSurface(gfxIntSize(48, 48),
-                          gfxImageFormatARGB32);
+                          gfxImageFormat::ARGB32);
     gfxContext context(imageSurface);
     context.SetOperator(gfxContext::OPERATOR_SOURCE);
     context.SetColor(gfxRGBA(1, 1, 1, 1));
     context.Rectangle(gfxRect(0, 0, 48, 48));
     context.Fill();
 
     context.Translate(gfxPoint(16, 16));
     context.SetOperator(gfxContext::OPERATOR_OVER);
--- a/widget/windows/nsDragService.cpp
+++ b/widget/windows/nsDragService.cpp
@@ -87,17 +87,17 @@ nsDragService::CreateDragImage(nsIDOMNod
 
   if (bmWidth == 0 || bmHeight == 0)
     return false;
 
   psdi->crColorKey = CLR_NONE;
 
   nsRefPtr<gfxImageSurface> imgSurface = new gfxImageSurface(
     gfxIntSize(bmWidth, bmHeight), 
-    gfxImageFormatARGB32);
+    gfxImageFormat::ARGB32);
   if (!imgSurface)
     return false;
 
   nsRefPtr<gfxContext> context = new gfxContext(imgSurface);
   if (!context)
     return false;
 
   context->SetOperator(gfxContext::OPERATOR_SOURCE);
--- a/widget/windows/nsImageClipboard.cpp
+++ b/widget/windows/nsImageClipboard.cpp
@@ -130,21 +130,21 @@ nsImageToClipboard::CreateFromImage ( im
     uint32_t format;
     nsAutoString options;
     if (mWantDIBV5) {
       options.AppendLiteral("version=5;bpp=");
     } else {
       options.AppendLiteral("version=3;bpp=");
     }
     switch (frame->Format()) {
-    case gfxImageFormatARGB32:
+    case gfxImageFormat::ARGB32:
         format = imgIEncoder::INPUT_FORMAT_HOSTARGB;
         options.AppendInt(32);
         break;
-    case gfxImageFormatRGB24:
+    case gfxImageFormat::RGB24:
         format = imgIEncoder::INPUT_FORMAT_RGB;
         options.AppendInt(24);
         break;
     default:
         return NS_ERROR_INVALID_ARG;  
     }
 
     rv = encoder->InitFromData(frame->Data(), 0, frame->Width(),
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6875,24 +6875,24 @@ void nsWindow::ResizeTranslucentWindow(i
 {
   if (!force && aNewWidth == mBounds.width && aNewHeight == mBounds.height)
     return;
 
 #ifdef CAIRO_HAS_D2D_SURFACE
   if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
       gfxWindowsPlatform::RENDER_DIRECT2D) {
     nsRefPtr<gfxD2DSurface> newSurface =
-      new gfxD2DSurface(gfxIntSize(aNewWidth, aNewHeight), gfxImageFormatARGB32);
+      new gfxD2DSurface(gfxIntSize(aNewWidth, aNewHeight), gfxImageFormat::ARGB32);
     mTransparentSurface = newSurface;
     mMemoryDC = nullptr;
   } else
 #endif
   {
     nsRefPtr<gfxWindowsSurface> newSurface =
-      new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxImageFormatARGB32);
+      new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxImageFormat::ARGB32);
     mTransparentSurface = newSurface;
     mMemoryDC = newSurface->GetDC();
   }
 }
 
 void nsWindow::SetWindowTranslucencyInner(nsTransparencyMode aMode)
 {
   if (aMode == mTransparencyMode)
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -368,17 +368,17 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
               return false;
             }
 
             // don't use the shared surface directly; instead, create a new one
             // that just reuses its buffer.
             targetSurfaceImage = new gfxImageSurface(sSharedSurfaceData.get(),
                                                      surfaceSize,
                                                      surfaceSize.width * 4,
-                                                     gfxImageFormatRGB24);
+                                                     gfxImageFormat::RGB24);
 
             if (targetSurfaceImage && !targetSurfaceImage->CairoStatus()) {
               targetSurfaceImage->SetDeviceOffset(gfxPoint(-ps.rcPaint.left, -ps.rcPaint.top));
               targetSurface = targetSurfaceImage;
             }
           }
 
           if (!targetSurface) {
@@ -667,17 +667,17 @@ nsresult nsWindowGfx::CreateIcon(imgICon
       (aScaledSize.width == width && aScaledSize.height == height)) {
     // We're not scaling the image. The data is simply what's in the frame.
     data = frame->Data();
   }
   else {
     NS_ENSURE_ARG(aScaledSize.width > 0);
     NS_ENSURE_ARG(aScaledSize.height > 0);
     // Draw a scaled version of the image to a temporary surface
-    dest = new gfxImageSurface(aScaledSize, gfxImageFormatARGB32);
+    dest = new gfxImageSurface(aScaledSize, gfxImageFormat::ARGB32);
     if (!dest)
       return NS_ERROR_OUT_OF_MEMORY;
 
     gfxContext ctx(dest);
 
     // Set scaling
     gfxFloat sw = (double) aScaledSize.width / width;
     gfxFloat sh = (double) aScaledSize.height / height;
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -99,17 +99,17 @@ PuppetWidget::Create(nsIWidget        *a
   BaseCreate(nullptr, aRect, aContext, aInitData);
 
   mBounds = aRect;
   mEnabled = true;
   mVisible = true;
 
   mSurface = gfxPlatform::GetPlatform()
              ->CreateOffscreenSurface(gfxIntSize(1, 1),
-                                      gfxASurface::ContentFromFormat(gfxImageFormatARGB32));
+                                      gfxASurface::ContentFromFormat(gfxImageFormat::ARGB32));
 
   mIMEComposing = false;
   mNeedIMEStateInit = MightNeedIMEFocus(aInitData);
 
   PuppetWidget* parent = static_cast<PuppetWidget*>(aParent);
   if (parent) {
     parent->SetChild(this);
     mLayerManager = parent->GetLayerManager();