Bug 958375 - 4/9 - Make SurfaceFormat a typed enum - r=Bas
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 10 Jan 2014 14:06:16 -0500
changeset 162999 cf1cbaffbfbc60529b036e0bcdad3362c42615e5
parent 162998 ee7c42907379b179f3d5aaf49f2310094c3efcea
child 163000 82472493052dd05e4ab183b28d304fc6b48cf9b7
push id25979
push usercbook@mozilla.com
push dateMon, 13 Jan 2014 11:46:02 +0000
treeherdermozilla-central@ea6657f1d682 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs958375
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 958375 - 4/9 - Make SurfaceFormat a typed enum - r=Bas Specifically: r=Bas for manual changes f=Bas for automatic changes See attachments on the bug for the specific breakdown.
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/WebGLContextGL.cpp
gfx/2d/DataSurfaceHelpers.h
gfx/2d/DrawTargetCG.cpp
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetD2D1.cpp
gfx/2d/DrawTargetSkia.cpp
gfx/2d/FilterNodeSoftware.cpp
gfx/2d/FilterNodeSoftware.h
gfx/2d/FilterProcessing.cpp
gfx/2d/FilterProcessingSIMD-inl.h
gfx/2d/FilterProcessingScalar.cpp
gfx/2d/HelpersCairo.h
gfx/2d/HelpersD2D.h
gfx/2d/HelpersSkia.h
gfx/2d/MacIOSurface.cpp
gfx/2d/SVGTurbulenceRenderer-inl.h
gfx/2d/Scale.cpp
gfx/2d/SourceSurfaceCG.cpp
gfx/2d/SourceSurfaceCairo.cpp
gfx/2d/SourceSurfaceD2DTarget.cpp
gfx/2d/SourceSurfaceSkia.cpp
gfx/2d/Tools.h
gfx/2d/Types.h
gfx/2d/unittest/TestBugs.cpp
gfx/2d/unittest/TestDrawTargetD2D.cpp
gfx/gl/GLReadTexImageHelper.cpp
gfx/gl/GLSharedHandleHelpers.cpp
gfx/gl/GLUploadHelpers.cpp
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceGL.cpp
gfx/gl/TextureImageEGL.cpp
gfx/ipc/GfxMessageUtils.h
gfx/layers/Effects.h
gfx/layers/Layers.cpp
gfx/layers/LayersLogging.cpp
gfx/layers/RotatedBuffer.cpp
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
gfx/layers/basic/BasicLayerManager.cpp
gfx/layers/basic/MacIOSurfaceTextureHostBasic.cpp
gfx/layers/client/ContentClient.h
gfx/layers/client/ImageClient.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d10/ThebesLayerD3D10.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
gfx/layers/opengl/CompositingRenderTargetOGL.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/GrallocTextureClient.cpp
gfx/layers/opengl/GrallocTextureHost.cpp
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
gfx/layers/opengl/OGLShaderProgram.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
gfx/tests/gtest/TestTextures.cpp
gfx/thebes/gfx2DGlue.h
gfx/thebes/gfxBlur.cpp
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxPattern.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxQuartzNativeDrawing.cpp
gfx/thebes/gfxXlibNativeRenderer.cpp
gfx/ycbcr/YCbCrUtils.cpp
image/src/ClippedImage.cpp
image/src/OrientedImage.cpp
image/src/VectorImage.cpp
layout/base/nsLayoutUtils.cpp
layout/generic/nsCanvasFrame.cpp
layout/svg/nsSVGFilterInstance.cpp
widget/cocoa/nsChildView.mm
widget/cocoa/nsNativeThemeCocoa.mm
widget/gtk/nsWindow.cpp
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -327,17 +327,17 @@ public:
 
     mTempRect.ScaleRoundOut(1.0f);
 
     transform._31 -= mTempRect.x;
     transform._32 -= mTempRect.y;
 
     mTarget =
       mCtx->mTarget->CreateShadowDrawTarget(IntSize(int32_t(mTempRect.width), int32_t(mTempRect.height)),
-                                            FORMAT_B8G8R8A8, mSigma);
+                                            SurfaceFormat::B8G8R8A8, mSigma);
 
     if (!mTarget) {
       // XXX - Deal with the situation where our temp size is too big to
       // fit in a texture.
       mTarget = ctx->mTarget;
       mCtx = nullptr;
     } else {
       mTarget->SetTransform(transform);
@@ -1125,17 +1125,17 @@ CanvasRenderingContext2D::GetInputStream
 
   return ImageEncoder::GetInputStream(mWidth, mHeight, imageBuffer, format,
                                       encoder, aEncoderOptions, aStream);
 }
 
 SurfaceFormat
 CanvasRenderingContext2D::GetSurfaceFormat() const
 {
-  return mOpaque ? FORMAT_B8G8R8X8 : FORMAT_B8G8R8A8;
+  return mOpaque ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8;
 }
 
 //
 // state
 //
 
 void
 CanvasRenderingContext2D::Save()
@@ -3389,17 +3389,17 @@ CanvasRenderingContext2D::DrawWindow(nsG
   RefPtr<DrawTarget> drawDT;
   if (gfxPlatform::GetPlatform()->SupportsAzureContentForDrawTarget(mTarget)) {
     thebes = new gfxContext(mTarget);
     thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
                                 matrix._22, matrix._31, matrix._32));
   } else if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
     drawDT =
       gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(ceil(sw), ceil(sh)),
-                                                                   FORMAT_B8G8R8A8);
+                                                                   SurfaceFormat::B8G8R8A8);
     if (!drawDT) {
       error.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     thebes = new gfxContext(drawDT);
     thebes->Scale(matrix._11, matrix._22);
   } else {
@@ -3429,17 +3429,17 @@ CanvasRenderingContext2D::DrawWindow(nsG
         error.Throw(NS_ERROR_FAILURE);
         return;
       }
 
       source =
         mTarget->CreateSourceSurfaceFromData(img->Data(),
                                              IntSize(size.width, size.height),
                                              img->Stride(),
-                                             FORMAT_B8G8R8A8);
+                                             SurfaceFormat::B8G8R8A8);
     } else {
       RefPtr<SourceSurface> snapshot = drawDT->Snapshot();
       RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
 
       source =
         mTarget->CreateSourceSurfaceFromData(data->GetData(),
                                              data->GetSize(),
                                              data->Stride(),
@@ -3728,17 +3728,17 @@ CanvasRenderingContext2D::GetImageDataAr
 
 void
 CanvasRenderingContext2D::EnsureErrorTarget()
 {
   if (sErrorTarget) {
     return;
   }
 
-  RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), FORMAT_B8G8R8A8);
+  RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8);
   MOZ_ASSERT(errorTarget, "Failed to allocate the error target!");
 
   sErrorTarget = errorTarget;
   NS_ADDREF(sErrorTarget);
 }
 
 void
 CanvasRenderingContext2D::FillRuleChanged()
@@ -3874,17 +3874,17 @@ CanvasRenderingContext2D::PutImageData_e
   }
 
   EnsureTarget();
   if (!IsTargetValid()) {
     return NS_ERROR_FAILURE;
   }
 
   RefPtr<SourceSurface> sourceSurface =
-    mTarget->CreateSourceSurfaceFromData(imgsurf->Data(), IntSize(w, h), imgsurf->Stride(), FORMAT_B8G8R8A8);
+    mTarget->CreateSourceSurfaceFromData(imgsurf->Data(), IntSize(w, h), imgsurf->Stride(), SurfaceFormat::B8G8R8A8);
 
   // In certain scenarios, requesting larger than 8k image fails.  Bug 803568
   // covers the details of how to run into it, but the full detailed
   // investigation hasn't been done to determine the underlying cause.  We
   // will just handle the failure to allocate the surface to avoid a crash.
   if (!sourceSurface) {
     return NS_ERROR_FAILURE;
   }
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -2684,26 +2684,26 @@ WebGLContext::SurfaceFromElementResultTo
         return NS_ERROR_DOM_SECURITY_ERR;
     }
 
     // End of security checks, now we should be safe regarding cross-domain images
     // Notice that there is never a need to mark the WebGL canvas as write-only, since we reject write-only/cross-domain
     // texture sources in the first place.
 
     switch (data->GetFormat()) {
-        case FORMAT_B8G8R8A8:
+        case SurfaceFormat::B8G8R8A8:
             *format = WebGLTexelFormat::BGRA8; // careful, our ARGB means BGRA
             break;
-        case FORMAT_B8G8R8X8:
+        case SurfaceFormat::B8G8R8X8:
             *format = WebGLTexelFormat::BGRX8; // careful, our RGB24 is not tightly packed. Whence BGRX8.
             break;
-        case FORMAT_A8:
+        case SurfaceFormat::A8:
             *format = WebGLTexelFormat::A8;
             break;
-        case FORMAT_R5G6B5:
+        case SurfaceFormat::R5G6B5:
             *format = WebGLTexelFormat::RGB565;
             break;
         default:
             NS_ASSERTION(false, "Unsupported image format. Unimplemented.");
             return NS_ERROR_NOT_IMPLEMENTED;
     }
 
     imageOut = data;
--- a/gfx/2d/DataSurfaceHelpers.h
+++ b/gfx/2d/DataSurfaceHelpers.h
@@ -35,17 +35,17 @@ inline uint8_t *
 SurfaceToPackedBGRA(SourceSurface *aSurface)
 {
   RefPtr<DataSourceSurface> data = aSurface->GetDataSurface();
   if (!data) {
     return nullptr;
   }
 
   SurfaceFormat format = data->GetFormat();
-  if (format != FORMAT_B8G8R8A8 && format != FORMAT_B8G8R8X8) {
+  if (format != SurfaceFormat::B8G8R8A8 && format != SurfaceFormat::B8G8R8X8) {
     return nullptr;
   }
 
   IntSize size = data->GetSize();
 
   uint8_t* imageBuffer = new (std::nothrow) uint8_t[size.width * size.height * sizeof(uint32_t)];
   if (!imageBuffer) {
     return nullptr;
@@ -63,17 +63,17 @@ SurfaceToPackedBGRA(SourceSurface *aSurf
     for (int row = 0; row < size.height; ++row) {
       for (int column = 0; column < size.width; ++column) {
         *dst++ = src[column];
       }
       src += (stride/4);
     }
   }
 
-  if (format == FORMAT_B8G8R8X8) {
+  if (format == SurfaceFormat::B8G8R8X8) {
     // Convert BGRX to BGRA by setting a to 255.
     ConvertBGRXToBGRA(reinterpret_cast<uint8_t *>(imageBuffer), size, size.width * sizeof(uint32_t));
   }
 
   return imageBuffer;
 }
 
 }
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -1212,17 +1212,17 @@ DrawTargetCG::CopySurface(SourceSurface 
 
     CGContextScaleCTM(mCg, 1, -1);
 
     CGRect flippedRect = CGRectMake(aDestination.x, -(aDestination.y + aSourceRect.height),
                                     aSourceRect.width, aSourceRect.height);
 
     // Quartz seems to copy A8 surfaces incorrectly if we don't initialize them
     // to transparent first.
-    if (mFormat == FORMAT_A8) {
+    if (mFormat == SurfaceFormat::A8) {
       CGContextClearRect(mCg, flippedRect);
     }
     CGContextDrawImage(mCg, flippedRect, subimage);
 
     CGContextRestoreGState(mCg);
 
     CGImageRelease(subimage);
   }
@@ -1292,31 +1292,31 @@ DrawTargetCG::Init(BackendType aType,
 
   if (aType == BACKEND_COREGRAPHICS_ACCELERATED) {
     RefPtr<MacIOSurface> ioSurface = MacIOSurface::CreateIOSurface(aSize.width, aSize.height);
     mCg = ioSurface->CreateIOSurfaceContext();
     // If we don't have the symbol for 'CreateIOSurfaceContext' mCg will be null
     // and we will fallback to software below
   }
 
-  mFormat = FORMAT_B8G8R8A8;
+  mFormat = SurfaceFormat::B8G8R8A8;
 
   if (!mCg || aType == BACKEND_COREGRAPHICS) {
     int bitsPerComponent = 8;
 
     CGBitmapInfo bitinfo;
-    if (aFormat == FORMAT_A8) {
+    if (aFormat == SurfaceFormat::A8) {
       if (mColorSpace)
         CGColorSpaceRelease(mColorSpace);
       mColorSpace = nullptr;
       bitinfo = kCGImageAlphaOnly;
-      mFormat = FORMAT_A8;
+      mFormat = SurfaceFormat::A8;
     } else {
       bitinfo = kCGBitmapByteOrder32Host;
-      if (aFormat == FORMAT_B8G8R8X8) {
+      if (aFormat == SurfaceFormat::B8G8R8X8) {
         bitinfo |= kCGImageAlphaNoneSkipFirst;
         mFormat = aFormat;
       } else {
         bitinfo |= kCGImageAlphaPremultipliedFirst;
       }
     }
     // XXX: what should we do if this fails?
     mCg = CGBitmapContextCreate (aData,
@@ -1389,25 +1389,25 @@ DrawTargetCG::Init(CGContextRef cgContex
   // CGContext's default to have the origin at the bottom left.
   // However, currently the only use of this function is to construct a
   // DrawTargetCG around a CGContextRef from a cairo quartz surface which
   // already has it's origin adjusted.
   //
   // CGContextTranslateCTM(mCg, 0, mSize.height);
   // CGContextScaleCTM(mCg, 1, -1);
 
-  mFormat = FORMAT_B8G8R8A8;
+  mFormat = SurfaceFormat::B8G8R8A8;
   if (GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP) {
     CGColorSpaceRef colorspace;
     CGBitmapInfo bitinfo = CGBitmapContextGetBitmapInfo(mCg);
     colorspace = CGBitmapContextGetColorSpace (mCg);
     if (CGColorSpaceGetNumberOfComponents(colorspace) == 1) {
-      mFormat = FORMAT_A8;
+      mFormat = SurfaceFormat::A8;
     } else if ((bitinfo & kCGBitmapAlphaInfoMask) == kCGImageAlphaNoneSkipFirst) {
-      mFormat = FORMAT_B8G8R8X8;
+      mFormat = SurfaceFormat::B8G8R8X8;
     }
   }
 
   return true;
 }
 
 bool
 DrawTargetCG::Init(BackendType aType, const IntSize &aSize, SurfaceFormat &aFormat)
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -1153,18 +1153,18 @@ DrawTargetCairo::CreateSimilarDrawTarget
 bool
 DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize)
 {
   mContext = cairo_create(aSurface);
   mSurface = aSurface;
   mSize = aSize;
   mFormat = CairoContentToGfxFormat(cairo_surface_get_content(aSurface));
 
-  if (mFormat == FORMAT_B8G8R8A8 ||
-      mFormat == FORMAT_R8G8B8A8) {
+  if (mFormat == SurfaceFormat::B8G8R8A8 ||
+      mFormat == SurfaceFormat::R8G8B8A8) {
     SetPermitSubpixelAA(false);
   } else {
     SetPermitSubpixelAA(true);
   }
 
   return true;
 }
 
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -816,17 +816,17 @@ DrawTargetD2D::CopySurface(SourceSurface
   mRT->Clear(D2D1::ColorF(0, 0.0f));
   mRT->PopAxisAlignedClip();
 
   RefPtr<ID2D1Bitmap> bitmap = GetBitmapForSurface(aSurface, srcRect);
   if (!bitmap) {
     return;
   }
 
-  if (aSurface->GetFormat() == FORMAT_A8) {
+  if (aSurface->GetFormat() == SurfaceFormat::A8) {
     RefPtr<ID2D1SolidColorBrush> brush;
     mRT->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White),
                                D2D1::BrushProperties(), byRef(brush));
     mRT->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
     mRT->FillOpacityMask(bitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS);
   } else {
     mRT->DrawBitmap(bitmap, D2DRect(dstRect), 1.0f,
             D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
@@ -990,17 +990,17 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aF
   }
 
   AntialiasMode aaMode = font->GetDefaultAAMode();
 
   if (aOptions.mAntialiasMode != AA_DEFAULT) {
     aaMode = aOptions.mAntialiasMode;
   }
 
-  if (mFormat == FORMAT_B8G8R8A8 && mPermitSubpixelAA &&
+  if (mFormat == SurfaceFormat::B8G8R8A8 && mPermitSubpixelAA &&
       aOptions.mCompositionOp == OP_OVER && aPattern.GetType() == PATTERN_COLOR &&
       aaMode == AA_SUBPIXEL) {
     if (FillGlyphsManual(font, aBuffer,
                          static_cast<const ColorPattern*>(&aPattern)->mColor,
                          params, aOptions)) {
       return;
     }
   }
@@ -1021,17 +1021,17 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aF
   case AA_SUBPIXEL:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
     break;
   default:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
   }
 
   if (d2dAAMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE &&
-      mFormat != FORMAT_B8G8R8X8) {
+      mFormat != SurfaceFormat::B8G8R8X8) {
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
   }
 
   rt->SetTextAntialiasMode(d2dAAMode);
 
   if (rt != mRT || params != mTextRenderingParams) {
     rt->SetTextRenderingParams(params);
     if (rt == mRT) {
@@ -1482,17 +1482,17 @@ DrawTargetD2D::InitD2DRenderTarget()
   mRT = CreateRTForTexture(mTexture, mFormat);
 
   if (!mRT) {
     return false;
   }
 
   mRT->BeginDraw();
 
-  if (mFormat == FORMAT_B8G8R8X8) {
+  if (mFormat == SurfaceFormat::B8G8R8X8) {
     mRT->SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE);
   }
 
   mVRAMUsageDT += GetByteSize();
 
   return InitD3D10Data();
 }
 
@@ -1634,17 +1634,17 @@ DrawTargetD2D::GetRTForOperation(Composi
 
   EnsureViews();
 
   if (!mRTView || !mSRView) {
     gfxDebug() << *this << ": Failed to get required views. Defaulting to OP_OVER.";
     return mRT;
   }
 
-  mTempRT = CreateRTForTexture(mTempTexture, FORMAT_B8G8R8A8);
+  mTempRT = CreateRTForTexture(mTempTexture, SurfaceFormat::B8G8R8A8);
 
   if (!mTempRT) {
     return mRT;
   }
 
   mVRAMUsageDT += GetByteSize();
 
   mTempRT->BeginDraw();
@@ -1927,17 +1927,17 @@ DrawTargetD2D::CreateRTForTexture(ID3D10
     return nullptr;
   }
 
   D3D10_TEXTURE2D_DESC desc;
   aTexture->GetDesc(&desc);
 
   D2D1_ALPHA_MODE alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
 
-  if (aFormat == FORMAT_B8G8R8X8 && aTexture == mTexture) {
+  if (aFormat == SurfaceFormat::B8G8R8X8 && aTexture == mTexture) {
     alphaMode = D2D1_ALPHA_MODE_IGNORE;
   }
 
   D2D1_RENDER_TARGET_PROPERTIES props =
     D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(desc.Format, alphaMode));
   hr = factory()->CreateDxgiSurfaceRenderTarget(surface, props, byRef(rt));
 
   if (FAILED(hr)) {
@@ -2038,17 +2038,17 @@ DrawTargetD2D::EnsureClipMaskTexture(Int
 
   HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mCurrentClipMaskTexture));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to create texture for ClipMask!";
     return;
   }
 
-  RefPtr<ID2D1RenderTarget> rt = CreateRTForTexture(mCurrentClipMaskTexture, FORMAT_A8);
+  RefPtr<ID2D1RenderTarget> rt = CreateRTForTexture(mCurrentClipMaskTexture, SurfaceFormat::A8);
 
   if (!rt) {
     gfxWarning() << "Failed to create RT for ClipMask!";
     return;
   }
   
   RefPtr<ID2D1SolidColorBrush> brush;
   rt->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), byRef(brush));
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -350,17 +350,17 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *a
 
   if (aOptions.mAntialiasMode != AA_DEFAULT) {
     aaMode = aOptions.mAntialiasMode;
   }
 
   PrepareForDrawing(aOptions.mCompositionOp, aPattern);
 
   bool forceClearType = false;
-  if (mFormat == FORMAT_B8G8R8A8 && mPermitSubpixelAA &&
+  if (mFormat == SurfaceFormat::B8G8R8A8 && mPermitSubpixelAA &&
       aOptions.mCompositionOp == OP_OVER && aaMode == AA_SUBPIXEL) {
     forceClearType = true;    
   }
 
 
   D2D1_TEXT_ANTIALIAS_MODE d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
 
   switch (aaMode) {
@@ -373,17 +373,17 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *a
   case AA_SUBPIXEL:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
     break;
   default:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
   }
 
   if (d2dAAMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE &&
-      mFormat != FORMAT_B8G8R8X8 && !forceClearType) {
+      mFormat != SurfaceFormat::B8G8R8X8 && !forceClearType) {
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
   }
 
   mDC->SetTextAntialiasMode(d2dAAMode);
 
   if (params != mTextRenderingParams) {
     mDC->SetTextRenderingParams(params);
     mTextRenderingParams = params;
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -748,17 +748,17 @@ DrawTargetSkia::CopySurface(SourceSurfac
   mCanvas->restore();
 }
 
 bool
 DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
 {
   SkAutoTUnref<SkDevice> device(new SkDevice(GfxFormatToSkiaConfig(aFormat),
                                              aSize.width, aSize.height,
-                                             aFormat == FORMAT_B8G8R8X8));
+                                             aFormat == SurfaceFormat::B8G8R8X8));
 
   SkBitmap bitmap = device->accessBitmap(true);
   if (!bitmap.allocPixels()) {
     return false;
   }
 
   bitmap.eraseARGB(0, 0, 0, 0);
 
@@ -812,17 +812,17 @@ DrawTargetSkia::SetCacheLimits(int aCoun
   mGrContext->setTextureCacheLimits(aCount, aSizeInBytes);
 }
 #endif
 
 void
 DrawTargetSkia::Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat)
 {
   bool isOpaque = false;
-  if (aFormat == FORMAT_B8G8R8X8) {
+  if (aFormat == SurfaceFormat::B8G8R8X8) {
     // We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
     ConvertBGRXToBGRA(aData, aSize, aStride);
     isOpaque = true;
   }
 
   SkBitmap bitmap;
   bitmap.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride);
   bitmap.setPixels(aData);
--- 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() == FORMAT_A8 ? gfxImageFormatA8 : gfxImageFormatARGB32);
+                        aSurface->GetFormat() == SurfaceFormat::A8 ? gfxImageFormatA8 : gfxImageFormatARGB32);
   imageSurface->PrintAsDataURL();
 }
 } // namespace gfx
 } // namespace mozilla
 #endif
 
 namespace mozilla {
 namespace gfx {
@@ -425,17 +425,17 @@ GetDataSurfaceInRect(SourceSurface *aSur
 
   if (sourceRect.IsEqualEdges(aDestRect)) {
     return aSurface ? aSurface->GetDataSurface() : nullptr;
   }
 
   IntRect intersect = sourceRect.Intersect(aDestRect);
   IntRect intersectInSourceSpace = intersect - sourceRect.TopLeft();
   IntRect intersectInDestSpace = intersect - aDestRect.TopLeft();
-  SurfaceFormat format = aSurface ? aSurface->GetFormat() : FORMAT_B8G8R8A8;
+  SurfaceFormat format = aSurface ? aSurface->GetFormat() : SurfaceFormat(SurfaceFormat::B8G8R8A8);
 
   RefPtr<DataSourceSurface> target =
     Factory::CreateDataSourceSurface(aDestRect.Size(), format);
 
   if (!target) {
     return nullptr;
   }
 
@@ -637,20 +637,20 @@ FilterNodeSoftware::RequestInputRect(uin
   MOZ_ASSERT(filter, "missing input");
   filter->RequestRect(filter->GetOutputRectInRect(aRect));
 }
 
 SurfaceFormat
 FilterNodeSoftware::DesiredFormat(SurfaceFormat aCurrentFormat,
                                   FormatHint aFormatHint)
 {
-  if (aCurrentFormat == FORMAT_A8 && aFormatHint == CAN_HANDLE_A8) {
-    return FORMAT_A8;
+  if (aCurrentFormat == SurfaceFormat::A8 && aFormatHint == CAN_HANDLE_A8) {
+    return SurfaceFormat::A8;
   }
-  return FORMAT_B8G8R8A8;
+  return SurfaceFormat::B8G8R8A8;
 }
 
 TemporaryRef<DataSourceSurface>
 FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
                                               const IntRect& aRect,
                                               FormatHint aFormatHint,
                                               ConvolveMatrixEdgeMode aEdgeMode,
                                               const IntRect *aTransparencyPaddedSourceRect)
@@ -692,17 +692,17 @@ FilterNodeSoftware::GetInputDataSourceSu
     }
 #ifdef DEBUG_DUMP_SURFACES
     printf("input from input filter %s:\n", mInputFilters[inputIndex]->GetName());
 #endif
     surfaceRect = inputFilterOutput;
     MOZ_ASSERT(!surface || surfaceRect.Size() == surface->GetSize());
   }
 
-  if (surface && surface->GetFormat() == FORMAT_UNKNOWN) {
+  if (surface && surface->GetFormat() == SurfaceFormat::UNKNOWN) {
 #ifdef DEBUG_DUMP_SURFACES
     printf("wrong input format</section>\n\n");
 #endif
     return nullptr;
   }
 
   if (!surfaceRect.IsEmpty() && !surface) {
 #ifdef DEBUG_DUMP_SURFACES
@@ -729,18 +729,18 @@ FilterNodeSoftware::GetInputDataSourceSu
 
   if (result->Stride() != GetAlignedStride<16>(result->Stride()) ||
       reinterpret_cast<uintptr_t>(result->GetData()) % 16 != 0) {
     // Align unaligned surface.
     result = CloneAligned(result);
   }
 
   SurfaceFormat currentFormat = result->GetFormat();
-  if (DesiredFormat(currentFormat, aFormatHint) == FORMAT_B8G8R8A8 &&
-      currentFormat != FORMAT_B8G8R8A8) {
+  if (DesiredFormat(currentFormat, aFormatHint) == SurfaceFormat::B8G8R8A8 &&
+      currentFormat != SurfaceFormat::B8G8R8A8) {
     result = FilterProcessing::ConvertToB8G8R8A8(result);
   }
 
 #ifdef DEBUG_DUMP_SURFACES
   printf("<img src='"); DumpAsPNG(result); printf("'></section>");
 #endif
 
   MOZ_ASSERT(!result || result->GetSize() == aRect.Size(), "wrong surface size");
@@ -1066,17 +1066,17 @@ ApplyMorphology(const IntRect& aSourceRe
   MOZ_ASSERT(margin.top >= ry && margin.right >= rx &&
              margin.bottom >= ry && margin.left >= rx, "insufficient margin");
 #endif
 
   RefPtr<DataSourceSurface> tmp;
   if (rx == 0) {
     tmp = aInput;
   } else {
-    tmp = Factory::CreateDataSourceSurface(tmpRect.Size(), FORMAT_B8G8R8A8);
+    tmp = Factory::CreateDataSourceSurface(tmpRect.Size(), SurfaceFormat::B8G8R8A8);
     if (!tmp) {
       return nullptr;
     }
 
     int32_t sourceStride = aInput->Stride();
     uint8_t* sourceData = aInput->GetData();
     sourceData += DataOffset(aInput, destRect.TopLeft() - srcRect.TopLeft());
 
@@ -1087,17 +1087,17 @@ ApplyMorphology(const IntRect& aSourceRe
     FilterProcessing::ApplyMorphologyHorizontal(
       sourceData, sourceStride, tmpData, tmpStride, tmpRect, rx, aOperator);
   }
 
   RefPtr<DataSourceSurface> dest;
   if (ry == 0) {
     dest = tmp;
   } else {
-    dest = Factory::CreateDataSourceSurface(destRect.Size(), FORMAT_B8G8R8A8);
+    dest = Factory::CreateDataSourceSurface(destRect.Size(), SurfaceFormat::B8G8R8A8);
     if (!dest) {
       return nullptr;
     }
 
     int32_t tmpStride = tmp->Stride();
     uint8_t* tmpData = tmp->GetData();
     tmpData += DataOffset(tmp, destRect.TopLeft() - tmpRect.TopLeft());
 
@@ -1180,23 +1180,23 @@ FilterNodeColorMatrixSoftware::SetAttrib
   MOZ_ASSERT(aIndex == ATT_COLOR_MATRIX_ALPHA_MODE);
   mAlphaMode = (AlphaMode)aAlphaMode;
   Invalidate();
 }
 
 static TemporaryRef<DataSourceSurface>
 Premultiply(DataSourceSurface* aSurface)
 {
-  if (aSurface->GetFormat() == FORMAT_A8) {
+  if (aSurface->GetFormat() == SurfaceFormat::A8) {
     return aSurface;
   }
 
   IntSize size = aSurface->GetSize();
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* inputData = aSurface->GetData();
   int32_t inputStride = aSurface->Stride();
   uint8_t* targetData = target->GetData();
   int32_t targetStride = target->Stride();
@@ -1205,23 +1205,23 @@ Premultiply(DataSourceSurface* aSurface)
     size, targetData, targetStride, inputData, inputStride);
 
   return target;
 }
 
 static TemporaryRef<DataSourceSurface>
 Unpremultiply(DataSourceSurface* aSurface)
 {
-  if (aSurface->GetFormat() == FORMAT_A8) {
+  if (aSurface->GetFormat() == SurfaceFormat::A8) {
     return aSurface;
   }
 
   IntSize size = aSurface->GetSize();
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* inputData = aSurface->GetData();
   int32_t inputStride = aSurface->Stride();
   uint8_t* targetData = target->GetData();
   int32_t targetStride = target->Stride();
@@ -1288,43 +1288,43 @@ ColorToBGRA(const Color& aColor)
   components[B8G8R8A8_COMPONENT_BYTEOFFSET_A] = NS_lround(aColor.a * 255.0f);
   return color;
 }
 
 static SurfaceFormat
 FormatForColor(Color aColor)
 {
   if (aColor.r == 0 && aColor.g == 0 && aColor.b == 0) {
-    return FORMAT_A8;
+    return SurfaceFormat::A8;
   }
-  return FORMAT_B8G8R8A8;
+  return SurfaceFormat::B8G8R8A8;
 }
 
 TemporaryRef<DataSourceSurface>
 FilterNodeFloodSoftware::Render(const IntRect& aRect)
 {
   SurfaceFormat format = FormatForColor(mColor);
   RefPtr<DataSourceSurface> target =
     Factory::CreateDataSourceSurface(aRect.Size(), format);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* targetData = target->GetData();
   uint32_t stride = target->Stride();
 
-  if (format == FORMAT_B8G8R8A8) {
+  if (format == SurfaceFormat::B8G8R8A8) {
     uint32_t color = ColorToBGRA(mColor);
     for (int32_t y = 0; y < aRect.height; y++) {
       for (int32_t x = 0; x < aRect.width; x++) {
         *((uint32_t*)targetData + x) = color;
       }
       targetData += stride;
     }
-  } else if (format == FORMAT_A8) {
+  } else if (format == SurfaceFormat::A8) {
     uint8_t alpha = NS_lround(mColor.a * 255.0f);
     for (int32_t y = 0; y < aRect.height; y++) {
       for (int32_t x = 0; x < aRect.width; x++) {
         targetData[x] = alpha;
       }
       targetData += stride;
     }
   } else {
@@ -1567,39 +1567,39 @@ FilterNodeComponentTransferSoftware::Ren
   FormatHint pref = needColorChannels ? NEED_COLOR_CHANNELS : CAN_HANDLE_A8;
 
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_TRANSFER_IN, aRect, pref);
   if (!input) {
     return nullptr;
   }
 
-  if (input->GetFormat() == FORMAT_B8G8R8A8 && !needColorChannels) {
+  if (input->GetFormat() == SurfaceFormat::B8G8R8A8 && !needColorChannels) {
     bool colorChannelsBecomeBlack =
       IsAllZero(lookupTables[B8G8R8A8_COMPONENT_BYTEOFFSET_R]) &&
       IsAllZero(lookupTables[B8G8R8A8_COMPONENT_BYTEOFFSET_G]) &&
       IsAllZero(lookupTables[B8G8R8A8_COMPONENT_BYTEOFFSET_B]);
 
     if (colorChannelsBecomeBlack) {
       input = FilterProcessing::ExtractAlpha(input);
     }
   }
 
   SurfaceFormat format = input->GetFormat();
-  if (format == FORMAT_A8 && mDisableA) {
+  if (format == SurfaceFormat::A8 && mDisableA) {
     return input;
   }
 
   RefPtr<DataSourceSurface> target =
     Factory::CreateDataSourceSurface(aRect.Size(), format);
   if (!target) {
     return nullptr;
   }
 
-  if (format == FORMAT_A8) {
+  if (format == SurfaceFormat::A8) {
     TransferComponents<1>(input, target, &lookupTables[B8G8R8A8_COMPONENT_BYTEOFFSET_A]);
   } else {
     TransferComponents<4>(input, target, lookupTables);
   }
 
   return target;
 }
 
@@ -2201,24 +2201,24 @@ TemporaryRef<DataSourceSurface>
 FilterNodeConvolveMatrixSoftware::DoRender(const IntRect& aRect,
                                            CoordType aKernelUnitLengthX,
                                            CoordType aKernelUnitLengthY)
 {
   if (mKernelSize.width <= 0 || mKernelSize.height <= 0 ||
       mKernelMatrix.size() != uint32_t(mKernelSize.width * mKernelSize.height) ||
       !IntRect(IntPoint(0, 0), mKernelSize).Contains(mTarget) ||
       mDivisor == 0) {
-    return Factory::CreateDataSourceSurface(aRect.Size(), FORMAT_B8G8R8A8);
+    return Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8);
   }
 
   IntRect srcRect = InflatedSourceRect(aRect);
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_CONVOLVE_MATRIX_IN, srcRect, NEED_COLOR_CHANNELS, mEdgeMode, &mSourceRect);
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(aRect.Size(), FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8);
   if (!input || !target) {
     return nullptr;
   }
   ClearDataSourceSurface(target);
 
   uint8_t* sourceData = input->GetData();
   int32_t sourceStride = input->Stride();
   uint8_t* targetData = target->GetData();
@@ -2356,17 +2356,17 @@ TemporaryRef<DataSourceSurface>
 FilterNodeDisplacementMapSoftware::Render(const IntRect& aRect)
 {
   IntRect srcRect = InflatedSourceOrDestRect(aRect);
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_DISPLACEMENT_MAP_IN, srcRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> map =
     GetInputDataSourceSurface(IN_DISPLACEMENT_MAP_IN2, aRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(aRect.Size(), FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8);
   if (!input || !map || !target) {
     return nullptr;
   }
 
   uint8_t* sourceData = input->GetData();
   int32_t sourceStride = input->Stride();
   uint8_t* mapData = map->GetData();
   int32_t mapStride = map->Stride();
@@ -2615,17 +2615,17 @@ FilterNodeCompositeSoftware::SetAttribut
 }
 
 TemporaryRef<DataSourceSurface>
 FilterNodeCompositeSoftware::Render(const IntRect& aRect)
 {
   RefPtr<DataSourceSurface> start =
     GetInputDataSourceSurface(IN_COMPOSITE_IN_START, aRect, NEED_COLOR_CHANNELS);
   RefPtr<DataSourceSurface> dest =
-    Factory::CreateDataSourceSurface(aRect.Size(), FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(aRect.Size(), SurfaceFormat::B8G8R8A8);
   if (!dest) {
     return nullptr;
   }
 
   if (start) {
     CopyRect(start, dest, aRect - aRect.TopLeft(), IntPoint());
   } else {
     ClearDataSourceSurface(dest);
@@ -2707,18 +2707,18 @@ FilterNodeBlurXYSoftware::Render(const I
     GetInputDataSourceSurface(IN_GAUSSIAN_BLUR_IN, srcRect);
   if (!input) {
     return nullptr;
   }
 
   RefPtr<DataSourceSurface> target;
   Rect r(0, 0, srcRect.width, srcRect.height);
 
-  if (input->GetFormat() == FORMAT_A8) {
-    target = Factory::CreateDataSourceSurface(srcRect.Size(), FORMAT_A8);
+  if (input->GetFormat() == SurfaceFormat::A8) {
+    target = Factory::CreateDataSourceSurface(srcRect.Size(), SurfaceFormat::A8);
     CopyRect(input, target, IntRect(IntPoint(), input->GetSize()), IntPoint());
     AlphaBoxBlur blur(r, target->Stride(), sigmaXY.width, sigmaXY.height);
     blur.Blur(target->GetData());
   } else {
     RefPtr<DataSourceSurface> channel0, channel1, channel2, channel3;
     FilterProcessing::SeparateColorChannels(input, channel0, channel1, channel2, channel3);
     AlphaBoxBlur blur(r, channel0->Stride(), sigmaXY.width, sigmaXY.height);
     blur.Blur(channel0->GetData());
@@ -3206,22 +3206,22 @@ FilterNodeLightingSoftware<LightType, Li
   RefPtr<DataSourceSurface> input =
     GetInputDataSourceSurface(IN_LIGHTING_IN, srcRect, CAN_HANDLE_A8,
                               EDGE_MODE_DUPLICATE);
 
   if (!input) {
     return nullptr;
   }
 
-  if (input->GetFormat() != FORMAT_A8) {
+  if (input->GetFormat() != SurfaceFormat::A8) {
     input = FilterProcessing::ExtractAlpha(input);
   }
 
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* sourceData = input->GetData();
   int32_t sourceStride = input->Stride();
   uint8_t* targetData = target->GetData();
   int32_t targetStride = target->Stride();
--- a/gfx/2d/FilterNodeSoftware.h
+++ b/gfx/2d/FilterNodeSoftware.h
@@ -114,33 +114,33 @@ protected:
    * Callers that can only handle B8G8R8A8 surfaces pass NEED_COLOR_CHANNELS.
    */
   enum FormatHint {
     CAN_HANDLE_A8,
     NEED_COLOR_CHANNELS
   };
 
   /**
-   * Returns FORMAT_B8G8R8A8 or FORMAT_A8, depending on the current surface
+   * Returns SurfaceFormat::B8G8R8A8 or SurfaceFormat::A8, depending on the current surface
    * format and the format hint.
    */
   SurfaceFormat DesiredFormat(SurfaceFormat aCurrentFormat,
                               FormatHint aFormatHint);
 
   /**
    * Intended to be called by FilterNodeSoftware::Render implementations.
    * Returns a surface of size aRect.Size() or nullptr in error conditions. The
    * returned surface contains the output of the specified input filter or
    * input surface in aRect. If aRect extends beyond the input filter's output
    * rect (or the input surface's dimensions), the remaining area is filled
    * according to aEdgeMode: The default, EDGE_MODE_NONE, simply pads with
    * transparent black.
-   * If non-null, the returned surface is guaranteed to be of FORMAT_A8 or
-   * FORMAT_B8G8R8A8. If aFormatHint is NEED_COLOR_CHANNELS, the returned
-   * surface is guaranteed to be of FORMAT_B8G8R8A8 always.
+   * If non-null, the returned surface is guaranteed to be of SurfaceFormat::A8 or
+   * SurfaceFormat::B8G8R8A8. If aFormatHint is NEED_COLOR_CHANNELS, the returned
+   * surface is guaranteed to be of SurfaceFormat::B8G8R8A8 always.
    * Each pixel row of the returned surface is guaranteed to be 16-byte aligned.
    */
   TemporaryRef<DataSourceSurface>
     GetInputDataSourceSurface(uint32_t aInputEnumIndex, const IntRect& aRect,
                               FormatHint aFormatHint = CAN_HANDLE_A8,
                               ConvolveMatrixEdgeMode aEdgeMode = EDGE_MODE_NONE,
                               const IntRect *aTransparencyPaddedSourceRect = nullptr);
 
--- a/gfx/2d/FilterProcessing.cpp
+++ b/gfx/2d/FilterProcessing.cpp
@@ -7,17 +7,17 @@
 
 namespace mozilla {
 namespace gfx {
 
 TemporaryRef<DataSourceSurface>
 FilterProcessing::ExtractAlpha(DataSourceSurface* aSource)
 {
   IntSize size = aSource->GetSize();
-  RefPtr<DataSourceSurface> alpha = Factory::CreateDataSourceSurface(size, FORMAT_A8);
+  RefPtr<DataSourceSurface> alpha = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
   uint8_t* sourceData = aSource->GetData();
   int32_t sourceStride = aSource->Stride();
   uint8_t* alphaData = alpha->GetData();
   int32_t alphaStride = alpha->Stride();
 
   if (Factory::HasSSE2()) {
 #ifdef USE_SSE2
     ExtractAlpha_SSE2(size, sourceData, sourceStride, alphaData, alphaStride);
@@ -113,20 +113,20 @@ FilterProcessing::ApplyComposition(DataS
 void
 FilterProcessing::SeparateColorChannels(DataSourceSurface* aSource,
                                         RefPtr<DataSourceSurface>& aChannel0,
                                         RefPtr<DataSourceSurface>& aChannel1,
                                         RefPtr<DataSourceSurface>& aChannel2,
                                         RefPtr<DataSourceSurface>& aChannel3)
 {
   IntSize size = aSource->GetSize();
-  aChannel0 = Factory::CreateDataSourceSurface(size, FORMAT_A8);
-  aChannel1 = Factory::CreateDataSourceSurface(size, FORMAT_A8);
-  aChannel2 = Factory::CreateDataSourceSurface(size, FORMAT_A8);
-  aChannel3 = Factory::CreateDataSourceSurface(size, FORMAT_A8);
+  aChannel0 = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
+  aChannel1 = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
+  aChannel2 = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
+  aChannel3 = Factory::CreateDataSourceSurface(size, SurfaceFormat::A8);
   uint8_t* sourceData = aSource->GetData();
   int32_t sourceStride = aSource->Stride();
   uint8_t* channel0Data = aChannel0->GetData();
   uint8_t* channel1Data = aChannel1->GetData();
   uint8_t* channel2Data = aChannel2->GetData();
   uint8_t* channel3Data = aChannel3->GetData();
   int32_t channelStride = aChannel0->Stride();
 
@@ -140,17 +140,17 @@ FilterProcessing::SeparateColorChannels(
 }
 
 TemporaryRef<DataSourceSurface>
 FilterProcessing::CombineColorChannels(DataSourceSurface* aChannel0, DataSourceSurface* aChannel1,
                                        DataSourceSurface* aChannel2, DataSourceSurface* aChannel3)
 {
   IntSize size = aChannel0->GetSize();
   RefPtr<DataSourceSurface> result =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   int32_t resultStride = result->Stride();
   uint8_t* resultData = result->GetData();
   int32_t channelStride = aChannel0->Stride();
   uint8_t* channel0Data = aChannel0->GetData();
   uint8_t* channel1Data = aChannel1->GetData();
   uint8_t* channel2Data = aChannel2->GetData();
   uint8_t* channel3Data = aChannel3->GetData();
 
--- a/gfx/2d/FilterProcessingSIMD-inl.h
+++ b/gfx/2d/FilterProcessingSIMD-inl.h
@@ -13,62 +13,62 @@ namespace gfx {
 
 template<typename u8x16_t>
 inline TemporaryRef<DataSourceSurface>
 ConvertToB8G8R8A8_SIMD(SourceSurface* aSurface)
 {
   IntSize size = aSurface->GetSize();
   RefPtr<DataSourceSurface> input = aSurface->GetDataSurface();
   RefPtr<DataSourceSurface> output =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   uint8_t *inputData = input->GetData();
   uint8_t *outputData = output->GetData();
   int32_t inputStride = input->Stride();
   int32_t outputStride = output->Stride();
   switch (input->GetFormat()) {
-    case FORMAT_B8G8R8A8:
+    case SurfaceFormat::B8G8R8A8:
       output = input;
       break;
-    case FORMAT_B8G8R8X8:
+    case SurfaceFormat::B8G8R8X8:
       for (int32_t y = 0; y < size.height; y++) {
         for (int32_t x = 0; x < size.width; x++) {
           int32_t inputIndex = y * inputStride + 4 * x;
           int32_t outputIndex = y * outputStride + 4 * x;
           outputData[outputIndex + 0] = inputData[inputIndex + 0];
           outputData[outputIndex + 1] = inputData[inputIndex + 1];
           outputData[outputIndex + 2] = inputData[inputIndex + 2];
           outputData[outputIndex + 3] = 255;
         }
       }
       break;
-    case FORMAT_R8G8B8A8:
+    case SurfaceFormat::R8G8B8A8:
       for (int32_t y = 0; y < size.height; y++) {
         for (int32_t x = 0; x < size.width; x++) {
           int32_t inputIndex = y * inputStride + 4 * x;
           int32_t outputIndex = y * outputStride + 4 * x;
           outputData[outputIndex + 2] = inputData[inputIndex + 0];
           outputData[outputIndex + 1] = inputData[inputIndex + 1];
           outputData[outputIndex + 0] = inputData[inputIndex + 2];
           outputData[outputIndex + 3] = inputData[inputIndex + 3];
         }
       }
       break;
-    case FORMAT_R8G8B8X8:
+    case SurfaceFormat::R8G8B8X8:
       for (int32_t y = 0; y < size.height; y++) {
         for (int32_t x = 0; x < size.width; x++) {
           int32_t inputIndex = y * inputStride + 4 * x;
           int32_t outputIndex = y * outputStride + 4 * x;
           outputData[outputIndex + 2] = inputData[inputIndex + 0];
           outputData[outputIndex + 1] = inputData[inputIndex + 1];
           outputData[outputIndex + 0] = inputData[inputIndex + 2];
           outputData[outputIndex + 3] = 255;
         }
       }
       break;
-    case FORMAT_A8:
+    case SurfaceFormat::A8:
       for (int32_t y = 0; y < size.height; y++) {
         for (int32_t x = 0; x < size.width; x += 16) {
           int32_t inputIndex = y * inputStride + x;
           int32_t outputIndex = y * outputStride + 4 * x;
           u8x16_t p1To16 = simd::Load8<u8x16_t>(&inputData[inputIndex]);
           // Turn AAAAAAAAAAAAAAAA into four chunks of 000A000A000A000A by
           // interleaving with 0000000000000000 twice.
           u8x16_t zero = simd::FromZero8<u8x16_t>();
@@ -284,17 +284,17 @@ ShuffleAndPackComponents(i32x4_t bbbb123
 }
 
 template<typename i32x4_t, typename i16x8_t, typename u8x16_t, BlendMode mode>
 inline TemporaryRef<DataSourceSurface>
 ApplyBlending_SIMD(DataSourceSurface* aInput1, DataSourceSurface* aInput2)
 {
   IntSize size = aInput1->GetSize();
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* source1Data = aInput1->GetData();
   uint8_t* source2Data = aInput2->GetData();
   uint8_t* targetData = target->GetData();
   int32_t targetStride = target->Stride();
@@ -504,17 +504,17 @@ ColorMatrixMultiply(i16x8_t p, i16x8_t r
 }
 
 template<typename i32x4_t, typename i16x8_t, typename u8x16_t>
 static TemporaryRef<DataSourceSurface>
 ApplyColorMatrix_SIMD(DataSourceSurface* aInput, const Matrix5x4 &aMatrix)
 {
   IntSize size = aInput->GetSize();
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* sourceData = aInput->GetData();
   uint8_t* targetData = target->GetData();
   int32_t sourceStride = aInput->Stride();
   int32_t targetStride = target->Stride();
@@ -1009,17 +1009,17 @@ ArithmeticCombineTwoPixels(i16x8_t in1, 
 
 template<typename i32x4_t, typename i16x8_t, typename u8x16_t>
 static TemporaryRef<DataSourceSurface>
 ApplyArithmeticCombine_SIMD(DataSourceSurface* aInput1, DataSourceSurface* aInput2,
                             Float aK1, Float aK2, Float aK3, Float aK4)
 {
   IntSize size = aInput1->GetSize();
   RefPtr<DataSourceSurface> target =
-  Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+  Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* source1Data = aInput1->GetData();
   uint8_t* source2Data = aInput2->GetData();
   uint8_t* targetData = target->GetData();
   uint32_t source1Stride = aInput1->Stride();
--- a/gfx/2d/FilterProcessingScalar.cpp
+++ b/gfx/2d/FilterProcessingScalar.cpp
@@ -29,17 +29,17 @@ FilterProcessing::ConvertToB8G8R8A8_Scal
 }
 
 template<BlendMode aBlendMode>
 static TemporaryRef<DataSourceSurface>
 ApplyBlending_Scalar(DataSourceSurface* aInput1, DataSourceSurface* aInput2)
 {
   IntSize size = aInput1->GetSize();
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* source1Data = aInput1->GetData();
   uint8_t* source2Data = aInput2->GetData();
   uint8_t* targetData = target->GetData();
   uint32_t targetStride = target->Stride();
--- a/gfx/2d/HelpersCairo.h
+++ b/gfx/2d/HelpersCairo.h
@@ -126,41 +126,41 @@ GfxExtendToCairoExtend(ExtendMode extend
   return CAIRO_EXTEND_PAD;
 }
 
 static inline cairo_format_t
 GfxFormatToCairoFormat(SurfaceFormat format)
 {
   switch (format)
   {
-    case FORMAT_B8G8R8A8:
+    case SurfaceFormat::B8G8R8A8:
       return CAIRO_FORMAT_ARGB32;
-    case FORMAT_B8G8R8X8:
+    case SurfaceFormat::B8G8R8X8:
       return CAIRO_FORMAT_RGB24;
-    case FORMAT_A8:
+    case SurfaceFormat::A8:
       return CAIRO_FORMAT_A8;
-    case FORMAT_R5G6B5:
+    case SurfaceFormat::R5G6B5:
       return CAIRO_FORMAT_RGB16_565;
     default:
       gfxWarning() << "Unknown image format";
       return CAIRO_FORMAT_ARGB32;
   }
 }
 
 static inline cairo_content_t
 GfxFormatToCairoContent(SurfaceFormat format)
 {
   switch (format)
   {
-    case FORMAT_B8G8R8A8:
+    case SurfaceFormat::B8G8R8A8:
       return CAIRO_CONTENT_COLOR_ALPHA;
-    case FORMAT_B8G8R8X8:
-    case FORMAT_R5G6B5:  //fall through
+    case SurfaceFormat::B8G8R8X8:
+    case SurfaceFormat::R5G6B5:  //fall through
       return CAIRO_CONTENT_COLOR;
-    case FORMAT_A8:
+    case SurfaceFormat::A8:
       return CAIRO_CONTENT_ALPHA;
     default:
       gfxWarning() << "Unknown image format";
       return CAIRO_CONTENT_COLOR_ALPHA;
   }
 }
 
 static inline cairo_line_join_t
@@ -198,25 +198,25 @@ GfxLineCapToCairoLineCap(CapStyle style)
 }
 
 static inline SurfaceFormat
 CairoContentToGfxFormat(cairo_content_t content)
 {
   switch (content)
   {
     case CAIRO_CONTENT_COLOR_ALPHA:
-      return FORMAT_B8G8R8A8;
+      return SurfaceFormat::B8G8R8A8;
     case CAIRO_CONTENT_COLOR:
       // BEWARE! format may be 565
-      return FORMAT_B8G8R8X8;
+      return SurfaceFormat::B8G8R8X8;
     case CAIRO_CONTENT_ALPHA:
-      return FORMAT_A8;
+      return SurfaceFormat::A8;
   }
 
-  return FORMAT_B8G8R8A8;
+  return SurfaceFormat::B8G8R8A8;
 }
 
 static inline void
 GfxMatrixToCairoMatrix(const Matrix& mat, cairo_matrix_t& retval)
 {
   cairo_matrix_init(&retval, mat._11, mat._12, mat._21, mat._22, mat._31, mat._32);
 }
 
--- a/gfx/2d/HelpersD2D.h
+++ b/gfx/2d/HelpersD2D.h
@@ -129,25 +129,25 @@ static inline IntSize ToIntSize(const D2
 {
   return IntSize(aSize.width, aSize.height);
 }
 
 static inline SurfaceFormat ToPixelFormat(const D2D1_PIXEL_FORMAT &aFormat)
 {
   switch(aFormat.format) {
   case DXGI_FORMAT_A8_UNORM:
-    return FORMAT_A8;
+    return SurfaceFormat::A8;
   case DXGI_FORMAT_B8G8R8A8_UNORM:
     if (aFormat.alphaMode == D2D1_ALPHA_MODE_IGNORE) {
-      return FORMAT_B8G8R8X8;
+      return SurfaceFormat::B8G8R8X8;
     } else {
-      return FORMAT_B8G8R8A8;
+      return SurfaceFormat::B8G8R8A8;
     }
   default:
-    return FORMAT_B8G8R8A8;
+    return SurfaceFormat::B8G8R8A8;
   }
 }
 
 static inline Rect ToRect(const D2D1_RECT_F &aRect)
 {
   return Rect(aRect.left, aRect.top, aRect.right - aRect.left, aRect.bottom - aRect.top);
 }
 
@@ -161,31 +161,31 @@ static inline Matrix ToMatrix(const D2D1
 static inline Point ToPoint(const D2D1_POINT_2F &aPoint)
 {
   return Point(aPoint.x, aPoint.y);
 }
 
 static inline DXGI_FORMAT DXGIFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
-  case FORMAT_B8G8R8A8:
+  case SurfaceFormat::B8G8R8A8:
     return DXGI_FORMAT_B8G8R8A8_UNORM;
-  case FORMAT_B8G8R8X8:
+  case SurfaceFormat::B8G8R8X8:
     return DXGI_FORMAT_B8G8R8A8_UNORM;
-  case FORMAT_A8:
+  case SurfaceFormat::A8:
     return DXGI_FORMAT_A8_UNORM;
   default:
     return DXGI_FORMAT_UNKNOWN;
   }
 }
 
 static inline D2D1_ALPHA_MODE D2DAlphaModeForFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
-  case FORMAT_B8G8R8X8:
+  case SurfaceFormat::B8G8R8X8:
     return D2D1_ALPHA_MODE_IGNORE;
   default:
     return D2D1_ALPHA_MODE_PREMULTIPLIED;
   }
 }
 
 static inline D2D1_PIXEL_FORMAT D2DPixelFormat(SurfaceFormat aFormat)
 {
--- a/gfx/2d/HelpersSkia.h
+++ b/gfx/2d/HelpersSkia.h
@@ -19,60 +19,60 @@
 namespace mozilla {
 namespace gfx {
 
 static inline SkBitmap::Config
 GfxFormatToSkiaConfig(SurfaceFormat format)
 {
   switch (format)
   {
-    case FORMAT_B8G8R8A8:
+    case SurfaceFormat::B8G8R8A8:
       return SkBitmap::kARGB_8888_Config;
-    case FORMAT_B8G8R8X8:
+    case SurfaceFormat::B8G8R8X8:
       // We probably need to do something here.
       return SkBitmap::kARGB_8888_Config;
-    case FORMAT_R5G6B5:
+    case SurfaceFormat::R5G6B5:
       return SkBitmap::kRGB_565_Config;
-    case FORMAT_A8:
+    case SurfaceFormat::A8:
       return SkBitmap::kA8_Config;
     default:
       return SkBitmap::kARGB_8888_Config;
   }
 }
 
 static inline SurfaceFormat
 SkiaConfigToGfxFormat(SkBitmap::Config config)
 {
   switch (config)
   {
     case SkBitmap::kARGB_8888_Config:
-      return FORMAT_B8G8R8A8;
+      return SurfaceFormat::B8G8R8A8;
     case SkBitmap::kRGB_565_Config:
-      return FORMAT_R5G6B5;
+      return SurfaceFormat::R5G6B5;
     case SkBitmap::kA8_Config:
-      return FORMAT_A8;
+      return SurfaceFormat::A8;
     default:
-      return FORMAT_B8G8R8A8;
+      return SurfaceFormat::B8G8R8A8;
   }
 }
 
 #ifdef USE_SKIA_GPU
 static inline GrPixelConfig
 GfxFormatToGrConfig(SurfaceFormat format)
 {
   switch (format)
   {
-    case FORMAT_B8G8R8A8:
+    case SurfaceFormat::B8G8R8A8:
       return kBGRA_8888_GrPixelConfig;
-    case FORMAT_B8G8R8X8:
+    case SurfaceFormat::B8G8R8X8:
       // We probably need to do something here.
       return kBGRA_8888_GrPixelConfig;
-    case FORMAT_R5G6B5:
+    case SurfaceFormat::R5G6B5:
       return kRGB_565_GrPixelConfig;
-    case FORMAT_A8:
+    case SurfaceFormat::A8:
       return kAlpha_8_GrPixelConfig;
     default:
       return kRGBA_8888_GrPixelConfig;
   }
 
 }
 #endif
 static inline void
--- a/gfx/2d/MacIOSurface.cpp
+++ b/gfx/2d/MacIOSurface.cpp
@@ -333,18 +333,18 @@ MacIOSurface::GetAsSurface() {
   unsigned char* dataCpy = (unsigned char*)malloc(bytesPerRow*ioHeight);
   for (size_t i = 0; i < ioHeight; i++) {
     memcpy(dataCpy + i * bytesPerRow,
            ioData + i * bytesPerRow, ioWidth * 4);
   }
 
   Unlock();
 
-  SurfaceFormat format = HasAlpha() ? mozilla::gfx::FORMAT_B8G8R8A8 :
-                                      mozilla::gfx::FORMAT_B8G8R8X8;
+  SurfaceFormat format = HasAlpha() ? mozilla::gfx::SurfaceFormat::B8G8R8A8 :
+                                      mozilla::gfx::SurfaceFormat::B8G8R8X8;
 
   RefPtr<SourceSurfaceRawData> surf = new SourceSurfaceRawData();
   surf->InitWrappingData(dataCpy, IntSize(ioWidth, ioHeight), bytesPerRow, format, true);
 
   return surf.forget();
 }
 
 CGLError
--- a/gfx/2d/SVGTurbulenceRenderer-inl.h
+++ b/gfx/2d/SVGTurbulenceRenderer-inl.h
@@ -323,17 +323,17 @@ SVGTurbulenceRenderer<Type,Stitch,f32x4_
                MakeNonNegative(aOffset.y, repeatingSize.height));
 }
 
 template<TurbulenceType Type, bool Stitch, typename f32x4_t, typename i32x4_t, typename u8x16_t>
 TemporaryRef<DataSourceSurface>
 SVGTurbulenceRenderer<Type,Stitch,f32x4_t,i32x4_t,u8x16_t>::Render(const IntSize &aSize, const Point &aOffset) const
 {
   RefPtr<DataSourceSurface> target =
-    Factory::CreateDataSourceSurface(aSize, FORMAT_B8G8R8A8);
+    Factory::CreateDataSourceSurface(aSize, SurfaceFormat::B8G8R8A8);
   if (!target) {
     return nullptr;
   }
 
   uint8_t* targetData = target->GetData();
   uint32_t stride = target->Stride();
 
   Point startOffset = EquivalentNonNegativeOffset(aOffset);
--- a/gfx/2d/Scale.cpp
+++ b/gfx/2d/Scale.cpp
@@ -14,17 +14,17 @@ namespace mozilla {
 namespace gfx {
 
 bool Scale(uint8_t* srcData, int32_t srcWidth, int32_t srcHeight, int32_t srcStride,
            uint8_t* dstData, int32_t dstWidth, int32_t dstHeight, int32_t dstStride,
            SurfaceFormat format)
 {
 #ifdef USE_SKIA
   bool opaque;
-  if (format == FORMAT_B8G8R8A8) {
+  if (format == SurfaceFormat::B8G8R8A8) {
     opaque = false;
   } else {
     opaque = true;
   }
 
   SkBitmap::Config config = GfxFormatToSkiaConfig(format);
 
   SkBitmap imgSrc;
--- a/gfx/2d/SourceSurfaceCG.cpp
+++ b/gfx/2d/SourceSurfaceCG.cpp
@@ -61,47 +61,47 @@ CreateCGImage(void *aInfo,
 {
   //XXX: we should avoid creating this colorspace everytime
   CGColorSpaceRef colorSpace = nullptr;
   CGBitmapInfo bitinfo = 0;
   int bitsPerComponent = 0;
   int bitsPerPixel = 0;
 
   switch (aFormat) {
-    case FORMAT_B8G8R8A8:
+    case SurfaceFormat::B8G8R8A8:
       colorSpace = CGColorSpaceCreateDeviceRGB();
       bitinfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
       bitsPerComponent = 8;
       bitsPerPixel = 32;
       break;
 
-    case FORMAT_B8G8R8X8:
+    case SurfaceFormat::B8G8R8X8:
       colorSpace = CGColorSpaceCreateDeviceRGB();
       bitinfo = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
       bitsPerComponent = 8;
       bitsPerPixel = 32;
       break;
 
-    case FORMAT_A8:
+    case SurfaceFormat::A8:
       // XXX: why don't we set a colorspace here?
       bitsPerComponent = 8;
       bitsPerPixel = 8;
       break;
 
     default:
       MOZ_CRASH();
   }
 
   CGDataProviderRef dataProvider = CGDataProviderCreateWithData(aInfo,
                                                                 aData,
                                                                 aSize.height * aStride,
                                                                 releaseCallback);
 
   CGImageRef image;
-  if (aFormat == FORMAT_A8) {
+  if (aFormat == SurfaceFormat::A8) {
     CGFloat decode[] = {1.0, 0.0};
     image = CGImageMaskCreate (aSize.width, aSize.height,
                                bitsPerComponent,
                                bitsPerPixel,
                                aStride,
                                dataProvider,
                                decode,
                                true);
@@ -214,17 +214,17 @@ CGContextRef CreateBitmapContextForImage
 
   CGColorSpaceRelease(colorSpace);
 
   return cg;
 }
 
 DataSourceSurfaceCG::DataSourceSurfaceCG(CGImageRef aImage)
 {
-  mFormat = FORMAT_B8G8R8A8;
+  mFormat = SurfaceFormat::B8G8R8A8;
   mImage = aImage;
   mCg = CreateBitmapContextForImage(aImage);
   if (mCg == nullptr) {
     // error creating context
     return;
   }
 
   // Get image width, height. We'll use the entire image.
@@ -360,17 +360,17 @@ void SourceSurfaceCGIOSurfaceContext::En
   // Instead of using CGBitmapContextCreateImage we create
   // a CGImage around the data associated with the CGBitmapContext
   // we do this to avoid the vm_copy that CGBitmapContextCreateImage.
   // vm_copy tends to cause all sorts of unexpected performance problems
   // because of the mm tricks that vm_copy does. Using a regular
   // memcpy when the bitmap context is modified gives us more predictable
   // performance characteristics.
   if (!mImage) {
-    mImage = CreateCGImage(mData, mData, mSize, mStride, FORMAT_B8G8R8A8);
+    mImage = CreateCGImage(mData, mData, mSize, mStride, SurfaceFormat::B8G8R8A8);
   }
 
 }
 
 IntSize
 SourceSurfaceCGIOSurfaceContext::GetSize() const
 {
   return mSize;
--- a/gfx/2d/SourceSurfaceCairo.cpp
+++ b/gfx/2d/SourceSurfaceCairo.cpp
@@ -14,23 +14,23 @@ namespace mozilla {
 namespace gfx {
 
 static SurfaceFormat
 CairoFormatToSurfaceFormat(cairo_format_t format)
 {
   switch (format)
   {
     case CAIRO_FORMAT_ARGB32:
-      return FORMAT_B8G8R8A8;
+      return SurfaceFormat::B8G8R8A8;
     case CAIRO_FORMAT_RGB24:
-      return FORMAT_B8G8R8X8;
+      return SurfaceFormat::B8G8R8X8;
     case CAIRO_FORMAT_A8:
-      return FORMAT_A8;
+      return SurfaceFormat::A8;
     default:
-      return FORMAT_B8G8R8A8;
+      return SurfaceFormat::B8G8R8A8;
   }
 }
 
 SourceSurfaceCairo::SourceSurfaceCairo(cairo_surface_t* aSurface,
                                        const IntSize& aSize,
                                        const SurfaceFormat& aFormat,
                                        DrawTargetCairo* aDrawTarget /* = nullptr */)
  : mSize(aSize)
--- a/gfx/2d/SourceSurfaceD2DTarget.cpp
+++ b/gfx/2d/SourceSurfaceD2DTarget.cpp
@@ -137,17 +137,17 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1R
     gfxWarning() << "Failed to query interface texture to DXGISurface. Code: " << hr;
     return nullptr;
   }
 
   D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(mFormat));
   hr = aRT->CreateSharedBitmap(IID_IDXGISurface, surf, &props, byRef(mBitmap));
 
   if (FAILED(hr)) {
-    // This seems to happen for FORMAT_A8 sometimes...
+    // This seems to happen for SurfaceFormat::A8 sometimes...
     aRT->CreateBitmap(D2D1::SizeU(desc.Width, desc.Height),
                       D2D1::BitmapProperties(D2DPixelFormat(mFormat)),
                       byRef(mBitmap));
 
     RefPtr<ID2D1RenderTarget> rt;
 
     if (mDrawTarget) {
       rt = mDrawTarget->mRT;
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -67,17 +67,17 @@ SourceSurfaceSkia::InitFromData(unsigned
   SkBitmap temp;
   temp.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride);
   temp.setPixels(aData);
 
   if (!temp.copyTo(&mBitmap, GfxFormatToSkiaConfig(aFormat))) {
     return false;
   }
 
-  if (aFormat == FORMAT_B8G8R8X8) {
+  if (aFormat == SurfaceFormat::B8G8R8X8) {
     mBitmap.lockPixels();
     // We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
     ConvertBGRXToBGRA(reinterpret_cast<unsigned char*>(mBitmap.getPixels()), aSize, mBitmap.rowBytes());
     mBitmap.unlockPixels();
     mBitmap.notifyPixelsChanged();
     mBitmap.setIsOpaque(true);
   }
 
--- a/gfx/2d/Tools.h
+++ b/gfx/2d/Tools.h
@@ -67,19 +67,19 @@ Distance(Point aA, Point aB)
 {
   return hypotf(aB.x - aA.x, aB.y - aA.y);
 }
 
 static inline int
 BytesPerPixel(SurfaceFormat aFormat)
 {
   switch (aFormat) {
-  case FORMAT_A8:
+  case SurfaceFormat::A8:
     return 1;
-  case FORMAT_R5G6B5:
+  case SurfaceFormat::R5G6B5:
     return 2;
   default:
     return 4;
   }
 }
 
 template<typename T, int alignment = 16>
 struct AlignedArray
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -26,27 +26,26 @@ MOZ_BEGIN_ENUM_CLASS(SurfaceType)
   COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */
   COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */
   SKIA, /* Surface wrapping a Skia bitmap */
   DUAL_DT, /* Snapshot of a dual drawtarget */
   D2D1_1_IMAGE, /* A D2D 1.1 ID2D1Image SourceSurface */
   RECORDING /* Surface used for recording */
 MOZ_END_ENUM_CLASS(SurfaceType)
 
-enum SurfaceFormat
-{
-  FORMAT_B8G8R8A8,
-  FORMAT_B8G8R8X8,
-  FORMAT_R8G8B8A8,
-  FORMAT_R8G8B8X8,
-  FORMAT_R5G6B5,
-  FORMAT_A8,
-  FORMAT_YUV,
-  FORMAT_UNKNOWN
-};
+MOZ_BEGIN_ENUM_CLASS(SurfaceFormat)
+  B8G8R8A8,
+  B8G8R8X8,
+  R8G8B8A8,
+  R8G8B8X8,
+  R5G6B5,
+  A8,
+  YUV,
+  UNKNOWN
+MOZ_END_ENUM_CLASS(SurfaceFormat)
 
 enum FilterType
 {
   FILTER_BLEND = 0,
   FILTER_TRANSFORM,
   FILTER_MORPHOLOGY,
   FILTER_COLOR_MATRIX,
   FILTER_FLOOD,
--- a/gfx/2d/unittest/TestBugs.cpp
+++ b/gfx/2d/unittest/TestBugs.cpp
@@ -16,20 +16,20 @@ TestBugs::TestBugs()
   REGISTER_TEST(TestBugs, PushPopClip950550);
 }
 
 void
 TestBugs::CairoClip918671()
 {
   RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BACKEND_CAIRO,
                                                     IntSize(100, 100),
-                                                    FORMAT_B8G8R8A8);
+                                                    SurfaceFormat::B8G8R8A8);
   RefPtr<DrawTarget> ref = Factory::CreateDrawTarget(BACKEND_CAIRO,
                                                      IntSize(100, 100),
-                                                     FORMAT_B8G8R8A8);
+                                                     SurfaceFormat::B8G8R8A8);
   // Create a path that extends around the center rect but doesn't intersect it.
   RefPtr<PathBuilder> pb1 = dt->CreatePathBuilder();
   pb1->MoveTo(Point(10, 10));
   pb1->LineTo(Point(90, 10));
   pb1->LineTo(Point(90, 20));
   pb1->LineTo(Point(10, 20));
   pb1->Close();
   pb1->MoveTo(Point(90, 90));
@@ -68,17 +68,17 @@ TestBugs::CairoClip918671()
 
 }
 
 void
 TestBugs::PushPopClip950550()
 {
   RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BACKEND_CAIRO,
                                                     IntSize(500, 500),
-                                                    FORMAT_B8G8R8A8);
+                                                    SurfaceFormat::B8G8R8A8);
   dt->PushClipRect(Rect(0, 0, 100, 100));
   Matrix m(1, 0, 0, 1, 45, -100);
   dt->SetTransform(m);
   dt->PopClip();
 
   // We fail the test if we assert in this call because our draw target's
   // transforms are out of sync.
   dt->FillRect(Rect(50, 50, 50, 50), ColorPattern(Color(0.5f, 0, 0, 1.0f)));
--- a/gfx/2d/unittest/TestDrawTargetD2D.cpp
+++ b/gfx/2d/unittest/TestDrawTargetD2D.cpp
@@ -14,10 +14,10 @@ TestDrawTargetD2D::TestDrawTargetD2D()
                        D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                        D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                        D3D10_FEATURE_LEVEL_10_0,
                        D3D10_1_SDK_VERSION,
                        byRef(mDevice));
 
   Factory::SetDirect3D10Device(mDevice);
 
-  mDT = Factory::CreateDrawTarget(BACKEND_DIRECT2D, IntSize(DT_WIDTH, DT_HEIGHT), FORMAT_B8G8R8A8);
+  mDT = Factory::CreateDrawTarget(BACKEND_DIRECT2D, IntSize(DT_WIDTH, DT_HEIGHT), SurfaceFormat::B8G8R8A8);
 }
--- a/gfx/gl/GLReadTexImageHelper.cpp
+++ b/gfx/gl/GLReadTexImageHelper.cpp
@@ -284,24 +284,24 @@ ReadPixelsIntoImageSurface(GLContext* gl
         if (gl->DebugMode()) {
             NS_WARNING("Needing intermediary surface for ReadPixels. This will be slow!");
         }
         SurfaceFormat readFormatGFX;
 
         switch (readFormat) {
             case LOCAL_GL_RGBA:
             case LOCAL_GL_BGRA: {
-                readFormatGFX = hasAlpha ? FORMAT_B8G8R8A8
-                                         : FORMAT_B8G8R8X8;
+                readFormatGFX = hasAlpha ? SurfaceFormat::B8G8R8A8
+                                         : SurfaceFormat::B8G8R8X8;
                 break;
             }
             case LOCAL_GL_RGB: {
                 MOZ_ASSERT(readPixelSize == 2);
                 MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV);
-                readFormatGFX = FORMAT_R5G6B5;
+                readFormatGFX = SurfaceFormat::R5G6B5;
                 break;
             }
             default: {
                 MOZ_CRASH("Bad read format.");
             }
         }
 
         switch (readType) {
@@ -439,34 +439,34 @@ ReadBackSurface(GLContext* gl, GLuint aT
     gl->fActiveTexture(LOCAL_GL_TEXTURE0);
     gl->fBindTexture(LOCAL_GL_TEXTURE_2D, aTexture);
 
     IntSize size;
     gl->fGetTexLevelParameteriv(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_TEXTURE_WIDTH, &size.width);
     gl->fGetTexLevelParameteriv(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_TEXTURE_HEIGHT, &size.height);
 
     RefPtr<DataSourceSurface> surf =
-      Factory::CreateDataSourceSurfaceWithStride(size, FORMAT_B8G8R8A8,
-                                                 GetAlignedStride<4>(size.width * BytesPerPixel(FORMAT_B8G8R8A8)));
+      Factory::CreateDataSourceSurfaceWithStride(size, SurfaceFormat::B8G8R8A8,
+                                                 GetAlignedStride<4>(size.width * BytesPerPixel(SurfaceFormat::B8G8R8A8)));
 
     if (!surf) {
         return nullptr;
     }
 
     uint32_t currentPackAlignment = 0;
     gl->fGetIntegerv(LOCAL_GL_PACK_ALIGNMENT, (GLint*)&currentPackAlignment);
     if (currentPackAlignment != 4) {
         gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 4);
     }
     gl->fGetTexImage(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, surf->GetData());
     if (currentPackAlignment != 4) {
         gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, currentPackAlignment);
     }
 
-    if (aFormat == FORMAT_R8G8B8A8 || aFormat == FORMAT_R8G8B8X8) {
+    if (aFormat == SurfaceFormat::R8G8B8A8 || aFormat == SurfaceFormat::R8G8B8X8) {
       SwapRAndBComponents(surf);
     }
 
     if (aYInvert) {
       surf = YInvertImageSurface(surf);
     }
 
     return surf.forget();
--- a/gfx/gl/GLSharedHandleHelpers.cpp
+++ b/gfx/gl/GLSharedHandleHelpers.cpp
@@ -242,25 +242,25 @@ bool GetSharedHandleDetails(GLContext* g
     SharedTextureHandleWrapper* wrapper = reinterpret_cast<SharedTextureHandleWrapper*>(sharedHandle);
 
     switch (wrapper->Type()) {
 #ifdef MOZ_WIDGET_ANDROID
     case SharedHandleType_SurfaceTexture: {
         SurfaceTextureWrapper* surfaceWrapper = reinterpret_cast<SurfaceTextureWrapper*>(wrapper);
 
         details.mTarget = LOCAL_GL_TEXTURE_EXTERNAL;
-        details.mTextureFormat = gfx::FORMAT_R8G8B8A8;
+        details.mTextureFormat = gfx::SurfaceFormat::R8G8B8A8;
         surfaceWrapper->SurfaceTexture()->GetTransformMatrix(details.mTextureTransform);
         break;
     }
 #endif
 
     case SharedHandleType_Image:
         details.mTarget = LOCAL_GL_TEXTURE_2D;
-        details.mTextureFormat = gfx::FORMAT_R8G8B8A8;
+        details.mTextureFormat = gfx::SurfaceFormat::R8G8B8A8;
         break;
 
     default:
         NS_ERROR("Unknown shared handle type");
         return false;
     }
 
     return true;
--- a/gfx/gl/GLUploadHelpers.cpp
+++ b/gfx/gl/GLUploadHelpers.cpp
@@ -25,23 +25,23 @@ DataOffset(const nsIntPoint &aPoint, int
   data += aPoint.x * gfxASurface::BytePerPixelFromFormat(aFormat);
   return data;
 }
 
 static gfxImageFormat
 ImageFormatForSurfaceFormat(gfx::SurfaceFormat aFormat)
 {
     switch (aFormat) {
-        case gfx::FORMAT_B8G8R8A8:
+        case gfx::SurfaceFormat::B8G8R8A8:
             return gfxImageFormatARGB32;
-        case gfx::FORMAT_B8G8R8X8:
+        case gfx::SurfaceFormat::B8G8R8X8:
             return gfxImageFormatRGB24;
-        case gfx::FORMAT_R5G6B5:
+        case gfx::SurfaceFormat::R5G6B5:
             return gfxImageFormatRGB16_565;
-        case gfx::FORMAT_A8:
+        case gfx::SurfaceFormat::A8:
             return gfxImageFormatA8;
         default:
             return gfxImageFormatUnknown;
     }
 }
 
 static GLint GetAddressAlignment(ptrdiff_t aAddress)
 {
@@ -415,55 +415,55 @@ UploadImageDataToTexture(GLContext* gl,
     SurfaceFormat surfaceFormat;
 
     MOZ_ASSERT(gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA ||
                gl->GetPreferredARGB32Format() == LOCAL_GL_RGBA);
     switch (aFormat) {
         case gfxImageFormatARGB32:
             if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
               format = LOCAL_GL_BGRA;
-              surfaceFormat = gfx::FORMAT_R8G8B8A8;
+              surfaceFormat = gfx::SurfaceFormat::R8G8B8A8;
               type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             } else {
               format = LOCAL_GL_RGBA;
-              surfaceFormat = gfx::FORMAT_B8G8R8A8;
+              surfaceFormat = gfx::SurfaceFormat::B8G8R8A8;
               type = LOCAL_GL_UNSIGNED_BYTE;
             }
             internalFormat = LOCAL_GL_RGBA;
             break;
         case gfxImageFormatRGB24:
             // Treat RGB24 surfaces as RGBA32 except for the surface
             // format used.
             if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
               format = LOCAL_GL_BGRA;
-              surfaceFormat = gfx::FORMAT_R8G8B8X8;
+              surfaceFormat = gfx::SurfaceFormat::R8G8B8X8;
               type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             } else {
               format = LOCAL_GL_RGBA;
-              surfaceFormat = gfx::FORMAT_B8G8R8X8;
+              surfaceFormat = gfx::SurfaceFormat::B8G8R8X8;
               type = LOCAL_GL_UNSIGNED_BYTE;
             }
             internalFormat = LOCAL_GL_RGBA;
             break;
         case gfxImageFormatRGB16_565:
             internalFormat = format = LOCAL_GL_RGB;
             type = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
-            surfaceFormat = gfx::FORMAT_R5G6B5;
+            surfaceFormat = gfx::SurfaceFormat::R5G6B5;
             break;
         case gfxImageFormatA8:
             internalFormat = format = LOCAL_GL_LUMINANCE;
             type = LOCAL_GL_UNSIGNED_BYTE;
             // We don't have a specific luminance shader
-            surfaceFormat = gfx::FORMAT_A8;
+            surfaceFormat = gfx::SurfaceFormat::A8;
             break;
         default:
             NS_ASSERTION(false, "Unhandled image surface format!");
             format = 0;
             type = 0;
-            surfaceFormat = gfx::FORMAT_UNKNOWN;
+            surfaceFormat = gfx::SurfaceFormat::UNKNOWN;
     }
 
     nsIntRegionRectIterator iter(paintRegion);
     const nsIntRect *iterRect;
 
     // Top left point of the region's bounding rectangle.
     nsIntPoint topLeft = paintRegion.GetBounds().TopLeft();
 
--- a/gfx/gl/SharedSurfaceEGL.cpp
+++ b/gfx/gl/SharedSurfaceEGL.cpp
@@ -166,18 +166,18 @@ SharedSurface_EGLImage::Fence()
                                    &mProdTexForPipe, &mImage))
             {
                 mPipeFailed = true;
             }
         }
 
         if (!mPixels) {
             SurfaceFormat format =
-                  HasAlpha() ? FORMAT_B8G8R8A8
-                             : FORMAT_B8G8R8X8;
+                  HasAlpha() ? SurfaceFormat::B8G8R8A8
+                             : SurfaceFormat::B8G8R8X8;
             mPixels = Factory::CreateDataSourceSurface(Size(), format);
         }
 
         nsRefPtr<gfxImageSurface> wrappedData =
             new gfxImageSurface(mPixels->GetData(),
                                 ThebesIntSize(mPixels->GetSize()),
                                 mPixels->Stride(),
                                 SurfaceFormatToImageFormat(mPixels->GetFormat()));
--- a/gfx/gl/SharedSurfaceGL.cpp
+++ b/gfx/gl/SharedSurfaceGL.cpp
@@ -249,28 +249,28 @@ SharedSurface_Basic::Create(GLContext* g
                             bool hasAlpha)
 {
     gl->MakeCurrent();
     GLuint tex = CreateTexture(gl, formats.color_texInternalFormat,
                                formats.color_texFormat,
                                formats.color_texType,
                                size);
 
-    SurfaceFormat format = FORMAT_B8G8R8X8;
+    SurfaceFormat format = SurfaceFormat::B8G8R8X8;
     switch (formats.color_texInternalFormat) {
     case LOCAL_GL_RGB:
     case LOCAL_GL_RGB8:
         if (formats.color_texType == LOCAL_GL_UNSIGNED_SHORT_5_6_5)
-            format = FORMAT_R5G6B5;
+            format = SurfaceFormat::R5G6B5;
         else
-            format = FORMAT_B8G8R8X8;
+            format = SurfaceFormat::B8G8R8X8;
         break;
     case LOCAL_GL_RGBA:
     case LOCAL_GL_RGBA8:
-        format = FORMAT_B8G8R8A8;
+        format = SurfaceFormat::B8G8R8A8;
         break;
     default:
         MOZ_CRASH("Unhandled Tex format.");
     }
     return new SharedSurface_Basic(gl, size, hasAlpha, format, tex);
 }
 
 SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
--- a/gfx/gl/TextureImageEGL.cpp
+++ b/gfx/gl/TextureImageEGL.cpp
@@ -66,24 +66,24 @@ TextureImageEGL::TextureImageEGL(GLuint 
     , mTextureState(aTextureState)
     , mBound(false)
 {
     if (mUpdateFormat == gfxImageFormatUnknown) {
         mUpdateFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(GetContentType());
     }
 
     if (mUpdateFormat == gfxImageFormatRGB16_565) {
-        mTextureFormat = gfx::FORMAT_R8G8B8X8;
+        mTextureFormat = gfx::SurfaceFormat::R8G8B8X8;
     } else if (mUpdateFormat == gfxImageFormatRGB24) {
         // RGB24 means really RGBX for Thebes, which means we have to
         // use the right shader and ignore the uninitialized alpha
         // value.
-        mTextureFormat = gfx::FORMAT_B8G8R8X8;
+        mTextureFormat = gfx::SurfaceFormat::B8G8R8X8;
     } else {
-        mTextureFormat = gfx::FORMAT_B8G8R8A8;
+        mTextureFormat = gfx::SurfaceFormat::B8G8R8A8;
     }
 }
 
 TextureImageEGL::~TextureImageEGL()
 {
     if (mGLContext->IsDestroyed() || !mGLContext->IsOwningThreadCurrent()) {
         return;
     }
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -655,19 +655,19 @@ template <>
 struct ParamTraits<mozilla::layers::CompositableType>
   : public EnumSerializer<mozilla::layers::CompositableType,
                           mozilla::layers::BUFFER_UNKNOWN,
                           mozilla::layers::BUFFER_COUNT>
 {};
 
 template <>
 struct ParamTraits<mozilla::gfx::SurfaceFormat>
-  : public EnumSerializer<mozilla::gfx::SurfaceFormat,
-                          mozilla::gfx::FORMAT_B8G8R8A8,
-                          mozilla::gfx::FORMAT_UNKNOWN>
+  : public TypedEnumSerializer<mozilla::gfx::SurfaceFormat,
+                               mozilla::gfx::SurfaceFormat::B8G8R8A8,
+                               mozilla::gfx::SurfaceFormat::UNKNOWN>
 {};
 
 template <>
 struct ParamTraits<mozilla::layers::ScrollableLayerGuid>
 {
   typedef mozilla::layers::ScrollableLayerGuid paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -209,32 +209,32 @@ struct EffectChain
 inline TemporaryRef<TexturedEffect>
 CreateTexturedEffect(gfx::SurfaceFormat aFormat,
                      TextureSource* aSource,
                      const gfx::Filter& aFilter)
 {
   MOZ_ASSERT(aSource);
   RefPtr<TexturedEffect> result;
   switch (aFormat) {
-  case gfx::FORMAT_B8G8R8A8:
+  case gfx::SurfaceFormat::B8G8R8A8:
     result = new EffectBGRA(aSource, true, aFilter);
     break;
-  case gfx::FORMAT_B8G8R8X8:
+  case gfx::SurfaceFormat::B8G8R8X8:
     result = new EffectBGRX(aSource, true, aFilter);
     break;
-  case gfx::FORMAT_R8G8B8X8:
+  case gfx::SurfaceFormat::R8G8B8X8:
     result = new EffectRGBX(aSource, true, aFilter);
     break;
-  case gfx::FORMAT_R5G6B5:
+  case gfx::SurfaceFormat::R5G6B5:
     result = new EffectRGBX(aSource, true, aFilter);
     break;
-  case gfx::FORMAT_R8G8B8A8:
+  case gfx::SurfaceFormat::R8G8B8A8:
     result = new EffectRGBA(aSource, true, aFilter);
     break;
-  case gfx::FORMAT_YUV:
+  case gfx::SurfaceFormat::YUV:
     result = new EffectYCbCr(aSource, aFilter);
     break;
   default:
     NS_WARNING("unhandled program type");
     break;
   }
 
   return result;
@@ -248,18 +248,18 @@ CreateTexturedEffect(gfx::SurfaceFormat 
  */
 inline TemporaryRef<TexturedEffect>
 CreateTexturedEffect(TextureSource* aSource,
                      TextureSource* aSourceOnWhite,
                      const gfx::Filter& aFilter)
 {
   MOZ_ASSERT(aSource);
   if (aSourceOnWhite) {
-    MOZ_ASSERT(aSource->GetFormat() == gfx::FORMAT_R8G8B8X8 ||
-               aSourceOnWhite->GetFormat() == gfx::FORMAT_B8G8R8X8);
+    MOZ_ASSERT(aSource->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 ||
+               aSourceOnWhite->GetFormat() == gfx::SurfaceFormat::B8G8R8X8);
     return new EffectComponentAlpha(aSource, aSourceOnWhite, aFilter);
   }
 
   return CreateTexturedEffect(aSource->GetFormat(), aSource, aFilter);
 }
 
 /**
  * Create a textured effect based on aSource format.
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -1502,17 +1502,17 @@ PrintInfo(nsACString& aTo, LayerComposit
   }
   return aTo;
 }
 
 void
 SetAntialiasingFlags(Layer* aLayer, DrawTarget* aTarget)
 {
   bool permitSubpixelAA = !(aLayer->GetContentFlags() & Layer::CONTENT_DISABLE_SUBPIXEL_AA);
-  if (aTarget->GetFormat() != FORMAT_B8G8R8A8) {
+  if (aTarget->GetFormat() != SurfaceFormat::B8G8R8A8) {
     aTarget->SetPermitSubpixelAA(permitSubpixelAA);
     return;
   }
 
   const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
   gfx::Rect transformedBounds = aTarget->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y),
                                                                                   Float(bounds.width), Float(bounds.height)));
   transformedBounds.RoundOut();
--- a/gfx/layers/LayersLogging.cpp
+++ b/gfx/layers/LayersLogging.cpp
@@ -232,23 +232,23 @@ AppendToString(nsACString& s, TextureFla
 }
 
 nsACString&
 AppendToString(nsACString& s, mozilla::gfx::SurfaceFormat format,
                const char* pfx, const char* sfx)
 {
   s += pfx;
   switch (format) {
-  case FORMAT_B8G8R8A8:  s += "FORMAT_B8G8R8A8"; break;
-  case FORMAT_B8G8R8X8:  s += "FORMAT_B8G8R8X8"; break;
-  case FORMAT_R8G8B8A8:  s += "FORMAT_R8G8B8A8"; break;
-  case FORMAT_R8G8B8X8:  s += "FORMAT_R8G8B8X8"; break;
-  case FORMAT_R5G6B5:    s += "FORMAT_R5G6B5"; break;
-  case FORMAT_A8:        s += "FORMAT_A8"; break;
-  case FORMAT_YUV:       s += "FORMAT_YUV"; break;
-  case FORMAT_UNKNOWN:   s += "FORMAT_UNKNOWN"; break;
+  case SurfaceFormat::B8G8R8A8:  s += "SurfaceFormat::B8G8R8A8"; break;
+  case SurfaceFormat::B8G8R8X8:  s += "SurfaceFormat::B8G8R8X8"; break;
+  case SurfaceFormat::R8G8B8A8:  s += "SurfaceFormat::R8G8B8A8"; break;
+  case SurfaceFormat::R8G8B8X8:  s += "SurfaceFormat::R8G8B8X8"; break;
+  case SurfaceFormat::R5G6B5:    s += "SurfaceFormat::R5G6B5"; break;
+  case SurfaceFormat::A8:        s += "SurfaceFormat::A8"; break;
+  case SurfaceFormat::YUV:       s += "SurfaceFormat::YUV"; break;
+  case SurfaceFormat::UNKNOWN:   s += "SurfaceFormat::UNKNOWN"; break;
   }
 
   return s += sfx;
 }
 
 } // namespace
 } // namespace
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -98,17 +98,17 @@ RotatedBuffer::DrawBufferQuadrant(gfx::D
   MOZ_ASSERT(aOperator == OP_OVER || aOperator == OP_SOURCE);
   // direct2d is much slower when using OP_SOURCE so use OP_OVER and
   // (maybe) a clear instead. Normally we need to draw in a single operation
   // (to avoid flickering) but direct2d is ok since it defers rendering.
   // We should try abstract this logic in a helper when we have other use
   // cases.
   if (aTarget->GetType() == BACKEND_DIRECT2D && aOperator == OP_SOURCE) {
     aOperator = OP_OVER;
-    if (mDTBuffer->GetFormat() == FORMAT_B8G8R8A8) {
+    if (mDTBuffer->GetFormat() == SurfaceFormat::B8G8R8A8) {
       aTarget->ClearRect(ToRect(fillRect));
     }
   }
 
   RefPtr<gfx::SourceSurface> snapshot;
   if (aSource == BUFFER_BLACK) {
     snapshot = mDTBuffer->Snapshot();
   } else {
--- a/gfx/layers/YCbCrImageDataSerializer.cpp
+++ b/gfx/layers/YCbCrImageDataSerializer.cpp
@@ -245,17 +245,17 @@ YCbCrImageDataSerializer::CopyData(const
   }
   return true;
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 YCbCrImageDataDeserializer::ToDataSourceSurface()
 {
   RefPtr<gfx::DataSourceSurface> result =
-    gfx::Factory::CreateDataSourceSurface(GetYSize(), gfx::FORMAT_R8G8B8X8);
+    gfx::Factory::CreateDataSourceSurface(GetYSize(), gfx::SurfaceFormat::R8G8B8X8);
 
   gfx::ConvertYCbCrToRGB32(GetYData(), GetCbData(), GetCrData(),
                            result->GetData(),
                            0, 0, //pic x and y
                            GetYSize().width, GetYSize().height,
                            GetYStride(), GetCbCrStride(),
                            result->Stride(),
                            gfx::YV12);
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -170,17 +170,17 @@ public:
   }
 
   bool ConvertImageToRGB(const SurfaceDescriptor& aImage)
   {
     YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
     PlanarYCbCrData data;
     DeserializerToPlanarYCbCrImageData(deserializer, data);
 
-    gfx::SurfaceFormat format = FORMAT_B8G8R8X8;
+    gfx::SurfaceFormat format = SurfaceFormat::B8G8R8X8;
     gfx::IntSize size;
     gfx::GetYCbCrToRGBDestFormatAndSize(data, format, size);
     if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
         size.height > PlanarYCbCrImage::MAX_DIMENSION) {
       NS_ERROR("Illegal image dest width or height");
       return false;
     }
 
@@ -230,29 +230,29 @@ void BasicCompositor::Destroy()
 {
   mWidget->CleanupRemoteDrawing();
   mWidget = nullptr;
 }
 
 TemporaryRef<CompositingRenderTarget>
 BasicCompositor::CreateRenderTarget(const IntRect& aRect, SurfaceInitMode aInit)
 {
-  RefPtr<DrawTarget> target = mDrawTarget->CreateSimilarDrawTarget(aRect.Size(), FORMAT_B8G8R8A8);
+  RefPtr<DrawTarget> target = mDrawTarget->CreateSimilarDrawTarget(aRect.Size(), SurfaceFormat::B8G8R8A8);
 
   RefPtr<BasicCompositingRenderTarget> rt = new BasicCompositingRenderTarget(target, aRect);
 
   return rt.forget();
 }
 
 TemporaryRef<CompositingRenderTarget>
 BasicCompositor::CreateRenderTargetFromSource(const IntRect &aRect,
                                               const CompositingRenderTarget *aSource,
                                               const IntPoint &aSourcePoint)
 {
-  RefPtr<DrawTarget> target = mDrawTarget->CreateSimilarDrawTarget(aRect.Size(), FORMAT_B8G8R8A8);
+  RefPtr<DrawTarget> target = mDrawTarget->CreateSimilarDrawTarget(aRect.Size(), SurfaceFormat::B8G8R8A8);
   RefPtr<BasicCompositingRenderTarget> rt = new BasicCompositingRenderTarget(target, aRect);
 
   DrawTarget *source;
   if (aSource) {
     const BasicCompositingRenderTarget* sourceSurface =
       static_cast<const BasicCompositingRenderTarget*>(aSource);
     source = sourceSurface->mDrawTarget;
   } else {
@@ -416,17 +416,17 @@ BasicCompositor::DrawQuad(const gfx::Rec
   Rect transformBounds;
   gfx3DMatrix new3DTransform;
   IntPoint offset = mRenderTarget->GetOrigin();
 
   if (aTransform.Is2D()) {
     newTransform = aTransform.As2D();
   } else {
     // Create a temporary surface for the transform.
-    dest = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(RoundOut(aRect).Size(), FORMAT_B8G8R8A8);
+    dest = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(RoundOut(aRect).Size(), SurfaceFormat::B8G8R8A8);
     if (!dest) {
       return;
     }
 
     // Get the bounds post-transform.
     To3DMatrix(aTransform, new3DTransform);
     gfxRect bounds = new3DTransform.TransformBounds(ThebesRect(aRect));
     bounds.IntersectRect(bounds, gfxRect(offset.x, offset.y, buffer->GetSize().width, buffer->GetSize().height));
@@ -509,17 +509,17 @@ BasicCompositor::DrawQuad(const gfx::Rec
   }
 
   if (!aTransform.Is2D()) {
     dest->Flush();
 
     RefPtr<SourceSurface> snapshot = dest->Snapshot();
     RefPtr<DataSourceSurface> source = snapshot->GetDataSurface();
     RefPtr<DataSourceSurface> temp =
-      Factory::CreateDataSourceSurface(RoundOut(transformBounds).Size(), FORMAT_B8G8R8A8);
+      Factory::CreateDataSourceSurface(RoundOut(transformBounds).Size(), SurfaceFormat::B8G8R8A8);
     if (!temp) {
       return;
     }
 
     PixmanTransform(temp, source, new3DTransform, gfxPoint(0, 0));
 
     buffer->DrawSurface(temp, transformBounds, transformBounds);
   }
@@ -549,17 +549,17 @@ BasicCompositor::BeginFrame(const nsIntR
 
   if (mInvalidRect.width <= 0 || mInvalidRect.height <= 0) {
     return;
   }
 
   if (mCopyTarget) {
     // If we have a copy target, then we don't have a widget-provided mDrawTarget (currently). Create a dummy
     // placeholder so that CreateRenderTarget() works.
-    mDrawTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1,1), FORMAT_B8G8R8A8);
+    mDrawTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1,1), SurfaceFormat::B8G8R8A8);
   } else {
     mDrawTarget = mWidget->StartRemoteDrawing();
   }
   if (!mDrawTarget) {
     return;
   }
 
   // Setup an intermediate render target to buffer all compositing. We will
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -25,17 +25,17 @@ public:
     , mSize(aRect.Size())
   { }
 
   virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
 
   virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
   {
     return mDrawTarget ? mDrawTarget->GetFormat()
-                       : gfx::FORMAT_UNKNOWN;
+                       : gfx::SurfaceFormat(gfx::SurfaceFormat::UNKNOWN);
   }
 
   RefPtr<gfx::DrawTarget> mDrawTarget;
   gfx::IntSize mSize;
 };
 
 class BasicCompositor : public Compositor
 {
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -725,17 +725,17 @@ PixmanTransform(const gfxImageSurface* a
   IntSize destSize = ToIntSize(aDest->GetSize());
   pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormatARGB32 ? 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() == FORMAT_B8G8R8A8 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
+  pixman_image_t* src = pixman_image_create_bits(aSrc->GetFormat() == SurfaceFormat::B8G8R8A8 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
                                                  srcSize.width,
                                                  srcSize.height,
                                                  (uint32_t*)aSrc->GetData(),
                                                  aSrc->Stride());
 
   NS_ABORT_IF_FALSE(src && dest, "Failed to create pixman images?");
 
   pixman_transform pixTransform = BasicLayerManager_Matrix3DToPixman(aTransform);
@@ -950,17 +950,17 @@ BasicLayerManager::PaintLayer(gfxContext
       FlushGroup(paintLayerContext, needsClipToVisibleRegion);
     } else {
       PaintSelfOrChildren(paintLayerContext, aTarget);
     }
   } else {
     const nsIntRect& bounds = visibleRegion.GetBounds();
     RefPtr<DrawTarget> untransformedDT =
       gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(bounds.width, bounds.height),
-                                                                   FORMAT_B8G8R8A8);
+                                                                   SurfaceFormat::B8G8R8A8);
     if (!untransformedDT) {
       return;
     }
 
     nsRefPtr<gfxContext> groupTarget = new gfxContext(untransformedDT);
     groupTarget->Translate(gfxPoint(-bounds.x, -bounds.y));
 
     PaintSelfOrChildren(paintLayerContext, groupTarget);
--- a/gfx/layers/basic/MacIOSurfaceTextureHostBasic.cpp
+++ b/gfx/layers/basic/MacIOSurfaceTextureHostBasic.cpp
@@ -26,17 +26,17 @@ MacIOSurfaceTextureSourceBasic::GetSize(
 {
   return gfx::IntSize(mSurface->GetDevicePixelWidth(),
                       mSurface->GetDevicePixelHeight());
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureSourceBasic::GetFormat() const
 {
-  return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8;
+  return mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8X8;
 }
 
 MacIOSurfaceTextureHostBasic::MacIOSurfaceTextureHostBasic(
     TextureFlags aFlags,
     const SurfaceDescriptorMacIOSurface& aDescriptor
 )
   : TextureHost(aFlags)
 {
@@ -80,17 +80,17 @@ MacIOSurfaceTextureHostBasic::SetComposi
   mCompositor = compositor;
   if (mTextureSource) {
     mTextureSource->SetCompositor(compositor);
   }
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureHostBasic::GetFormat() const {
-  return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8;
+  return mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8X8;
 }
 
 gfx::IntSize
 MacIOSurfaceTextureHostBasic::GetSize() const {
   return gfx::IntSize(mSurface->GetDevicePixelWidth(),
                       mSurface->GetDevicePixelHeight());
 }
 
--- a/gfx/layers/client/ContentClient.h
+++ b/gfx/layers/client/ContentClient.h
@@ -193,17 +193,17 @@ class ContentClientRemoteBuffer : public
   using RotatedContentBuffer::BufferRect;
   using RotatedContentBuffer::BufferRotation;
 public:
   ContentClientRemoteBuffer(CompositableForwarder* aForwarder)
     : ContentClientRemote(aForwarder)
     , RotatedContentBuffer(ContainsVisibleBounds)
     , mIsNewBuffer(false)
     , mFrontAndBackBufferDiffer(false)
-    , mSurfaceFormat(gfx::FORMAT_B8G8R8A8)
+    , mSurfaceFormat(gfx::SurfaceFormat::B8G8R8A8)
   {}
 
   typedef RotatedContentBuffer::PaintState PaintState;
   typedef RotatedContentBuffer::ContentType ContentType;
 
   virtual void Clear() { RotatedContentBuffer::Clear(); }
 
   virtual PaintState BeginPaintBuffer(ThebesLayer* aLayer, ContentType aContentType,
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -165,17 +165,17 @@ ImageClientSingle::UpdateImage(ImageCont
 
     if (mFrontBuffer && mFrontBuffer->IsImmutable()) {
       mFrontBuffer->ForceRemove();
       mFrontBuffer = nullptr;
     }
 
     bool bufferCreated = false;
     if (!mFrontBuffer) {
-      mFrontBuffer = CreateBufferTextureClient(gfx::FORMAT_YUV, TEXTURE_FLAGS_DEFAULT);
+      mFrontBuffer = CreateBufferTextureClient(gfx::SurfaceFormat::YUV, TEXTURE_FLAGS_DEFAULT);
       gfx::IntSize ySize(data->mYSize.width, data->mYSize.height);
       gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
       if (!mFrontBuffer->AsTextureClientYCbCr()->AllocateForYCbCr(ySize, cbCrSize, data->mStereoMode)) {
         mFrontBuffer = nullptr;
         return false;
       }
       bufferCreated = true;
     }
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -314,17 +314,17 @@ TextureClient::ShouldDeallocateInDestruc
   // deallocate on the client instead.
   return !IsSharedWithCompositor();
 }
 
 bool
 ShmemTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor)
 {
   MOZ_ASSERT(IsValid());
-  if (!IsAllocated() || GetFormat() == gfx::FORMAT_UNKNOWN) {
+  if (!IsAllocated() || GetFormat() == gfx::SurfaceFormat::UNKNOWN) {
     return false;
   }
 
   aDescriptor = SurfaceDescriptorShmem(mShmem, GetFormat());
 
   return true;
 }
 
@@ -378,17 +378,17 @@ ShmemTextureClient::~ShmemTextureClient(
     mCompositable->GetForwarder()->DeallocShmem(mShmem);
   }
 }
 
 bool
 MemoryTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor)
 {
   MOZ_ASSERT(IsValid());
-  if (!IsAllocated() || GetFormat() == gfx::FORMAT_UNKNOWN) {
+  if (!IsAllocated() || GetFormat() == gfx::SurfaceFormat::UNKNOWN) {
     return false;
   }
   aDescriptor = SurfaceDescriptorMemory(reinterpret_cast<uintptr_t>(mBuffer),
                                         GetFormat());
   return true;
 }
 
 bool
@@ -494,17 +494,17 @@ BufferTextureClient::GetAsSurface()
   nsRefPtr<gfxASurface> result = surf.get();
   return result.forget();
 }
 
 bool
 BufferTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
 {
   MOZ_ASSERT(IsValid());
-  MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This textureClient cannot use YCbCr data");
+  MOZ_ASSERT(mFormat != gfx::SurfaceFormat::YUV, "This textureClient cannot use YCbCr data");
   MOZ_ASSERT(aSize.width * aSize.height);
 
   int bufSize
     = ImageDataSerializer::ComputeMinBufferSize(aSize, mFormat);
   if (!Allocate(bufSize)) {
     return false;
   }
 
@@ -604,17 +604,17 @@ BufferTextureClient::Unlock()
   }
   mDrawTarget = nullptr;
   mUsingFallbackDrawTarget = false;
 }
 
 bool
 BufferTextureClient::UpdateYCbCr(const PlanarYCbCrData& aData)
 {
-  MOZ_ASSERT(mFormat == gfx::FORMAT_YUV, "This textureClient can only use YCbCr data");
+  MOZ_ASSERT(mFormat == gfx::SurfaceFormat::YUV, "This textureClient can only use YCbCr data");
   MOZ_ASSERT(!IsImmutable());
   MOZ_ASSERT(IsValid());
   MOZ_ASSERT(aData.mCbSkip == aData.mCrSkip);
 
   YCbCrImageDataSerializer serializer(GetBuffer());
   MOZ_ASSERT(serializer.IsValid());
   if (!serializer.CopyData(aData.mYChannel, aData.mCbChannel, aData.mCrChannel,
                            aData.mYSize, aData.mYStride,
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -263,17 +263,17 @@ TextureSource::~TextureSource()
 {
     MOZ_COUNT_DTOR(TextureSource);
 }
 
 DeprecatedTextureHost::DeprecatedTextureHost()
   : mFlags(0)
   , mBuffer(nullptr)
   , mDeAllocator(nullptr)
-  , mFormat(gfx::FORMAT_UNKNOWN)
+  , mFormat(gfx::SurfaceFormat::UNKNOWN)
 {
   MOZ_COUNT_CTOR(DeprecatedTextureHost);
 }
 
 DeprecatedTextureHost::~DeprecatedTextureHost()
 {
   if (mBuffer) {
     if (!(mFlags & TEXTURE_DEALLOCATE_CLIENT)) {
@@ -425,20 +425,20 @@ BufferTextureHost::GetTextureSources()
 gfx::SurfaceFormat
 BufferTextureHost::GetFormat() const
 {
   // mFormat is the format of the data that we share with the content process.
   // GetFormat, on the other hand, expects the format that we present to the
   // Compositor (it is used to choose the effect type).
   // if the compositor does not support YCbCr effects, we give it a RGBX texture
   // instead (see BufferTextureHost::Upload)
-  if (mFormat == gfx::FORMAT_YUV &&
+  if (mFormat == gfx::SurfaceFormat::YUV &&
     mCompositor &&
     !mCompositor->SupportsEffect(EFFECT_YCBCR)) {
-    return gfx::FORMAT_R8G8B8X8;
+    return gfx::SurfaceFormat::R8G8B8X8;
   }
   return mFormat;
 }
 
 bool
 BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
 {
   if (mFirstSource && mFirstSource->GetUpdateSerial() == mUpdateSerial) {
@@ -462,20 +462,20 @@ BufferTextureHost::Upload(nsIntRegion *a
   }
   if (!mCompositor) {
     NS_WARNING("Tried to upload without a compositor. Skipping texture upload...");
     // If we are in this situation it means we should have called SetCompositor
     // earlier. It is conceivable that on certain rare conditions with async-video
     // we may end up here for the first frame, but this should not happen repeatedly.
     return false;
   }
-  if (mFormat == gfx::FORMAT_UNKNOWN) {
+  if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
     NS_WARNING("BufferTextureHost: unsupported format!");
     return false;
-  } else if (mFormat == gfx::FORMAT_YUV) {
+  } else if (mFormat == gfx::SurfaceFormat::YUV) {
     YCbCrImageDataDeserializer yuvDeserializer(GetBuffer());
     MOZ_ASSERT(yuvDeserializer.IsValid());
 
     if (!mCompositor->SupportsEffect(EFFECT_YCBCR)) {
       RefPtr<gfx::DataSourceSurface> surf = yuvDeserializer.ToDataSourceSurface();
       if (!mFirstSource) {
         mFirstSource = mCompositor->CreateDataTextureSource(mFlags);
       }
@@ -506,27 +506,27 @@ BufferTextureHost::Upload(nsIntRegion *a
       srcV = mFirstSource->GetNextSibling()->GetNextSibling()->AsDataTextureSource();
     }
 
 
     RefPtr<gfx::DataSourceSurface> tempY =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetYData(),
                                                     yuvDeserializer.GetYStride(),
                                                     yuvDeserializer.GetYSize(),
-                                                    gfx::FORMAT_A8);
+                                                    gfx::SurfaceFormat::A8);
     RefPtr<gfx::DataSourceSurface> tempCb =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
                                                     yuvDeserializer.GetCbCrStride(),
                                                     yuvDeserializer.GetCbCrSize(),
-                                                    gfx::FORMAT_A8);
+                                                    gfx::SurfaceFormat::A8);
     RefPtr<gfx::DataSourceSurface> tempCr =
       gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
                                                     yuvDeserializer.GetCbCrStride(),
                                                     yuvDeserializer.GetCbCrSize(),
-                                                    gfx::FORMAT_A8);
+                                                    gfx::SurfaceFormat::A8);
     // We don't support partial updates for Y U V textures
     NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
     if (!srcY->Update(tempY) ||
         !srcU->Update(tempCb) ||
         !srcV->Update(tempCr)) {
       NS_WARNING("failed to update the DataTextureSource");
       return false;
     }
@@ -553,20 +553,20 @@ BufferTextureHost::Upload(nsIntRegion *a
   }
   return true;
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 BufferTextureHost::GetAsSurface()
 {
   RefPtr<gfx::DataSourceSurface> result;
-  if (mFormat == gfx::FORMAT_UNKNOWN) {
+  if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
     NS_WARNING("BufferTextureHost: unsupported format!");
     return nullptr;
-  } else if (mFormat == gfx::FORMAT_YUV) {
+  } else if (mFormat == gfx::SurfaceFormat::YUV) {
     YCbCrImageDataDeserializer yuvDeserializer(GetBuffer());
     if (!yuvDeserializer.IsValid()) {
       return nullptr;
     }
     result = yuvDeserializer.ToDataSourceSurface();
   } else {
     ImageDataDeserializer deserializer(GetBuffer());
     if (!deserializer.IsValid()) {
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -88,17 +88,17 @@ public:
    * Return the size of the texture in texels.
    * If this is a tile iterator, GetSize must return the size of the current tile.
    */
   virtual gfx::IntSize GetSize() const = 0;
 
   /**
    * Return the pixel format of this texture
    */
-  virtual gfx::SurfaceFormat GetFormat() const { return gfx::FORMAT_UNKNOWN; }
+  virtual gfx::SurfaceFormat GetFormat() const { return gfx::SurfaceFormat::UNKNOWN; }
 
   /**
    * Cast to a TextureSource for for each backend..
    */
   virtual TextureSourceOGL* AsSourceOGL() { return nullptr; }
   virtual TextureSourceD3D9* AsSourceD3D9() { return nullptr; }
   virtual TextureSourceD3D11* AsSourceD3D11() { return nullptr; }
   virtual TextureSourceBasic* AsSourceBasic() { return nullptr; }
@@ -452,17 +452,17 @@ public:
 
   virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
 
   /**
    * Return the format that is exposed to the compositor when calling
    * GetTextureSources.
    *
    * If the shared format is YCbCr and the compositor does not support it,
-   * GetFormat will be RGB32 (even though mFormat is FORMAT_YUV).
+   * GetFormat will be RGB32 (even though mFormat is SurfaceFormat::YUV).
    */
   virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
 
   virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
 
   virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
 
 protected:
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -167,17 +167,17 @@ CanvasLayerD3D10::UpdateSurface()
 
         DataSourceSurface* frameData = shareSurf->GetData();
         // Scope for gfxContext, so it's destroyed before Unmap.
         {
           RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
                                                                       (uint8_t*)map.pData,
                                                                       shareSurf->Size(),
                                                                       map.RowPitch,
-                                                                      FORMAT_B8G8R8A8);
+                                                                      SurfaceFormat::B8G8R8A8);
 
           nsRefPtr<gfxImageSurface> thebesFrameData =
               new gfxImageSurface(frameData->GetData(),
                                   ThebesIntSize(frameData->GetSize()),
                                   frameData->Stride(),
                                   SurfaceFormatToImageFormat(frameData->GetFormat()));
 
           nsRefPtr<gfxContext> ctx = new gfxContext(mapDt);
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -494,18 +494,18 @@ LayerManagerD3D10::CreateOptimalMaskSurf
   return CreateOptimalSurface(aSize, gfxImageFormatARGB32);
 }
 
 
 TemporaryRef<DrawTarget>
 LayerManagerD3D10::CreateDrawTarget(const IntSize &aSize,
                                     SurfaceFormat aFormat)
 {
-  if ((aFormat != FORMAT_B8G8R8A8 &&
-       aFormat != FORMAT_B8G8R8X8) ||
+  if ((aFormat != SurfaceFormat::B8G8R8A8 &&
+       aFormat != SurfaceFormat::B8G8R8X8) ||
        gfxPlatform::GetPlatform()->GetPreferredCanvasBackend() != BACKEND_DIRECT2D) {
     return LayerManager::CreateDrawTarget(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;
--- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp
@@ -297,17 +297,17 @@ ThebesLayerD3D10::VerifyContentType(Surf
         mD2DSurface = nullptr;
         return;
       }
 
       mValidRegion.SetEmpty();
     }
   } else if (mDrawTarget) {
     SurfaceFormat format = aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
-      FORMAT_B8G8R8X8 : FORMAT_B8G8R8A8;
+      SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8;
 
     if (format != mDrawTarget->GetFormat()) {
       mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, format);
 
       if (!mDrawTarget) {
         NS_WARNING("Failed to create drawtarget for ThebesLayerD3D10.");
         return;
       }
@@ -497,20 +497,20 @@ ThebesLayerD3D10::CreateNewTextures(cons
       }
     } else {
       mDrawTarget = nullptr;
     }
   }
 
   if (gfxPlatform::GetPlatform()->SupportsAzureContent() && !mDrawTarget) {
     if (aMode == SURFACE_COMPONENT_ALPHA) {
-      mDrawTarget = Factory::CreateDualDrawTargetForD3D10Textures(mTexture, mTextureOnWhite, FORMAT_B8G8R8X8);
+      mDrawTarget = Factory::CreateDualDrawTargetForD3D10Textures(mTexture, mTextureOnWhite, SurfaceFormat::B8G8R8X8);
     } else {
       mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
-        FORMAT_B8G8R8X8 : FORMAT_B8G8R8A8);
+        SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8);
     }
 
     if (!mDrawTarget) {
       NS_WARNING("Failed to create DrawTarget for ThebesLayerD3D10.");
       mDrawTarget = nullptr;
       return;
     }
   }
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -336,17 +336,17 @@ CompositorD3D11::Initialize()
   }
 
   return true;
 }
 
 TemporaryRef<DataTextureSource>
 CompositorD3D11::CreateDataTextureSource(TextureFlags aFlags)
 {
-  RefPtr<DataTextureSource> result = new DataTextureSourceD3D11(gfx::FORMAT_UNKNOWN,
+  RefPtr<DataTextureSource> result = new DataTextureSourceD3D11(gfx::SurfaceFormat::UNKNOWN,
                                                                 this);
   return result.forget();
 }
 
 TextureFactoryIdentifier
 CompositorD3D11::GetTextureFactoryIdentifier()
 {
   TextureFactoryIdentifier ident;
@@ -952,17 +952,17 @@ CompositorD3D11::PaintToTarget()
   mContext->CopyResource(readTexture, backBuf);
 
   D3D11_MAPPED_SUBRESOURCE map;
   mContext->Map(readTexture, 0, D3D11_MAP_READ, 0, &map);
   RefPtr<DataSourceSurface> sourceSurface =
     Factory::CreateWrappingDataSourceSurface((uint8_t*)map.pData,
                                              map.RowPitch,
                                              IntSize(bbDesc.Width, bbDesc.Height),
-                                             FORMAT_B8G8R8A8);
+                                             SurfaceFormat::B8G8R8A8);
   mTarget->CopySurface(sourceSurface,
                        IntRect(0, 0, bbDesc.Width, bbDesc.Height),
                        IntPoint());
   mTarget->Flush();
   mContext->Unmap(readTexture, 0);
 }
 
 }
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -19,21 +19,21 @@ namespace mozilla {
 using namespace gfx;
 
 namespace layers {
 
 static DXGI_FORMAT
 SurfaceFormatToDXGIFormat(gfx::SurfaceFormat aFormat)
 {
   switch (aFormat) {
-    case FORMAT_B8G8R8A8:
+    case SurfaceFormat::B8G8R8A8:
       return DXGI_FORMAT_B8G8R8A8_UNORM;
-    case FORMAT_B8G8R8X8:
+    case SurfaceFormat::B8G8R8X8:
       return DXGI_FORMAT_B8G8R8A8_UNORM;
-    case FORMAT_A8:
+    case SurfaceFormat::A8:
       return DXGI_FORMAT_A8_UNORM;
     default:
       MOZ_ASSERT(false, "unsupported format");
       return DXGI_FORMAT_UNKNOWN;
   }
 }
 
 static uint32_t
@@ -582,26 +582,26 @@ DeprecatedTextureClientD3D11::EnsureDraw
     return;
   }
 
   LockTexture();
 
   SurfaceFormat format;
   switch (mContentType) {
   case GFX_CONTENT_ALPHA:
-    format = FORMAT_A8;
+    format = SurfaceFormat::A8;
     break;
   case GFX_CONTENT_COLOR:
-    format = FORMAT_B8G8R8X8;
+    format = SurfaceFormat::B8G8R8X8;
     break;
   case GFX_CONTENT_COLOR_ALPHA:
-    format = FORMAT_B8G8R8A8;
+    format = SurfaceFormat::B8G8R8A8;
     break;
   default:
-    format = FORMAT_B8G8R8A8;
+    format = SurfaceFormat::B8G8R8A8;
   }
 
   mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, format);
   ReleaseTexture();
 }
 
 void
 DeprecatedTextureClientD3D11::LockTexture()
@@ -686,27 +686,27 @@ DeprecatedTextureHostShmemD3D11::UpdateI
 
   gfx::IntSize size = gfx::ToIntSize(surf->GetSize());
 
   uint32_t bpp = 0;
 
   DXGI_FORMAT dxgiFormat;
   switch (surf->Format()) {
   case gfxImageFormatRGB24:
-    mFormat = FORMAT_B8G8R8X8;
+    mFormat = SurfaceFormat::B8G8R8X8;
     dxgiFormat = DXGI_FORMAT_B8G8R8X8_UNORM;
     bpp = 4;
     break;
   case gfxImageFormatARGB32:
-    mFormat = FORMAT_B8G8R8A8;
+    mFormat = SurfaceFormat::B8G8R8A8;
     dxgiFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
     bpp = 4;
     break;
   case gfxImageFormatA8:
-    mFormat = FORMAT_A8;
+    mFormat = SurfaceFormat::A8;
     dxgiFormat = DXGI_FORMAT_A8_UNORM;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
   mSize = size;
@@ -826,17 +826,17 @@ DeprecatedTextureHostDXGID3D11::ReleaseT
   mTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex));
 
   mutex->ReleaseSync(0);
 }
 
 DeprecatedTextureHostYCbCrD3D11::DeprecatedTextureHostYCbCrD3D11()
   : mCompositor(nullptr)
 {
-  mFormat = FORMAT_YUV;
+  mFormat = SurfaceFormat::YUV;
 }
 
 DeprecatedTextureHostYCbCrD3D11::~DeprecatedTextureHostYCbCrD3D11()
 {
 }
 
 ID3D11Device*
 DeprecatedTextureHostYCbCrD3D11::GetDevice()
@@ -872,44 +872,44 @@ DeprecatedTextureHostYCbCrD3D11::UpdateI
   gfx::IntSize gfxCbCrSize = yuvDeserializer.GetCbCrSize();
 
   gfx::IntSize size = yuvDeserializer.GetYSize();
 
   RefPtr<DataTextureSource> srcY;
   RefPtr<DataTextureSource> srcCb;
   RefPtr<DataTextureSource> srcCr;
   if (!mFirstSource) {
-    srcY  = new DataTextureSourceD3D11(FORMAT_A8, mCompositor);
-    srcCb = new DataTextureSourceD3D11(FORMAT_A8, mCompositor);
-    srcCr = new DataTextureSourceD3D11(FORMAT_A8, mCompositor);
+    srcY  = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor);
+    srcCb = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor);
+    srcCr = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor);
     mFirstSource = srcY;
     srcY->SetNextSibling(srcCb);
     srcCb->SetNextSibling(srcCr);
   } else {
     MOZ_ASSERT(mFirstSource->GetNextSibling());
     MOZ_ASSERT(mFirstSource->GetNextSibling()->GetNextSibling());
     srcY  = mFirstSource;
     srcCb = mFirstSource->GetNextSibling()->AsDataTextureSource();
     srcCr = mFirstSource->GetNextSibling()->GetNextSibling()->AsDataTextureSource();
   }
   RefPtr<gfx::DataSourceSurface> wrapperY =
     gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetYData(),
                                                   yuvDeserializer.GetYStride(),
                                                   yuvDeserializer.GetYSize(),
-                                                  FORMAT_A8);
+                                                  SurfaceFormat::A8);
   RefPtr<gfx::DataSourceSurface> wrapperCb =
     gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
                                                   yuvDeserializer.GetCbCrStride(),
                                                   yuvDeserializer.GetCbCrSize(),
-                                                  FORMAT_A8);
+                                                  SurfaceFormat::A8);
   RefPtr<gfx::DataSourceSurface> wrapperCr =
     gfx::Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
                                                   yuvDeserializer.GetCbCrStride(),
                                                   yuvDeserializer.GetCbCrSize(),
-                                                  FORMAT_A8);
+                                                  SurfaceFormat::A8);
   // We don't support partial updates for YCbCr textures
   NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
   if (!srcY->Update(wrapperY) ||
       !srcCb->Update(wrapperCb) ||
       !srcCr->Update(wrapperCr)) {
     NS_WARNING("failed to update the DataTextureSource");
     mFirstSource = nullptr;
     mSize.width = 0;
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -103,17 +103,17 @@ CanvasLayerD3D9::UpdateSurface()
     
     DataSourceSurface* frameData = shareSurf->GetData();
     // Scope for gfxContext, so it's destroyed early.
     {
       RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
                                                                   (uint8_t*)rect.pBits,
                                                                   shareSurf->Size(),
                                                                   rect.Pitch,
-                                                                  FORMAT_B8G8R8A8);
+                                                                  SurfaceFormat::B8G8R8A8);
 
       nsRefPtr<gfxImageSurface> thebesFrameData =
           new gfxImageSurface(frameData->GetData(),
                               ThebesIntSize(frameData->GetSize()),
                               frameData->Stride(),
                               SurfaceFormatToImageFormat(frameData->GetFormat()));
 
       nsRefPtr<gfxContext> ctx = new gfxContext(mapDt);
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -84,17 +84,17 @@ int32_t
 CompositorD3D9::GetMaxTextureSize() const
 {
   return mDeviceManager ? mDeviceManager->GetMaxTextureSize() : INT32_MAX;
 }
 
 TemporaryRef<DataTextureSource>
 CompositorD3D9::CreateDataTextureSource(TextureFlags aFlags)
 {
-  return new DataTextureSourceD3D9(FORMAT_UNKNOWN, this,
+  return new DataTextureSourceD3D9(SurfaceFormat::UNKNOWN, this,
                                    !(aFlags & TEXTURE_DISALLOW_BIGIMAGE));
 }
 
 TemporaryRef<CompositingRenderTarget>
 CompositorD3D9::CreateRenderTarget(const gfx::IntRect &aRect,
                                    SurfaceInitMode aInit)
 {
   if (!mDeviceManager) {
@@ -719,17 +719,17 @@ CompositorD3D9::PaintToTarget()
   device()->GetRenderTargetData(backBuff, destSurf);
 
   D3DLOCKED_RECT rect;
   destSurf->LockRect(&rect, nullptr, D3DLOCK_READONLY);
   RefPtr<DataSourceSurface> sourceSurface =
     Factory::CreateWrappingDataSourceSurface((uint8_t*)rect.pBits,
                                              rect.Pitch,
                                              IntSize(desc.Width, desc.Height),
-                                             FORMAT_B8G8R8A8);
+                                             SurfaceFormat::B8G8R8A8);
   mTarget->CopySurface(sourceSurface,
                        IntRect(0, 0, desc.Width, desc.Height),
                        IntPoint());
   mTarget->Flush();
   destSurf->UnlockRect();
 }
 
 void
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -83,36 +83,36 @@ CreateTextureHostD3D9(const SurfaceDescr
   return result.forget();
 }
 
 static SurfaceFormat
 D3D9FormatToSurfaceFormat(_D3DFORMAT format)
 {
   switch (format) {
   case D3DFMT_X8R8G8B8:
-    return FORMAT_B8G8R8X8;
+    return SurfaceFormat::B8G8R8X8;
   case D3DFMT_A8R8G8B8:
-    return FORMAT_B8G8R8A8;
+    return SurfaceFormat::B8G8R8A8;
   case D3DFMT_A8:
-    return FORMAT_A8;
+    return SurfaceFormat::A8;
   default:
     NS_ERROR("Bad texture format");
   }
-  return FORMAT_UNKNOWN;
+  return SurfaceFormat::UNKNOWN;
 }
 
 static _D3DFORMAT
 SurfaceFormatToD3D9Format(SurfaceFormat format)
 {
   switch (format) {
-  case FORMAT_B8G8R8X8:
+  case SurfaceFormat::B8G8R8X8:
     return D3DFMT_X8R8G8B8;
-  case FORMAT_B8G8R8A8:
+  case SurfaceFormat::B8G8R8A8:
     return D3DFMT_A8R8G8B8;
-  case FORMAT_A8:
+  case SurfaceFormat::A8:
     return D3DFMT_A8;
   default:
     NS_ERROR("Bad texture format");
   }
   return D3DFMT_A8R8G8B8;
 }
 
 CompositingRenderTargetD3D9::CompositingRenderTargetD3D9(IDirect3DTexture9* aTexture,
@@ -328,27 +328,27 @@ DeprecatedTextureHostShmemD3D9::UpdateIm
 
   mSize = ToIntSize(surf->GetSize());
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   switch (surf->Format()) {
   case gfxImageFormatRGB24:
-    mFormat = FORMAT_B8G8R8X8;
+    mFormat = SurfaceFormat::B8G8R8X8;
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
   case gfxImageFormatARGB32:
-    mFormat = FORMAT_B8G8R8A8;
+    mFormat = SurfaceFormat::B8G8R8A8;
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
   case gfxImageFormatA8:
-    mFormat = FORMAT_A8;
+    mFormat = SurfaceFormat::A8;
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
   int32_t maxSize = mCompositor->GetMaxTextureSize();
@@ -402,17 +402,17 @@ DeprecatedTextureHostD3D9::GetTileRect(u
                  verticalTile * maxSize,
                  horizontalTile < (horizontalTiles - 1) ? maxSize : mSize.width % maxSize,
                  verticalTile < (verticalTiles - 1) ? maxSize : mSize.height % maxSize);
 }
 
 DeprecatedTextureHostYCbCrD3D9::DeprecatedTextureHostYCbCrD3D9()
   : mCompositor(nullptr)
 {
-  mFormat = FORMAT_YUV;
+  mFormat = SurfaceFormat::YUV;
 
   MOZ_COUNT_CTOR(DeprecatedTextureHostYCbCrD3D9);
 }
 
 DeprecatedTextureHostYCbCrD3D9::~DeprecatedTextureHostYCbCrD3D9()
 {
   MOZ_COUNT_DTOR(DeprecatedTextureHostYCbCrD3D9);
 }
@@ -446,48 +446,48 @@ DeprecatedTextureHostYCbCrD3D9::UpdateIm
   IntSize cbCrSize = yuvDeserializer.GetCbCrSize();
   mStereoMode = yuvDeserializer.GetStereoMode();
 
   DeviceManagerD3D9* deviceManager = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager();
   RefPtr<DataTextureSource> srcY;
   RefPtr<DataTextureSource> srcCb;
   RefPtr<DataTextureSource> srcCr;
   if (!mFirstSource) {
-    srcY  = new DataTextureSourceD3D9(FORMAT_A8, mCompositor,
+    srcY  = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
                                       TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
-    srcCb = new DataTextureSourceD3D9(FORMAT_A8, mCompositor,
+    srcCb = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
                                       TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
-    srcCr = new DataTextureSourceD3D9(FORMAT_A8, mCompositor,
+    srcCr = new DataTextureSourceD3D9(SurfaceFormat::A8, mCompositor,
                                       TEXTURE_DISALLOW_BIGIMAGE, mStereoMode);
     mFirstSource = srcY;
     srcY->SetNextSibling(srcCb);
     srcCb->SetNextSibling(srcCr);
   } else {
     MOZ_ASSERT(mFirstSource->GetNextSibling());
     MOZ_ASSERT(mFirstSource->GetNextSibling()->GetNextSibling());
     srcY = mFirstSource;
     srcCb = mFirstSource->GetNextSibling()->AsDataTextureSource();
     srcCr = mFirstSource->GetNextSibling()->GetNextSibling()->AsDataTextureSource();
   }
 
   RefPtr<DataSourceSurface> wrapperY =
     Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetYData(),
                                              yuvDeserializer.GetYStride(),
                                              yuvDeserializer.GetYSize(),
-                                             FORMAT_A8);
+                                             SurfaceFormat::A8);
   RefPtr<DataSourceSurface> wrapperCb =
     Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCbData(),
                                              yuvDeserializer.GetCbCrStride(),
                                              yuvDeserializer.GetCbCrSize(),
-                                             FORMAT_A8);
+                                             SurfaceFormat::A8);
   RefPtr<DataSourceSurface> wrapperCr =
     Factory::CreateWrappingDataSourceSurface(yuvDeserializer.GetCrData(),
                                              yuvDeserializer.GetCbCrStride(),
                                              yuvDeserializer.GetCbCrSize(),
-                                             FORMAT_A8);
+                                             SurfaceFormat::A8);
   // We don't support partial updates for YCbCr textures
   NS_ASSERTION(!aRegion, "Unsupported partial updates for YCbCr textures");
   if (!srcY->Update(wrapperY) ||
       !srcCb->Update(wrapperCb) ||
       !srcCr->Update(wrapperCr)) {
     NS_WARNING("failed to update the DataTextureSource");
     mSize.width = 0;
     mSize.height = 0;
@@ -550,25 +550,25 @@ DeprecatedTextureHostSystemMemD3D9::Upda
 
   mSize.width = desc.Width;
   mSize.height = desc.Height;
 
   _D3DFORMAT format = desc.Format;
   uint32_t bpp = 0;
   switch (format) {
   case D3DFMT_X8R8G8B8:
-    mFormat = FORMAT_B8G8R8X8;
+    mFormat = SurfaceFormat::B8G8R8X8;
     bpp = 4;
     break;
   case D3DFMT_A8R8G8B8:
-    mFormat = FORMAT_B8G8R8A8;
+    mFormat = SurfaceFormat::B8G8R8A8;
     bpp = 4;
     break;
   case D3DFMT_A8:
-    mFormat = FORMAT_A8;
+    mFormat = SurfaceFormat::A8;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
   int32_t maxSize = mCompositor->GetMaxTextureSize();
   if (mSize.width <= maxSize && mSize.height <= maxSize) {
@@ -662,27 +662,27 @@ DeprecatedTextureHostDIB::UpdateImpl(con
 
   mSize = ToIntSize(surf->GetSize());
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   switch (gfxPlatform::GetPlatform()->OptimalFormatForContent(surf->GetContentType())) {
   case gfxImageFormatRGB24:
-    mFormat = FORMAT_B8G8R8X8;
+    mFormat = SurfaceFormat::B8G8R8X8;
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
   case gfxImageFormatARGB32:
-    mFormat = FORMAT_B8G8R8A8;
+    mFormat = SurfaceFormat::B8G8R8A8;
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
   case gfxImageFormatA8:
-    mFormat = FORMAT_A8;
+    mFormat = SurfaceFormat::A8;
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
   int32_t maxSize = mCompositor->GetMaxTextureSize();
@@ -1067,25 +1067,25 @@ DataTextureSourceD3D9::Update(gfx::DataS
   }
   mSize = aSurface->GetSize();
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   mFormat = aSurface->GetFormat();
   switch (mFormat) {
-  case FORMAT_B8G8R8X8:
+  case SurfaceFormat::B8G8R8X8:
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
-  case FORMAT_B8G8R8A8:
+  case SurfaceFormat::B8G8R8A8:
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
-  case FORMAT_A8:
+  case SurfaceFormat::A8:
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_WARNING("Bad image format");
     return false;
   }
 
@@ -1142,25 +1142,25 @@ DataTextureSourceD3D9::Update(gfxWindows
   mSize = ToIntSize(aSurface->GetSize());
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   mFormat = ImageFormatToSurfaceFormat(
     gfxPlatform::GetPlatform()->OptimalFormatForContent(aSurface->GetContentType()));
   switch (mFormat) {
-  case FORMAT_B8G8R8X8:
+  case SurfaceFormat::B8G8R8X8:
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
-  case FORMAT_B8G8R8A8:
+  case SurfaceFormat::B8G8R8A8:
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
-  case FORMAT_A8:
+  case SurfaceFormat::A8:
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_WARNING("Bad image format");
     return false;
   }
 
@@ -1505,33 +1505,33 @@ SharedTextureClientD3D9::ToSurfaceDescri
 
   aOutDescriptor = SurfaceDescriptorD3D10((WindowsHandle)(mHandle), mFormat);
   return true;
 }
 
 TextureHostD3D9::TextureHostD3D9(TextureFlags aFlags,
                                  const SurfaceDescriptorD3D9& aDescriptor)
   : TextureHost(aFlags)
-  , mFormat(FORMAT_UNKNOWN)
+  , mFormat(SurfaceFormat::UNKNOWN)
   , mIsLocked(false)
 {
   mTexture = reinterpret_cast<IDirect3DTexture9*>(aDescriptor.texture());
   MOZ_ASSERT(mTexture);
   D3DSURFACE_DESC desc;
   HRESULT hr = mTexture->GetLevelDesc(0, &desc);
   if (!FAILED(hr)) {
     mFormat = D3D9FormatToSurfaceFormat(desc.Format);
     mSize.width = desc.Width;
     mSize.height = desc.Height;
   }
 }
 
 TextureHostD3D9::TextureHostD3D9(TextureFlags aFlags)
   : TextureHost(aFlags)
-  , mFormat(FORMAT_UNKNOWN)
+  , mFormat(SurfaceFormat::UNKNOWN)
   , mIsLocked(false)
 {}
 
 IDirect3DDevice9*
 TextureHostD3D9::GetDevice()
 {
   return mCompositor ? mCompositor->device() : nullptr;
 }
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SharedPlanarYCbCrImage.h"
 #include <stddef.h>                     // for size_t
 #include <stdio.h>                      // for printf
 #include "gfx2DGlue.h"                  // for Moz2D transition helpers
 #include "ISurfaceAllocator.h"          // for ISurfaceAllocator, etc
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
-#include "mozilla/gfx/Types.h"          // for SurfaceFormat::FORMAT_YUV
+#include "mozilla/gfx/Types.h"          // for SurfaceFormat::SurfaceFormat::YUV
 #include "mozilla/ipc/SharedMemory.h"   // for SharedMemory, etc
 #include "mozilla/layers/ImageClient.h"  // for ImageClient
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "mozilla/layers/TextureClient.h"  // for BufferTextureClient, etc
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
 #include "mozilla/layers/ImageBridgeChild.h"  // for ImageBridgeChild
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsISupportsImpl.h"            // for Image::AddRef
@@ -26,17 +26,17 @@ namespace mozilla {
 namespace layers {
 
 using namespace mozilla::ipc;
 
 SharedPlanarYCbCrImage::SharedPlanarYCbCrImage(ImageClient* aCompositable)
 : PlanarYCbCrImage(nullptr)
 , mCompositable(aCompositable)
 {
-  mTextureClient = aCompositable->CreateBufferTextureClient(gfx::FORMAT_YUV);
+  mTextureClient = aCompositable->CreateBufferTextureClient(gfx::SurfaceFormat::YUV);
   MOZ_COUNT_CTOR(SharedPlanarYCbCrImage);
 }
 
 SharedPlanarYCbCrImage::~SharedPlanarYCbCrImage() {
   MOZ_COUNT_DTOR(SharedPlanarYCbCrImage);
 
   if (mCompositable->GetAsyncID() != 0 &&
       !InImageBridgeChildThread()) {
--- a/gfx/layers/opengl/CompositingRenderTargetOGL.h
+++ b/gfx/layers/opengl/CompositingRenderTargetOGL.h
@@ -142,17 +142,17 @@ public:
     MOZ_ASSERT(false, "CompositingRenderTargetOGL should not be used as a TextureSource");
     return gfx::IntSize(0, 0);
   }
 
   gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
   {
     // XXX - Should it be implemented ? is the above assert true ?
     MOZ_ASSERT(false, "Not implemented");
-    return gfx::FORMAT_UNKNOWN;
+    return gfx::SurfaceFormat::UNKNOWN;
   }
 
   const gfxMatrix& GetTransform() {
     return mTransform;
   }
 
 #ifdef MOZ_DUMP_PAINTING
   virtual TemporaryRef<gfx::DataSourceSurface> Dump(Compositor* aCompositor);
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1381,17 +1381,17 @@ CompositorOGL::EndFrame()
 #ifdef MOZ_DUMP_PAINTING
   if (gfxUtils::sDumpPainting) {
     nsIntRect rect;
     if (mUseExternalSurfaceSize) {
       rect = nsIntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height);
     } else {
       mWidget->GetBounds(rect);
     }
-    RefPtr<DrawTarget> target = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(rect.width, rect.height), FORMAT_B8G8R8A8);
+    RefPtr<DrawTarget> target = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(rect.width, rect.height), SurfaceFormat::B8G8R8A8);
     CopyToTarget(target, mCurrentRenderTarget->GetTransform());
 
     WriteSnapshotToDumpFile(this, target);
   }
 #endif
 
   mFrameInProgress = false;
 
@@ -1481,17 +1481,17 @@ CompositorOGL::CopyToTarget(DrawTarget *
 
   if (!mGLContext->IsGLES2()) {
     // GLES2 promises that binding to any custom FBO will attach
     // to GL_COLOR_ATTACHMENT0 attachment point.
     mGLContext->fReadBuffer(LOCAL_GL_BACK);
   }
 
   RefPtr<DataSourceSurface> source =
-        Factory::CreateDataSourceSurface(rect.Size(), gfx::FORMAT_B8G8R8A8);
+        Factory::CreateDataSourceSurface(rect.Size(), gfx::SurfaceFormat::B8G8R8A8);
   // XXX we should do this properly one day without using the gfxImageSurface
   nsRefPtr<gfxImageSurface> surf =
     new gfxImageSurface(source->GetData(),
                         gfxIntSize(width, height),
                         source->Stride(),
                         gfxImageFormatARGB32);
   ReadPixelsIntoImageSurface(mGLContext, surf);
   source->MarkDirty();
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -160,17 +160,17 @@ public:
   virtual nsIWidget* GetWidget() const MOZ_OVERRIDE { return mWidget; }
 
   GLContext* gl() const { return mGLContext; }
   ShaderProgramType GetFBOLayerProgramType() const {
     return mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB ?
            RGBARectLayerProgramType : RGBALayerProgramType;
   }
   gfx::SurfaceFormat GetFBOFormat() const {
-    return gfx::FORMAT_R8G8B8A8;
+    return gfx::SurfaceFormat::R8G8B8A8;
   }
 
   /**
    * The compositor provides with temporary textures for use with direct
    * textruing like gralloc texture.
    * Doing so lets us use gralloc the way it has been designed to be used
    * (see https://wiki.mozilla.org/Platform/GFX/Gralloc)
    */
--- a/gfx/layers/opengl/GrallocTextureClient.cpp
+++ b/gfx/layers/opengl/GrallocTextureClient.cpp
@@ -87,17 +87,17 @@ GrallocTextureClientOGL::DropTextureData
     mGraphicBuffer = nullptr;
     return result;
   }
 }
 
 GrallocTextureClientOGL::GrallocTextureClientOGL(GrallocBufferActor* aActor,
                                                  gfx::IntSize aSize,
                                                  TextureFlags aFlags)
-: BufferTextureClient(nullptr, gfx::FORMAT_UNKNOWN, aFlags)
+: BufferTextureClient(nullptr, gfx::SurfaceFormat::UNKNOWN, aFlags)
 , mAllocator(nullptr)
 , mGrallocFlags(android::GraphicBuffer::USAGE_SW_READ_OFTEN)
 , mMappedBuffer(nullptr)
 {
   InitWith(aActor, aSize);
   MOZ_COUNT_CTOR(GrallocTextureClientOGL);
 }
 
@@ -210,31 +210,31 @@ GrallocTextureClientOGL::AllocateForSurf
 {
   MOZ_ASSERT(IsValid());
 
   uint32_t format;
   uint32_t usage = android::GraphicBuffer::USAGE_SW_READ_OFTEN;
   bool swapRB = GetFlags() & TEXTURE_RB_SWAPPED;
 
   switch (mFormat) {
-  case gfx::FORMAT_R8G8B8A8:
+  case gfx::SurfaceFormat::R8G8B8A8:
     format = swapRB ? android::PIXEL_FORMAT_BGRA_8888 : android::PIXEL_FORMAT_RGBA_8888;
     break;
-  case gfx::FORMAT_B8G8R8A8:
+  case gfx::SurfaceFormat::B8G8R8A8:
     format = swapRB ? android::PIXEL_FORMAT_RGBA_8888 : android::PIXEL_FORMAT_BGRA_8888;
     break;
-  case gfx::FORMAT_R8G8B8X8:
-  case gfx::FORMAT_B8G8R8X8:
+  case gfx::SurfaceFormat::R8G8B8X8:
+  case gfx::SurfaceFormat::B8G8R8X8:
     // there is no android BGRX format?
     format = android::PIXEL_FORMAT_RGBX_8888;
     break;
-  case gfx::FORMAT_R5G6B5:
+  case gfx::SurfaceFormat::R5G6B5:
     format = android::PIXEL_FORMAT_RGB_565;
     break;
-  case gfx::FORMAT_A8:
+  case gfx::SurfaceFormat::A8:
     format = android::PIXEL_FORMAT_A_8;
     break;
   default:
     NS_WARNING("Unsupported surface format");
     return false;
   }
 
   return AllocateGralloc(aSize, format, usage);
@@ -254,29 +254,29 @@ GrallocTextureClientOGL::AllocateForGLRe
 {
   MOZ_ASSERT(IsValid());
 
   uint32_t format;
   uint32_t usage = android::GraphicBuffer::USAGE_HW_RENDER |
                    android::GraphicBuffer::USAGE_HW_TEXTURE;
 
   switch (mFormat) {
-  case gfx::FORMAT_R8G8B8A8:
-  case gfx::FORMAT_B8G8R8A8:
+  case gfx::SurfaceFormat::R8G8B8A8:
+  case gfx::SurfaceFormat::B8G8R8A8:
     format = android::PIXEL_FORMAT_RGBA_8888;
     break;
-  case gfx::FORMAT_R8G8B8X8:
-  case gfx::FORMAT_B8G8R8X8:
+  case gfx::SurfaceFormat::R8G8B8X8:
+  case gfx::SurfaceFormat::B8G8R8X8:
     // there is no android BGRX format?
     format = android::PIXEL_FORMAT_RGBX_8888;
     break;
-  case gfx::FORMAT_R5G6B5:
+  case gfx::SurfaceFormat::R5G6B5:
     format = android::PIXEL_FORMAT_RGB_565;
     break;
-  case gfx::FORMAT_A8:
+  case gfx::SurfaceFormat::A8:
     format = android::PIXEL_FORMAT_A_8;
     break;
   default:
     NS_WARNING("Unsupported surface format");
     return false;
   }
 
   return AllocateGralloc(aSize, format, usage);
--- a/gfx/layers/opengl/GrallocTextureHost.cpp
+++ b/gfx/layers/opengl/GrallocTextureHost.cpp
@@ -19,45 +19,45 @@ namespace layers {
 using namespace android;
 
 static gfx::SurfaceFormat
 SurfaceFormatForAndroidPixelFormat(android::PixelFormat aFormat,
                                    bool swapRB = false)
 {
   switch (aFormat) {
   case android::PIXEL_FORMAT_BGRA_8888:
-    return swapRB ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8A8;
+    return swapRB ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8A8;
   case android::PIXEL_FORMAT_RGBA_8888:
-    return swapRB ? gfx::FORMAT_B8G8R8A8 : gfx::FORMAT_R8G8B8A8;
+    return swapRB ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::R8G8B8A8;
   case android::PIXEL_FORMAT_RGBX_8888:
-    return swapRB ? gfx::FORMAT_B8G8R8X8 : gfx::FORMAT_R8G8B8X8;
+    return swapRB ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::R8G8B8X8;
   case android::PIXEL_FORMAT_RGB_565:
-    return gfx::FORMAT_R5G6B5;
+    return gfx::SurfaceFormat::R5G6B5;
   case android::PIXEL_FORMAT_A_8:
-    return gfx::FORMAT_A8;
+    return gfx::SurfaceFormat::A8;
   case HAL_PIXEL_FORMAT_YCbCr_422_SP:
   case HAL_PIXEL_FORMAT_YCrCb_420_SP:
   case HAL_PIXEL_FORMAT_YCbCr_422_I:
   case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
   case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
   case HAL_PIXEL_FORMAT_YV12:
-    return gfx::FORMAT_B8G8R8A8; // yup, use FORMAT_B8G8R8A8 even though it's a YUV texture. This is an external texture.
+    return gfx::SurfaceFormat::B8G8R8A8; // yup, use SurfaceFormat::B8G8R8A8 even though it's a YUV texture. This is an external texture.
   default:
     if (aFormat >= 0x100 && aFormat <= 0x1FF) {
       // Reserved range for HAL specific formats.
-      return gfx::FORMAT_B8G8R8A8;
+      return gfx::SurfaceFormat::B8G8R8A8;
     } else {
       // This is not super-unreachable, there's a bunch of hypothetical pixel
       // formats we don't deal with.
       // We only want to abort in debug builds here, since if we crash here
       // we'll take down the compositor process and thus the phone. This seems
       // like undesirable behaviour. We'd rather have a subtle artifact.
       printf_stderr(" xxxxx unknow android format %i\n", (int)aFormat);
       MOZ_ASSERT(false, "Unknown Android pixel format.");
-      return gfx::FORMAT_UNKNOWN;
+      return gfx::SurfaceFormat::UNKNOWN;
     }
   }
 }
 
 static GLenum
 TextureTargetForAndroidPixelFormat(android::PixelFormat aFormat)
 {
   switch (aFormat) {
@@ -155,20 +155,20 @@ GrallocTextureSourceOGL::GetTextureTarge
 {
   MOZ_ASSERT(mGraphicBuffer.get());
   return TextureTargetForAndroidPixelFormat(mGraphicBuffer->getPixelFormat());
 }
 
 gfx::SurfaceFormat
 GrallocTextureSourceOGL::GetFormat() const {
   if (!mGraphicBuffer.get()) {
-    return gfx::FORMAT_UNKNOWN;
+    return gfx::SurfaceFormat::UNKNOWN;
   }
   if (GetTextureTarget() == LOCAL_GL_TEXTURE_EXTERNAL) {
-    return gfx::FORMAT_R8G8B8A8;
+    return gfx::SurfaceFormat::R8G8B8A8;
   }
   return mFormat;
 }
 
 void
 GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData)
 {
   if (mCompositableBackendData != aBackendData) {
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
@@ -26,17 +26,17 @@ MacIOSurfaceTextureSourceOGL::GetSize() 
 {
   return gfx::IntSize(mSurface->GetDevicePixelWidth(),
                       mSurface->GetDevicePixelHeight());
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureSourceOGL::GetFormat() const
 {
-  return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8;
+  return mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8X8;
 }
 
 MacIOSurfaceTextureHostOGL::MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
                                                        const SurfaceDescriptorMacIOSurface& aDescriptor)
   : TextureHost(aFlags)
 {
   mSurface = MacIOSurface::LookupSurface(aDescriptor.surface(),
                                          aDescriptor.scaleFactor(),
@@ -90,17 +90,17 @@ MacIOSurfaceTextureSourceOGL::SetComposi
 gl::GLContext*
 MacIOSurfaceTextureSourceOGL::gl() const
 {
   return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureHostOGL::GetFormat() const {
-  return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8;
+  return mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8X8;
 }
 
 gfx::IntSize
 MacIOSurfaceTextureHostOGL::GetSize() const {
   return gfx::IntSize(mSurface->GetDevicePixelWidth(),
                       mSurface->GetDevicePixelHeight());
 }
 
--- a/gfx/layers/opengl/OGLShaderProgram.h
+++ b/gfx/layers/opengl/OGLShaderProgram.h
@@ -49,46 +49,46 @@ enum ShaderProgramType {
   Copy2DRectProgramType,
   NumProgramTypes
 };
 
 static inline ShaderProgramType
 ShaderProgramFromSurfaceFormat(gfx::SurfaceFormat aFormat)
 {
   switch (aFormat) {
-    case gfx::FORMAT_B8G8R8A8:
+    case gfx::SurfaceFormat::B8G8R8A8:
       return BGRALayerProgramType;
-    case gfx::FORMAT_B8G8R8X8:
+    case gfx::SurfaceFormat::B8G8R8X8:
       return BGRXLayerProgramType;
-    case gfx::FORMAT_R8G8B8A8:
+    case gfx::SurfaceFormat::R8G8B8A8:
       return RGBALayerProgramType;
-    case gfx::FORMAT_R8G8B8X8:
-    case gfx::FORMAT_R5G6B5:
+    case gfx::SurfaceFormat::R8G8B8X8:
+    case gfx::SurfaceFormat::R5G6B5:
       return RGBXLayerProgramType;
-    case gfx::FORMAT_A8:
+    case gfx::SurfaceFormat::A8:
       // We don't have a specific luminance shader
       break;
     default:
       NS_ASSERTION(false, "Unhandled surface format!");
   }
   return ShaderProgramType(0);
 }
 
 static inline ShaderProgramType
 ShaderProgramFromTargetAndFormat(GLenum aTarget,
                                  gfx::SurfaceFormat aFormat)
 {
   switch(aTarget) {
     case LOCAL_GL_TEXTURE_EXTERNAL:
-      MOZ_ASSERT(aFormat == gfx::FORMAT_R8G8B8A8);
+      MOZ_ASSERT(aFormat == gfx::SurfaceFormat::R8G8B8A8);
       return RGBAExternalLayerProgramType;
     case LOCAL_GL_TEXTURE_RECTANGLE_ARB:
-      MOZ_ASSERT(aFormat == gfx::FORMAT_R8G8B8A8 ||
-                 aFormat == gfx::FORMAT_R8G8B8X8);
-      if (aFormat == gfx::FORMAT_R8G8B8A8)
+      MOZ_ASSERT(aFormat == gfx::SurfaceFormat::R8G8B8A8 ||
+                 aFormat == gfx::SurfaceFormat::R8G8B8X8);
+      if (aFormat == gfx::SurfaceFormat::R8G8B8A8)
         return RGBARectLayerProgramType;
       else
         return RGBXRectLayerProgramType;
     default:
       return ShaderProgramFromSurfaceFormat(aFormat);
   }
 }
 
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -494,43 +494,43 @@ StreamTextureSourceOGL::RetrieveTextureF
   DataSourceSurface* toUpload = nullptr;
   switch (sharedSurf->Type()) {
     case SharedSurfaceType::GLTextureShare: {
       SharedSurface_GLTexture* glTexSurf = SharedSurface_GLTexture::Cast(sharedSurf);
       glTexSurf->SetConsumerGL(gl());
       mTextureHandle = glTexSurf->Texture();
       mTextureTarget = glTexSurf->TextureTarget();
       MOZ_ASSERT(mTextureHandle);
-      mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
-                                       : FORMAT_R8G8B8X8;
+      mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
+                                       : SurfaceFormat::R8G8B8X8;
       break;
     }
     case SharedSurfaceType::EGLImageShare: {
       SharedSurface_EGLImage* eglImageSurf =
           SharedSurface_EGLImage::Cast(sharedSurf);
 
       mTextureHandle = eglImageSurf->AcquireConsumerTexture(gl());
       mTextureTarget = eglImageSurf->TextureTarget();
       if (!mTextureHandle) {
         toUpload = eglImageSurf->GetPixels();
         MOZ_ASSERT(toUpload);
       } else {
-        mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
-                                         : FORMAT_R8G8B8X8;
+        mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
+                                         : SurfaceFormat::R8G8B8X8;
       }
       break;
     }
 #ifdef XP_MACOSX
     case SharedSurfaceType::IOSurface: {
       SharedSurface_IOSurface* glTexSurf = SharedSurface_IOSurface::Cast(sharedSurf);
       mTextureHandle = glTexSurf->Texture();
       mTextureTarget = glTexSurf->TextureTarget();
       MOZ_ASSERT(mTextureHandle);
-      mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
-                                       : FORMAT_R8G8B8X8;
+      mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
+                                       : SurfaceFormat::R8G8B8X8;
       break;
     }
 #endif
     case SharedSurfaceType::Basic: {
       toUpload = SharedSurface_Basic::Cast(sharedSurf)->GetData();
       MOZ_ASSERT(toUpload);
       break;
     }
@@ -938,17 +938,17 @@ SurfaceStreamHostOGL::UpdateImpl(const S
   MOZ_ASSERT(mStream);
   mStreamGL = dont_AddRef(mStream->GLContext());
 }
 
 void
 SurfaceStreamHostOGL::Unlock()
 {
   // We don't know what this is unless we're locked
-  mFormat = gfx::FORMAT_UNKNOWN;
+  mFormat = gfx::SurfaceFormat::UNKNOWN;
 }
 
 bool
 SurfaceStreamHostOGL::Lock()
 {
   if (!mGL->MakeCurrent()) {
     return false;
   }
@@ -966,43 +966,43 @@ SurfaceStreamHostOGL::Lock()
   DataSourceSurface* toUpload = nullptr;
   switch (sharedSurf->Type()) {
     case SharedSurfaceType::GLTextureShare: {
       SharedSurface_GLTexture* glTexSurf = SharedSurface_GLTexture::Cast(sharedSurf);
       glTexSurf->SetConsumerGL(mGL);
       mTextureHandle = glTexSurf->Texture();
       mTextureTarget = glTexSurf->TextureTarget();
       MOZ_ASSERT(mTextureHandle);
-      mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
-                                       : FORMAT_R8G8B8X8;
+      mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
+                                       : SurfaceFormat::R8G8B8X8;
       break;
     }
     case SharedSurfaceType::EGLImageShare: {
       SharedSurface_EGLImage* eglImageSurf =
           SharedSurface_EGLImage::Cast(sharedSurf);
 
       mTextureHandle = eglImageSurf->AcquireConsumerTexture(mGL);
       mTextureTarget = eglImageSurf->TextureTarget();
       if (!mTextureHandle) {
         toUpload = eglImageSurf->GetPixels();
         MOZ_ASSERT(toUpload);
       } else {
-        mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
-                                         : FORMAT_R8G8B8X8;
+        mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
+                                         : SurfaceFormat::R8G8B8X8;
       }
       break;
     }
 #ifdef XP_MACOSX
     case SharedSurfaceType::IOSurface: {
       SharedSurface_IOSurface* glTexSurf = SharedSurface_IOSurface::Cast(sharedSurf);
       mTextureHandle = glTexSurf->Texture();
       mTextureTarget = glTexSurf->TextureTarget();
       MOZ_ASSERT(mTextureHandle);
-      mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
-                                       : FORMAT_R8G8B8X8;
+      mFormat = sharedSurf->HasAlpha() ? SurfaceFormat::R8G8B8A8
+                                       : SurfaceFormat::R8G8B8X8;
       break;
     }
 #endif
     case SharedSurfaceType::Basic: {
       toUpload = SharedSurface_Basic::Cast(sharedSurf)->GetData();
       MOZ_ASSERT(toUpload);
       break;
     }
@@ -1221,19 +1221,19 @@ TiledDeprecatedTextureHostOGL::Update(gf
                    TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE, 0,
                    mGLFormat, type, buf);
 
   gl::GfxTexturesReporter::UpdateAmount(gl::GfxTexturesReporter::MemoryAllocated,
                                         mGLFormat, type,
                                         TILEDLAYERBUFFER_TILE_SIZE);
 
   if (mGLFormat == LOCAL_GL_RGB) {
-    mFormat = FORMAT_R8G8B8X8;
+    mFormat = SurfaceFormat::R8G8B8X8;
   } else {
-    mFormat = FORMAT_B8G8R8A8;
+    mFormat = SurfaceFormat::B8G8R8A8;
   }
 }
 
 bool
 TiledDeprecatedTextureHostOGL::Lock()
 {
   if (!mTextureHandle) {
     NS_WARNING("TiledDeprecatedTextureHostOGL not ready to be composited");
@@ -1250,44 +1250,44 @@ TiledDeprecatedTextureHostOGL::Lock()
 
 #ifdef MOZ_WIDGET_GONK
 static gfx::SurfaceFormat
 Deprecated_SurfaceFormatForAndroidPixelFormat(android::PixelFormat aFormat,
                                    bool swapRB = false)
 {
   switch (aFormat) {
   case android::PIXEL_FORMAT_BGRA_8888:
-    return swapRB ? FORMAT_R8G8B8A8 : FORMAT_B8G8R8A8;
+    return swapRB ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::B8G8R8A8;
   case android::PIXEL_FORMAT_RGBA_8888:
-    return swapRB ? FORMAT_B8G8R8A8 : FORMAT_R8G8B8A8;
+    return swapRB ? SurfaceFormat::B8G8R8A8 : SurfaceFormat::R8G8B8A8;
   case android::PIXEL_FORMAT_RGBX_8888:
-    return swapRB ? FORMAT_B8G8R8X8 : FORMAT_R8G8B8X8;
+    return swapRB ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::R8G8B8X8;
   case android::PIXEL_FORMAT_RGB_565:
-    return FORMAT_R5G6B5;
+    return SurfaceFormat::R5G6B5;
   case android::PIXEL_FORMAT_A_8:
-    return FORMAT_A8;
+    return SurfaceFormat::A8;
   case HAL_PIXEL_FORMAT_YCbCr_422_SP:
   case HAL_PIXEL_FORMAT_YCrCb_420_SP:
   case HAL_PIXEL_FORMAT_YCbCr_422_I:
   case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
   case GrallocImage::HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
   case HAL_PIXEL_FORMAT_YV12:
-    return FORMAT_B8G8R8A8; // yup, use FORMAT_B8G8R8A8 even though it's a YUV texture. This is an external texture.
+    return SurfaceFormat::B8G8R8A8; // yup, use SurfaceFormat::B8G8R8A8 even though it's a YUV texture. This is an external texture.
   default:
     if (aFormat >= 0x100 && aFormat <= 0x1FF) {
       // Reserved range for HAL specific formats.
-      return FORMAT_B8G8R8A8;
+      return SurfaceFormat::B8G8R8A8;
     } else {
       // This is not super-unreachable, there's a bunch of hypothetical pixel
       // formats we don't deal with.
       // We only want to abort in debug builds here, since if we crash here
       // we'll take down the compositor process and thus the phone. This seems
       // like undesirable behaviour. We'd rather have a subtle artifact.
       MOZ_ASSERT(false, "Unknown Android pixel format.");
-      return FORMAT_UNKNOWN;
+      return SurfaceFormat::UNKNOWN;
     }
   }
 }
 
 static GLenum
 Deprecated_TextureTargetForAndroidPixelFormat(android::PixelFormat aFormat)
 {
   switch (aFormat) {
@@ -1335,19 +1335,19 @@ void GrallocDeprecatedTextureHostOGL::Se
   }
   mCompositor = glCompositor;
 }
 
 gfx::SurfaceFormat
 GrallocDeprecatedTextureHostOGL::GetFormat() const
 {
   switch (mTextureTarget) {
-  case LOCAL_GL_TEXTURE_EXTERNAL: return gfx::FORMAT_R8G8B8A8;
+  case LOCAL_GL_TEXTURE_EXTERNAL: return gfx::SurfaceFormat::R8G8B8A8;
   case LOCAL_GL_TEXTURE_2D: return mFormat;
-  default: return gfx::FORMAT_UNKNOWN;
+  default: return gfx::SurfaceFormat::UNKNOWN;
   }
 }
 
 void
 GrallocDeprecatedTextureHostOGL::DeleteTextures()
 {
   if (mEGLImage) {
     if (gl()->MakeCurrent()) {
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -92,23 +92,23 @@ protected:
  * of objects sharing references to GL resources to make the tear down
  * sequence as simple as possible.
  */
 
 inline ShaderProgramType
 GetProgramTypeForSurfaceFormat(gfx::SurfaceFormat aFormat)
  {
   switch (aFormat) {
-  case gfx::FORMAT_B8G8R8A8:
+  case gfx::SurfaceFormat::B8G8R8A8:
     return BGRALayerProgramType;;
-  case gfx::FORMAT_B8G8R8X8:
+  case gfx::SurfaceFormat::B8G8R8X8:
     return BGRXLayerProgramType;;
-  case gfx::FORMAT_R8G8B8X8:
+  case gfx::SurfaceFormat::R8G8B8X8:
     return RGBXLayerProgramType;;
-  case gfx::FORMAT_R8G8B8A8:
+  case gfx::SurfaceFormat::R8G8B8A8:
     return RGBALayerProgramType;;
   default:
     MOZ_CRASH("unhandled program type");
   }
 }
 
 inline ShaderProgramType
 GetProgramTypeForTexture(const DeprecatedTextureHost *aDeprecatedTextureHost)
@@ -346,17 +346,17 @@ class StreamTextureSourceOGL : public Ne
 public:
   StreamTextureSourceOGL(CompositorOGL* aCompositor,
                          gfx::SurfaceStream* aStream)
     : mCompositor(aCompositor)
     , mStream(aStream)
     , mTextureHandle(0)
     , mTextureTarget(LOCAL_GL_TEXTURE_2D)
     , mUploadTexture(0)
-    , mFormat(gfx::FORMAT_UNKNOWN)
+    , mFormat(gfx::SurfaceFormat::UNKNOWN)
   {
     MOZ_COUNT_CTOR(StreamTextureSourceOGL);
   }
 
   ~StreamTextureSourceOGL()
   {
     MOZ_COUNT_DTOR(StreamTextureSourceOGL);
   }
@@ -577,17 +577,17 @@ class YCbCrDeprecatedTextureHostOGL : pu
 public:
   YCbCrDeprecatedTextureHostOGL()
     : mGL(nullptr)
   {
     MOZ_COUNT_CTOR(YCbCrDeprecatedTextureHostOGL);
     mYTexture  = new Channel;
     mCbTexture = new Channel;
     mCrTexture = new Channel;
-    mFormat = gfx::FORMAT_YUV;
+    mFormat = gfx::SurfaceFormat::YUV;
   }
 
   ~YCbCrDeprecatedTextureHostOGL()
   {
     MOZ_COUNT_DTOR(YCbCrDeprecatedTextureHostOGL);
   }
 
   virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
@@ -627,17 +627,17 @@ public:
       return gfx::IntSize(mTexImage->GetSize().width, mTexImage->GetSize().height);
     }
     virtual GLenum GetWrapMode() const MOZ_OVERRIDE
     {
       return mTexImage->GetWrapMode();
     }
     virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
     {
-      return gfx::FORMAT_A8;
+      return gfx::SurfaceFormat::A8;
     }
   };
 
   // TextureSource implementation
 
   TextureSource* GetSubSource(int index) MOZ_OVERRIDE
   {
     switch (index) {
@@ -734,17 +734,17 @@ public:
   {
     MOZ_ASSERT(mGL);
     // Lock already bound us!
     MOZ_ASSERT(activetex == LOCAL_GL_TEXTURE0);
   }
   GLuint GetTextureID() { return mTextureHandle; }
   ContentType GetContentType()
   {
-    return (mFormat == gfx::FORMAT_B8G8R8A8) ?
+    return (mFormat == gfx::SurfaceFormat::B8G8R8A8) ?
              GFX_CONTENT_COLOR_ALPHA :
              GFX_CONTENT_COLOR;
   }
 
   virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE;
 
   virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
 
@@ -813,17 +813,17 @@ public:
   {
     return mTextureTarget;
   }
 
   void BindTexture(GLenum activetex) MOZ_OVERRIDE;
 
   GLuint GetTextureID() { return mTextureHandle; }
   ContentType GetContentType() {
-    return (mFormat == gfx::FORMAT_B8G8R8A8) ?
+    return (mFormat == gfx::SurfaceFormat::B8G8R8A8) ?
              GFX_CONTENT_COLOR_ALPHA :
              GFX_CONTENT_COLOR;
   }
 
   virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
 
   virtual const char* Name() { return "SurfaceStreamHostOGL"; }
 
--- a/gfx/tests/gtest/TestTextures.cpp
+++ b/gfx/tests/gtest/TestTextures.cpp
@@ -172,22 +172,22 @@ void TestTextureClientYCbCr(TextureClien
                                                                         client->GetFlags());
 
   RefPtr<BufferTextureHost> host = static_cast<BufferTextureHost*>(textureHost.get());
 
   ASSERT_TRUE(host.get() != nullptr);
   ASSERT_EQ(host->GetFlags(), client->GetFlags());
 
   // This will work iff the compositor is not BasicCompositor
-  ASSERT_EQ(host->GetFormat(), mozilla::gfx::FORMAT_YUV);
+  ASSERT_EQ(host->GetFormat(), mozilla::gfx::SurfaceFormat::YUV);
 
   // host read
   ASSERT_TRUE(host->Lock());
 
-  ASSERT_TRUE(host->GetFormat() == mozilla::gfx::FORMAT_YUV);
+  ASSERT_TRUE(host->GetFormat() == mozilla::gfx::SurfaceFormat::YUV);
 
   YCbCrImageDataDeserializer yuvDeserializer(host->GetBuffer());
   ASSERT_TRUE(yuvDeserializer.IsValid());
   PlanarYCbCrData data;
   data.mYChannel = yuvDeserializer.GetYData();
   data.mCbChannel = yuvDeserializer.GetCbData();
   data.mCrChannel = yuvDeserializer.GetCrData();
   data.mYStride = yuvDeserializer.GetYStride();
@@ -252,15 +252,15 @@ TEST(Layers, TextureYCbCrSerialization) 
   clientData.mCbSkip = 0;
   clientData.mCrSkip = 0;
   clientData.mCrSkip = 0;
   clientData.mPicX = 0;
   clientData.mPicX = 0;
 
   RefPtr<TextureClient> client
     = new MemoryTextureClient(nullptr,
-                              mozilla::gfx::FORMAT_YUV,
+                              mozilla::gfx::SurfaceFormat::YUV,
                               TEXTURE_DEALLOCATE_CLIENT);
 
   TestTextureClientYCbCr(client, clientData);
 
   // XXX - Test more texture client types.
 }
--- a/gfx/thebes/gfx2DGlue.h
+++ b/gfx/thebes/gfx2DGlue.h
@@ -203,57 +203,57 @@ inline JoinStyle ToJoinStyle(gfxContext:
     return JOIN_ROUND;
   }
   MOZ_CRASH("Incomplete switch");
 }
 
 inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
-  case FORMAT_B8G8R8A8:
+  case SurfaceFormat::B8G8R8A8:
     return gfxImageFormatARGB32;
-  case FORMAT_B8G8R8X8:
+  case SurfaceFormat::B8G8R8X8:
     return gfxImageFormatRGB24;
-  case FORMAT_R5G6B5:
+  case SurfaceFormat::R5G6B5:
     return gfxImageFormatRGB16_565;
-  case FORMAT_A8:
+  case SurfaceFormat::A8:
     return gfxImageFormatA8;
   default:
     return gfxImageFormatUnknown;
   }
 }
 
 inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
 {
   switch (aFormat) {
   case gfxImageFormatARGB32:
-    return FORMAT_B8G8R8A8;
+    return SurfaceFormat::B8G8R8A8;
   case gfxImageFormatRGB24:
-    return FORMAT_B8G8R8X8;
+    return SurfaceFormat::B8G8R8X8;
   case gfxImageFormatRGB16_565:
-    return FORMAT_R5G6B5;
+    return SurfaceFormat::R5G6B5;
   case gfxImageFormatA8:
-    return FORMAT_A8;
+    return SurfaceFormat::A8;
   default:
   case gfxImageFormatUnknown:
-    return FORMAT_B8G8R8A8;
+    return SurfaceFormat::B8G8R8A8;
   }
 }
 
 inline gfxContentType ContentForFormat(const SurfaceFormat &aFormat)
 {
   switch (aFormat) {
-  case FORMAT_R5G6B5:
-  case FORMAT_B8G8R8X8:
-  case FORMAT_R8G8B8X8:
+  case SurfaceFormat::R5G6B5:
+  case SurfaceFormat::B8G8R8X8:
+  case SurfaceFormat::R8G8B8X8:
     return GFX_CONTENT_COLOR;
-  case FORMAT_A8:
+  case SurfaceFormat::A8:
     return GFX_CONTENT_ALPHA;
-  case FORMAT_B8G8R8A8:
-  case FORMAT_R8G8B8A8:
+  case SurfaceFormat::B8G8R8A8:
+  case SurfaceFormat::R8G8B8A8:
   default:
     return GFX_CONTENT_COLOR_ALPHA;
   }
 }
 
 inline CompositionOp CompositionOpForOp(gfxContext::GraphicsOperator aOp)
 {
   switch (aOp) {
--- a/gfx/thebes/gfxBlur.cpp
+++ b/gfx/thebes/gfxBlur.cpp
@@ -60,17 +60,17 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRe
     // Make an alpha-only surface to draw on. We will play with the data after
     // everything is drawn to create a blur effect.
     mData = new unsigned char[blurDataSize];
     memset(mData, 0, blurDataSize);
 
     mozilla::RefPtr<DrawTarget> dt =
         gfxPlatform::GetPlatform()->CreateDrawTargetForData(mData, size,
                                                             mBlur->GetStride(),
-                                                            FORMAT_A8);
+                                                            SurfaceFormat::A8);
     if (!dt) {
         nsRefPtr<gfxImageSurface> image =
             new gfxImageSurface(mData,
                                 gfxIntSize(size.width, size.height),
                                 mBlur->GetStride(),
                                 gfxImageFormatA8);
         dt = Factory::CreateDrawTargetForCairoSurface(image->CairoSurface(), size);
         if (!dt) {
@@ -102,17 +102,17 @@ gfxAlphaBoxBlur::Paint(gfxContext* aDest
       NS_ERROR("Blurring not supported for Thebes contexts!");
       return;
     }
 
     mozilla::RefPtr<SourceSurface> mask
       = dest->CreateSourceSurfaceFromData(mData,
                                           mBlur->GetSize(),
                                           mBlur->GetStride(),
-                                          FORMAT_A8);
+                                          SurfaceFormat::A8);
     if (!mask) {
       NS_ERROR("Failed to create mask!");
       return;
     }
 
     nsRefPtr<gfxPattern> thebesPat = aDestinationCtx->GetPattern();
     Pattern* pat = thebesPat->GetPattern(dest, nullptr);
 
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -1632,21 +1632,21 @@ gfxContext::PushGroupAndCopyBackground(g
           CopySurface(s, d, gfxPoint(0, 0));
         }
         d->SetOpaqueRect(s->GetOpaqueRect());
         return;
       }
     }
   } else {
     IntRect clipExtents;
-    if (mDT->GetFormat() != FORMAT_B8G8R8X8) {
+    if (mDT->GetFormat() != SurfaceFormat::B8G8R8X8) {
       gfxRect clipRect = GetRoundOutDeviceClipExtents(this);
       clipExtents = IntRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
     }
-    if ((mDT->GetFormat() == FORMAT_B8G8R8X8 ||
+    if ((mDT->GetFormat() == SurfaceFormat::B8G8R8X8 ||
          mDT->GetOpaqueRect().Contains(clipExtents)) &&
         !mDT->GetUserData(&sDontUseAsSourceKey)) {
       DrawTarget *oldDT = mDT;
       RefPtr<SourceSurface> source = mDT->Snapshot();
       Point oldDeviceOffset = CurrentState().deviceOffset;
 
       PushNewDT(GFX_CONTENT_COLOR);
 
@@ -2127,17 +2127,17 @@ gfxContext::GetOp()
   AzureState &state = CurrentState();
   if (state.pattern) {
     if (state.pattern->IsOpaque()) {
       return OP_OVER;
     } else {
       return OP_SOURCE;
     }
   } else if (state.sourceSurface) {
-    if (state.sourceSurface->GetFormat() == FORMAT_B8G8R8X8) {
+    if (state.sourceSurface->GetFormat() == SurfaceFormat::B8G8R8X8) {
       return OP_OVER;
     } else {
       return OP_SOURCE;
     }
   } else {
     if (state.color.a > 0.999) {
       return OP_OVER;
     } else {
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -370,17 +370,17 @@ gfxPattern::IsOpaque()
           return true;
         }
       }
     default:
       return false;
     }
   }
 
-  if (mSourceSurface->GetFormat() == FORMAT_B8G8R8X8) {
+  if (mSourceSurface->GetFormat() == SurfaceFormat::B8G8R8X8) {
     return true;
   }
   return false;
 }
 
 gfxPattern::GraphicsExtend
 gfxPattern::Extend() const
 {
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -440,17 +440,17 @@ gfxPlatform::Init()
                                           GFX_CONTENT_COLOR_ALPHA);
     if (!gPlatform->mScreenReferenceSurface) {
         NS_RUNTIMEABORT("Could not initialize mScreenReferenceSurface");
     }
 
     if (gPlatform->SupportsAzureContent()) {
         gPlatform->mScreenReferenceDrawTarget =
             gPlatform->CreateOffscreenContentDrawTarget(IntSize(1, 1),
-                                                        FORMAT_B8G8R8A8);
+                                                        SurfaceFormat::B8G8R8A8);
       if (!gPlatform->mScreenReferenceDrawTarget) {
         NS_RUNTIMEABORT("Could not initialize mScreenReferenceDrawTarget");
       }
     }
 
     rv = gfxFontCache::Init();
     if (NS_FAILED(rv)) {
         NS_RUNTIMEABORT("Could not initialize gfxFontCache");
@@ -743,28 +743,28 @@ gfxPlatform::GetSourceSurfaceForSurface(
       return surf->mSrcSurface;
     }
     // We can just continue here as when setting new user data the destroy
     // function will be called for the old user data.
   }
 
   SurfaceFormat format;
   if (aSurface->GetContentType() == GFX_CONTENT_ALPHA) {
-    format = FORMAT_A8;
+    format = SurfaceFormat::A8;
   } else if (aSurface->GetContentType() == GFX_CONTENT_COLOR) {
-    format = FORMAT_B8G8R8X8;
+    format = SurfaceFormat::B8G8R8X8;
   } else {
-    format = FORMAT_B8G8R8A8;
+    format = SurfaceFormat::B8G8R8A8;
   }
 
   RefPtr<SourceSurface> srcBuffer;
 
 #ifdef XP_WIN
   if (aSurface->GetType() == gfxSurfaceTypeD2D &&
-      format != FORMAT_A8) {
+      format != SurfaceFormat::A8) {
     NativeSurface surf;
     surf.mFormat = format;
     surf.mType = NATIVE_SURFACE_D3D10_TEXTURE;
     surf.mSurface = static_cast<gfxD2DSurface*>(aSurface)->GetTexture();
     mozilla::gfx::DrawTarget *dt = static_cast<mozilla::gfx::DrawTarget*>(aSurface->GetData(&kDrawTarget));
     if (dt) {
       dt->Flush();
     }
@@ -799,26 +799,26 @@ gfxPlatform::GetSourceSurfaceForSurface(
       ctx->SetSource(aSurface);
       ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
       ctx->Paint();
     }
 
     gfxImageFormat cairoFormat = imgSurface->Format();
     switch(cairoFormat) {
       case gfxImageFormatARGB32:
-        format = FORMAT_B8G8R8A8;
+        format = SurfaceFormat::B8G8R8A8;
         break;
       case gfxImageFormatRGB24:
-        format = FORMAT_B8G8R8X8;
+        format = SurfaceFormat::B8G8R8X8;
         break;
       case gfxImageFormatA8:
-        format = FORMAT_A8;
+        format = SurfaceFormat::A8;
         break;
       case gfxImageFormatRGB16_565:
-        format = FORMAT_R5G6B5;
+        format = SurfaceFormat::R5G6B5;
         break;
       default:
         NS_RUNTIMEABORT("Invalid surface format!");
     }
 
     IntSize size = IntSize(imgSurface->GetSize().width, imgSurface->GetSize().height);
     srcBuffer = aTarget->CreateSourceSurfaceFromData(imgSurface->Data(),
                                                      size,
@@ -1983,32 +1983,32 @@ gfxPlatform::GetScreenDepth() const
 
 mozilla::gfx::SurfaceFormat
 gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
 {
   switch (aContent) {
   case GFX_CONTENT_COLOR:
     switch (GetOffscreenFormat()) {
     case gfxImageFormatARGB32:
-      return mozilla::gfx::FORMAT_B8G8R8A8;
+      return mozilla::gfx::SurfaceFormat::B8G8R8A8;
     case gfxImageFormatRGB24:
-      return mozilla::gfx::FORMAT_B8G8R8X8;
+      return mozilla::gfx::SurfaceFormat::B8G8R8X8;
     case gfxImageFormatRGB16_565:
-      return mozilla::gfx::FORMAT_R5G6B5;
+      return mozilla::gfx::SurfaceFormat::R5G6B5;
     default:
       NS_NOTREACHED("unknown gfxImageFormat for GFX_CONTENT_COLOR");
-      return mozilla::gfx::FORMAT_B8G8R8A8;
+      return mozilla::gfx::SurfaceFormat::B8G8R8A8;
     }
   case GFX_CONTENT_ALPHA:
-    return mozilla::gfx::FORMAT_A8;
+    return mozilla::gfx::SurfaceFormat::A8;
   case GFX_CONTENT_COLOR_ALPHA:
-    return mozilla::gfx::FORMAT_B8G8R8A8;
+    return mozilla::gfx::SurfaceFormat::B8G8R8A8;
   default:
     NS_NOTREACHED("unknown gfxContentType");
-    return mozilla::gfx::FORMAT_B8G8R8A8;
+    return mozilla::gfx::SurfaceFormat::B8G8R8A8;
   }
 }
 
 gfxImageFormat
 gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
 {
   switch (aContent) {
   case GFX_CONTENT_COLOR:
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -44,17 +44,17 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
       if (dt->GetType() == BACKEND_COREGRAPHICS) {
         if (dt->IsDualDrawTarget()) {
           IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
                               NSToIntFloor(mNativeRect.height * mBackingScale));
 
          if (backingSize.IsEmpty())
             return nullptr;
 
-          mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, FORMAT_B8G8R8A8);
+          mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, SurfaceFormat::B8G8R8A8);
 
           Matrix transform;
           transform.Scale(mBackingScale, mBackingScale);
           transform.Translate(-mNativeRect.x, -mNativeRect.y);
 
           mDrawTarget->SetTransform(transform);
           dt = mDrawTarget;
         }
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -573,17 +573,17 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
 
     if (!DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft())) {
         cairo_surface_destroy(tempXlibSurface);
         return;
     }
   
     SurfaceFormat moz2DFormat =
         cairo_surface_get_content(tempXlibSurface) == CAIRO_CONTENT_COLOR ?
-            FORMAT_B8G8R8A8 : FORMAT_B8G8R8X8;
+            SurfaceFormat::B8G8R8A8 : SurfaceFormat::B8G8R8X8;
     if (method != eAlphaExtraction) {
         if (drawTarget) {
             // It doesn't matter if moz2DFormat doesn't exactly match the format
             // of tempXlibSurface, since this DrawTarget just wraps the cairo
             // drawing.
             RefPtr<SourceSurface> sourceSurface =
                 Factory::CreateSourceSurfaceForCairoSurface(tempXlibSurface,
                                                             moz2DFormat);
--- a/gfx/ycbcr/YCbCrUtils.cpp
+++ b/gfx/ycbcr/YCbCrUtils.cpp
@@ -23,17 +23,17 @@ GetYCbCrToRGBDestFormatAndSize(const lay
                  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 &&
                   aSuggestedSize != aData.mPicSize;
 
-  if (aSuggestedFormat == FORMAT_R5G6B5) {
+  if (aSuggestedFormat == SurfaceFormat::R5G6B5) {
 #if defined(HAVE_YCBCR_TO_RGB565)
     if (prescale &&
         !IsScaleYCbCrToRGB565Fast(aData.mPicX,
                                   aData.mPicY,
                                   aData.mPicSize.width,
                                   aData.mPicSize.height,
                                   aSuggestedSize.width,
                                   aSuggestedSize.height,
@@ -43,24 +43,24 @@ GetYCbCrToRGBDestFormatAndSize(const lay
                                    aData.mPicY,
                                    aData.mPicSize.width,
                                    aData.mPicSize.height,
                                    yuvtype)) {
       prescale = false;
     }
 #else
     // yuv2rgb16 function not available
-    aSuggestedFormat = FORMAT_B8G8R8X8;
+    aSuggestedFormat = SurfaceFormat::B8G8R8X8;
 #endif
   }
-  else if (aSuggestedFormat != FORMAT_B8G8R8X8) {
+  else if (aSuggestedFormat != SurfaceFormat::B8G8R8X8) {
     // No other formats are currently supported.
-    aSuggestedFormat = FORMAT_B8G8R8X8;
+    aSuggestedFormat = SurfaceFormat::B8G8R8X8;
   }
-  if (aSuggestedFormat == FORMAT_B8G8R8X8) {
+  if (aSuggestedFormat == SurfaceFormat::B8G8R8X8) {
     /* 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) {
     aSuggestedSize = aData.mPicSize;
   }
@@ -83,17 +83,17 @@ ConvertYCbCrToRGB(const layers::PlanarYC
     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 (aDestSize != aData.mPicSize) {
 #if defined(HAVE_YCBCR_TO_RGB565)
-    if (aDestFormat == FORMAT_R5G6B5) {
+    if (aDestFormat == SurfaceFormat::R5G6B5) {
       ScaleYCbCrToRGB565(aData.mYChannel,
                          aData.mCbChannel,
                          aData.mCrChannel,
                          aDestBuffer,
                          aData.mPicX,
                          aData.mPicY,
                          aData.mPicSize.width,
                          aData.mPicSize.height,
@@ -117,17 +117,17 @@ ConvertYCbCrToRGB(const layers::PlanarYC
                         aData.mYStride,
                         aData.mCbCrStride,
                         aStride,
                         yuvtype,
                         ROTATE_0,
                         FILTER_BILINEAR);
   } else { // no prescale
 #if defined(HAVE_YCBCR_TO_RGB565)
-    if (aDestFormat == FORMAT_R5G6B5) {
+    if (aDestFormat == SurfaceFormat::R5G6B5) {
       ConvertYCbCrToRGB565(aData.mYChannel,
                            aData.mCbChannel,
                            aData.mCrChannel,
                            aDestBuffer,
                            aData.mPicX,
                            aData.mPicY,
                            aData.mPicSize.width,
                            aData.mPicSize.height,
--- a/image/src/ClippedImage.cpp
+++ b/image/src/ClippedImage.cpp
@@ -233,22 +233,22 @@ ClippedImage::GetFrameInternal(const nsI
                                                   aFlags)) {
     // Create a surface to draw into.
     mozilla::RefPtr<mozilla::gfx::DrawTarget> target;
     nsRefPtr<gfxContext> ctx;
 
     if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
       target = gfxPlatform::GetPlatform()->
         CreateOffscreenContentDrawTarget(gfx::IntSize(mClip.width, mClip.height),
-                                        gfx::FORMAT_B8G8R8A8);
+                                        gfx::SurfaceFormat::B8G8R8A8);
       ctx = new gfxContext(target);
     } else {
       target = gfxPlatform::GetPlatform()->
         CreateOffscreenCanvasDrawTarget(gfx::IntSize(mClip.width, mClip.height),
-                                        gfx::FORMAT_B8G8R8A8);
+                                        gfx::SurfaceFormat::B8G8R8A8);
       nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->
         GetThebesSurfaceForDrawTarget(target);
       ctx = new gfxContext(surface);
     }
 
     // Create our callback.
     nsRefPtr<gfxDrawingCallback> drawTileCallback =
       new DrawSingleTileCallback(this, mClip, aViewportSize, aSVGContext, aWhichFrame, aFlags);
--- a/image/src/OrientedImage.cpp
+++ b/image/src/OrientedImage.cpp
@@ -95,20 +95,20 @@ OrientedImage::GetFrame(uint32_t aWhichF
     rv = NS_FAILED(rv) ? rv : InnerImage()->GetHeight(&height);
   }
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   // Determine an appropriate format for the surface.
   gfx::SurfaceFormat surfaceFormat;
   gfxImageFormat imageFormat;
   if (InnerImage()->FrameIsOpaque(aWhichFrame)) {
-    surfaceFormat = gfx::FORMAT_B8G8R8X8;
+    surfaceFormat = gfx::SurfaceFormat::B8G8R8X8;
     imageFormat = gfxImageFormatARGB32;
   } else {
-    surfaceFormat = gfx::FORMAT_B8G8R8A8;
+    surfaceFormat = gfx::SurfaceFormat::B8G8R8A8;
     imageFormat = gfxImageFormatARGB32;
   }
 
   // Create a surface to draw into.
   mozilla::RefPtr<mozilla::gfx::DrawTarget> target;
   target = gfxPlatform::GetPlatform()->
     CreateOffscreenCanvasDrawTarget(gfx::IntSize(width, height), surfaceFormat);
   nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -846,17 +846,17 @@ VectorImage::CreateDrawableAndShow(const
     return Show(svgDrawable, aParams);
 
   // If the image is too big to fit in the cache, don't go any further.
   if (!SurfaceCache::CanHold(aParams.imageRect.Size()))
     return Show(svgDrawable, aParams);
 
   // Try to create an offscreen surface.
   mozilla::RefPtr<mozilla::gfx::DrawTarget> target =
-   gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aParams.imageRect.Size().ToIntSize(), gfx::FORMAT_B8G8R8A8);
+   gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aParams.imageRect.Size().ToIntSize(), gfx::SurfaceFormat::B8G8R8A8);
 
   // If we couldn't create the draw target, it was probably because it would end
   // up way too big. Generally it also wouldn't fit in the cache, but the prefs
   // could be set such that the cache isn't the limiting factor.
   if (!target)
     return Show(svgDrawable, aParams);
 
   nsRefPtr<gfxContext> ctx = new gfxContext(target);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4850,22 +4850,22 @@ nsLayoutUtils::SurfaceFromElement(nsIIma
   rv = imgContainer->GetWidth(&imgWidth);
   nsresult rv2 = imgContainer->GetHeight(&imgHeight);
   if (NS_FAILED(rv) || NS_FAILED(rv2))
     return result;
 
   nsRefPtr<gfxASurface> gfxsurf = framesurf;
   if (wantImageSurface) {
     IntSize size(imgWidth, imgHeight);
-    RefPtr<DataSourceSurface> output = Factory::CreateDataSourceSurface(size, FORMAT_B8G8R8A8);
+    RefPtr<DataSourceSurface> output = Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
     RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
                                                              output->GetData(),
                                                              size,
                                                              output->Stride(),
-                                                             FORMAT_B8G8R8A8);
+                                                             SurfaceFormat::B8G8R8A8);
     RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, gfxsurf);
 
     dt->CopySurface(source, IntRect(0, 0, imgWidth, imgHeight), IntPoint());
     dt->Flush();
 
     result.mSourceSurface = output;
   } else {
     result.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTarget, gfxsurf);
@@ -4911,30 +4911,30 @@ nsLayoutUtils::SurfaceFromElement(HTMLCa
     result.mSourceSurface = srcCanvas->GetSurfaceSnapshot();
   }
 
   if (!result.mSourceSurface) {
     nsRefPtr<gfxContext> ctx;
     RefPtr<DrawTarget> dt;
     if (premultAlpha) {
       if (aTarget) {
-        dt = aTarget->CreateSimilarDrawTarget(IntSize(size.width, size.height), FORMAT_B8G8R8A8);
+        dt = aTarget->CreateSimilarDrawTarget(IntSize(size.width, size.height), SurfaceFormat::B8G8R8A8);
       } else {
         dt = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(size.width, size.height),
-                                                                          FORMAT_B8G8R8A8);
+                                                                          SurfaceFormat::B8G8R8A8);
       }
       if (!dt) {
         return result;
       }
       ctx = new gfxContext(dt);
     } else {
       // TODO: RenderContextsExternal expects to get a gfxImageFormat
       // so that it can un-premultiply.
       RefPtr<DataSourceSurface> data = Factory::CreateDataSourceSurface(IntSize(size.width, size.height),
-                                                                        FORMAT_B8G8R8A8);
+                                                                        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);
       ctx = new gfxContext(image);
     }
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -240,17 +240,17 @@ nsDisplayCanvasBackgroundImage::Paint(ns
           gfxIntSize(ceil(destRect.width), ceil(destRect.height)));
     } else {
       dt = static_cast<DrawTarget*>(Frame()->Properties().Get(nsIFrame::CachedBackgroundImageDT()));
       DrawTarget* destDT = dest->GetDrawTarget();
       if (dt) {
         BlitSurface(destDT, destRect, dt);
         return;
       }
-      dt = destDT->CreateSimilarDrawTarget(IntSize(ceil(destRect.width), ceil(destRect.height)), FORMAT_B8G8R8A8);
+      dt = destDT->CreateSimilarDrawTarget(IntSize(ceil(destRect.width), ceil(destRect.height)), SurfaceFormat::B8G8R8A8);
     }
     if (surf || dt) {
       if (surf) {
         ctx = new gfxContext(surf);
       } else {
         ctx = new gfxContext(dt);
       }
       ctx->Translate(-gfxPoint(destRect.x, destRect.y));
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -304,17 +304,17 @@ nsSVGFilterInstance::BuildSourcePaint(So
     offscreenSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(
       neededRect.Size(), GFX_CONTENT_COLOR_ALPHA);
     if (!offscreenSurface || offscreenSurface->CairoStatus()) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     ctx = new gfxContext(offscreenSurface);
   } else {
     offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
-      ToIntSize(neededRect.Size()), FORMAT_B8G8R8A8);
+      ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8);
     if (!offscreenDT) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     ctx = new gfxContext(offscreenDT);
   }
 
   ctx->Translate(-neededRect.TopLeft());
 
@@ -391,17 +391,17 @@ nsSVGFilterInstance::BuildSourceImage(gf
     offscreenSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(
       neededRect.Size(), GFX_CONTENT_COLOR_ALPHA);
     if (!offscreenSurface || offscreenSurface->CairoStatus()) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     ctx = new gfxContext(offscreenSurface);
   } else {
     offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
-      ToIntSize(neededRect.Size()), FORMAT_B8G8R8A8);
+      ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8);
     if (!offscreenDT) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     ctx = new gfxContext(offscreenDT);
   }
 
   ctx->Translate(-neededRect.TopLeft());
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2630,17 +2630,17 @@ RectTextureImage::BeginUpdate(const nsIn
     return nullptr;
   }
 
   nsIntSize neededBufferSize = TextureSizeForSize(mUsedSize);
   if (!mUpdateDrawTarget || mBufferSize != neededBufferSize) {
     gfx::IntSize size(neededBufferSize.width, neededBufferSize.height);
     mUpdateDrawTarget =
       gfx::Factory::CreateDrawTarget(gfx::BACKEND_COREGRAPHICS, size,
-                                     gfx::FORMAT_B8G8R8A8);
+                                     gfx::SurfaceFormat::B8G8R8A8);
     mBufferSize = neededBufferSize;
   }
 
   mInUpdate = true;
 
   RefPtr<gfx::DrawTarget> drawTarget = mUpdateDrawTarget;
   return drawTarget;
 }
@@ -2700,17 +2700,17 @@ RectTextureImage::UpdateFromCGContext(co
   RefPtr<gfx::DrawTarget> dt = BeginUpdate(aNewSize, aDirtyRegion);
   if (dt) {
     gfx::Rect rect(0, 0, size.width, size.height);
     gfxUtils::ClipToRegion(dt, GetUpdateRegion());
     RefPtr<gfx::SourceSurface> sourceSurface =
       dt->CreateSourceSurfaceFromData(static_cast<uint8_t *>(CGBitmapContextGetData(aCGContext)),
                                       size,
                                       CGBitmapContextGetBytesPerRow(aCGContext),
-                                      gfx::FORMAT_B8G8R8A8);
+                                      gfx::SurfaceFormat::B8G8R8A8);
     dt->DrawSurface(sourceSurface, rect, rect,
                     gfx::DrawSurfaceOptions(),
                     gfx::DrawOptions(1.0, gfx::OP_SOURCE));
     dt->PopClip();
     EndUpdate();
   }
 }
 
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -2126,18 +2126,18 @@ nsNativeThemeCocoa::DrawWidgetBackground
       break;
 
     case NS_THEME_MENUITEM: {
       bool isTransparent;
       if (thebesCtx->IsCairo()) {
         isTransparent = thebesCtx->OriginalSurface()->GetContentType() == GFX_CONTENT_COLOR_ALPHA;
       } else {
         SurfaceFormat format  = thebesCtx->GetDrawTarget()->GetFormat();
-        isTransparent = (format == FORMAT_R8G8B8A8) ||
-                        (format == FORMAT_B8G8R8A8);
+        isTransparent = (format == SurfaceFormat::R8G8B8A8) ||
+                        (format == SurfaceFormat::B8G8R8A8);
       }
       if (isTransparent) {
         // Clear the background to get correct transparency.
         CGContextClearRect(cgContext, macRect);
       }
 
       // maybe use kThemeMenuItemHierBackground or PopUpBackground instead of just Plain?
       HIThemeMenuItemDrawInfo drawInfo;
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2268,23 +2268,23 @@ nsWindow::OnExposeEvent(cairo_t *cr)
 }
 
 void
 nsWindow::UpdateAlpha(gfxPattern* aPattern, nsIntRect aBoundsRect)
 {
   if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
       // We need to create our own buffer to force the stride to match the
       // expected stride.
-      int32_t stride = GetAlignedStride<4>(BytesPerPixel(FORMAT_A8) *
+      int32_t stride = GetAlignedStride<4>(BytesPerPixel(SurfaceFormat::A8) *
                                            aBoundsRect.width);
       int32_t bufferSize = stride * aBoundsRect.height;
       nsAutoArrayPtr<uint8_t> imageBuffer(new (std::nothrow) uint8_t[bufferSize]);
       RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
           CreateDrawTargetForData(imageBuffer, ToIntSize(aBoundsRect.Size()),
-                                  stride, FORMAT_A8);
+                                  stride, SurfaceFormat::A8);
 
       if (drawTarget) {
           drawTarget->FillRect(Rect(0, 0, aBoundsRect.width, aBoundsRect.height),
                                *aPattern->GetPattern(drawTarget),
                                DrawOptions(1.0, OP_SOURCE));
       }
       UpdateTranslucentWindowAlphaInternal(aBoundsRect, imageBuffer, stride);
   } else {