Bug 913872 - Take nested enums out of gfxASurface - 1/3 : automatic changes - r=jrmuizel
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 24 Sep 2013 16:45:13 -0400
changeset 157121 1892aa2a6de84d83a3c0aff80b0153d925e48ebc
parent 157120 6a26a65777a5b22010de9ece5eaa166ee25acd9b
child 157122 0f86bf03656bac01716606e7dfe1a136208e6966
push idunknown
push userunknown
push dateunknown
reviewersjrmuizel
bugs913872
milestone27.0a1
Bug 913872 - Take nested enums out of gfxASurface - 1/3 : automatic changes - r=jrmuizel Generated by these regexes: find . -name '*.h' -o -name '*.cpp' -o -name '*.mm' | grep -v '\.hg' | grep -v '^\.\/obj' | xargs sed -i 's/gfx[A-Za-z0-9_]*Surface\:\:[a-z]*\(\(ImageFormat\|SurfaceType\|ContentType\|MemoryLocation\)[0-9A-Za-z_]*\)/gfx\1/g' find . -name '*.h' -o -name '*.cpp' -o -name '*.mm' | grep -v '\.hg' | grep -v '^\.\/obj' | xargs sed -i 's/gfx[A-Za-z0-9_]*Surface\:\:[a-z]*\(\(CONTENT_\|MEMORY_\)[0-9A-Za-z_]*\)/GFX_\1/g' find . -name '*.h' -o -name '*.cpp' -o -name '*.mm' | grep -v '\.hg' | grep -v '^\.\/obj' | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)\(CONTENT_COLOR\|CONTENT_ALPHA\|CONTENT_COLOR_ALPHA\|CONTENT_SENTINEL\|MEMORY_IN_PROCESS_HEAP\|MEMORY_IN_PROCESS_NONHEAP\|MEMORY_OUT_OF_PROCESS\)\($\|[^A-Za-z0-9_]\)/\1GFX_\2\3/g' find . -name '*.h' -o -name '*.cpp' -o -name '*.mm' | grep -v '\.hg' | grep -v '^\.\/obj' | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)\(ImageFormatARGB32\|ImageFormatRGB24\|ImageFormatA8\|ImageFormatA1\|ImageFormatRGB16_565\|ImageFormatUnknown\|SurfaceTypeImage\|SurfaceTypePDF\|SurfaceTypePS\|SurfaceTypeXlib\|SurfaceTypeXcb\|SurfaceTypeGlitz\|SurfaceTypeQuartz\|SurfaceTypeWin32\|SurfaceTypeBeOS\|SurfaceTypeDirectFB\|SurfaceTypeSVG\|SurfaceTypeOS2\|SurfaceTypeWin32Printing\|SurfaceTypeQuartzImage\|SurfaceTypeScript\|SurfaceTypeQPainter\|SurfaceTypeRecording\|SurfaceTypeVG\|SurfaceTypeGL\|SurfaceTypeDRM\|SurfaceTypeTee\|SurfaceTypeXML\|SurfaceTypeSkia\|SurfaceTypeSubsurface\|SurfaceTypeD2D\|SurfaceTypeMax\)\($\|[^A-Za-z0-9_]\)/\1gfx\2\3/g'
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/DocumentRendererChild.cpp
content/canvas/src/DocumentRendererParent.cpp
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContextGL.cpp
content/html/content/src/HTMLCanvasElement.cpp
content/media/plugins/MediaPluginReader.cpp
content/svg/content/src/nsSVGFilters.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextProviderCGL.mm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLScreenBuffer.cpp
gfx/gl/GLTextureImage.cpp
gfx/gl/GLTextureImage.h
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceGL.cpp
gfx/gl/SharedSurfaceGL.h
gfx/gl/SharedSurfaceGralloc.cpp
gfx/ipc/GfxMessageUtils.h
gfx/ipc/SharedDIBSurface.cpp
gfx/layers/CopyableCanvasLayer.cpp
gfx/layers/D3D9SurfaceImage.cpp
gfx/layers/GrallocImages.cpp
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/layers/ThebesLayerBuffer.cpp
gfx/layers/ThebesLayerBuffer.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/basic/BasicImages.cpp
gfx/layers/basic/BasicLayerManager.cpp
gfx/layers/basic/BasicLayers.h
gfx/layers/basic/BasicLayersImpl.cpp
gfx/layers/basic/BasicThebesLayer.cpp
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/ClientThebesLayer.cpp
gfx/layers/client/CompositableClient.cpp
gfx/layers/client/CompositableClient.h
gfx/layers/client/ContentClient.cpp
gfx/layers/client/ContentClient.h
gfx/layers/client/ImageClient.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/client/TiledContentClient.cpp
gfx/layers/client/TiledContentClient.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d10/ImageLayerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.h
gfx/layers/d3d10/ReadbackManagerD3D10.cpp
gfx/layers/d3d10/ThebesLayerD3D10.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/d3d9/ImageLayerD3D9.cpp
gfx/layers/d3d9/LayerManagerD3D9.cpp
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/d3d9/TextureD3D9.h
gfx/layers/d3d9/ThebesLayerD3D9.cpp
gfx/layers/ipc/AutoOpenSurface.h
gfx/layers/ipc/CompositableForwarder.h
gfx/layers/ipc/ISurfaceAllocator.cpp
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp
gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
gfx/layers/ipc/ShadowLayerUtilsMac.cpp
gfx/layers/ipc/ShadowLayerUtilsX11.cpp
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
gfx/layers/ipc/SharedRGBImage.cpp
gfx/layers/ipc/SharedRGBImage.h
gfx/layers/opengl/CanvasLayerOGL.cpp
gfx/layers/opengl/CanvasLayerOGL.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/ImageLayerOGL.cpp
gfx/layers/opengl/LayerManagerOGL.cpp
gfx/layers/opengl/LayerManagerOGLProgram.h
gfx/layers/opengl/TextureClientOGL.cpp
gfx/layers/opengl/TextureClientOGL.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
gfx/layers/opengl/ThebesLayerOGL.cpp
gfx/src/nsDeviceContext.cpp
gfx/tests/gtest/gfxFontSelectionTest.cpp
gfx/tests/gtest/gfxSurfaceRefCountTest.cpp
gfx/tests/gtest/gfxTextRunPerfTest.cpp
gfx/tests/gtest/gfxWordCacheTest.cpp
gfx/thebes/gfx2DGlue.h
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxASurface.h
gfx/thebes/gfxAlphaRecovery.cpp
gfx/thebes/gfxAlphaRecoverySSE2.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxAndroidPlatform.h
gfx/thebes/gfxBaseSharedMemorySurface.h
gfx/thebes/gfxBlur.cpp
gfx/thebes/gfxCachedTempSurface.cpp
gfx/thebes/gfxCachedTempSurface.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
gfx/thebes/gfxD2DSurface.h
gfx/thebes/gfxDrawable.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxImageSurface.cpp
gfx/thebes/gfxOS2Platform.cpp
gfx/thebes/gfxOS2Platform.h
gfx/thebes/gfxOS2Surface.cpp
gfx/thebes/gfxOS2Surface.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxPlatformMac.h
gfx/thebes/gfxQtPlatform.cpp
gfx/thebes/gfxQtPlatform.h
gfx/thebes/gfxQuartzNativeDrawing.cpp
gfx/thebes/gfxReusableImageSurfaceWrapper.cpp
gfx/thebes/gfxReusableImageSurfaceWrapper.h
gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp
gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h
gfx/thebes/gfxReusableSurfaceWrapper.h
gfx/thebes/gfxSharedImageSurface.h
gfx/thebes/gfxSharedQuartzSurface.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
gfx/thebes/gfxWindowsNativeDrawing.cpp
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
gfx/thebes/gfxWindowsSurface.cpp
gfx/thebes/gfxWindowsSurface.h
gfx/thebes/gfxXlibNativeRenderer.cpp
gfx/thebes/gfxXlibSurface.cpp
gfx/thebes/gfxXlibSurface.h
image/decoders/nsGIFDecoder2.cpp
image/decoders/nsPNGDecoder.cpp
image/decoders/nsPNGDecoder.h
image/src/ClippedImage.cpp
image/src/Decoder.cpp
image/src/Decoder.h
image/src/FrameBlender.cpp
image/src/FrameBlender.h
image/src/FrameSequence.cpp
image/src/FrameSequence.h
image/src/OrientedImage.cpp
image/src/RasterImage.cpp
image/src/RasterImage.h
image/src/VectorImage.cpp
image/src/imgFrame.cpp
image/src/imgFrame.h
image/src/imgTools.cpp
layout/base/FrameLayerBuilder.cpp
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsPresShell.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsSimplePageSequence.cpp
layout/svg/nsSVGClipPathFrame.cpp
layout/svg/nsSVGFilterInstance.cpp
layout/svg/nsSVGImageFrame.cpp
layout/svg/nsSVGIntegrationUtils.cpp
layout/svg/nsSVGMaskFrame.cpp
layout/svg/nsSVGPatternFrame.cpp
layout/svg/nsSVGTextFrame2.cpp
layout/svg/nsSVGUtils.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
widget/android/AndroidBridge.cpp
widget/android/AndroidDirectTexture.cpp
widget/android/AndroidDirectTexture.h
widget/android/AndroidGraphicBuffer.cpp
widget/android/AndroidGraphicBuffer.h
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.mm
widget/cocoa/nsDeviceContextSpecX.mm
widget/cocoa/nsDragService.mm
widget/cocoa/nsNativeThemeCocoa.mm
widget/gonk/Framebuffer.cpp
widget/gonk/nsWindow.cpp
widget/gtk/nsImageToPixbuf.cpp
widget/gtk/nsWindow.cpp
widget/os2/nsWindow.cpp
widget/os2/nsWindow.h
widget/qt/nsClipboard.cpp
widget/qt/nsNativeThemeQt.cpp
widget/qt/nsWindow.cpp
widget/shared/nsShmImage.cpp
widget/shared/nsShmImage.h
widget/windows/TaskbarPreview.cpp
widget/windows/WinUtils.cpp
widget/windows/nsDragService.cpp
widget/windows/nsImageClipboard.cpp
widget/windows/nsWindow.cpp
widget/windows/nsWindowGfx.cpp
widget/xpwidgets/PuppetWidget.cpp
widget/xpwidgets/nsBaseDragService.cpp
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -1073,17 +1073,17 @@ CanvasRenderingContext2D::GetInputStream
   if (!imageBuffer) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   nsRefPtr<gfxImageSurface> imgsurf =
     new gfxImageSurface(imageBuffer.get(),
                         gfxIntSize(mWidth, mHeight),
                         mWidth * 4,
-                        gfxASurface::ImageFormatARGB32);
+                        gfxImageFormatARGB32);
 
   if (!imgsurf || imgsurf->CairoStatus()) {
     return NS_ERROR_FAILURE;
   }
 
   nsRefPtr<gfxContext> ctx = new gfxContext(imgsurf);
 
   if (!ctx || ctx->HasError()) {
@@ -3253,17 +3253,17 @@ CanvasRenderingContext2D::DrawWindow(nsI
   nsRefPtr<gfxASurface> drawSurf;
   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 {
     drawSurf =
       gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(ceil(sw), ceil(sh)),
-                                                         gfxASurface::CONTENT_COLOR_ALPHA);
+                                                         GFX_CONTENT_COLOR_ALPHA);
     if (!drawSurf) {
       error.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     drawSurf->SetDeviceOffset(gfxPoint(-floor(x), -floor(y)));
     thebes = new gfxContext(drawSurf);
     thebes->Translate(gfxPoint(floor(x), floor(y)));
@@ -3673,17 +3673,17 @@ CanvasRenderingContext2D::PutImageData_e
   }
 
   uint32_t len = w * h * 4;
   if (aDataLen != len) {
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
 
   nsRefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfxIntSize(w, h),
-                                                          gfxASurface::ImageFormatARGB32,
+                                                          gfxImageFormatARGB32,
                                                           false);
   if (!imgsurf || imgsurf->CairoStatus()) {
     return NS_ERROR_FAILURE;
   }
 
   uint8_t *src = aData;
   uint8_t *dst = imgsurf->Data();
 
--- a/content/canvas/src/DocumentRendererChild.cpp
+++ b/content/canvas/src/DocumentRendererChild.cpp
@@ -66,17 +66,17 @@ DocumentRendererChild::RenderDocument(ns
 
     // Draw directly into the output array.
     data.SetLength(renderSize.width * renderSize.height * 4);
 
     nsRefPtr<gfxImageSurface> surf =
         new gfxImageSurface(reinterpret_cast<uint8_t*>(data.BeginWriting()),
                             gfxIntSize(renderSize.width, renderSize.height),
                             4 * renderSize.width,
-                            gfxASurface::ImageFormatARGB32);
+                            gfxImageFormatARGB32);
     nsRefPtr<gfxContext> ctx = new gfxContext(surf);
     ctx->SetMatrix(transform);
 
     nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
     shell->RenderDocument(documentRect, renderFlags, bgColor, ctx);
 
     return true;
 }
--- a/content/canvas/src/DocumentRendererParent.cpp
+++ b/content/canvas/src/DocumentRendererParent.cpp
@@ -27,17 +27,17 @@ void DocumentRendererParent::DrawToCanva
 {
     if (!mCanvas || !mCanvasContext)
         return;
 
     nsRefPtr<gfxImageSurface> surf =
         new gfxImageSurface(reinterpret_cast<uint8_t*>(const_cast<nsCString&>(aData).BeginWriting()),
                             gfxIntSize(aSize.width, aSize.height),
                             aSize.width * 4,
-                            gfxASurface::ImageFormatARGB32);
+                            gfxImageFormatARGB32);
     nsRefPtr<gfxPattern> pat = new gfxPattern(surf);
 
     gfxRect rect(gfxPoint(0, 0), gfxSize(aSize.width, aSize.height));
     mCanvasContext->NewPath();
     mCanvasContext->PixelSnappedRectangleAndSetPattern(rect, pat);
     mCanvasContext->Fill();
 
     // get rid of the pattern surface ref, because aData is very
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -596,17 +596,17 @@ WebGLContext::SetDimensions(int32_t widt
 
 NS_IMETHODIMP
 WebGLContext::Render(gfxContext *ctx, gfxPattern::GraphicsFilter f, uint32_t aFlags)
 {
     if (!gl)
         return NS_OK;
 
     nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(gfxIntSize(mWidth, mHeight),
-                                                         gfxASurface::ImageFormatARGB32);
+                                                         gfxImageFormatARGB32);
     if (surf->CairoStatus() != 0)
         return NS_ERROR_FAILURE;
 
     gl->MakeCurrent();
     gl->ReadScreenIntoImageSurface(surf);
 
     bool srcPremultAlpha = mOptions.premultipliedAlpha;
     bool dstPremultAlpha = aFlags & RenderFlagPremultAlpha;
@@ -726,17 +726,17 @@ WebGLContext::GetInputStream(const char*
                              const PRUnichar* aEncoderOptions,
                              nsIInputStream **aStream)
 {
     NS_ASSERTION(gl, "GetInputStream on invalid context?");
     if (!gl)
         return NS_ERROR_FAILURE;
 
     nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(gfxIntSize(mWidth, mHeight),
-                                                         gfxASurface::ImageFormatARGB32);
+                                                         gfxImageFormatARGB32);
     if (surf->CairoStatus() != 0)
         return NS_ERROR_FAILURE;
 
     nsRefPtr<gfxContext> tmpcx = new gfxContext(surf);
     // Use Render() to make sure that appropriate y-flip gets applied
     uint32_t flags = mOptions.premultipliedAlpha ? RenderFlagPremultAlpha : 0;
     nsresult rv = Render(tmpcx, gfxPattern::FILTER_NEAREST, flags);
     if (NS_FAILED(rv))
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -2527,17 +2527,17 @@ WebGLContext::StencilOpSeparate(GLenum f
 }
 
 nsresult
 WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromElementResult& res,
                                                      gfxImageSurface **imageOut, WebGLTexelFormat *format)
 {
     if (!res.mSurface)
         return NS_ERROR_FAILURE;
-    if (res.mSurface->GetType() != gfxASurface::SurfaceTypeImage) {
+    if (res.mSurface->GetType() != gfxSurfaceTypeImage) {
         // SurfaceFromElement lied!
         return NS_ERROR_FAILURE;
     }
 
     // We disallow loading cross-domain images and videos that have not been validated
     // with CORS as WebGL textures. The reason for doing that is that timing
     // attacks on WebGL shaders are able to retrieve approximations of the
     // pixel values in WebGL textures; see bug 655987.
@@ -2573,26 +2573,26 @@ WebGLContext::SurfaceFromElementResultTo
     // texture sources in the first place.
 
     gfxImageSurface* surf = static_cast<gfxImageSurface*>(res.mSurface.get());
 
     res.mSurface.forget();
     *imageOut = surf;
 
     switch (surf->Format()) {
-        case gfxASurface::ImageFormatARGB32:
+        case gfxImageFormatARGB32:
             *format = WebGLTexelConversions::BGRA8; // careful, our ARGB means BGRA
             break;
-        case gfxASurface::ImageFormatRGB24:
+        case gfxImageFormatRGB24:
             *format = WebGLTexelConversions::BGRX8; // careful, our RGB24 is not tightly packed. Whence BGRX8.
             break;
-        case gfxASurface::ImageFormatA8:
+        case gfxImageFormatA8:
             *format = WebGLTexelConversions::A8;
             break;
-        case gfxASurface::ImageFormatRGB16_565:
+        case gfxImageFormatRGB16_565:
             *format = WebGLTexelConversions::RGB565;
             break;
         default:
             NS_ASSERTION(false, "Unsupported image format. Unimplemented.");
             return NS_ERROR_NOT_IMPLEMENTED;
     }
 
     return NS_OK;
--- a/content/html/content/src/HTMLCanvasElement.cpp
+++ b/content/html/content/src/HTMLCanvasElement.cpp
@@ -393,17 +393,17 @@ HTMLCanvasElement::ExtractData(const nsA
                                bool& aFellBackToPNG)
 {
   // note that if we don't have a current context, the spec says we're
   // supposed to just return transparent black pixels of the canvas
   // dimensions.
   nsRefPtr<gfxImageSurface> emptyCanvas;
   nsIntSize size = GetWidthHeight();
   if (!mCurrentContext) {
-    emptyCanvas = new gfxImageSurface(gfxIntSize(size.width, size.height), gfxASurface::ImageFormatARGB32);
+    emptyCanvas = new gfxImageSurface(gfxIntSize(size.width, size.height), gfxImageFormatARGB32);
     if (emptyCanvas->CairoStatus()) {
       return NS_ERROR_INVALID_ARG;
     }
   }
 
   nsresult rv;
 
   // get image bytes
--- a/content/media/plugins/MediaPluginReader.cpp
+++ b/content/media/plugins/MediaPluginReader.cpp
@@ -358,17 +358,17 @@ MediaPluginReader::ImageBufferCallback::
     return nullptr;
   }
 
   nsRefPtr<Image> rgbImage;
   switch(aColorFormat) {
     case MPAPI::RGB565:
       rgbImage = mozilla::layers::CreateSharedRGBImage(mImageContainer,
                                                        nsIntSize(aWidth, aHeight),
-                                                       gfxASurface::ImageFormatRGB16_565);
+                                                       gfxImageFormatRGB16_565);
       if (!rgbImage) {
         NS_WARNING("Could not create rgb image");
         return nullptr;
       }
 
       mImage = rgbImage;
       return rgbImage->AsSharedImage()->GetBuffer();
     case MPAPI::YCbCr:
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -150,19 +150,19 @@ nsSVGFE::SetupScalingFilter(nsSVGFilterI
 
   // Rounding in the code above can mean that result.mDataRect is not contained
   // within the bounds of the surfaces that we're about to create. We must
   // clamp to these bounds to prevent out-of-bounds reads and writes:
   result.mDataRect.IntersectRect(result.mDataRect,
                                  nsIntRect(nsIntPoint(), scaledSize));
 
   result.mSource = new gfxImageSurface(scaledSize,
-                                       gfxASurface::ImageFormatARGB32);
+                                       gfxImageFormatARGB32);
   result.mTarget = new gfxImageSurface(scaledSize,
-                                       gfxASurface::ImageFormatARGB32);
+                                       gfxImageFormatARGB32);
   if (!result.mSource || result.mSource->CairoStatus() ||
       !result.mTarget || result.mTarget->CairoStatus()) {
     result.mSource = nullptr;
     result.mTarget = nullptr;
     return result;
   }
 
   CopyAndScaleDeviceOffset(aSource->mImage, result.mSource, kernelX, kernelY);
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -2677,17 +2677,17 @@ void nsPluginInstanceOwner::Paint(gfxCon
 #ifdef ANP_BITMAP_DRAWING_MODEL
   static nsRefPtr<gfxImageSurface> pluginSurface;
 
   if (pluginSurface == nullptr ||
       aFrameRect.width  != pluginSurface->Width() ||
       aFrameRect.height != pluginSurface->Height()) {
 
     pluginSurface = new gfxImageSurface(gfxIntSize(aFrameRect.width, aFrameRect.height), 
-                                        gfxImageSurface::ImageFormatARGB32);
+                                        gfxImageFormatARGB32);
     if (!pluginSurface)
       return;
   }
 
   // Clears buffer.  I think this is needed.
   nsRefPtr<gfxContext> ctx = new gfxContext(pluginSurface);
   ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
   ctx->Paint();
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -130,17 +130,17 @@ PluginInstanceChild::PluginInstanceChild
 #endif
     , mLayersRendering(false)
 #ifdef XP_WIN
     , mCurrentSurfaceActor(NULL)
     , mBackSurfaceActor(NULL)
 #endif
     , mAccumulatedInvalidRect(0,0,0,0)
     , mIsTransparent(false)
-    , mSurfaceType(gfxASurface::SurfaceTypeMax)
+    , mSurfaceType(gfxSurfaceTypeMax)
     , mCurrentInvalidateTask(nullptr)
     , mCurrentAsyncSetWindowTask(nullptr)
     , mPendingPluginCall(false)
     , mDoAlphaExtraction(false)
     , mHasPainted(false)
     , mSurfaceDifferenceRect(0,0,0,0)
 {
     memset(&mWindow, 0, sizeof(mWindow));
@@ -2765,36 +2765,36 @@ static inline gfxRect
 GfxFromNsRect(const nsIntRect& aRect)
 {
     return gfxRect(aRect.x, aRect.y, aRect.width, aRect.height);
 }
 
 bool
 PluginInstanceChild::CreateOptSurface(void)
 {
-    NS_ABORT_IF_FALSE(mSurfaceType != gfxASurface::SurfaceTypeMax,
+    NS_ABORT_IF_FALSE(mSurfaceType != gfxSurfaceTypeMax,
                       "Need a valid surface type here");
     NS_ASSERTION(!mCurrentSurface, "mCurrentSurfaceActor can get out of sync.");
 
     nsRefPtr<gfxASurface> retsurf;
     // Use an opaque surface unless we're transparent and *don't* have
     // a background to source from.
-    gfxASurface::gfxImageFormat format =
-        (mIsTransparent && !mBackground) ? gfxASurface::ImageFormatARGB32 :
-                                           gfxASurface::ImageFormatRGB24;
+    gfxImageFormat format =
+        (mIsTransparent && !mBackground) ? gfxImageFormatARGB32 :
+                                           gfxImageFormatRGB24;
 
 #ifdef MOZ_X11
     Display* dpy = mWsInfo.display;
     Screen* screen = DefaultScreenOfDisplay(dpy);
-    if (format == gfxASurface::ImageFormatRGB24 &&
+    if (format == gfxImageFormatRGB24 &&
         DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
-        format = gfxASurface::ImageFormatRGB16_565;
+        format = gfxImageFormatRGB16_565;
     }
 
-    if (mSurfaceType == gfxASurface::SurfaceTypeXlib) {
+    if (mSurfaceType == gfxSurfaceTypeXlib) {
         if (!mIsTransparent  || mBackground) {
             Visual* defaultVisual = DefaultVisualOfScreen(screen);
             mCurrentSurface =
                 gfxXlibSurface::Create(screen, defaultVisual,
                                        gfxIntSize(mWindow.width,
                                                   mWindow.height));
             return mCurrentSurface != nullptr;
         }
@@ -2808,18 +2808,18 @@ PluginInstanceChild::CreateOptSurface(vo
             gfxXlibSurface::Create(screen, xfmt,
                                    gfxIntSize(mWindow.width,
                                               mWindow.height));
         return mCurrentSurface != nullptr;
     }
 #endif
 
 #ifdef XP_WIN
-    if (mSurfaceType == gfxASurface::SurfaceTypeWin32 ||
-        mSurfaceType == gfxASurface::SurfaceTypeD2D) {
+    if (mSurfaceType == gfxSurfaceTypeWin32 ||
+        mSurfaceType == gfxSurfaceTypeD2D) {
         bool willHaveTransparentPixels = mIsTransparent && !mBackground;
 
         SharedDIBSurface* s = new SharedDIBSurface();
         if (!s->Create(reinterpret_cast<HDC>(mWindow.window),
                        mWindow.width, mWindow.height,
                        willHaveTransparentPixels))
             return false;
 
@@ -2848,27 +2848,27 @@ PluginInstanceChild::MaybeCreatePlatform
     bool supportNonDefaultVisual = false;
     Screen* screen = DefaultScreenOfDisplay(mWsInfo.display);
     Visual* defaultVisual = DefaultVisualOfScreen(screen);
     Visual* visual = nullptr;
     Colormap colormap = 0;
     mDoAlphaExtraction = false;
     bool createHelperSurface = false;
 
-    if (mCurrentSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
+    if (mCurrentSurface->GetType() == gfxSurfaceTypeXlib) {
         static_cast<gfxXlibSurface*>(mCurrentSurface.get())->
             GetColormapAndVisual(&colormap, &visual);
         // Create helper surface if layer surface visual not same as default
         // and we don't support non-default visual rendering
         if (!visual || (defaultVisual != visual && !supportNonDefaultVisual)) {
             createHelperSurface = true;
             visual = defaultVisual;
             mDoAlphaExtraction = mIsTransparent;
         }
-    } else if (mCurrentSurface->GetType() == gfxASurface::SurfaceTypeImage) {
+    } else if (mCurrentSurface->GetType() == gfxSurfaceTypeImage) {
         // For image layer surface we should always create helper surface
         createHelperSurface = true;
         // Check if we can create helper surface with non-default visual
         visual = gfxXlibSurface::FindVisual(screen,
             static_cast<gfxImageSurface*>(mCurrentSurface.get())->Format());
         if (!visual || (defaultVisual != visual && !supportNonDefaultVisual)) {
             visual = defaultVisual;
             mDoAlphaExtraction = mIsTransparent;
@@ -2911,19 +2911,19 @@ PluginInstanceChild::EnsureCurrentBuffer
                                nsIntRect(0, 0, winSize.width, winSize.height));
     }
 
     if (mCurrentSurface) {
         gfxIntSize surfSize = mCurrentSurface->GetSize();
         if (winSize != surfSize ||
             (mBackground && !CanPaintOnBackground()) ||
             (mBackground &&
-             gfxASurface::CONTENT_COLOR != mCurrentSurface->GetContentType()) ||
+             GFX_CONTENT_COLOR != mCurrentSurface->GetContentType()) ||
             (!mBackground && mIsTransparent &&
-             gfxASurface::CONTENT_COLOR == mCurrentSurface->GetContentType())) {
+             GFX_CONTENT_COLOR == mCurrentSurface->GetContentType())) {
             // Don't try to use an old, invalid DC.
             mWindow.window = nullptr;
             ClearCurrentSurface();
             toInvalidate.UnionRect(toInvalidate,
                                    nsIntRect(0, 0, winSize.width, winSize.height));
         }
     }
 
@@ -3006,17 +3006,17 @@ PluginInstanceChild::EnsureCurrentBuffer
 void
 PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow)
 {
     nsRefPtr<gfxASurface> curSurface = mHelperSurface ? mHelperSurface : mCurrentSurface;
     bool needWindowUpdate = aForceSetWindow;
 #ifdef MOZ_X11
     Visual* visual = nullptr;
     Colormap colormap = 0;
-    if (curSurface && curSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
+    if (curSurface && curSurface->GetType() == gfxSurfaceTypeXlib) {
         static_cast<gfxXlibSurface*>(curSurface.get())->
             GetColormapAndVisual(&colormap, &visual);
         if (visual != mWsInfo.visual || colormap != mWsInfo.colormap) {
             mWsInfo.visual = visual;
             mWsInfo.colormap = colormap;
             needWindowUpdate = true;
         }
     }
@@ -3098,17 +3098,17 @@ PluginInstanceChild::UpdateWindowAttribu
 void
 PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect,
                                                 gfxASurface* aSurface)
 {
     UpdateWindowAttributes();
 
 #ifdef MOZ_X11
     {
-        NS_ASSERTION(aSurface->GetType() == gfxASurface::SurfaceTypeXlib,
+        NS_ASSERTION(aSurface->GetType() == gfxSurfaceTypeXlib,
                      "Non supported platform surface type");
 
         NPEvent pluginEvent;
         XGraphicsExposeEvent& exposeEvent = pluginEvent.xgraphicsexpose;
         exposeEvent.type = GraphicsExpose;
         exposeEvent.display = mWsInfo.display;
         exposeEvent.drawable = static_cast<gfxXlibSurface*>(aSurface)->XDrawable();
         exposeEvent.x = aRect.x;
@@ -3192,29 +3192,29 @@ PluginInstanceChild::PaintRectToSurface(
         ctx->Fill();
     }
 }
 
 void
 PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
                                                   gfxASurface* aSurface)
 {
-    NS_ABORT_IF_FALSE(aSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA,
+    NS_ABORT_IF_FALSE(aSurface->GetContentType() == GFX_CONTENT_COLOR_ALPHA,
                       "Refusing to pointlessly recover alpha");
 
     nsIntRect rect(aRect);
     // If |aSurface| can be used to paint and can have alpha values
     // recovered directly to it, do that to save a tmp surface and
     // copy.
     bool useSurfaceSubimageForBlack = false;
-    if (gfxASurface::SurfaceTypeImage == aSurface->GetType()) {
+    if (gfxSurfaceTypeImage == aSurface->GetType()) {
         gfxImageSurface* surfaceAsImage =
             static_cast<gfxImageSurface*>(aSurface);
         useSurfaceSubimageForBlack =
-            (surfaceAsImage->Format() == gfxASurface::ImageFormatARGB32);
+            (surfaceAsImage->Format() == gfxImageFormatARGB32);
         // If we're going to use a subimage, nudge the rect so that we
         // can use optimal alpha recovery.  If we're not using a
         // subimage, the temporaries should automatically get
         // fast-path alpha recovery so we don't need to do anything.
         if (useSurfaceSubimageForBlack) {
             rect =
                 gfxAlphaRecovery::AlignRectForSubimageRecovery(aRect,
                                                                surfaceAsImage);
@@ -3223,17 +3223,17 @@ PluginInstanceChild::PaintRectWithAlphaE
 
     nsRefPtr<gfxImageSurface> whiteImage;
     nsRefPtr<gfxImageSurface> blackImage;
     gfxRect targetRect(rect.x, rect.y, rect.width, rect.height);
     gfxIntSize targetSize(rect.width, rect.height);
     gfxPoint deviceOffset = -targetRect.TopLeft();
 
     // We always use a temporary "white image"
-    whiteImage = new gfxImageSurface(targetSize, gfxASurface::ImageFormatRGB24);
+    whiteImage = new gfxImageSurface(targetSize, gfxImageFormatRGB24);
     if (whiteImage->CairoStatus()) {
         return;
     }
 
 #ifdef XP_WIN
     // On windows, we need an HDC and so can't paint directly to
     // vanilla image surfaces.  Bifurcate this painting code so that
     // we don't accidentally attempt that.
@@ -3266,17 +3266,17 @@ PluginInstanceChild::PaintRectWithAlphaE
     whiteImage->SetDeviceOffset(deviceOffset);
     PaintRectToSurface(rect, whiteImage, gfxRGBA(1.0, 1.0, 1.0));
 
     if (useSurfaceSubimageForBlack) {
         gfxImageSurface *surface = static_cast<gfxImageSurface*>(aSurface);
         blackImage = surface->GetSubimage(targetRect);
     } else {
         blackImage = new gfxImageSurface(targetSize,
-                                         gfxASurface::ImageFormatARGB32);
+                                         gfxImageFormatARGB32);
     }
 
     // Paint onto black background
     blackImage->SetDeviceOffset(deviceOffset);
     PaintRectToSurface(rect, blackImage, gfxRGBA(0.0, 0.0, 0.0));
 #endif
 
     NS_ABORT_IF_FALSE(whiteImage && blackImage, "Didn't paint enough!");
@@ -3410,17 +3410,17 @@ PluginInstanceChild::ShowPluginFrame()
     if (!ReadbackDifferenceRect(rect)) {
         // We couldn't read back the pixels that differ between the
         // current surface and last, so we have to invalidate the
         // entire window.
         rect.SetRect(0, 0, mWindow.width, mWindow.height);
     }
 
     bool haveTransparentPixels =
-        gfxASurface::CONTENT_COLOR_ALPHA == mCurrentSurface->GetContentType();
+        GFX_CONTENT_COLOR_ALPHA == mCurrentSurface->GetContentType();
     PLUGIN_LOG_DEBUG(
         ("[InstanceChild][%p] Painting%s <x=%d,y=%d, w=%d,h=%d> on surface <w=%d,h=%d>",
          this, haveTransparentPixels ? " with alpha" : "",
          rect.x, rect.y, rect.width, rect.height,
          mCurrentSurface->GetSize().width, mCurrentSurface->GetSize().height));
 
     if (CanPaintOnBackground()) {
         PLUGIN_LOG_DEBUG(("  (on background)"));
@@ -3476,17 +3476,17 @@ PluginInstanceChild::ShowPluginFrame()
         mAccumulatedInvalidRect.SetRect(0, 0, mWindow.width, mWindow.height);
         return true;
     }
 
     NPRect r = { (uint16_t)rect.y, (uint16_t)rect.x,
                  (uint16_t)rect.YMost(), (uint16_t)rect.XMost() };
     SurfaceDescriptor currSurf;
 #ifdef MOZ_X11
-    if (mCurrentSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
+    if (mCurrentSurface->GetType() == gfxSurfaceTypeXlib) {
         gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(mCurrentSurface.get());
         currSurf = SurfaceDescriptorX11(xsurf);
         // Need to sync all pending x-paint requests
         // before giving drawable to another process
         XSync(mWsInfo.display, False);
     } else
 #endif
 #ifdef XP_WIN
@@ -3528,17 +3528,17 @@ bool
 PluginInstanceChild::ReadbackDifferenceRect(const nsIntRect& rect)
 {
     if (!mBackSurface)
         return false;
 
     // We can read safely from XSurface,SharedDIBSurface and Unsafe SharedMemory,
     // because PluginHost is not able to modify that surface
 #if defined(MOZ_X11)
-    if (mBackSurface->GetType() != gfxASurface::SurfaceTypeXlib &&
+    if (mBackSurface->GetType() != gfxSurfaceTypeXlib &&
         !gfxSharedImageSurface::IsSharedImage(mBackSurface))
         return false;
 #elif defined(XP_WIN)
     if (!SharedDIBSurface::IsSharedDIBSurface(mBackSurface))
         return false;
 #else
     return false;
 #endif
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -601,17 +601,17 @@ PluginInstanceParent::RecvShow(const NPR
     }
 #endif
 
     if (mFrontSurface) {
         // This is the "old front buffer" we're about to hand back to
         // the plugin.  We might still have drawing operations
         // referencing it.
 #ifdef MOZ_X11
-        if (mFrontSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
+        if (mFrontSurface->GetType() == gfxSurfaceTypeXlib) {
             // Finish with the surface and XSync here to ensure the server has
             // finished operations on the surface before the plugin starts
             // scribbling on it again, or worse, destroys it.
             mFrontSurface->Finish();
             FinishX(DefaultXDisplay());
         } else 
 #endif
         {
@@ -874,17 +874,17 @@ PluginInstanceParent::CreateBackground(c
 
 #elif defined(XP_WIN)
     // We have chosen to create an unsafe surface in which the plugin
     // can read from the region while we're writing to it.
     mBackground =
         gfxSharedImageSurface::CreateUnsafe(
             this,
             gfxIntSize(aSize.width, aSize.height),
-            gfxASurface::ImageFormatRGB24);
+            gfxImageFormatRGB24);
     return !!mBackground;
 #else
     return nullptr;
 #endif
 }
 
 void
 PluginInstanceParent::DestroyBackground()
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -1858,17 +1858,17 @@ GLContext::GetTexImage(GLuint aTexture, 
     GuaranteeResolve();
     fActiveTexture(LOCAL_GL_TEXTURE0);
     fBindTexture(LOCAL_GL_TEXTURE_2D, aTexture);
 
     gfxIntSize size;
     fGetTexLevelParameteriv(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_TEXTURE_WIDTH, &size.width);
     fGetTexLevelParameteriv(LOCAL_GL_TEXTURE_2D, 0, LOCAL_GL_TEXTURE_HEIGHT, &size.height);
 
-    nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(size, gfxASurface::ImageFormatARGB32);
+    nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(size, gfxImageFormatARGB32);
     if (!surf || surf->CairoStatus()) {
         return nullptr;
     }
 
     uint32_t currentPackAlignment = 0;
     fGetIntegerv(LOCAL_GL_PACK_ALIGNMENT, (GLint*)&currentPackAlignment);
     if (currentPackAlignment != 4) {
         fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 4);
@@ -1982,17 +1982,17 @@ GLContext::ReadTextureImage(GLuint aText
 
     fUniform1i(fGetUniformLocation(prog, "uTexture"), 0);
 
     fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
 
     fDisableVertexAttribArray(1);
     fDisableVertexAttribArray(0);
 
-    isurf = new gfxImageSurface(aSize, gfxASurface::ImageFormatARGB32);
+    isurf = new gfxImageSurface(aSize, gfxImageFormatARGB32);
     if (!isurf || isurf->CairoStatus()) {
         isurf = nullptr;
         goto cleanup;
     }
 
     if (oldPackAlignment != 4)
         fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 4);
 
@@ -2086,41 +2086,41 @@ GLContext::ReadScreenIntoImageSurface(gf
 }
 
 void
 GLContext::ReadPixelsIntoImageSurface(gfxImageSurface* dest)
 {
     MakeCurrent();
     MOZ_ASSERT(dest->GetSize() != gfxIntSize(0, 0));
 
-    /* ImageFormatARGB32:
+    /* gfxImageFormatARGB32:
      * RGBA+UByte: be[RGBA], le[ABGR]
      * RGBA+UInt: le[RGBA]
      * BGRA+UInt: le[BGRA]
      * BGRA+UIntRev: le[ARGB]
      *
-     * ImageFormatRGB16_565:
+     * gfxImageFormatRGB16_565:
      * RGB+UShort: le[rrrrrggg,gggbbbbb]
      */
-    bool hasAlpha = dest->Format() == gfxASurface::ImageFormatARGB32;
+    bool hasAlpha = dest->Format() == gfxImageFormatARGB32;
 
     int destPixelSize;
     GLenum destFormat;
     GLenum destType;
 
     switch (dest->Format()) {
-        case gfxASurface::ImageFormatRGB24: // XRGB
-        case gfxASurface::ImageFormatARGB32:
+        case gfxImageFormatRGB24: // XRGB
+        case gfxImageFormatARGB32:
             destPixelSize = 4;
             // Needs host (little) endian ARGB.
             destFormat = LOCAL_GL_BGRA;
             destType = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             break;
 
-        case gfxASurface::ImageFormatRGB16_565:
+        case gfxImageFormatRGB16_565:
             destPixelSize = 2;
             destFormat = LOCAL_GL_RGB;
             destType = LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV;
             break;
 
         default:
             MOZ_CRASH("Bad format.");
     }
@@ -2139,24 +2139,24 @@ GLContext::ReadPixelsIntoImageSurface(gf
         if (DebugMode()) {
             NS_WARNING("Needing intermediary surface for ReadPixels. This will be slow!");
         }
         ImageFormat readFormatGFX;
 
         switch (readFormat) {
             case LOCAL_GL_RGBA:
             case LOCAL_GL_BGRA: {
-                readFormatGFX = hasAlpha ? gfxASurface::ImageFormatARGB32
-                                         : gfxASurface::ImageFormatRGB24;
+                readFormatGFX = hasAlpha ? gfxImageFormatARGB32
+                                         : gfxImageFormatRGB24;
                 break;
             }
             case LOCAL_GL_RGB: {
                 MOZ_ASSERT(readPixelSize == 2);
                 MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV);
-                readFormatGFX = gfxASurface::ImageFormatRGB16_565;
+                readFormatGFX = gfxImageFormatRGB16_565;
                 break;
             }
             default: {
                 MOZ_CRASH("Bad read format.");
             }
         }
 
         switch (readType) {
@@ -2222,17 +2222,17 @@ GLContext::ReadPixelsIntoImageSurface(gf
         ctx.Paint();
     }
 
     // Check if GL is giving back 1.0 alpha for
     // RGBA reads to RGBA images from no-alpha buffers.
 #ifdef XP_MACOSX
     if (WorkAroundDriverBugs() &&
         mVendor == VendorNVIDIA &&
-        dest->Format() == gfxASurface::ImageFormatARGB32 &&
+        dest->Format() == gfxImageFormatARGB32 &&
         width && height)
     {
         GLint alphaBits = 0;
         fGetIntegerv(LOCAL_GL_ALPHA_BITS, &alphaBits);
         if (!alphaBits) {
             const uint32_t alphaMask = gfxPackedPixelNoPreMultiply(0xff,0,0,0);
 
             dest->Flush();
@@ -2392,27 +2392,27 @@ GLContext::BlitTextureImage(TextureImage
 
     fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, savedFb);
 
     fEnable(LOCAL_GL_SCISSOR_TEST);
     fEnable(LOCAL_GL_BLEND);
 }
 
 static unsigned int
-DataOffset(const nsIntPoint &aPoint, int32_t aStride, gfxASurface::gfxImageFormat aFormat)
+DataOffset(const nsIntPoint &aPoint, int32_t aStride, gfxImageFormat aFormat)
 {
   unsigned int data = aPoint.y * aStride;
   data += aPoint.x * gfxASurface::BytePerPixelFromFormat(aFormat);
   return data;
 }
 
 GLContext::SurfaceFormat
 GLContext::UploadImageDataToTexture(unsigned char* aData,
                                     int32_t aStride,
-                                    gfxASurface::gfxImageFormat aFormat,
+                                    gfxImageFormat aFormat,
                                     const nsIntRegion& aDstRegion,
                                     GLuint& aTexture,
                                     bool aOverwrite,
                                     bool aPixelBuffer,
                                     GLenum aTextureUnit,
                                     GLenum aTextureTarget)
 {
     bool textureInited = aOverwrite ? false : true;
@@ -2450,48 +2450,48 @@ GLContext::UploadImageDataToTexture(unsi
     GLenum internalFormat;
     GLenum type;
     int32_t pixelSize = gfxASurface::BytePerPixelFromFormat(aFormat);
     SurfaceFormat surfaceFormat;
 
     MOZ_ASSERT(GetPreferredARGB32Format() == LOCAL_GL_BGRA ||
                GetPreferredARGB32Format() == LOCAL_GL_RGBA);
     switch (aFormat) {
-        case gfxASurface::ImageFormatARGB32:
+        case gfxImageFormatARGB32:
             if (GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
               format = LOCAL_GL_BGRA;
               surfaceFormat = FORMAT_R8G8B8A8;
               type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             } else {
               format = LOCAL_GL_RGBA;
               surfaceFormat = FORMAT_B8G8R8A8;
               type = LOCAL_GL_UNSIGNED_BYTE;
             }
             internalFormat = LOCAL_GL_RGBA;
             break;
-        case gfxASurface::ImageFormatRGB24:
+        case gfxImageFormatRGB24:
             // Treat RGB24 surfaces as RGBA32 except for the surface
             // format used.
             if (GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
               format = LOCAL_GL_BGRA;
               surfaceFormat = FORMAT_R8G8B8X8;
               type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
             } else {
               format = LOCAL_GL_RGBA;
               surfaceFormat = FORMAT_B8G8R8X8;
               type = LOCAL_GL_UNSIGNED_BYTE;
             }
             internalFormat = LOCAL_GL_RGBA;
             break;
-        case gfxASurface::ImageFormatRGB16_565:
+        case gfxImageFormatRGB16_565:
             internalFormat = format = LOCAL_GL_RGB;
             type = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
             surfaceFormat = FORMAT_R5G6B5;
             break;
-        case gfxASurface::ImageFormatA8:
+        case gfxImageFormatA8:
             internalFormat = format = LOCAL_GL_LUMINANCE;
             type = LOCAL_GL_UNSIGNED_BYTE;
             // We don't have a specific luminance shader
             surfaceFormat = FORMAT_A8;
             break;
         default:
             NS_ASSERTION(false, "Unhandled image surface format!");
             format = 0;
@@ -2556,25 +2556,25 @@ GLContext::UploadSurfaceToTexture(gfxASu
                                   GLenum aTextureUnit,
                                   GLenum aTextureTarget)
 {
 
     nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
     unsigned char* data = nullptr;
 
     if (!imageSurface ||
-        (imageSurface->Format() != gfxASurface::ImageFormatARGB32 &&
-         imageSurface->Format() != gfxASurface::ImageFormatRGB24 &&
-         imageSurface->Format() != gfxASurface::ImageFormatRGB16_565 &&
-         imageSurface->Format() != gfxASurface::ImageFormatA8)) {
+        (imageSurface->Format() != gfxImageFormatARGB32 &&
+         imageSurface->Format() != gfxImageFormatRGB24 &&
+         imageSurface->Format() != gfxImageFormatRGB16_565 &&
+         imageSurface->Format() != gfxImageFormatA8)) {
         // We can't get suitable pixel data for the surface, make a copy
         nsIntRect bounds = aDstRegion.GetBounds();
         imageSurface =
           new gfxImageSurface(gfxIntSize(bounds.width, bounds.height),
-                              gfxASurface::ImageFormatARGB32);
+                              gfxImageFormatARGB32);
 
         nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
 
         context->Translate(-gfxPoint(aSrcPoint.x, aSrcPoint.y));
         context->SetSource(aSurface);
         context->Paint();
         data = imageSurface->Data();
         NS_ASSERTION(!aPixelBuffer,
@@ -2594,46 +2594,46 @@ GLContext::UploadSurfaceToTexture(gfxASu
 
     return UploadImageDataToTexture(data,
                                     imageSurface->Stride(),
                                     imageSurface->Format(),
                                     aDstRegion, aTexture, aOverwrite,
                                     aPixelBuffer, aTextureUnit, aTextureTarget);
 }
 
-static gfxASurface::gfxImageFormat
+static gfxImageFormat
 ImageFormatForSurfaceFormat(gfx::SurfaceFormat aFormat)
 {
     switch (aFormat) {
         case gfx::FORMAT_B8G8R8A8:
-            return gfxASurface::ImageFormatARGB32;
+            return gfxImageFormatARGB32;
         case gfx::FORMAT_B8G8R8X8:
-            return gfxASurface::ImageFormatRGB24;
+            return gfxImageFormatRGB24;
         case gfx::FORMAT_R5G6B5:
-            return gfxASurface::ImageFormatRGB16_565;
+            return gfxImageFormatRGB16_565;
         case gfx::FORMAT_A8:
-            return gfxASurface::ImageFormatA8;
+            return gfxImageFormatA8;
         default:
-            return gfxASurface::ImageFormatUnknown;
+            return gfxImageFormatUnknown;
     }
 }
 
 GLContext::SurfaceFormat
 GLContext::UploadSurfaceToTexture(gfx::DataSourceSurface *aSurface,
                                   const nsIntRegion& aDstRegion,
                                   GLuint& aTexture,
                                   bool aOverwrite,
                                   const nsIntPoint& aSrcPoint,
                                   bool aPixelBuffer,
                                   GLenum aTextureUnit,
                                   GLenum aTextureTarget)
 {
     unsigned char* data = aPixelBuffer ? nullptr : aSurface->GetData();
     int32_t stride = aSurface->Stride();
-    gfxASurface::gfxImageFormat format =
+    gfxImageFormat format =
         ImageFormatForSurfaceFormat(aSurface->GetFormat());
     data += DataOffset(aSrcPoint, stride, format);
     return UploadImageDataToTexture(data, stride, format,
                                     aDstRegion, aTexture, aOverwrite,
                                     aPixelBuffer, aTextureUnit,
                                     aTextureTarget);
 }
 
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -2280,17 +2280,17 @@ public:
 
 
 // -----------------------------------------------------------------------------
 // Everything that isn't standard GL APIs
 protected:
 
     typedef class gfx::SharedSurface SharedSurface;
     typedef gfx::SharedSurfaceType SharedSurfaceType;
-    typedef gfxASurface::gfxImageFormat ImageFormat;
+    typedef gfxImageFormat ImageFormat;
     typedef gfx::SurfaceFormat SurfaceFormat;
 
 public:
 
     virtual bool MakeCurrentImpl(bool aForce = false) = 0;
 
 #ifdef DEBUG
     static void StaticInit() {
@@ -2647,40 +2647,40 @@ public:
      * GLContext is destroyed will result in undefined (and likely
      * crashy) behavior.
      */
     virtual already_AddRefed<TextureImage>
     CreateTextureImage(const nsIntSize& aSize,
                        TextureImage::ContentType aContentType,
                        GLenum aWrapMode,
                        TextureImage::Flags aFlags = TextureImage::NoFlags,
-                       TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                       TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
 
     /**
      * In EGL we want to use Tiled Texture Images, which we return
      * from CreateTextureImage above.
      * Inside TiledTextureImage we need to create actual images and to
      * prevent infinite recursion we need to differentiate the two
      * functions.
      **/
     virtual already_AddRefed<TextureImage>
     TileGenFunc(const nsIntSize& aSize,
                 TextureImage::ContentType aContentType,
                 TextureImage::Flags aFlags = TextureImage::NoFlags,
-                TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown)
+                TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown)
     {
         return nullptr;
     }
 
     /**
      * Read the image data contained in aTexture, and return it as an ImageSurface.
-     * If GL_RGBA is given as the format, a ImageFormatARGB32 surface is returned.
+     * If GL_RGBA is given as the format, a gfxImageFormatARGB32 surface is returned.
      * Not implemented yet:
-     * If GL_RGB is given as the format, a ImageFormatRGB24 surface is returned.
-     * If GL_LUMINANCE is given as the format, a ImageFormatA8 surface is returned.
+     * If GL_RGB is given as the format, a gfxImageFormatRGB24 surface is returned.
+     * If GL_LUMINANCE is given as the format, a gfxImageFormatA8 surface is returned.
      *
      * THIS IS EXPENSIVE.  It is ridiculously expensive.  Only do this
      * if you absolutely positively must, and never in any performance
      * critical path.
      */
     already_AddRefed<gfxImageSurface> ReadTextureImage(GLuint aTexture,
                                                        const gfxIntSize& aSize,
                                                        GLenum aTextureFormat,
@@ -2757,17 +2757,17 @@ public:
      * \param aTextureUnit, the texture unit used temporarily to upload the
      *  surface. This testure may be overridden, clients should not rely on
      *  the contents of this texture after this call or even on this
      *  texture unit being active.
      * \return Surface format of this texture.
      */
     SurfaceFormat UploadImageDataToTexture(unsigned char* aData,
                                            int32_t aStride,
-                                           gfxASurface::gfxImageFormat aFormat,
+                                           gfxImageFormat aFormat,
                                            const nsIntRegion& aDstRegion,
                                            GLuint& aTexture,
                                            bool aOverwrite = false,
                                            bool aPixelBuffer = false,
                                            GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
                                            GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
 
     /**
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -181,23 +181,23 @@ public:
 
     bool ResizeOffscreen(const gfxIntSize& aNewSize);
 
     virtual already_AddRefed<TextureImage>
     CreateTextureImage(const nsIntSize& aSize,
                        TextureImage::ContentType aContentType,
                        GLenum aWrapMode,
                        TextureImage::Flags aFlags = TextureImage::NoFlags,
-                       TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown) MOZ_OVERRIDE;
+                       TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown) MOZ_OVERRIDE;
 
     virtual already_AddRefed<TextureImage>
     TileGenFunc(const nsIntSize& aSize,
                 TextureImage::ContentType aContentType,
                 TextureImage::Flags aFlags = TextureImage::NoFlags,
-                TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown) MOZ_OVERRIDE;
+                TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown) MOZ_OVERRIDE;
 
     virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
                                                    void* buffer,
                                                    SharedTextureBufferType bufferType)
     {
         return GLContextProviderCGL::CreateSharedHandle(shareType, buffer, bufferType);
     }
 
@@ -335,17 +335,17 @@ protected:
 
 private:
     TextureImageCGL(GLuint aTexture,
                     const nsIntSize& aSize,
                     GLenum aWrapMode,
                     ContentType aContentType,
                     GLContext* aContext,
                     TextureImage::Flags aFlags = TextureImage::NoFlags,
-                    TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown)
+                    TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown)
         : BasicTextureImage(aTexture, aSize, aWrapMode, aContentType,
                             aContext, aFlags, aImageFormat)
         , mPixelBuffer(0)
         , mPixelBufferSize(0)
         , mBoundPixelBuffer(false)
     {}
     
     GLuint mPixelBuffer;
@@ -542,17 +542,17 @@ GLContextProviderCGL::GetSharedHandleAsS
   surf->Lock();
   size_t bytesPerRow = surf->GetBytesPerRow();
   size_t ioWidth = surf->GetWidth();
   size_t ioHeight = surf->GetHeight();
 
   unsigned char* ioData = (unsigned char*)surf->GetBaseAddress();
 
   nsRefPtr<gfxImageSurface> imgSurface =
-    new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxASurface::ImageFormatARGB32);
+    new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxImageFormatARGB32);
 
   for (size_t i = 0; i < ioHeight; i++) {
     memcpy(imgSurface->Data() + i * imgSurface->Stride(),
            ioData + i * bytesPerRow, ioWidth * 4);
   }
 
   surf->Unlock();
 
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -606,24 +606,24 @@ public:
         }
     }
     // GLContext interface - returns Tiled Texture Image in our case
     virtual already_AddRefed<TextureImage>
     CreateTextureImage(const nsIntSize& aSize,
                        TextureImage::ContentType aContentType,
                        GLenum aWrapMode,
                        TextureImage::Flags aFlags = TextureImage::NoFlags,
-                       TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                       TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
 
     // a function to generate Tiles for Tiled Texture Image
     virtual already_AddRefed<TextureImage>
     TileGenFunc(const nsIntSize& aSize,
                 TextureImage::ContentType aContentType,
                 TextureImage::Flags aFlags = TextureImage::NoFlags,
-                TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown) MOZ_OVERRIDE;
+                TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown) MOZ_OVERRIDE;
     // hold a reference to the given surface
     // for the lifetime of this context.
     void HoldSurface(gfxASurface *aSurf) {
         mThebesSurface = aSurf;
     }
 
     void SetPlatformContext(void *context) {
         mPlatformContext = context;
@@ -1058,42 +1058,42 @@ GLContextEGL::ResizeOffscreen(const gfxI
 
 static GLContextEGL *
 GetGlobalContextEGL()
 {
     return static_cast<GLContextEGL*>(GLContextProviderEGL::GetGlobalContext());
 }
 
 static GLenum
-GLFormatForImage(gfxASurface::gfxImageFormat aFormat)
+GLFormatForImage(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-    case gfxASurface::ImageFormatARGB32:
-    case gfxASurface::ImageFormatRGB24:
+    case gfxImageFormatARGB32:
+    case gfxImageFormatRGB24:
         // Thebes only supports RGBX, not packed RGB.
         return LOCAL_GL_RGBA;
-    case gfxASurface::ImageFormatRGB16_565:
+    case gfxImageFormatRGB16_565:
         return LOCAL_GL_RGB;
-    case gfxASurface::ImageFormatA8:
+    case gfxImageFormatA8:
         return LOCAL_GL_LUMINANCE;
     default:
         NS_WARNING("Unknown GL format for Image format");
     }
     return 0;
 }
 
 static GLenum
-GLTypeForImage(gfxASurface::gfxImageFormat aFormat)
+GLTypeForImage(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-    case gfxASurface::ImageFormatARGB32:
-    case gfxASurface::ImageFormatRGB24:
-    case gfxASurface::ImageFormatA8:
+    case gfxImageFormatARGB32:
+    case gfxImageFormatRGB24:
+    case gfxImageFormatA8:
         return LOCAL_GL_UNSIGNED_BYTE;
-    case gfxASurface::ImageFormatRGB16_565:
+    case gfxImageFormatRGB16_565:
         return LOCAL_GL_UNSIGNED_SHORT_5_6_5;
     default:
         NS_WARNING("Unknown GL format for Image format");
     }
     return 0;
 }
 
 class TextureImageEGL
@@ -1102,42 +1102,42 @@ class TextureImageEGL
 public:
     TextureImageEGL(GLuint aTexture,
                     const nsIntSize& aSize,
                     GLenum aWrapMode,
                     ContentType aContentType,
                     GLContext* aContext,
                     Flags aFlags = TextureImage::NoFlags,
                     TextureState aTextureState = Created,
-                    TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown)
+                    TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown)
         : TextureImage(aSize, aWrapMode, aContentType, aFlags)
         , mGLContext(aContext)
         , mUpdateFormat(aImageFormat)
         , mEGLImage(nullptr)
         , mTexture(aTexture)
         , mSurface(nullptr)
         , mConfig(nullptr)
         , mTextureState(aTextureState)
         , mBound(false)
     {
-        if (mUpdateFormat == gfxASurface::ImageFormatUnknown) {
+        if (mUpdateFormat == gfxImageFormatUnknown) {
             mUpdateFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(GetContentType());
         }
 
         if (gUseBackingSurface) {
-            if (mUpdateFormat != gfxASurface::ImageFormatARGB32) {
+            if (mUpdateFormat != gfxImageFormatARGB32) {
                 mTextureFormat = FORMAT_R8G8B8X8;
             } else {
                 mTextureFormat = FORMAT_R8G8B8A8;
             }
             Resize(aSize);
         } else {
-            if (mUpdateFormat == gfxASurface::ImageFormatRGB16_565) {
+            if (mUpdateFormat == gfxImageFormatRGB16_565) {
                 mTextureFormat = FORMAT_R8G8B8X8;
-            } else if (mUpdateFormat == gfxASurface::ImageFormatRGB24) {
+            } 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 = FORMAT_B8G8R8X8;
             } else {
                 mTextureFormat = FORMAT_B8G8R8A8;
             }
         }
@@ -1217,17 +1217,17 @@ public:
     }
 
     virtual void EndUpdate()
     {
         NS_ASSERTION(!!mUpdateSurface, "EndUpdate() without BeginUpdate()?");
 
         if (mBackingSurface && mUpdateSurface == mBackingSurface) {
 #ifdef MOZ_X11
-            if (mBackingSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
+            if (mBackingSurface->GetType() == gfxSurfaceTypeXlib) {
                 FinishX(DefaultXDisplay());
             }
 #endif
 
             mBackingSurface->SetDeviceOffset(gfxPoint(0, 0));
             mTextureState = Valid;
             mUpdateSurface = nullptr;
             return;
@@ -1242,17 +1242,17 @@ public:
         // Undo the device offset that BeginUpdate set; doesn't much
         // matter for us here, but important if we ever do anything
         // directly with the surface.
         mUpdateSurface->SetDeviceOffset(gfxPoint(0, 0));
 
         nsRefPtr<gfxImageSurface> uploadImage = nullptr;
         gfxIntSize updateSize(mUpdateRect.width, mUpdateRect.height);
 
-        NS_ASSERTION(mUpdateSurface->GetType() == gfxASurface::SurfaceTypeImage &&
+        NS_ASSERTION(mUpdateSurface->GetType() == gfxSurfaceTypeImage &&
                      mUpdateSurface->GetSize() == updateSize,
                      "Upload image isn't an image surface when one is expected, or is wrong size!");
 
         uploadImage = static_cast<gfxImageSurface*>(mUpdateSurface.get());
 
         if (!uploadImage) {
             return;
         }
@@ -1413,17 +1413,17 @@ public:
     virtual bool CreateEGLSurface(gfxASurface* aSurface)
     {
 #ifdef MOZ_X11
         if (!aSurface) {
             NS_WARNING("no surface");
             return false;
         }
 
-        if (aSurface->GetType() != gfxASurface::SurfaceTypeXlib) {
+        if (aSurface->GetType() != gfxSurfaceTypeXlib) {
             NS_WARNING("wrong surface type, must be xlib");
             return false;
         }
 
         if (mSurface) {
             return true;
         }
 
@@ -1503,17 +1503,17 @@ public:
 
         return mBackingSurface != nullptr;
 #endif
 
         return mBackingSurface != nullptr;
     }
 
 protected:
-    typedef gfxASurface::gfxImageFormat ImageFormat;
+    typedef gfxImageFormat ImageFormat;
 
     GLContext* mGLContext;
 
     nsIntRect mUpdateRect;
     ImageFormat mUpdateFormat;
     bool mUsingDirectTexture;
     nsRefPtr<gfxASurface> mBackingSurface;
     nsRefPtr<gfxASurface> mUpdateSurface;
@@ -1850,17 +1850,17 @@ GLContextEGL::CreateEGLPBufferOffscreenC
 }
 
 #ifdef MOZ_X11
 EGLSurface
 CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig)
 {
     gfxXlibSurface* xsurface = static_cast<gfxXlibSurface*>(aSurface);
     bool opaque =
-        aSurface->GetContentType() == gfxASurface::CONTENT_COLOR;
+        aSurface->GetContentType() == GFX_CONTENT_COLOR;
 
     static EGLint pixmap_config_rgb[] = {
         LOCAL_EGL_TEXTURE_TARGET,       LOCAL_EGL_TEXTURE_2D,
         LOCAL_EGL_TEXTURE_FORMAT,       LOCAL_EGL_TEXTURE_RGB,
         LOCAL_EGL_NONE
     };
 
     static EGLint pixmap_config_rgba[] = {
@@ -1936,17 +1936,17 @@ GLContextEGL::CreateEGLPixmapOffscreenCo
 {
     gfxASurface *thebesSurface = nullptr;
     EGLNativePixmapType pixmap = 0;
 
 #ifdef MOZ_X11
     nsRefPtr<gfxXlibSurface> xsurface =
         gfxXlibSurface::Create(DefaultScreenOfDisplay(DefaultXDisplay()),
                                gfxXlibSurface::FindRenderFormat(DefaultXDisplay(),
-                                                                gfxASurface::ImageFormatRGB24),
+                                                                gfxImageFormatRGB24),
                                size);
 
     // XSync required after gfxXlibSurface::Create, otherwise EGL will fail with BadDrawable error
     XSync(DefaultXDisplay(), False);
     if (xsurface->CairoStatus() != 0)
         return nullptr;
 
     thebesSurface = xsurface;
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -274,17 +274,17 @@ GLXLibrary::EnsureInitialized(LibType li
 
 bool
 GLXLibrary::SupportsTextureFromPixmap(gfxASurface* aSurface)
 {
     if (!EnsureInitialized(mLibType)) {
         return false;
     }
     
-    if (aSurface->GetType() != gfxASurface::SurfaceTypeXlib || !mUseTextureFromPixmap) {
+    if (aSurface->GetType() != gfxSurfaceTypeXlib || !mUseTextureFromPixmap) {
         return false;
     }
 
     return true;
 }
 
 GLXPixmap 
 GLXLibrary::CreatePixmap(gfxASurface* aSurface)
@@ -940,17 +940,17 @@ TRY_AGAIN_NO_SHARING:
         return false;
     }
 
     virtual already_AddRefed<TextureImage>
     CreateTextureImage(const nsIntSize& aSize,
                        TextureImage::ContentType aContentType,
                        GLenum aWrapMode,
                        TextureImage::Flags aFlags = TextureImage::NoFlags,
-                       TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                       TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
 
 private:
     friend class GLContextProviderGLX;
 
     GLContextGLX(const SurfaceCaps& caps,
                  GLContext* shareContext,
                  bool isOffscreen,
                  Display *aDisplay,
@@ -1064,17 +1064,17 @@ private:
         : TextureImage(aSize, aWrapMode, aContentType, aFlags)
         , mGLContext(aContext)
         , mUpdateSurface(aSurface)
         , mPixmap(aPixmap)
         , mInUpdate(false)
         , mTexture(aTexture)
         , sGLXLib(sGLXLibrary[aLibType])
     {
-        if (aSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
+        if (aSurface->GetContentType() == GFX_CONTENT_COLOR_ALPHA) {
             mTextureFormat = FORMAT_R8G8B8A8;
         } else {
             mTextureFormat = FORMAT_R8G8B8X8;
         }
     }
 
     nsRefPtr<GLContext> mGLContext;
     nsRefPtr<gfxASurface> mUpdateSurface;
@@ -1101,42 +1101,42 @@ GLContextGLX::CreateTextureImage(const n
                                              aContentType, 
                                              aWrapMode, 
                                              aFlags,
                                              aImageFormat);
     }
 
     Display *display = DefaultXDisplay();
     int xscreen = DefaultScreen(display);
-    gfxASurface::gfxImageFormat imageFormat =
+    gfxImageFormat imageFormat =
         gfxPlatform::GetPlatform()->OptimalFormatForContent(aContentType);
 
     XRenderPictFormat* xrenderFormat =
         gfxXlibSurface::FindRenderFormat(display, imageFormat);
     NS_ASSERTION(xrenderFormat, "Could not find a render format for our display!");
 
 
     nsRefPtr<gfxXlibSurface> surface =
         gfxXlibSurface::Create(ScreenOfDisplay(display, xscreen),
                                xrenderFormat,
                                gfxIntSize(aSize.width, aSize.height));
 
     NS_ASSERTION(surface, "Failed to create xlib surface!");
 
-    if (aContentType == gfxASurface::CONTENT_COLOR_ALPHA) {
+    if (aContentType == GFX_CONTENT_COLOR_ALPHA) {
         nsRefPtr<gfxContext> ctx = new gfxContext(surface);
         ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
         ctx->Paint();
     }
 
     MakeCurrent();
     GLXPixmap pixmap = mGLX->CreatePixmap(surface);
     // GLX might not be able to give us an A8 pixmap. If so, just use CPU
     // memory.
-    if (!pixmap && imageFormat == gfxASurface::ImageFormatA8) {
+    if (!pixmap && imageFormat == gfxImageFormatA8) {
         return GLContext::CreateTextureImage(aSize,
                                              aContentType,
                                              aWrapMode,
                                              aFlags,
                                              aImageFormat);
     }
     NS_ASSERTION(pixmap, "Failed to create pixmap!");
 
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -470,18 +470,18 @@ GLScreenBuffer::CreateRead(SharedSurface
 }
 
 
 void
 GLScreenBuffer::Readback(SharedSurface_GL* src, gfxImageSurface* dest)
 {
     MOZ_ASSERT(src && dest);
     MOZ_ASSERT(dest->GetSize() == src->Size());
-    MOZ_ASSERT(dest->Format() == (src->HasAlpha() ? gfxImageSurface::ImageFormatARGB32
-                                                  : gfxImageSurface::ImageFormatRGB24));
+    MOZ_ASSERT(dest->Format() == (src->HasAlpha() ? gfxImageFormatARGB32
+                                                  : gfxImageFormatRGB24));
 
     mGL->MakeCurrent();
 
     bool needsSwap = src != SharedSurf();
     if (needsSwap) {
         SharedSurf()->UnlockProd();
         src->LockProd();
     }
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -94,18 +94,18 @@ BasicTextureImage::BeginUpdate(nsIntRegi
 
     nsIntRect rgnSize = mUpdateRegion.GetBounds();
     if (!nsIntRect(nsIntPoint(0, 0), mSize).Contains(rgnSize)) {
         NS_ERROR("update outside of image");
         return nullptr;
     }
 
     ImageFormat format =
-        (GetContentType() == gfxASurface::CONTENT_COLOR) ?
-        gfxASurface::ImageFormatRGB24 : gfxASurface::ImageFormatARGB32;
+        (GetContentType() == GFX_CONTENT_COLOR) ?
+        gfxImageFormatRGB24 : gfxImageFormatARGB32;
     mUpdateSurface =
         GetSurfaceForUpdate(gfxIntSize(rgnSize.width, rgnSize.height), format);
 
     if (!mUpdateSurface || mUpdateSurface->CairoStatus()) {
         mUpdateSurface = nullptr;
         return nullptr;
     }
 
@@ -247,17 +247,17 @@ TextureImage::TextureImage(const gfx::In
 {}
 
 BasicTextureImage::BasicTextureImage(GLuint aTexture,
                                      const nsIntSize& aSize,
                                      GLenum aWrapMode,
                                      ContentType aContentType,
                                      GLContext* aContext,
                                      TextureImage::Flags aFlags /* = TextureImage::NoFlags */,
-                                     TextureImage::ImageFormat aImageFormat /* = gfxASurface::ImageFormatUnknown */)
+                                     TextureImage::ImageFormat aImageFormat /* = gfxImageFormatUnknown */)
     : TextureImage(aSize, aWrapMode, aContentType, aFlags, aImageFormat)
     , mTexture(aTexture)
     , mTextureState(Created)
     , mGLContext(aContext)
     , mUpdateOffset(0, 0)
 {
 }
 
@@ -459,19 +459,19 @@ TiledTextureImage::BeginUpdate(nsIntRegi
 
     // Get the real updated region, taking into account the capabilities of
     // each TextureImage tile
     GetUpdateRegion(aRegion);
     mUpdateRegion = aRegion;
     bounds = aRegion.GetBounds();
 
     // update covers multiple Images - create a temp surface to paint in
-    gfxASurface::gfxImageFormat format =
-        (GetContentType() == gfxASurface::CONTENT_COLOR) ?
-        gfxASurface::ImageFormatRGB24 : gfxASurface::ImageFormatARGB32;
+    gfxImageFormat format =
+        (GetContentType() == GFX_CONTENT_COLOR) ?
+        gfxImageFormatRGB24 : gfxImageFormatARGB32;
     mUpdateSurface = gfxPlatform::GetPlatform()->
         CreateOffscreenSurface(gfxIntSize(bounds.width, bounds.height), gfxASurface::ContentFromFormat(format));
     mUpdateSurface->SetDeviceOffset(gfxPoint(-bounds.x, -bounds.y));
 
     return mUpdateSurface;
 }
 
 void
--- a/gfx/gl/GLTextureImage.h
+++ b/gfx/gl/GLTextureImage.h
@@ -53,18 +53,18 @@ public:
 
     enum Flags {
         NoFlags          = 0x0,
         UseNearestFilter = 0x1,
         NeedsYFlip       = 0x2,
         DisallowBigImage = 0x4
     };
 
-    typedef gfxASurface::gfxContentType ContentType;
-    typedef gfxASurface::gfxImageFormat ImageFormat;
+    typedef gfxContentType ContentType;
+    typedef gfxImageFormat ImageFormat;
 
     static already_AddRefed<TextureImage> Create(
                        GLContext* gl,
                        const nsIntSize& aSize,
                        TextureImage::ContentType aContentType,
                        GLenum aWrapMode,
                        TextureImage::Flags aFlags = TextureImage::NoFlags);
     // Moz2D equivalent...
@@ -258,17 +258,17 @@ protected:
      * After the ctor, the TextureImage is invalid.  Implementations
      * must allocate resources successfully before returning the new
      * TextureImage from GLContext::CreateTextureImage().  That is,
      * clients must not be given partially-constructed TextureImages.
      */
     TextureImage(const nsIntSize& aSize,
                  GLenum aWrapMode, ContentType aContentType,
                  Flags aFlags = NoFlags,
-                 ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown)
+                 ImageFormat aImageFormat = gfxImageFormatUnknown)
         : mSize(aSize)
         , mWrapMode(aWrapMode)
         , mContentType(aContentType)
         , mImageFormat(aImageFormat)
         , mFilter(gfxPattern::FILTER_GOOD)
         , mFlags(aFlags)
     {}
 
@@ -304,24 +304,24 @@ public:
     virtual ~BasicTextureImage();
 
     BasicTextureImage(GLuint aTexture,
                       const nsIntSize& aSize,
                       GLenum aWrapMode,
                       ContentType aContentType,
                       GLContext* aContext,
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
-                      TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                      TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
     BasicTextureImage(GLuint aTexture,
                       const gfx::IntSize& aSize,
                       GLenum aWrapMode,
                       ContentType aContentType,
                       GLContext* aContext,
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
-                      TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                      TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
 
     virtual void BindTexture(GLenum aTextureUnit);
 
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
     virtual void EndUpdate();
     virtual bool DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0));
     virtual GLuint GetTextureID() { return mTexture; }
@@ -364,17 +364,17 @@ protected:
 class TiledTextureImage
     : public TextureImage
 {
 public:
     TiledTextureImage(GLContext* aGL,
                       nsIntSize aSize,
                       TextureImage::ContentType,
                       TextureImage::Flags aFlags = TextureImage::NoFlags,
-                      TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                      TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
     ~TiledTextureImage();
     void DumpDiv();
     virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
     virtual void GetUpdateRegion(nsIntRegion& aForRegion);
     virtual void EndUpdate();
     virtual void Resize(const nsIntSize& aSize);
     virtual uint32_t GetTileCount();
     virtual void BeginTileIteration();
@@ -416,17 +416,17 @@ protected:
  * In doubt, use GLContext::CreateTextureImage instead.
  */
 already_AddRefed<TextureImage>
 CreateBasicTextureImage(GLContext* aGL,
                         const nsIntSize& aSize,
                         TextureImage::ContentType aContentType,
                         GLenum aWrapMode,
                         TextureImage::Flags aFlags,
-                        TextureImage::ImageFormat aImageFormat = gfxASurface::ImageFormatUnknown);
+                        TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
 
 already_AddRefed<TextureImage>
 CreateBasicTextureImage(GLContext* aGL,
                         const gfx::IntSize& aSize,
                         TextureImage::ContentType aContentType,
                         GLenum aWrapMode,
                         TextureImage::Flags aFlags);
 
--- a/gfx/gl/SharedSurfaceEGL.cpp
+++ b/gfx/gl/SharedSurfaceEGL.cpp
@@ -163,19 +163,19 @@ SharedSurface_EGLImage::Fence()
             if (!CreateTexturePipe(mEGL, mGL, mFormats, Size(),
                                    &mProdTexForPipe, &mImage))
             {
                 mPipeFailed = true;
             }
         }
 
         if (!mPixels) {
-            gfxASurface::gfxImageFormat format =
-                  HasAlpha() ? gfxASurface::ImageFormatARGB32
-                             : gfxASurface::ImageFormatRGB24;
+            gfxImageFormat format =
+                  HasAlpha() ? gfxImageFormatARGB32
+                             : gfxImageFormatRGB24;
             mPixels = new gfxImageSurface(Size(), format);
         }
 
         mPixels->Flush();
         mGL->ReadScreenIntoImageSurface(mPixels);
         mPixels->MarkDirty();
         return;
     }
--- a/gfx/gl/SharedSurfaceGL.cpp
+++ b/gfx/gl/SharedSurfaceGL.cpp
@@ -246,39 +246,39 @@ SharedSurface_Basic::Create(GLContext* g
                             bool hasAlpha)
 {
     gl->MakeCurrent();
     GLuint tex = gl->CreateTexture(formats.color_texInternalFormat,
                                    formats.color_texFormat,
                                    formats.color_texType,
                                    size);
 
-    gfxASurface::gfxImageFormat format = gfxASurface::ImageFormatRGB24;
+    gfxImageFormat format = gfxImageFormatRGB24;
     switch (formats.color_texInternalFormat) {
     case LOCAL_GL_RGB:
     case LOCAL_GL_RGB8:
         if (formats.color_texType == LOCAL_GL_UNSIGNED_SHORT_5_6_5)
-            format = gfxASurface::ImageFormatRGB16_565;
+            format = gfxImageFormatRGB16_565;
         else
-            format = gfxASurface::ImageFormatRGB24;
+            format = gfxImageFormatRGB24;
         break;
     case LOCAL_GL_RGBA:
     case LOCAL_GL_RGBA8:
-        format = gfxASurface::ImageFormatARGB32;
+        format = gfxImageFormatARGB32;
         break;
     default:
         MOZ_CRASH("Unhandled Tex format.");
     }
     return new SharedSurface_Basic(gl, size, hasAlpha, format, tex);
 }
 
 SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
                                          const gfxIntSize& size,
                                          bool hasAlpha,
-                                         gfxASurface::gfxImageFormat format,
+                                         gfxImageFormat format,
                                          GLuint tex)
     : SharedSurface_GL(SharedSurfaceType::Basic,
                        AttachmentType::GLTexture,
                        gl,
                        size,
                        hasAlpha)
     , mTex(tex)
 {
--- a/gfx/gl/SharedSurfaceGL.h
+++ b/gfx/gl/SharedSurfaceGL.h
@@ -132,17 +132,17 @@ public:
 
 protected:
     const GLuint mTex;
     nsRefPtr<gfxImageSurface> mData;
 
     SharedSurface_Basic(GLContext* gl,
                         const gfxIntSize& size,
                         bool hasAlpha,
-                        gfxASurface::gfxImageFormat format,
+                        gfxImageFormat format,
                         GLuint tex);
 
 public:
     virtual ~SharedSurface_Basic();
 
     virtual void LockProdImpl() {}
     virtual void UnlockProdImpl() {}
 
--- a/gfx/gl/SharedSurfaceGralloc.cpp
+++ b/gfx/gl/SharedSurfaceGralloc.cpp
@@ -67,18 +67,18 @@ SharedSurface_Gralloc::Create(GLContext*
     DEBUG_PRINT("SharedSurface_Gralloc::Create -------\n");
 
     if (!HasExtensions(egl, prodGL))
         return nullptr;
 
     SurfaceDescriptor baseDesc;
     SurfaceDescriptorGralloc desc;
 
-    gfxASurface::gfxContentType type = hasAlpha ? gfxASurface::CONTENT_COLOR_ALPHA
-                                                : gfxASurface::CONTENT_COLOR;
+    gfxContentType type = hasAlpha ? GFX_CONTENT_COLOR_ALPHA
+                                                : GFX_CONTENT_COLOR;
     if (!allocator->AllocSurfaceDescriptorWithCaps(size, type, USING_GL_RENDERING_ONLY, &baseDesc))
         return false;
 
     if (baseDesc.type() != SurfaceDescriptor::TSurfaceDescriptorGralloc) {
         allocator->DestroySharedSurface(&baseDesc);
         return false;
     }
 
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -29,19 +29,19 @@
 #include "FrameMetrics.h"
 
 #ifdef _MSC_VER
 #pragma warning( disable : 4800 )
 #endif
 
 namespace mozilla {
 
-typedef gfxASurface::gfxContentType gfxContentType;
-typedef gfxASurface::gfxImageFormat PixelFormat;
-typedef gfxASurface::gfxSurfaceType gfxSurfaceType;
+typedef gfxContentType gfxContentType;
+typedef gfxImageFormat PixelFormat;
+typedef gfxSurfaceType gfxSurfaceType;
 typedef gfxPattern::GraphicsFilter GraphicsFilterType;
 
 } // namespace mozilla
 
 namespace IPC {
 
 template<>
 struct ParamTraits<gfxMatrix>
@@ -183,25 +183,25 @@ struct ParamTraits<gfx3DMatrix>
             Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44));
 #undef Rd
   }
 };
 
 template <>
 struct ParamTraits<mozilla::gfxContentType>
   : public EnumSerializer<mozilla::gfxContentType,
-                          gfxASurface::CONTENT_COLOR,
-                          gfxASurface::CONTENT_SENTINEL>
+                          GFX_CONTENT_COLOR,
+                          GFX_CONTENT_SENTINEL>
 {};
 
 template <>
 struct ParamTraits<mozilla::gfxSurfaceType>
-  : public EnumSerializer<gfxASurface::gfxSurfaceType,
-                          gfxASurface::SurfaceTypeImage,
-                          gfxASurface::SurfaceTypeMax>
+  : public EnumSerializer<gfxSurfaceType,
+                          gfxSurfaceTypeImage,
+                          gfxSurfaceTypeMax>
 {};
 
 template <>
 struct ParamTraits<mozilla::GraphicsFilterType>
   : public EnumSerializer<mozilla::GraphicsFilterType,
                           gfxPattern::FILTER_FAST,
                           gfxPattern::FILTER_SENTINEL>
 {};
@@ -218,18 +218,18 @@ struct ParamTraits<mozilla::layers::Scal
   : public EnumSerializer<mozilla::layers::ScaleMode,
                           mozilla::layers::SCALE_NONE,
                           mozilla::layers::SCALE_SENTINEL>
 {};
 
 template <>
 struct ParamTraits<mozilla::PixelFormat>
   : public EnumSerializer<mozilla::PixelFormat,
-                          gfxASurface::ImageFormatARGB32,
-                          gfxASurface::ImageFormatUnknown>
+                          gfxImageFormatARGB32,
+                          gfxImageFormatUnknown>
 {};
 
 
 template<>
 struct ParamTraits<gfxRGBA>
 {
   typedef gfxRGBA paramType;
 
--- a/gfx/ipc/SharedDIBSurface.cpp
+++ b/gfx/ipc/SharedDIBSurface.cpp
@@ -40,26 +40,26 @@ SharedDIBSurface::Attach(Handle aHandle,
 
 void
 SharedDIBSurface::InitSurface(uint32_t aWidth, uint32_t aHeight,
                               bool aTransparent)
 {
   long stride = long(aWidth * kBytesPerPixel);
   unsigned char* data = reinterpret_cast<unsigned char*>(mSharedDIB.GetBits());
 
-  gfxImageFormat format = aTransparent ? ImageFormatARGB32 : ImageFormatRGB24;
+  gfxImageFormat format = aTransparent ? gfxImageFormatARGB32 : gfxImageFormatRGB24;
 
   gfxImageSurface::InitWithData(data, gfxIntSize(aWidth, aHeight),
                                 stride, format);
 
   cairo_surface_set_user_data(mSurface, &SHAREDDIB_KEY, this, nullptr);
 }
 
 bool
 SharedDIBSurface::IsSharedDIBSurface(gfxASurface* aSurface)
 {
   return aSurface &&
-    aSurface->GetType() == gfxASurface::SurfaceTypeImage &&
+    aSurface->GetType() == gfxSurfaceTypeImage &&
     aSurface->GetData(&SHAREDDIB_KEY);
 }
 
 } // namespace gfx
 } // namespace mozilla
--- a/gfx/layers/CopyableCanvasLayer.cpp
+++ b/gfx/layers/CopyableCanvasLayer.cpp
@@ -96,18 +96,18 @@ CopyableCanvasLayer::UpdateSurface(gfxAS
     SharedSurface* sharedSurf = mGLContext->RequestFrame();
     if (!sharedSurf) {
       NS_WARNING("Null frame received.");
       return;
     }
 
     gfxIntSize readSize(sharedSurf->Size());
     gfxImageFormat format = (GetContentFlags() & CONTENT_OPAQUE)
-                            ? gfxASurface::ImageFormatRGB24
-                            : gfxASurface::ImageFormatARGB32;
+                            ? gfxImageFormatRGB24
+                            : gfxImageFormatARGB32;
 
     if (aDestSurface) {
       resultSurf = aDestSurface;
     } else {
       resultSurf = GetTempSurface(readSize, format);
     }
     MOZ_ASSERT(resultSurf);
     if (resultSurf->CairoStatus() != 0) {
--- a/gfx/layers/D3D9SurfaceImage.cpp
+++ b/gfx/layers/D3D9SurfaceImage.cpp
@@ -117,17 +117,17 @@ D3D9SurfaceImage::GetSize()
 
 already_AddRefed<gfxASurface>
 D3D9SurfaceImage::GetAsSurface()
 {
   NS_ENSURE_TRUE(mTexture, nullptr);
 
   HRESULT hr;
   nsRefPtr<gfxImageSurface> surface =
-    new gfxImageSurface(mSize, gfxASurface::ImageFormatRGB24);
+    new gfxImageSurface(mSize, gfxImageFormatRGB24);
 
   if (!surface->CairoSurface() || surface->CairoStatus()) {
     NS_WARNING("Failed to created Cairo image surface for D3D9SurfaceImage.");
     return nullptr;
   }
 
   // Ensure that the texture is ready to be used.
   EnsureSynchronized();
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -224,17 +224,17 @@ GrallocImage::GetAsSurface()
   }
 
   if (!omxFormat) {
     NS_WARNING("Unknown color format");
     return nullptr;
   }
 
   nsRefPtr<gfxImageSurface> imageSurface =
-    new gfxImageSurface(GetSize(), gfxASurface::ImageFormatRGB16_565);
+    new gfxImageSurface(GetSize(), gfxImageFormatRGB16_565);
 
   uint32_t width = GetSize().width;
   uint32_t height = GetSize().height;
 
   if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
     // The Adreno hardware decoder aligns image dimensions to a multiple of 32,
     // so we have to account for that here
     uint32_t alignedWidth = ALIGN(width, 32);
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -273,18 +273,18 @@ ImageContainer::LockCurrentAsSurface(gfx
     if (!mActiveImage) {
       return nullptr;
     } 
 
     if (mActiveImage->GetFormat() == REMOTE_IMAGE_BITMAP) {
       nsRefPtr<gfxImageSurface> newSurf =
         new gfxImageSurface(mRemoteData->mBitmap.mData, mRemoteData->mSize, mRemoteData->mBitmap.mStride,
                             mRemoteData->mFormat == RemoteImageData::BGRX32 ?
-                                                   gfxASurface::ImageFormatARGB32 :
-                                                   gfxASurface::ImageFormatRGB24);
+                                                   gfxImageFormatARGB32 :
+                                                   gfxImageFormatRGB24);
 
       *aSize = newSurf->GetSize();
     
       return newSurf.forget();
     }
 
     *aSize = mActiveImage->GetSize();
     return mActiveImage->GetAsSurface();
@@ -405,17 +405,17 @@ ImageContainer::EnsureActiveImage()
 #endif
   }
 }
 
 
 PlanarYCbCrImage::PlanarYCbCrImage(BufferRecycleBin *aRecycleBin)
   : Image(nullptr, PLANAR_YCBCR)
   , mBufferSize(0)
-  , mOffscreenFormat(gfxASurface::ImageFormatUnknown)
+  , mOffscreenFormat(gfxImageFormatUnknown)
   , mRecycleBin(aRecycleBin)
 {
 }
 
 PlanarYCbCrImage::~PlanarYCbCrImage()
 {
   if (mBuffer) {
     mRecycleBin->RecycleBuffer(mBuffer.forget(), mBufferSize);
@@ -481,20 +481,20 @@ PlanarYCbCrImage::CopyData(const Data& a
 }
 
 void
 PlanarYCbCrImage::SetData(const Data &aData)
 {
   CopyData(aData);
 }
 
-gfxASurface::gfxImageFormat
+gfxImageFormat
 PlanarYCbCrImage::GetOffscreenFormat()
 {
-  return mOffscreenFormat == gfxASurface::ImageFormatUnknown ?
+  return mOffscreenFormat == gfxImageFormatUnknown ?
     gfxPlatform::GetPlatform()->GetOffscreenFormat() :
     mOffscreenFormat;
 }
 
 void
 PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
 {
   mData = aData;
@@ -515,17 +515,17 @@ PlanarYCbCrImage::AllocateAndGetNewBuffe
 already_AddRefed<gfxASurface>
 PlanarYCbCrImage::GetAsSurface()
 {
   if (mSurface) {
     nsRefPtr<gfxASurface> result = mSurface.get();
     return result.forget();
   }
 
-  gfxASurface::gfxImageFormat format = GetOffscreenFormat();
+  gfxImageFormat format = GetOffscreenFormat();
   gfxIntSize size(mSize);
   gfxUtils::GetYCbCrToRGBDestFormatAndSize(mData, format, size);
   if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
       size.height > PlanarYCbCrImage::MAX_DIMENSION) {
     NS_ERROR("Illegal image dest width or height");
     return nullptr;
   }
 
@@ -541,17 +541,17 @@ PlanarYCbCrImage::GetAsSurface()
   return imageSurface.forget();
 }
 
 already_AddRefed<gfxASurface>
 RemoteBitmapImage::GetAsSurface()
 {
   nsRefPtr<gfxImageSurface> newSurf =
     new gfxImageSurface(mSize,
-    mFormat == RemoteImageData::BGRX32 ? gfxASurface::ImageFormatRGB24 : gfxASurface::ImageFormatARGB32);
+    mFormat == RemoteImageData::BGRX32 ? gfxImageFormatRGB24 : gfxImageFormatARGB32);
 
   for (int y = 0; y < mSize.height; y++) {
     memcpy(newSurf->Data() + newSurf->Stride() * y,
            mData + mStride * y,
            mSize.width * 4);
   }
 
   return newSurf.forget();
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -825,24 +825,24 @@ protected:
    * Return a buffer to store image data in.
    * The default implementation returns memory that can
    * be freed wit delete[]
    */
   virtual uint8_t* AllocateBuffer(uint32_t aSize);
 
   already_AddRefed<gfxASurface> GetAsSurface();
 
-  void SetOffscreenFormat(gfxASurface::gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
-  gfxASurface::gfxImageFormat GetOffscreenFormat();
+  void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
+  gfxImageFormat GetOffscreenFormat();
 
   nsAutoArrayPtr<uint8_t> mBuffer;
   uint32_t mBufferSize;
   Data mData;
   gfxIntSize mSize;
-  gfxASurface::gfxImageFormat mOffscreenFormat;
+  gfxImageFormat mOffscreenFormat;
   nsCountedRef<nsMainThreadSurfaceRef> mSurface;
   nsRefPtr<BufferRecycleBin> mRecycleBin;
 };
 
 /**
  * Currently, the data in a CairoImage surface is treated as being in the
  * device output color space. This class is very simple as all backends
  * have to know about how to deal with drawing a cairo image.
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -113,26 +113,26 @@ LayerManager::GetScrollableLayers(nsTArr
       queue.AppendElement(child);
       child = child->GetNextSibling();
     }
   }
 }
 
 already_AddRefed<gfxASurface>
 LayerManager::CreateOptimalSurface(const gfxIntSize &aSize,
-                                   gfxASurface::gfxImageFormat aFormat)
+                                   gfxImageFormat aFormat)
 {
   return gfxPlatform::GetPlatform()->
     CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFormat));
 }
 
 already_AddRefed<gfxASurface>
 LayerManager::CreateOptimalMaskSurface(const gfxIntSize &aSize)
 {
-  return CreateOptimalSurface(aSize, gfxASurface::ImageFormatA8);
+  return CreateOptimalSurface(aSize, gfxImageFormatA8);
 }
 
 TemporaryRef<DrawTarget>
 LayerManager::CreateDrawTarget(const IntSize &aSize,
                                SurfaceFormat aFormat)
 {
   return gfxPlatform::GetPlatform()->
     CreateOffscreenCanvasDrawTarget(aSize, aFormat);
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -391,17 +391,17 @@ public:
   virtual LayersBackend GetBackendType() = 0;
 
   /**
    * Creates a surface which is optimized for inter-operating with this layer
    * manager.
    */
   virtual already_AddRefed<gfxASurface>
     CreateOptimalSurface(const gfxIntSize &aSize,
-                         gfxASurface::gfxImageFormat imageFormat);
+                         gfxImageFormat imageFormat);
 
   /**
    * Creates a surface for alpha masks which is optimized for inter-operating
    * with this layer manager. In contrast to CreateOptimalSurface, this surface
    * is optimised for drawing alpha only and we assume that drawing the mask
    * is fairly simple.
    */
   virtual already_AddRefed<gfxASurface>
--- a/gfx/layers/ThebesLayerBuffer.cpp
+++ b/gfx/layers/ThebesLayerBuffer.cpp
@@ -120,17 +120,17 @@ RotatedBuffer::DrawBufferQuadrant(gfxCon
   pattern->SetMatrix(transform);
   aTarget->SetPattern(pattern);
 
   if (aMask) {
     if (aOpacity == 1.0) {
       aTarget->SetMatrix(*aMaskTransform);
       aTarget->Mask(aMask);
     } else {
-      aTarget->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
+      aTarget->PushGroup(GFX_CONTENT_COLOR_ALPHA);
       aTarget->Paint(aOpacity);
       aTarget->PopGroupToSource();
       aTarget->SetMatrix(*aMaskTransform);
       aTarget->Mask(aMask);
     }
   } else {
     if (aOpacity == 1.0) {
       aTarget->Fill();
@@ -394,37 +394,37 @@ ThebesLayerBuffer::GetContextForQuadrant
 
   if (aTopLeft) {
     *aTopLeft = nsIntPoint(quadrantRect.x, quadrantRect.y);
   }
 
   return ctx.forget();
 }
 
-gfxASurface::gfxContentType
+gfxContentType
 ThebesLayerBuffer::BufferContentType()
 {
   if (mBuffer) {
     return mBuffer->GetContentType();
   }
   if (mBufferProvider) {
     return mBufferProvider->GetContentType();
   }
   if (mDTBuffer) {
     switch (mDTBuffer->GetFormat()) {
     case FORMAT_A8:
-      return gfxASurface::CONTENT_ALPHA;
+      return GFX_CONTENT_ALPHA;
     case FORMAT_B8G8R8A8:
     case FORMAT_R8G8B8A8:
-      return gfxASurface::CONTENT_COLOR_ALPHA;
+      return GFX_CONTENT_COLOR_ALPHA;
     default:
-      return gfxASurface::CONTENT_COLOR;
+      return GFX_CONTENT_COLOR;
     }
   }
-  return gfxASurface::CONTENT_SENTINEL;
+  return GFX_CONTENT_SENTINEL;
 }
 
 bool
 ThebesLayerBuffer::BufferSizeOkFor(const nsIntSize& aSize)
 {
   return (aSize == mBufferRect.Size() ||
           (SizedToVisibleBounds != mBufferSizePolicy &&
            aSize < mBufferRect.Size()));
@@ -571,27 +571,27 @@ ThebesLayerBuffer::BeginPaint(ThebesLaye
       if (!aLayer->GetParent() ||
           !aLayer->GetParent()->SupportsComponentAlphaChildren() ||
           !aLayer->Manager()->IsCompositingCheap() ||
           !aLayer->AsShadowableLayer() ||
           !aLayer->AsShadowableLayer()->HasShadow() ||
           !gfxPlatform::ComponentAlphaEnabled()) {
         mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
       } else {
-        contentType = gfxASurface::CONTENT_COLOR;
+        contentType = GFX_CONTENT_COLOR;
       }
 #endif
     }
 
     if ((aFlags & PAINT_WILL_RESAMPLE) &&
         (!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
          neededRegion.GetNumRects() > 1)) {
       // The area we add to neededRegion might not be painted opaquely
       if (mode == Layer::SURFACE_OPAQUE) {
-        contentType = gfxASurface::CONTENT_COLOR_ALPHA;
+        contentType = GFX_CONTENT_COLOR_ALPHA;
         mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
       }
 
       // We need to validate the entire buffer, to make sure that only valid
       // pixels are sampled
       neededRegion = destBufferRect;
     }
 
@@ -795,17 +795,17 @@ ThebesLayerBuffer::BeginPaint(ThebesLaye
                                    ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
       }
     } else {
       MOZ_ASSERT(mBuffer && mBufferOnWhite);
       FillSurface(mBuffer, result.mRegionToDraw, topLeft, gfxRGBA(0.0, 0.0, 0.0, 1.0));
       FillSurface(mBufferOnWhite, result.mRegionToDraw, topLeft, gfxRGBA(1.0, 1.0, 1.0, 1.0));
     }
     gfxUtils::ClipToRegionSnapped(result.mContext, result.mRegionToDraw);
-  } else if (contentType == gfxASurface::CONTENT_COLOR_ALPHA && !isClear) {
+  } else if (contentType == GFX_CONTENT_COLOR_ALPHA && !isClear) {
     if (IsAzureBuffer()) {
       nsIntRegionRectIterator iter(result.mRegionToDraw);
       const nsIntRect *iterRect;
       while ((iterRect = iter.Next())) {
         result.mContext->GetDrawTarget()->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
       }
       // Clear will do something expensive with a complex clip pushed, so clip
       // here.
--- a/gfx/layers/ThebesLayerBuffer.h
+++ b/gfx/layers/ThebesLayerBuffer.h
@@ -47,17 +47,17 @@ class ThebesLayer;
  * and paint content rows H to H+N-1 into rows 0 to N-1 of the buffer.
  * Then we can refresh the screen by painting rows N to H-1 of the buffer
  * at row 0 on the screen, and then painting rows 0 to N-1 of the buffer
  * at row H-N on the screen.
  * mBufferRotation.y would be N in this example.
  */
 class RotatedBuffer {
 public:
-  typedef gfxASurface::gfxContentType ContentType;
+  typedef gfxContentType ContentType;
 
   RotatedBuffer(gfxASurface* aBuffer, gfxASurface* aBufferOnWhite,
                 const nsIntRect& aBufferRect,
                 const nsIntPoint& aBufferRotation)
     : mBuffer(aBuffer)
     , mBufferOnWhite(aBufferOnWhite)
     , mBufferRect(aBufferRect)
     , mBufferRotation(aBufferRotation)
@@ -149,17 +149,17 @@ protected:
 };
 
 /**
  * This class encapsulates the buffer used to retain ThebesLayer contents,
  * i.e., the contents of the layer's GetVisibleRegion().
  */
 class ThebesLayerBuffer : public RotatedBuffer {
 public:
-  typedef gfxASurface::gfxContentType ContentType;
+  typedef gfxContentType ContentType;
 
   /**
    * Controls the size of the backing buffer of this.
    * - SizedToVisibleBounds: the backing buffer is exactly the same
    *   size as the bounds of ThebesLayer's visible region
    * - ContainsVisibleBounds: the backing buffer is large enough to
    *   fit visible bounds.  May be larger.
    */
@@ -373,17 +373,17 @@ protected:
 protected:
   // Buffer helpers.  Don't use mBuffer directly; instead use one of
   // these helpers.
 
   /**
    * Return the buffer's content type.  Requires a valid buffer or
    * buffer provider.
    */
-  gfxASurface::gfxContentType BufferContentType();
+  gfxContentType BufferContentType();
   bool BufferSizeOkFor(const nsIntSize& aSize);
   /**
    * If the buffer hasn't been mapped, map it.
    */
   void EnsureBuffer();
   void EnsureBufferOnWhite();
   /**
    * True if we have a buffer where we can get it (but not necessarily
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -179,17 +179,17 @@ public:
   }
 
   void ConvertImageToRGB(const SurfaceDescriptor& aImage)
   {
     YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
     PlanarYCbCrImage::Data data;
     DeserializerToPlanarYCbCrImageData(deserializer, data);
 
-    gfxASurface::gfxImageFormat format = gfxASurface::ImageFormatRGB24;
+    gfxImageFormat format = gfxImageFormatRGB24;
     gfxIntSize size;
     gfxUtils::GetYCbCrToRGBDestFormatAndSize(data, format, size);
     if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
         size.height > PlanarYCbCrImage::MAX_DIMENSION) {
       NS_ERROR("Illegal image dest width or height");
       return;
     }
 
@@ -197,17 +197,17 @@ public:
       new gfxImageSurface(size, format);
 
     gfxUtils::ConvertYCbCrToRGB(data, format, size,
                                 mThebesImage->Data(),
                                 mThebesImage->Stride());
 
     mSize = IntSize(size.width, size.height);
     mFormat =
-      (format == gfxASurface::ImageFormatARGB32) ? FORMAT_B8G8R8A8 :
+      (format == gfxImageFormatARGB32) ? FORMAT_B8G8R8A8 :
                                                    FORMAT_B8G8R8X8;
   }
 
 };
 
 TemporaryRef<DeprecatedTextureHost>
 CreateBasicDeprecatedTextureHost(SurfaceDescriptorType aDescriptorType,
                              uint32_t aTextureHostFlags,
--- a/gfx/layers/basic/BasicImageLayer.cpp
+++ b/gfx/layers/basic/BasicImageLayer.cpp
@@ -134,17 +134,17 @@ PaintContext(gfxPattern* aPattern,
   // outside the bounds of the video image.
   gfxPattern::GraphicsExtend extend = gfxPattern::EXTEND_PAD;
 
 #ifdef MOZ_X11
   // PAD is slow with cairo and old X11 servers, so prefer speed over
   // correctness and use NONE.
   if (aContext->IsCairo()) {
     nsRefPtr<gfxASurface> target = aContext->CurrentSurface();
-    if (target->GetType() == gfxASurface::SurfaceTypeXlib &&
+    if (target->GetType() == gfxSurfaceTypeXlib &&
         static_cast<gfxXlibSurface*>(target.get())->IsPadSlow()) {
       extend = gfxPattern::EXTEND_NONE;
     }
   }
 #endif
 
   aContext->NewPath();
   // No need to snap here; our transform has already taken care of it.
--- a/gfx/layers/basic/BasicImages.cpp
+++ b/gfx/layers/basic/BasicImages.cpp
@@ -94,17 +94,17 @@ BasicPlanarYCbCrImage::SetData(const Dat
 
   // Do some sanity checks to prevent integer overflow
   if (aData.mYSize.width > PlanarYCbCrImage::MAX_DIMENSION ||
       aData.mYSize.height > PlanarYCbCrImage::MAX_DIMENSION) {
     NS_ERROR("Illegal image source width or height");
     return;
   }
 
-  gfxASurface::gfxImageFormat format = GetOffscreenFormat();
+  gfxImageFormat format = GetOffscreenFormat();
 
   gfxIntSize size(mScaleHint);
   gfxUtils::GetYCbCrToRGBDestFormatAndSize(aData, format, size);
   if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
       size.height > PlanarYCbCrImage::MAX_DIMENSION) {
     NS_ERROR("Illegal image dest width or height");
     return;
   }
@@ -138,17 +138,17 @@ BasicPlanarYCbCrImage::GetAsSurface()
     nsRefPtr<gfxASurface> result = mSurface.get();
     return result.forget();
   }
 
   if (!mDecodedBuffer) {
     return PlanarYCbCrImage::GetAsSurface();
   }
 
-  gfxASurface::gfxImageFormat format = GetOffscreenFormat();
+  gfxImageFormat format = GetOffscreenFormat();
 
   nsRefPtr<gfxImageSurface> imgSurface =
       new gfxImageSurface(mDecodedBuffer, mSize, mStride, format);
   if (!imgSurface || imgSurface->CairoStatus() != 0) {
     return nullptr;
   }
 
   // Pass ownership of the buffer to the surface
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -87,29 +87,29 @@ BasicLayerManager::PushGroupForLayer(gfx
   // If we need to call PushGroup, we should clip to the smallest possible
   // area first to minimize the size of the temporary surface.
   bool didCompleteClip = ClipToContain(aContext, aRegion.GetBounds());
 
   nsRefPtr<gfxContext> result;
   if (aLayer->CanUseOpaqueSurface() &&
       ((didCompleteClip && aRegion.GetNumRects() == 1) ||
        !aContext->CurrentMatrix().HasNonIntegerTranslation())) {
-    // If the layer is opaque in its visible region we can push a CONTENT_COLOR
+    // If the layer is opaque in its visible region we can push a GFX_CONTENT_COLOR
     // group. We need to make sure that only pixels inside the layer's visible
     // region are copied back to the destination. Remember if we've already
     // clipped precisely to the visible region.
     *aNeedsClipToVisibleRegion = !didCompleteClip || aRegion.GetNumRects() > 1;
-    result = PushGroupWithCachedSurface(aContext, gfxASurface::CONTENT_COLOR);
+    result = PushGroupWithCachedSurface(aContext, GFX_CONTENT_COLOR);
   } else {
     *aNeedsClipToVisibleRegion = false;
     result = aContext;
     if (aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) {
-      aContext->PushGroupAndCopyBackground(gfxASurface::CONTENT_COLOR_ALPHA);
+      aContext->PushGroupAndCopyBackground(GFX_CONTENT_COLOR_ALPHA);
     } else {
-      aContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
+      aContext->PushGroup(GFX_CONTENT_COLOR_ALPHA);
     }
   }
   return result.forget();
 }
 
 static nsIntRect
 ToOutsideIntRect(const gfxRect &aRect)
 {
@@ -285,17 +285,17 @@ BasicLayerManager::BeginTransaction()
 {
   mInTransaction = true;
   mUsingDefaultTarget = true;
   BeginTransactionWithTarget(mDefaultTarget);
 }
 
 already_AddRefed<gfxContext>
 BasicLayerManager::PushGroupWithCachedSurface(gfxContext *aTarget,
-                                              gfxASurface::gfxContentType aContent)
+                                              gfxContentType aContent)
 {
   nsRefPtr<gfxContext> ctx;
   // We can't cache Azure DrawTargets at this point.
   if (!mCachedSurfaceInUse && aTarget->IsCairo()) {
     gfxContextMatrixAutoSaveRestore saveMatrix(aTarget);
     aTarget->IdentityMatrix();
 
     nsRefPtr<gfxASurface> currentSurf = aTarget->CurrentSurface();
@@ -585,17 +585,17 @@ BasicLayerManager::EndTransactionInterna
   RenderTraceLayers(aLayer, "FF00");
 
   mTransactionIncomplete = false;
 
   if (aFlags & END_NO_COMPOSITE) {
     if (!mDummyTarget) {
       // XXX: We should really just set mTarget to null and make sure we can handle that further down the call chain
       // Creating this temporary surface can be expensive on some platforms (d2d in particular), so cache it between paints.
-      nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(1, 1), gfxASurface::CONTENT_COLOR);
+      nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(1, 1), GFX_CONTENT_COLOR);
       mDummyTarget = new gfxContext(surf);
     }
     mTarget = mDummyTarget;
   }
 
   if (mTarget && mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) {
     nsIntRect clipRect;
     if (HasShadowManager()) {
@@ -733,24 +733,24 @@ Matrix3DToPixman(const gfx3DMatrix& aMat
 
 static void
 PixmanTransform(const gfxImageSurface *aDest, 
                 const gfxImageSurface *aSrc, 
                 const gfx3DMatrix& aTransform, 
                 gfxPoint aDestOffset)
 {
   gfxIntSize destSize = aDest->GetSize();
-  pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxASurface::ImageFormatARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
+  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());
 
   gfxIntSize srcSize = aSrc->GetSize();
-  pixman_image_t* src = pixman_image_create_bits(aSrc->Format() == gfxASurface::ImageFormatARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
+  pixman_image_t* src = pixman_image_create_bits(aSrc->Format() == gfxImageFormatARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
                                                  srcSize.width,
                                                  srcSize.height,
                                                  (uint32_t*)aSrc->Data(),
                                                  aSrc->Stride());
 
   NS_ABORT_IF_FALSE(src && dest, "Failed to create pixman images?");
 
   pixman_transform pixTransform = Matrix3DToPixman(aTransform);
@@ -820,17 +820,17 @@ Transform3D(gfxASurface* aSource, gfxCon
 
   // Create a surface the size of the transformed object.
   nsRefPtr<gfxASurface> dest = aDest->CurrentSurface();
   nsRefPtr<gfxImageSurface> destImage;
   gfxPoint offset;
   bool blitComplete;
   if (!destImage || aDontBlit || !aDest->ClipContainsRect(aDestRect)) {
     destImage = new gfxImageSurface(gfxIntSize(aDestRect.width, aDestRect.height),
-                                    gfxASurface::ImageFormatARGB32);
+                                    gfxImageFormatARGB32);
     offset = aDestRect.TopLeft();
     blitComplete = false;
   } else {
     offset = -dest->GetDeviceOffset();
     blitComplete = true;
   }
 
   // Include a translation to the correct origin.
@@ -995,17 +995,17 @@ BasicLayerManager::PaintLayer(gfxContext
       FlushGroup(paintLayerContext, needsClipToVisibleRegion);
     } else {
       PaintSelfOrChildren(paintLayerContext, aTarget);
     }
   } else {
     const nsIntRect& bounds = visibleRegion.GetBounds();
     nsRefPtr<gfxASurface> untransformedSurface =
       gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(bounds.width, bounds.height),
-                                                         gfxASurface::CONTENT_COLOR_ALPHA);
+                                                         GFX_CONTENT_COLOR_ALPHA);
     if (!untransformedSurface) {
       return;
     }
     untransformedSurface->SetDeviceOffset(gfxPoint(-bounds.x, -bounds.y));
     nsRefPtr<gfxContext> groupTarget = new gfxContext(untransformedSurface);
 
     PaintSelfOrChildren(paintLayerContext, groupTarget);
 
--- a/gfx/layers/basic/BasicLayers.h
+++ b/gfx/layers/basic/BasicLayers.h
@@ -134,17 +134,17 @@ public:
 
   void SetTransactionIncomplete() { mTransactionIncomplete = true; }
   bool IsTransactionIncomplete() { return mTransactionIncomplete; }
 
   already_AddRefed<gfxContext> PushGroupForLayer(gfxContext* aContext, Layer* aLayer,
                                                  const nsIntRegion& aRegion,
                                                  bool* aNeedsClipToVisibleRegion);
   already_AddRefed<gfxContext> PushGroupWithCachedSurface(gfxContext *aTarget,
-                                                          gfxASurface::gfxContentType aContent);
+                                                          gfxContentType aContent);
   void PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxContext *aPushed);
 
   virtual bool IsCompositingCheap() { return false; }
   virtual int32_t GetMaxTextureSize() const { return INT32_MAX; }
   bool CompositorMightResample() { return mCompositorMightResample; }
   bool HasShadowTarget() { return !!mShadowTarget; }
 
 protected:
--- a/gfx/layers/basic/BasicLayersImpl.cpp
+++ b/gfx/layers/basic/BasicLayersImpl.cpp
@@ -85,17 +85,17 @@ GetMaskData(Layer* aMaskLayer, AutoMaskD
 }
 
 void
 PaintWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer)
 {
   AutoMaskData mask;
   if (GetMaskData(aMaskLayer, &mask)) {
     if (aOpacity < 1.0) {
-      aContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
+      aContext->PushGroup(GFX_CONTENT_COLOR_ALPHA);
       aContext->Paint(aOpacity);
       aContext->PopGroupToSource();
     }
     aContext->SetMatrix(mask.GetTransform());
     aContext->Mask(mask.GetSurface());
     return;
   }
 
@@ -104,17 +104,17 @@ PaintWithMask(gfxContext* aContext, floa
 }
 
 void
 FillWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer)
 {
   AutoMaskData mask;
   if (GetMaskData(aMaskLayer, &mask)) {
     if (aOpacity < 1.0) {
-      aContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
+      aContext->PushGroup(GFX_CONTENT_COLOR_ALPHA);
       aContext->FillWithOpacity(aOpacity);
       aContext->PopGroupToSource();
       aContext->SetMatrix(mask.GetTransform());
       aContext->Mask(mask.GetSurface());
     } else {
       aContext->Save();
       aContext->Clip();
       aContext->SetMatrix(mask.GetTransform());
--- a/gfx/layers/basic/BasicThebesLayer.cpp
+++ b/gfx/layers/basic/BasicThebesLayer.cpp
@@ -59,17 +59,17 @@ SetAntialiasingFlags(Layer* aLayer, gfxC
                                                                      Float(bounds.width), Float(bounds.height)));
     transformedBounds.RoundOut();
     IntRect intTransformedBounds;
     transformedBounds.ToIntRect(&intTransformedBounds);
     dt->SetPermitSubpixelAA(!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
                             dt->GetOpaqueRect().Contains(intTransformedBounds));
   } else {
     nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
-    if (surface->GetContentType() != gfxASurface::CONTENT_COLOR_ALPHA) {
+    if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) {
       // Destination doesn't have alpha channel; no need to set any special flags
       return;
     }
 
     const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
     surface->SetSubpixelAntialiasingEnabled(
         !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
         surface->GetOpaqueRect().Contains(
@@ -100,18 +100,18 @@ BasicThebesLayer::PaintThebes(gfxContext
   }
   //TODO: This is going to copy back pixels that we might end up
   // drawing over anyway. It would be nice if we could avoid
   // this duplication.
   mContentClient->SyncFrontBufferToBackBuffer();
 
   bool canUseOpaqueSurface = CanUseOpaqueSurface();
   ContentType contentType =
-    canUseOpaqueSurface ? gfxASurface::CONTENT_COLOR :
-                          gfxASurface::CONTENT_COLOR_ALPHA;
+    canUseOpaqueSurface ? GFX_CONTENT_COLOR :
+                          GFX_CONTENT_COLOR_ALPHA;
   float opacity = GetEffectiveOpacity();
   gfxContext::GraphicsOperator mixBlendMode = GetEffectiveMixBlendMode();
 
   if (!BasicManager()->IsRetained()) {
     NS_ASSERTION(readbackUpdates.IsEmpty(), "Can't do readback for non-retained layer");
 
     mValidRegion.SetEmpty();
     mContentClient->Clear();
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -59,20 +59,20 @@ CanvasClient2D::Update(gfx::IntSize aSiz
       (mBuffer->IsImmutable() || mBuffer->GetSize() != aSize)) {
     RemoveTextureClient(mBuffer);
     mBuffer = nullptr;
   }
 
   bool bufferCreated = false;
   if (!mBuffer) {
     bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
-    gfxASurface::gfxContentType contentType = isOpaque
-                                                ? gfxASurface::CONTENT_COLOR
-                                                : gfxASurface::CONTENT_COLOR_ALPHA;
-    gfxASurface::gfxImageFormat format
+    gfxContentType contentType = isOpaque
+                                                ? GFX_CONTENT_COLOR
+                                                : GFX_CONTENT_COLOR_ALPHA;
+    gfxImageFormat format
       = gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
     mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format));
     MOZ_ASSERT(mBuffer->AsTextureClientSurface());
     mBuffer->AsTextureClientSurface()->AllocateForSurface(aSize);
 
     bufferCreated = true;
   }
 
@@ -117,19 +117,19 @@ DeprecatedCanvasClient2D::DeprecatedCanv
 {
   mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
 }
 
 void
 DeprecatedCanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
 {
   bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
-  gfxASurface::gfxContentType contentType = isOpaque
-                                              ? gfxASurface::CONTENT_COLOR
-                                              : gfxASurface::CONTENT_COLOR_ALPHA;
+  gfxContentType contentType = isOpaque
+                                              ? GFX_CONTENT_COLOR
+                                              : GFX_CONTENT_COLOR_ALPHA;
 
   if (!mDeprecatedTextureClient) {
     mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT, contentType);
     if (!mDeprecatedTextureClient) {
       mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK, contentType);
       if (!mDeprecatedTextureClient) {
         NS_WARNING("Could not create texture client");
         return;
@@ -170,25 +170,25 @@ DeprecatedCanvasClientSurfaceStream::Dep
 }
 
 void
 DeprecatedCanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
 {
   if (!mDeprecatedTextureClient) {
     mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_STREAM_GL,
                                                              aLayer->GetSurfaceMode() == Layer::SURFACE_OPAQUE
-                                                               ? gfxASurface::CONTENT_COLOR
-                                                               : gfxASurface::CONTENT_COLOR_ALPHA);
+                                                               ? GFX_CONTENT_COLOR
+                                                               : GFX_CONTENT_COLOR_ALPHA);
     MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
   }
 
   NS_ASSERTION(aLayer->mGLContext, "CanvasClientSurfaceStream should only be used with GL canvases");
 
   // the content type won't be used
-  mDeprecatedTextureClient->EnsureAllocated(aSize, gfxASurface::CONTENT_COLOR);
+  mDeprecatedTextureClient->EnsureAllocated(aSize, GFX_CONTENT_COLOR);
 
   GLScreenBuffer* screen = aLayer->mGLContext->Screen();
   SurfaceStream* stream = screen->Stream();
 
   bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
   if (isCrossProcess) {
     // swap staging -> consumer so we can send it to the compositor
     SharedSurface* surf = stream->SwapConsumer();
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -258,17 +258,17 @@ ClientLayerManager::MakeSnapshotIfRequir
     return;
   }
   if (mWidget) {
     if (CompositorChild* remoteRenderer = GetRemoteRenderer()) {
       nsIntRect bounds;
       mWidget->GetBounds(bounds);
       SurfaceDescriptor inSnapshot, snapshot;
       if (AllocSurfaceDescriptor(bounds.Size(),
-                                 gfxASurface::CONTENT_COLOR_ALPHA,
+                                 GFX_CONTENT_COLOR_ALPHA,
                                  &inSnapshot) &&
           // The compositor will usually reuse |snapshot| and return
           // it through |outSnapshot|, but if it doesn't, it's
           // responsible for freeing |snapshot|.
           remoteRenderer->SendMakeSnapshot(inSnapshot, &snapshot)) {
         AutoOpenSurface opener(OPEN_READ_ONLY, snapshot);
         gfxASurface* source = opener.Get();
 
--- a/gfx/layers/client/ClientThebesLayer.cpp
+++ b/gfx/layers/client/ClientThebesLayer.cpp
@@ -43,17 +43,17 @@ SetAntialiasingFlags(Layer* aLayer, gfxC
                                                                      Float(bounds.width), Float(bounds.height)));
     transformedBounds.RoundOut();
     IntRect intTransformedBounds;
     transformedBounds.ToIntRect(&intTransformedBounds);
     dt->SetPermitSubpixelAA(!(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
                             dt->GetOpaqueRect().Contains(intTransformedBounds));
   } else {
     nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
-    if (surface->GetContentType() != gfxASurface::CONTENT_COLOR_ALPHA) {
+    if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) {
       // Destination doesn't have alpha channel; no need to set any special flags
       return;
     }
 
     const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
     surface->SetSubpixelAntialiasingEnabled(
         !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
         surface->GetOpaqueRect().Contains(
@@ -70,18 +70,18 @@ ClientThebesLayer::PaintThebes()
   
   //TODO: This is going to copy back pixels that we might end up
   // drawing over anyway. It would be nice if we could avoid
   // this duplication.
   mContentClient->SyncFrontBufferToBackBuffer();
 
   bool canUseOpaqueSurface = CanUseOpaqueSurface();
   ContentType contentType =
-    canUseOpaqueSurface ? gfxASurface::CONTENT_COLOR :
-                          gfxASurface::CONTENT_COLOR_ALPHA;
+    canUseOpaqueSurface ? GFX_CONTENT_COLOR :
+                          GFX_CONTENT_COLOR_ALPHA;
 
   {
     uint32_t flags = 0;
 #ifndef MOZ_WIDGET_ANDROID
     if (ClientManager()->CompositorMightResample()) {
       flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE;
     }
     if (!(flags & ThebesLayerBuffer::PAINT_WILL_RESAMPLE)) {
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -104,17 +104,17 @@ CompositableClient::GetAsyncID() const
 void
 CompositableChild::Destroy()
 {
   Send__delete__(this);
 }
 
 TemporaryRef<DeprecatedTextureClient>
 CompositableClient::CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType,
-                                                  gfxASurface::gfxContentType aContentType)
+                                                  gfxContentType aContentType)
 {
   MOZ_ASSERT(GetForwarder(), "Can't create a texture client if the compositable is not connected to the compositor.");
   LayersBackend parentBackend = GetForwarder()->GetCompositorBackendType();
   RefPtr<DeprecatedTextureClient> result;
 
   switch (aDeprecatedTextureClientType) {
   case TEXTURE_SHARED_GL:
     if (parentBackend == LAYERS_OPENGL) {
@@ -142,17 +142,17 @@ CompositableClient::CreateDeprecatedText
   case TEXTURE_CONTENT:
 #ifdef XP_WIN
     if (parentBackend == LAYERS_D3D11 && gfxWindowsPlatform::GetPlatform()->GetD2DDevice()) {
       result = new DeprecatedTextureClientD3D11(GetForwarder(), GetTextureInfo());
       break;
     }
     if (parentBackend == LAYERS_D3D9 &&
         !GetForwarder()->ForwardsToDifferentProcess()) {
-      if (aContentType == gfxASurface::CONTENT_COLOR_ALPHA) {
+      if (aContentType == GFX_CONTENT_COLOR_ALPHA) {
         result = new DeprecatedTextureClientDIB(GetForwarder(), GetTextureInfo());
       } else {
         result = new DeprecatedTextureClientD3D9(GetForwarder(), GetTextureInfo());
       }
       break;
     }
 #endif
      // fall through to TEXTURE_SHMEM
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -77,17 +77,17 @@ public:
   virtual ~CompositableClient();
 
   virtual TextureInfo GetTextureInfo() const = 0;
 
   LayersBackend GetCompositorBackendType() const;
 
   TemporaryRef<DeprecatedTextureClient>
   CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType,
-                                gfxASurface::gfxContentType aContentType = gfxASurface::CONTENT_SENTINEL);
+                                gfxContentType aContentType = GFX_CONTENT_SENTINEL);
 
   virtual TemporaryRef<BufferTextureClient>
   CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
 
   virtual TemporaryRef<BufferTextureClient>
   CreateBufferTextureClient(gfx::SurfaceFormat aFormat);
 
   virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -83,17 +83,17 @@ ContentClientBasic::CreateBuffer(Content
                                  uint32_t aFlags,
                                  gfxASurface** aBlackSurface,
                                  gfxASurface** aWhiteSurface,
                                  RefPtr<gfx::DrawTarget>* aBlackDT,
                                  RefPtr<gfx::DrawTarget>* aWhiteDT)
 {
   MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
   if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
-    gfxASurface::gfxImageFormat format =
+    gfxImageFormat format =
       gfxPlatform::GetPlatform()->OptimalFormatForContent(aType);
 
     *aBlackDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
       IntSize(aRect.width, aRect.height),
       ImageFormatToSurfaceFormat(format));
     return;
   }
 
@@ -701,29 +701,29 @@ ContentClientIncremental::BeginPaintBuff
     }
 
     if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
       if (!gfxPlatform::ComponentAlphaEnabled() ||
           !aLayer->GetParent() ||
           !aLayer->GetParent()->SupportsComponentAlphaChildren()) {
         mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
       } else {
-        contentType = gfxASurface::CONTENT_COLOR;
+        contentType = GFX_CONTENT_COLOR;
       }
     }
 
     if ((aFlags & ThebesLayerBuffer::PAINT_WILL_RESAMPLE) &&
         (!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
          neededRegion.GetNumRects() > 1)) {
       // The area we add to neededRegion might not be painted opaquely
       if (mode == Layer::SURFACE_OPAQUE) {
-        contentType = gfxASurface::CONTENT_COLOR_ALPHA;
+        contentType = GFX_CONTENT_COLOR_ALPHA;
         mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
       }
-      // For component alpha layers, we leave contentType as CONTENT_COLOR.
+      // For component alpha layers, we leave contentType as GFX_CONTENT_COLOR.
 
       // We need to validate the entire buffer, to make sure that only valid
       // pixels are sampled
       neededRegion = destBufferRect;
     }
 
     if (mHasBuffer &&
         (mContentType != contentType ||
@@ -898,17 +898,17 @@ ContentClientIncremental::BeginPaintBuff
   // If we don't clip, background images will be fillrect'd to the region correctly,
   // while text or lines will paint outside of the regionToDraw. This becomes apparent
   // with concave regions. Right now the scrollbars invalidate a narrow strip of the bar
   // although they never cover it. This leads to two draw rects, the narow strip and the actually
   // newly exposed area. It would be wise to fix this glitch in any way to have simpler
   // clip and draw regions.
   gfxUtils::ClipToRegion(result.mContext, result.mRegionToDraw);
 
-  if (mContentType == gfxASurface::CONTENT_COLOR_ALPHA) {
+  if (mContentType == GFX_CONTENT_COLOR_ALPHA) {
     result.mContext->SetOperator(gfxContext::OPERATOR_CLEAR);
     result.mContext->Paint();
     result.mContext->SetOperator(gfxContext::OPERATOR_OVER);
   }
 
   return result;
 }
 
--- a/gfx/layers/client/ContentClient.h
+++ b/gfx/layers/client/ContentClient.h
@@ -188,17 +188,17 @@ class ContentClientRemoteBuffer : public
   using ThebesLayerBuffer::BufferRotation;
 public:
   ContentClientRemoteBuffer(CompositableForwarder* aForwarder)
     : ContentClientRemote(aForwarder)
     , ThebesLayerBuffer(ContainsVisibleBounds)
     , mDeprecatedTextureClient(nullptr)
     , mIsNewBuffer(false)
     , mFrontAndBackBufferDiffer(false)
-    , mContentType(gfxASurface::CONTENT_COLOR_ALPHA)
+    , mContentType(GFX_CONTENT_COLOR_ALPHA)
   {}
 
   typedef ThebesLayerBuffer::PaintState PaintState;
   typedef ThebesLayerBuffer::ContentType ContentType;
 
   virtual void Clear() { ThebesLayerBuffer::Clear(); }
   PaintState BeginPaintBuffer(ThebesLayer* aLayer, ContentType aContentType,
                               uint32_t aFlags)
@@ -350,17 +350,17 @@ protected:
  * passed to the host side during the transaction, and we need to create
  * new ones each frame.
  */
 class ContentClientIncremental : public ContentClientRemote
 {
 public:
   ContentClientIncremental(CompositableForwarder* aFwd)
     : ContentClientRemote(aFwd)
-    , mContentType(gfxASurface::CONTENT_COLOR_ALPHA)
+    , mContentType(GFX_CONTENT_COLOR_ALPHA)
     , mHasBuffer(false)
     , mHasBufferOnWhite(false)
   {
     mTextureInfo.mCompositableType = BUFFER_CONTENT_INC;
   }
 
   typedef ThebesLayerBuffer::PaintState PaintState;
   typedef ThebesLayerBuffer::ContentType ContentType;
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -218,17 +218,17 @@ ImageClientSingle::UpdateImage(ImageCont
     if (mFrontBuffer &&
         (mFrontBuffer->IsImmutable() || mFrontBuffer->GetSize() != size)) {
       RemoveTextureClient(mFrontBuffer);
       mFrontBuffer = nullptr;
     }
 
     bool bufferCreated = false;
     if (!mFrontBuffer) {
-      gfxASurface::gfxImageFormat format
+      gfxImageFormat format
         = gfxPlatform::GetPlatform()->OptimalFormatForContent(surface->GetContentType());
       mFrontBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format),
                                                TEXTURE_DEALLOCATE_HOST);
       MOZ_ASSERT(mFrontBuffer->AsTextureClientSurface());
       mFrontBuffer->AsTextureClientSurface()->AllocateForSurface(size);
 
       bufferCreated = true;
     }
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -401,31 +401,31 @@ DeprecatedTextureClientShmem::ReleaseRes
   if (IsSurfaceDescriptorValid(mDescriptor)) {
     mForwarder->DestroySharedSurface(&mDescriptor);
     mDescriptor = SurfaceDescriptor();
   }
 }
 
 bool
 DeprecatedTextureClientShmem::EnsureAllocated(gfx::IntSize aSize,
-                                    gfxASurface::gfxContentType aContentType)
+                                    gfxContentType aContentType)
 {
   if (aSize != mSize ||
       aContentType != mContentType ||
       !IsSurfaceDescriptorValid(mDescriptor)) {
     ReleaseResources();
 
     mContentType = aContentType;
     mSize = aSize;
 
     if (!mForwarder->AllocSurfaceDescriptor(gfxIntSize(mSize.width, mSize.height),
                                             mContentType, &mDescriptor)) {
       NS_WARNING("creating SurfaceDescriptor failed!");
     }
-    if (mContentType == gfxASurface::CONTENT_COLOR_ALPHA) {
+    if (mContentType == GFX_CONTENT_COLOR_ALPHA) {
       gfxASurface* surface = GetSurface();
       if (!surface) {
         return false;
       }
       nsRefPtr<gfxContext> context = new gfxContext(surface);
       context->SetColor(gfxRGBA(0, 0, 0, 0));
       context->SetOperator(gfxContext::OPERATOR_SOURCE);
       context->Paint();
@@ -550,44 +550,44 @@ DeprecatedTextureClientShmemYCbCr::SetDe
     mDescriptor = SurfaceDescriptor();
   } else {
     SetDescriptor(aDescriptor);
   }
 }
 
 bool
 DeprecatedTextureClientShmemYCbCr::EnsureAllocated(gfx::IntSize aSize,
-                                         gfxASurface::gfxContentType aType)
+                                         gfxContentType aType)
 {
   NS_RUNTIMEABORT("not enough arguments to do this (need both Y and CbCr sizes)");
   return false;
 }
 
 
 DeprecatedTextureClientTile::DeprecatedTextureClientTile(CompositableForwarder* aForwarder,
                                                          const TextureInfo& aTextureInfo,
                                                          gfxReusableSurfaceWrapper* aSurface)
   : DeprecatedTextureClient(aForwarder, aTextureInfo)
   , mSurface(aSurface)
 {
   mTextureInfo.mDeprecatedTextureHostFlags = TEXTURE_HOST_TILED;
 }
 
 bool
-DeprecatedTextureClientTile::EnsureAllocated(gfx::IntSize aSize, gfxASurface::gfxContentType aType)
+DeprecatedTextureClientTile::EnsureAllocated(gfx::IntSize aSize, gfxContentType aType)
 {
   if (!mSurface ||
       mSurface->Format() != gfxPlatform::GetPlatform()->OptimalFormatForContent(aType)) {
 #ifdef MOZ_ANDROID_OMTC
     // If we're using OMTC, we can save some cycles by not using shared
     // memory. Using shared memory here is a small, but significant
     // performance regression.
     gfxImageSurface* tmpTile = new gfxImageSurface(gfxIntSize(aSize.width, aSize.height),
                                                    gfxPlatform::GetPlatform()->OptimalFormatForContent(aType),
-                                                   aType != gfxASurface::CONTENT_COLOR);
+                                                   aType != GFX_CONTENT_COLOR);
     mSurface = new gfxReusableImageSurfaceWrapper(tmpTile);
 #else
     nsRefPtr<gfxSharedImageSurface> sharedImage =
       gfxSharedImageSurface::CreateUnsafe(mForwarder,
                                           gfxIntSize(aSize.width, aSize.height),
                                           gfxPlatform::GetPlatform()->OptimalFormatForContent(aType));
     mSurface = new gfxReusableSharedImageSurfaceWrapper(mForwarder, sharedImage);
 #endif
@@ -616,21 +616,21 @@ bool AutoLockShmemClient::Update(Image* 
                                  gfxASurface *aSurface)
 {
   if (!aImage) {
     return false;
   }
 
   gfxIntSize size = aImage->GetSize();
 
-  gfxASurface::gfxContentType contentType = aSurface->GetContentType();
+  gfxContentType contentType = aSurface->GetContentType();
   bool isOpaque = (aContentFlags & Layer::CONTENT_OPAQUE);
-  if (contentType != gfxASurface::CONTENT_ALPHA &&
+  if (contentType != GFX_CONTENT_ALPHA &&
       isOpaque) {
-    contentType = gfxASurface::CONTENT_COLOR;
+    contentType = GFX_CONTENT_COLOR;
   }
   mDeprecatedTextureClient->EnsureAllocated(gfx::IntSize(size.width, size.height), contentType);
 
   OpenMode mode = mDeprecatedTextureClient->GetAccessMode() == DeprecatedTextureClient::ACCESS_READ_WRITE
                   ? OPEN_READ_WRITE
                   : OPEN_READ_ONLY;
   nsRefPtr<gfxASurface> tmpASurface =
     ShadowLayerForwarder::OpenDescriptor(mode,
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -418,17 +418,17 @@ public:
   virtual void Unlock() {}
 
   /**
    * Ensure that the texture client is suitable for the given size and content
    * type and that any initialisation has taken place.
    * Returns true if succeeded, false if failed.
    */
   virtual bool EnsureAllocated(gfx::IntSize aSize,
-                               gfxASurface::gfxContentType aType) = 0;
+                               gfxContentType aType) = 0;
 
   /**
    * _Only_ used at the end of the layer transaction when receiving a reply from
    *  the compositor.
    */
   virtual void SetDescriptorFromReply(const SurfaceDescriptor& aDescriptor)
   {
     // default implementation
@@ -467,17 +467,17 @@ public:
     mAccessMode = aAccessMode;
   }
 
   AccessMode GetAccessMode() const
   {
     return mAccessMode;
   }
 
-  virtual gfxASurface::gfxContentType GetContentType() = 0;
+  virtual gfxContentType GetContentType() = 0;
 
 protected:
   DeprecatedTextureClient(CompositableForwarder* aForwarder,
                 const TextureInfo& aTextureInfo);
 
   CompositableForwarder* mForwarder;
   // So far all DeprecatedTextureClients use a SurfaceDescriptor, so it makes sense to
   // keep the reference here.
@@ -499,80 +499,80 @@ public:
   virtual gfxImageSurface* LockImageSurface() MOZ_OVERRIDE;
   virtual gfxASurface* LockSurface() MOZ_OVERRIDE { return GetSurface(); }
   virtual gfx::DrawTarget* LockDrawTarget();
   virtual gfx::BackendType BackendType() MOZ_OVERRIDE
   {
     return gfx::BACKEND_CAIRO;
   }
   virtual void Unlock() MOZ_OVERRIDE;
-  virtual bool EnsureAllocated(gfx::IntSize aSize, gfxASurface::gfxContentType aType) MOZ_OVERRIDE;
+  virtual bool EnsureAllocated(gfx::IntSize aSize, gfxContentType aType) MOZ_OVERRIDE;
 
   virtual void ReleaseResources() MOZ_OVERRIDE;
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
-  virtual gfxASurface::gfxContentType GetContentType() MOZ_OVERRIDE { return mContentType; }
+  virtual gfxContentType GetContentType() MOZ_OVERRIDE { return mContentType; }
 private:
   gfxASurface* GetSurface();
 
   nsRefPtr<gfxASurface> mSurface;
   nsRefPtr<gfxImageSurface> mSurfaceAsImage;
   RefPtr<gfx::DrawTarget> mDrawTarget;
 
-  gfxASurface::gfxContentType mContentType;
+  gfxContentType mContentType;
   gfx::IntSize mSize;
 
   friend class CompositingFactory;
 };
 
 // XXX - this class can be removed as soon as we remove DeprecatedImageClientSingle
 class DeprecatedTextureClientShmemYCbCr : public DeprecatedTextureClient
 {
 public:
   DeprecatedTextureClientShmemYCbCr(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo)
     : DeprecatedTextureClient(aForwarder, aTextureInfo)
   { }
   ~DeprecatedTextureClientShmemYCbCr() { ReleaseResources(); }
 
   virtual bool SupportsType(DeprecatedTextureClientType aType) MOZ_OVERRIDE { return aType == TEXTURE_YCBCR; }
-  bool EnsureAllocated(gfx::IntSize aSize, gfxASurface::gfxContentType aType) MOZ_OVERRIDE;
+  bool EnsureAllocated(gfx::IntSize aSize, gfxContentType aType) MOZ_OVERRIDE;
   virtual void SetDescriptorFromReply(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
   virtual void ReleaseResources();
-  virtual gfxASurface::gfxContentType GetContentType() MOZ_OVERRIDE { return gfxASurface::CONTENT_COLOR_ALPHA; }
+  virtual gfxContentType GetContentType() MOZ_OVERRIDE { return GFX_CONTENT_COLOR_ALPHA; }
 };
 
 class DeprecatedTextureClientTile : public DeprecatedTextureClient
 {
 public:
   DeprecatedTextureClientTile(const DeprecatedTextureClientTile& aOther);
   DeprecatedTextureClientTile(CompositableForwarder* aForwarder,
                               const TextureInfo& aTextureInfo,
                               gfxReusableSurfaceWrapper* aSurface = nullptr);
   ~DeprecatedTextureClientTile();
 
   virtual bool EnsureAllocated(gfx::IntSize aSize,
-                               gfxASurface::gfxContentType aType) MOZ_OVERRIDE;
+                               gfxContentType aType) MOZ_OVERRIDE;
 
   virtual gfxImageSurface* LockImageSurface() MOZ_OVERRIDE;
 
   gfxReusableSurfaceWrapper* GetReusableSurfaceWrapper()
   {
     return mSurface;
   }
 
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
   {
     MOZ_ASSERT(false, "Tiled texture clients don't use SurfaceDescriptors.");
   }
 
 
-  virtual gfxASurface::gfxContentType GetContentType() { return mContentType; }
+  virtual gfxContentType GetContentType() { return mContentType; }
 
 private:
-  gfxASurface::gfxContentType mContentType;
+  gfxContentType mContentType;
   nsRefPtr<gfxReusableSurfaceWrapper> mSurface;
 
   friend class CompositingFactory;
 };
 
 /**
  * Base class for AutoLock*Client.
  * handles lock/unlock
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -110,23 +110,23 @@ BasicTiledLayerBuffer::BasicTiledLayerBu
 
 bool
 BasicTiledLayerBuffer::HasFormatChanged() const
 {
   return mThebesLayer->CanUseOpaqueSurface() != mLastPaintOpaque;
 }
 
 
-gfxASurface::gfxContentType
+gfxContentType
 BasicTiledLayerBuffer::GetContentType() const
 {
   if (mThebesLayer->CanUseOpaqueSurface()) {
-    return gfxASurface::CONTENT_COLOR;
+    return GFX_CONTENT_COLOR;
   } else {
-    return gfxASurface::CONTENT_COLOR_ALPHA;
+    return GFX_CONTENT_COLOR_ALPHA;
   }
 }
 
 
 TileDescriptor
 BasicTiledLayerTile::GetTileDescriptor()
 {
   gfxReusableSurfaceWrapper* surface = GetSurface();
@@ -234,17 +234,17 @@ BasicTiledLayerBuffer::PaintThebes(const
   */
 
   if (useSinglePaintBuffer) {
     nsRefPtr<gfxContext> ctxt;
 
     const nsIntRect bounds = aPaintRegion.GetBounds();
     {
       PROFILER_LABEL("BasicTiledLayerBuffer", "PaintThebesSingleBufferAlloc");
-      gfxASurface::gfxImageFormat format =
+      gfxImageFormat format =
         gfxPlatform::GetPlatform()->OptimalFormatForContent(
           GetContentType());
 
       if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
         mSinglePaintDrawTarget =
           gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
             gfx::IntSize(ceilf(bounds.width * mResolution),
                          ceilf(bounds.height * mResolution)),
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -215,17 +215,17 @@ protected:
 
   void SwapTiles(BasicTiledLayerTile& aTileA, BasicTiledLayerTile& aTileB) {
     std::swap(aTileA, aTileB);
   }
 
   BasicTiledLayerTile GetPlaceholderTile() const { return BasicTiledLayerTile(); }
 
 private:
-  gfxASurface::gfxContentType GetContentType() const;
+  gfxContentType GetContentType() const;
   ClientTiledThebesLayer* mThebesLayer;
   ClientLayerManager* mManager;
   LayerManager::DrawThebesLayerCallback mCallback;
   void* mCallbackData;
   gfxSize mFrameResolution;
   bool mLastPaintOpaque;
 
   // The buffer we use when UseSinglePaintBuffer() above is true.
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -465,17 +465,17 @@ BufferTextureHost::GetAsSurface()
   } else if (mFormat == gfx::FORMAT_YUV) {
     YCbCrImageDataDeserializer yuvDeserializer(GetBuffer());
     if (!yuvDeserializer.IsValid()) {
       return nullptr;
     }
     result = new gfxImageSurface(yuvDeserializer.GetYData(),
                                  yuvDeserializer.GetYSize(),
                                  yuvDeserializer.GetYStride(),
-                                 gfxASurface::ImageFormatA8);
+                                 gfxImageFormatA8);
   } else {
     ImageDataDeserializer deserializer(GetBuffer());
     if (!deserializer.IsValid()) {
       return nullptr;
     }
     RefPtr<gfxImageSurface> surf = deserializer.GetAsThebesSurface();
     result = surf.get();
   }
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -670,17 +670,17 @@ public:
 #endif
 
   /**
    * TEMPORARY.
    *
    * Ensure that a buffer of the given size/type has been allocated so that
    * we can update it using Update and/or CopyTo.
    */
-  virtual void EnsureBuffer(const nsIntSize& aSize, gfxASurface::gfxContentType aType)
+  virtual void EnsureBuffer(const nsIntSize& aSize, gfxContentType aType)
   {
     NS_RUNTIMEABORT("DeprecatedTextureHost doesn't support EnsureBuffer");
   }
 
   /**
    * Copy the contents of this DeprecatedTextureHost to aDest. aDest must already
    * have a suitable buffer allocated using EnsureBuffer.
    *
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -88,24 +88,24 @@ CanvasLayerD3D10::Initialize(const Data&
     // bypassing Thebes
     mSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget);
   } else {
     NS_ERROR("CanvasLayer created without mSurface, mDrawTarget or mGLContext?");
   }
 
   mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
 
-  if (mSurface && mSurface->GetType() == gfxASurface::SurfaceTypeD2D) {
+  if (mSurface && mSurface->GetType() == gfxSurfaceTypeD2D) {
     void *data = mSurface->GetData(&gKeyD3D10Texture);
     if (data) {
       mTexture = static_cast<ID3D10Texture2D*>(data);
       mIsD2DTexture = true;
       device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView));
       mHasAlpha =
-        mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
+        mSurface->GetContentType() == GFX_CONTENT_COLOR_ALPHA;
       return;
     }
   }
 
   mIsD2DTexture = false;
 
   // Create a texture in case we need to readback.
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, mBounds.width, mBounds.height, 1, 1);
@@ -161,17 +161,17 @@ CanvasLayerD3D10::UpdateSurface()
 
         gfxImageSurface* frameData = shareSurf->GetData();
         // Scope for gfxContext, so it's destroyed before Unmap.
         {
           nsRefPtr<gfxImageSurface> mapSurf = 
               new gfxImageSurface((uint8_t*)map.pData,
                                   shareSurf->Size(),
                                   map.RowPitch,
-                                  gfxASurface::ImageFormatARGB32);
+                                  gfxImageFormatARGB32);
 
           nsRefPtr<gfxContext> ctx = new gfxContext(mapSurf);
           ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
           ctx->SetSource(frameData);
           ctx->Paint();
 
           mapSurf->Flush();
         }
@@ -199,17 +199,17 @@ CanvasLayerD3D10::UpdateSurface()
       return;
     }
 
     nsRefPtr<gfxImageSurface> dstSurface;
 
     dstSurface = new gfxImageSurface((unsigned char*)map.pData,
                                      gfxIntSize(mBounds.width, mBounds.height),
                                      map.RowPitch,
-                                     gfxASurface::ImageFormatARGB32);
+                                     gfxImageFormatARGB32);
     nsRefPtr<gfxContext> ctx = new gfxContext(dstSurface);
     ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
     ctx->SetSource(mSurface);
     ctx->Paint();
     
     mTexture->Unmap(0);
     mSRView = mUploadSRView;
   }
--- a/gfx/layers/d3d10/ImageLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp
@@ -48,33 +48,33 @@ static already_AddRefed<ID3D10Texture2D>
 SurfaceToTexture(ID3D10Device *aDevice,
                  gfxASurface *aSurface,
                  const gfxIntSize &aSize)
 {
   if (!aSurface) {
     return nullptr;
   }
 
-  if (aSurface->GetType() == gfxASurface::SurfaceTypeD2D) {
+  if (aSurface->GetType() == gfxSurfaceTypeD2D) {
     void *data = aSurface->GetData(&gKeyD3D10Texture);
     if (data) {
       nsRefPtr<ID3D10Texture2D> texture = static_cast<ID3D10Texture2D*>(data);
       ID3D10Device *dev;
       texture->GetDevice(&dev);
       if (dev == aDevice) {
         return texture.forget();
       }
     }
   }
 
   nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
 
   if (!imageSurface) {
     imageSurface = new gfxImageSurface(aSize,
-                                       gfxASurface::ImageFormatARGB32);
+                                       gfxImageFormatARGB32);
 
     nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
     context->SetSource(aSurface);
     context->SetOperator(gfxContext::OPERATOR_SOURCE);
     context->Paint();
   }
 
   return DataToTexture(aDevice, imageSurface->Data(), imageSurface->Stride(), aSize);
@@ -132,17 +132,17 @@ ImageLayerD3D10::GetImageSRView(Image* a
       dat->mTexture = SurfaceToTexture(device(), cairoImage->mSurface, cairoImage->mSize);
 
       if (dat->mTexture) {
         device()->CreateShaderResourceView(dat->mTexture, nullptr, getter_AddRefs(dat->mSRView));
         aImage->SetBackendData(mozilla::layers::LAYERS_D3D10, dat.forget());
       }
     }
 
-    aHasAlpha = cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
+    aHasAlpha = cairoImage->mSurface->GetContentType() == GFX_CONTENT_COLOR_ALPHA;
   } else if (aImage->GetFormat() == ImageFormat::D3D9_RGB32_TEXTURE) {
     if (!aImage->GetBackendData(mozilla::layers::LAYERS_D3D10)) {
       // Use resource sharing to open the D3D9 texture as a D3D10 texture,
       HRESULT hr;
       D3D9SurfaceImage* d3dImage = reinterpret_cast<D3D9SurfaceImage*>(aImage);
       nsRefPtr<ID3D10Texture2D> texture;
       hr = device()->OpenSharedResource(d3dImage->GetShareHandle(),
                                         IID_ID3D10Texture2D,
@@ -210,17 +210,17 @@ ImageLayerD3D10::RenderLayer()
   nsRefPtr<IDXGIKeyedMutex> keyedMutex;
 
   if (image->GetFormat() == ImageFormat::CAIRO_SURFACE ||
       image->GetFormat() == ImageFormat::REMOTE_IMAGE_BITMAP ||
       image->GetFormat() == ImageFormat::REMOTE_IMAGE_DXGI_TEXTURE ||
       image->GetFormat() == ImageFormat::D3D9_RGB32_TEXTURE) {
     NS_ASSERTION(image->GetFormat() != ImageFormat::CAIRO_SURFACE ||
                  !static_cast<CairoImage*>(image)->mSurface ||
-                 static_cast<CairoImage*>(image)->mSurface->GetContentType() != gfxASurface::CONTENT_ALPHA,
+                 static_cast<CairoImage*>(image)->mSurface->GetContentType() != GFX_CONTENT_ALPHA,
                  "Image layer has alpha image");
     bool hasAlpha = false;
 
     nsRefPtr<ID3D10ShaderResourceView> srView = GetImageSRView(image, hasAlpha, getter_AddRefs(keyedMutex));
     if (!srView) {
       return;
     }
 
@@ -461,18 +461,18 @@ RemoteDXGITextureImage::GetAsSurface()
     return nullptr;
   }
 
   device->CopyResource(softTexture, data->mTexture);
   keyedMutex->ReleaseSync(0);
 
   nsRefPtr<gfxImageSurface> surface =
     new gfxImageSurface(mSize, mFormat == RemoteImageData::BGRX32 ?
-                                          gfxASurface::ImageFormatRGB24 :
-                                          gfxASurface::ImageFormatARGB32);
+                                          gfxImageFormatRGB24 :
+                                          gfxImageFormatARGB32);
 
   if (!surface->CairoSurface() || surface->CairoStatus()) {
     NS_WARNING("Failed to created image surface for DXGI texture.");
     return nullptr;
   }
 
   D3D10_MAPPED_TEXTURE2D mapped;
   softTexture->Map(0, D3D10_MAP_READ, 0, &mapped);
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -446,20 +446,20 @@ LayerManagerD3D10::CreateReadbackLayer()
 
 static void ReleaseTexture(void *texture)
 {
   static_cast<ID3D10Texture2D*>(texture)->Release();
 }
 
 already_AddRefed<gfxASurface>
 LayerManagerD3D10::CreateOptimalSurface(const gfxIntSize &aSize,
-                                   gfxASurface::gfxImageFormat aFormat)
+                                   gfxImageFormat aFormat)
 {
-  if ((aFormat != gfxASurface::ImageFormatRGB24 &&
-       aFormat != gfxASurface::ImageFormatARGB32)) {
+  if ((aFormat != gfxImageFormatRGB24 &&
+       aFormat != gfxImageFormatARGB32)) {
     return LayerManager::CreateOptimalSurface(aSize, aFormat);
   }
 
   nsRefPtr<ID3D10Texture2D> texture;
   
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, aSize.width, aSize.height, 1, 1);
   desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
   desc.MiscFlags = D3D10_RESOURCE_MISC_GDI_COMPATIBLE;
@@ -467,35 +467,35 @@ LayerManagerD3D10::CreateOptimalSurface(
   HRESULT hr = device()->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture));
 
   if (FAILED(hr)) {
     NS_WARNING("Failed to create new texture for CreateOptimalSurface!");
     return LayerManager::CreateOptimalSurface(aSize, aFormat);
   }
 
   nsRefPtr<gfxD2DSurface> surface =
-    new gfxD2DSurface(texture, aFormat == gfxASurface::ImageFormatRGB24 ?
-      gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA);
+    new gfxD2DSurface(texture, aFormat == gfxImageFormatRGB24 ?
+      GFX_CONTENT_COLOR : GFX_CONTENT_COLOR_ALPHA);
 
   if (!surface || surface->CairoStatus()) {
     return LayerManager::CreateOptimalSurface(aSize, aFormat);
   }
 
   surface->SetData(&gKeyD3D10Texture,
                    texture.forget().get(),
                    ReleaseTexture);
 
   return surface.forget();
 }
 
 
 already_AddRefed<gfxASurface>
 LayerManagerD3D10::CreateOptimalMaskSurface(const gfxIntSize &aSize)
 {
-  return CreateOptimalSurface(aSize, gfxASurface::ImageFormatARGB32);
+  return CreateOptimalSurface(aSize, gfxImageFormatARGB32);
 }
 
 
 TemporaryRef<DrawTarget>
 LayerManagerD3D10::CreateDrawTarget(const IntSize &aSize,
                                     SurfaceFormat aFormat)
 {
   if ((aFormat != FORMAT_B8G8R8A8 &&
@@ -765,17 +765,17 @@ LayerManagerD3D10::PaintToTarget()
 
   D3D10_MAPPED_TEXTURE2D map;
   readTexture->Map(0, D3D10_MAP_READ, 0, &map);
 
   nsRefPtr<gfxImageSurface> tmpSurface =
     new gfxImageSurface((unsigned char*)map.pData,
                         gfxIntSize(bbDesc.Width, bbDesc.Height),
                         map.RowPitch,
-                        gfxASurface::ImageFormatARGB32);
+                        gfxImageFormatARGB32);
 
   mTarget->SetSource(tmpSurface);
   mTarget->SetOperator(gfxContext::OPERATOR_OVER);
   mTarget->Paint();
 
   readTexture->Unmap(0);
 }
 
--- a/gfx/layers/d3d10/LayerManagerD3D10.h
+++ b/gfx/layers/d3d10/LayerManagerD3D10.h
@@ -106,17 +106,17 @@ public:
   virtual already_AddRefed<ContainerLayer> CreateContainerLayer();
   virtual already_AddRefed<ImageLayer> CreateImageLayer();
   virtual already_AddRefed<ColorLayer> CreateColorLayer();
   virtual already_AddRefed<CanvasLayer> CreateCanvasLayer();
   virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer();
 
   virtual already_AddRefed<gfxASurface>
     CreateOptimalSurface(const gfxIntSize &aSize,
-                         gfxASurface::gfxImageFormat imageFormat);
+                         gfxImageFormat imageFormat);
 
   virtual already_AddRefed<gfxASurface>
     CreateOptimalMaskSurface(const gfxIntSize &aSize);
 
   virtual TemporaryRef<mozilla::gfx::DrawTarget>
     CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
                      mozilla::gfx::SurfaceFormat aFormat);
 
--- a/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
+++ b/gfx/layers/d3d10/ReadbackManagerD3D10.cpp
@@ -67,17 +67,17 @@ public:
       update->mLayer->GetSink()->SetUnknown(update->mSequenceCounter);
       return NS_OK;
     }
 
     nsRefPtr<gfxImageSurface> sourceSurface =
       new gfxImageSurface((unsigned char*)mappedTex.pData,
                           gfxIntSize(desc.Width, desc.Height),
                           mappedTex.RowPitch,
-                          gfxASurface::ImageFormatRGB24);
+                          gfxImageFormatRGB24);
 
     nsRefPtr<gfxContext> ctx =
       update->mLayer->GetSink()->BeginUpdate(update->mUpdateRect + offset,
                                              update->mSequenceCounter);
 
     if (ctx) {
       ctx->Translate(gfxPoint(offset.x, offset.y));
       ctx->SetSource(sourceSurface, gfxPoint(mTask->mOrigin.x,
--- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp
@@ -281,18 +281,18 @@ ThebesLayerD3D10::GetLayer()
 {
   return this;
 }
 
 void
 ThebesLayerD3D10::VerifyContentType(SurfaceMode aMode)
 {
   if (mD2DSurface) {
-    gfxASurface::gfxContentType type = aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
-      gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA;
+    gfxContentType type = aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
+      GFX_CONTENT_COLOR : GFX_CONTENT_COLOR_ALPHA;
 
     if (type != mD2DSurface->GetContentType()) {  
       mD2DSurface = new gfxD2DSurface(mTexture, type);
 
       if (!mD2DSurface || mD2DSurface->CairoStatus()) {
         NS_WARNING("Failed to create surface for ThebesLayerD3D10.");
         mD2DSurface = nullptr;
         return;
@@ -474,17 +474,17 @@ ThebesLayerD3D10::CreateNewTextures(cons
     hr = device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView));
 
     if (FAILED(hr)) {
       NS_WARNING("Failed to create shader resource view for ThebesLayerD3D10.");
     }
 
     if (!gfxPlatform::GetPlatform()->SupportsAzureContent()) {
       mD2DSurface = new gfxD2DSurface(mTexture, aMode != SURFACE_SINGLE_CHANNEL_ALPHA ?
-                                                gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA);
+                                                GFX_CONTENT_COLOR : GFX_CONTENT_COLOR_ALPHA);
 
       if (!mD2DSurface || mD2DSurface->CairoStatus()) {
         NS_WARNING("Failed to create surface for ThebesLayerD3D10.");
         mD2DSurface = nullptr;
         return;
       }
     } else {
       mDrawTarget = nullptr;
@@ -501,17 +501,17 @@ ThebesLayerD3D10::CreateNewTextures(cons
 
     hr = device()->CreateShaderResourceView(mTextureOnWhite, nullptr, getter_AddRefs(mSRViewOnWhite));
 
     if (FAILED(hr)) {
       NS_WARNING("Failed to create shader resource view for ThebesLayerD3D10.");
     }
 
     if (!gfxPlatform::GetPlatform()->SupportsAzureContent()) {
-      mD2DSurfaceOnWhite = new gfxD2DSurface(mTextureOnWhite, gfxASurface::CONTENT_COLOR);
+      mD2DSurfaceOnWhite = new gfxD2DSurface(mTextureOnWhite, GFX_CONTENT_COLOR);
 
       if (!mD2DSurfaceOnWhite || mD2DSurfaceOnWhite->CairoStatus()) {
         NS_WARNING("Failed to create surface for ThebesLayerD3D10.");
         mD2DSurfaceOnWhite = nullptr;
         return;
       }
     } else {
       mDrawTarget = nullptr;
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -907,17 +907,17 @@ CompositorD3D11::PaintToTarget()
 
   D3D11_MAPPED_SUBRESOURCE map;
   mContext->Map(readTexture, 0, D3D11_MAP_READ, 0, &map);
 
   nsRefPtr<gfxImageSurface> tmpSurface =
     new gfxImageSurface((unsigned char*)map.pData,
                         gfxIntSize(bbDesc.Width, bbDesc.Height),
                         map.RowPitch,
-                        gfxASurface::ImageFormatARGB32);
+                        gfxImageFormatARGB32);
 
   mTarget->SetSource(tmpSurface);
   mTarget->SetOperator(gfxContext::OPERATOR_SOURCE);
   mTarget->Paint();
 
   mContext->Unmap(readTexture, 0);
 }
 
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -74,17 +74,17 @@ DeprecatedTextureClientD3D11::~Deprecate
 {
   mDescriptor = SurfaceDescriptor();
 
   ClearDT();
 }
 
 bool
 DeprecatedTextureClientD3D11::EnsureAllocated(gfx::IntSize aSize,
-                                              gfxASurface::gfxContentType aType)
+                                              gfxContentType aType)
 {
   D3D10_TEXTURE2D_DESC desc;
 
   if (mTexture) {
     mTexture->GetDesc(&desc);
 
     if (desc.Width == aSize.width && desc.Height == aSize.height) {
       return true;
@@ -119,17 +119,17 @@ DeprecatedTextureClientD3D11::EnsureAllo
   hr = resource->GetSharedHandle(&sharedHandle);
 
   if (FAILED(hr)) {
     LOGD3D11("Error getting shared handle for texture.");
     return false;
   }
 
   mDescriptor = SurfaceDescriptorD3D10((WindowsHandle)sharedHandle,
-                                       aType == gfxASurface::CONTENT_COLOR_ALPHA);
+                                       aType == GFX_CONTENT_COLOR_ALPHA);
 
   mContentType = aType;
   return true;
 }
 
 gfxASurface*
 DeprecatedTextureClientD3D11::LockSurface()
 {
@@ -199,23 +199,23 @@ DeprecatedTextureClientD3D11::EnsureDraw
   if (mDrawTarget) {
     return;
   }
 
   LockTexture();
 
   SurfaceFormat format;
   switch (mContentType) {
-  case gfxASurface::CONTENT_ALPHA:
+  case GFX_CONTENT_ALPHA:
     format = FORMAT_A8;
     break;
-  case gfxASurface::CONTENT_COLOR:
+  case GFX_CONTENT_COLOR:
     format = FORMAT_B8G8R8X8;
     break;
-  case gfxASurface::CONTENT_COLOR_ALPHA:
+  case GFX_CONTENT_COLOR_ALPHA:
     format = FORMAT_B8G8R8A8;
     break;
   default:
     format = FORMAT_B8G8R8A8;
   }
 
   mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, format);
   ReleaseTexture();
@@ -312,27 +312,27 @@ DeprecatedTextureHostShmemD3D11::UpdateI
   nsRefPtr<gfxImageSurface> surf = openSurf.GetAsImage();
 
   gfxIntSize size = surf->GetSize();
 
   uint32_t bpp = 0;
 
   DXGI_FORMAT dxgiFormat;
   switch (surf->Format()) {
-  case gfxImageSurface::ImageFormatRGB24:
+  case gfxImageFormatRGB24:
     mFormat = FORMAT_B8G8R8X8;
     dxgiFormat = DXGI_FORMAT_B8G8R8X8_UNORM;
     bpp = 4;
     break;
-  case gfxImageSurface::ImageFormatARGB32:
+  case gfxImageFormatARGB32:
     mFormat = FORMAT_B8G8R8A8;
     dxgiFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
     bpp = 4;
     break;
-  case gfxImageSurface::ImageFormatA8:
+  case gfxImageFormatA8:
     mFormat = FORMAT_A8;
     dxgiFormat = DXGI_FORMAT_A8_UNORM;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -74,29 +74,29 @@ public:
   virtual ~DeprecatedTextureClientD3D11();
 
   virtual bool SupportsType(DeprecatedTextureClientType aType) MOZ_OVERRIDE
   {
     return aType == TEXTURE_CONTENT;
   }
 
   virtual bool EnsureAllocated(gfx::IntSize aSize,
-                               gfxASurface::gfxContentType aType) MOZ_OVERRIDE;
+                               gfxContentType aType) MOZ_OVERRIDE;
 
   virtual gfxASurface* LockSurface() MOZ_OVERRIDE;
   virtual gfx::DrawTarget* LockDrawTarget() MOZ_OVERRIDE;
   virtual gfx::BackendType BackendType() MOZ_OVERRIDE
   {
     return gfx::BACKEND_DIRECT2D;
   }
 
   virtual void Unlock() MOZ_OVERRIDE;
 
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
-  virtual gfxASurface::gfxContentType GetContentType() MOZ_OVERRIDE
+  virtual gfxContentType GetContentType() MOZ_OVERRIDE
   {
     return mContentType;
   }
 
 private:
   void EnsureSurface();
   void EnsureDrawTarget();
   void LockTexture();
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -103,17 +103,17 @@ CanvasLayerD3D9::UpdateSurface()
 
     gfxImageSurface* frameData = shareSurf->GetData();
     // Scope for gfxContext, so it's destroyed early.
     {
       nsRefPtr<gfxImageSurface> mapSurf =
           new gfxImageSurface((uint8_t*)rect.pBits,
                               shareSurf->Size(),
                               rect.Pitch,
-                              gfxASurface::ImageFormatARGB32);
+                              gfxImageFormatARGB32);
 
       gfxContext ctx(mapSurf);
       ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
       ctx.SetSource(frameData);
       ctx.Paint();
 
       mapSurf->Flush();
     }
@@ -129,38 +129,38 @@ CanvasLayerD3D9::UpdateSurface()
       NS_WARNING("Failed to lock CanvasLayer texture.");
       return;
     }
 
     D3DLOCKED_RECT lockedRect = textureLock.GetLockRect();
 
     nsRefPtr<gfxImageSurface> sourceSurface;
 
-    if (mSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
+    if (mSurface->GetType() == gfxSurfaceTypeWin32) {
       sourceSurface = mSurface->GetAsImageSurface();
-    } else if (mSurface->GetType() == gfxASurface::SurfaceTypeImage) {
+    } else if (mSurface->GetType() == gfxSurfaceTypeImage) {
       sourceSurface = static_cast<gfxImageSurface*>(mSurface.get());
-      if (sourceSurface->Format() != gfxASurface::ImageFormatARGB32 &&
-          sourceSurface->Format() != gfxASurface::ImageFormatRGB24)
+      if (sourceSurface->Format() != gfxImageFormatARGB32 &&
+          sourceSurface->Format() != gfxImageFormatRGB24)
       {
         return;
       }
     } else {
       sourceSurface = new gfxImageSurface(gfxIntSize(mBounds.width, mBounds.height),
-                                          gfxASurface::ImageFormatARGB32);
+                                          gfxImageFormatARGB32);
       nsRefPtr<gfxContext> ctx = new gfxContext(sourceSurface);
       ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
       ctx->SetSource(mSurface);
       ctx->Paint();
     }
 
     uint8_t *startBits = sourceSurface->Data();
     uint32_t sourceStride = sourceSurface->Stride();
 
-    if (sourceSurface->Format() != gfxASurface::ImageFormatARGB32) {
+    if (sourceSurface->Format() != gfxImageFormatARGB32) {
       mHasAlpha = false;
     } else {
       mHasAlpha = true;
     }
 
     for (int y = 0; y < mBounds.height; y++) {
       memcpy((uint8_t*)lockedRect.pBits + lockedRect.Pitch * y,
              startBits + sourceStride * y,
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -565,17 +565,17 @@ CompositorD3D9::PaintToTarget()
 
   D3DLOCKED_RECT rect;
   destSurf->LockRect(&rect, NULL, D3DLOCK_READONLY);
   mTarget->SetOperator(gfxContext::OPERATOR_SOURCE);
   nsRefPtr<gfxImageSurface> imageSurface =
     new gfxImageSurface((unsigned char*)rect.pBits,
                         gfxIntSize(desc.Width, desc.Height),
                         rect.Pitch,
-                        gfxASurface::ImageFormatARGB32);
+                        gfxImageFormatARGB32);
   mTarget->SetSource(imageSurface);
   mTarget->Paint();
   destSurf->UnlockRect();
 }
 
 void
 CompositorD3D9::ReportFailure(const nsACString &aMsg, HRESULT aCode)
 {
--- a/gfx/layers/d3d9/ImageLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp
@@ -18,17 +18,17 @@
 #include "D3D9SurfaceImage.h"
 
 namespace mozilla {
 namespace layers {
 
 static inline _D3DFORMAT
 D3dFormatForGfxFormat(gfxImageFormat aFormat)
 {
-  if (aFormat == gfxASurface::ImageFormatA8) {
+  if (aFormat == gfxImageFormatA8) {
     return D3DFMT_A8;
   }
 
   return D3DFMT_A8R8G8B8;
 }
 
 static already_AddRefed<IDirect3DTexture9>
 DataToTexture(IDirect3DDevice9 *aDevice,
@@ -132,17 +132,17 @@ SurfaceToTexture(IDirect3DDevice9 *aDevi
                  gfxASurface *aSurface,
                  const gfxIntSize &aSize)
 {
 
   nsRefPtr<gfxImageSurface> imageSurface = aSurface->GetAsImageSurface();
 
   if (!imageSurface) {
     imageSurface = new gfxImageSurface(aSize,
-                                       gfxASurface::ImageFormatARGB32);
+                                       gfxImageFormatARGB32);
 
     nsRefPtr<gfxContext> context = new gfxContext(imageSurface);
     context->SetSource(aSurface);
     context->SetOperator(gfxContext::OPERATOR_SOURCE);
     context->Paint();
   }
 
   return DataToTexture(aDevice, imageSurface->Data(), imageSurface->Stride(),
@@ -347,17 +347,17 @@ ImageLayerD3D9::GetTexture(Image *aImage
     if (!aImage->GetBackendData(mozilla::layers::LAYERS_D3D9)) {
       nsAutoPtr<TextureD3D9BackendData> dat(new TextureD3D9BackendData());
       dat->mTexture = SurfaceToTexture(device(), cairoImage->mSurface, cairoImage->mSize);
       if (dat->mTexture) {
         aImage->SetBackendData(mozilla::layers::LAYERS_D3D9, dat.forget());
       }
     }
 
-    aHasAlpha = cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
+    aHasAlpha = cairoImage->mSurface->GetContentType() == GFX_CONTENT_COLOR_ALPHA;
   } else if (aImage->GetFormat() == D3D9_RGB32_TEXTURE) {
     if (!aImage->GetBackendData(mozilla::layers::LAYERS_D3D9)) {
       // The texture in which the frame is stored belongs to DXVA's D3D9 device.
       // We need to open it on our device before we can use it.
       nsAutoPtr<TextureD3D9BackendData> backendData(new TextureD3D9BackendData());
       D3D9SurfaceImage* image = static_cast<D3D9SurfaceImage*>(aImage);
       backendData->mTexture = OpenSharedTexture(image->GetDesc(), image->GetShareHandle(), device());
       if (backendData->mTexture) {
@@ -406,17 +406,17 @@ ImageLayerD3D9::RenderLayer()
   gfxIntSize size = image->GetSize();
 
   if (image->GetFormat() == CAIRO_SURFACE ||
       image->GetFormat() == REMOTE_IMAGE_BITMAP ||
       image->GetFormat() == D3D9_RGB32_TEXTURE)
   {
     NS_ASSERTION(image->GetFormat() != CAIRO_SURFACE ||
                  !static_cast<CairoImage*>(image)->mSurface ||
-                 static_cast<CairoImage*>(image)->mSurface->GetContentType() != gfxASurface::CONTENT_ALPHA,
+                 static_cast<CairoImage*>(image)->mSurface->GetContentType() != GFX_CONTENT_ALPHA,
                  "Image layer has alpha image");
 
     bool hasAlpha = false;
     nsRefPtr<IDirect3DTexture9> texture = GetTexture(image, hasAlpha);
 
     device()->SetVertexShaderConstantF(CBvLayerQuad,
                                        ShaderConstantRect(0,
                                                           0,
--- a/gfx/layers/d3d9/LayerManagerD3D9.cpp
+++ b/gfx/layers/d3d9/LayerManagerD3D9.cpp
@@ -347,17 +347,17 @@ LayerManagerD3D9::PaintToTarget()
 
   D3DLOCKED_RECT rect;
   destSurf->LockRect(&rect, nullptr, D3DLOCK_READONLY);
 
   nsRefPtr<gfxImageSurface> imageSurface =
     new gfxImageSurface((unsigned char*)rect.pBits,
                         gfxIntSize(desc.Width, desc.Height),
                         rect.Pitch,
-                        gfxASurface::ImageFormatARGB32);
+                        gfxImageFormatARGB32);
 
   mTarget->SetSource(imageSurface);
   mTarget->SetOperator(gfxContext::OPERATOR_OVER);
   mTarget->Paint();
   destSurf->UnlockRect();
 }
 
 LayerD3D9::LayerD3D9(LayerManagerD3D9 *aManager)
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -257,27 +257,27 @@ DeprecatedTextureHostShmemD3D9::UpdateIm
 
   gfxIntSize size = surf->GetSize();
   mSize = IntSize(size.width, size.height);
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   switch (surf->Format()) {
-  case gfxImageSurface::ImageFormatRGB24:
+  case gfxImageFormatRGB24:
     mFormat = FORMAT_B8G8R8X8;
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageSurface::ImageFormatARGB32:
+  case gfxImageFormatARGB32:
     mFormat = FORMAT_B8G8R8A8;
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageSurface::ImageFormatA8:
+  case gfxImageFormatA8:
     mFormat = FORMAT_A8;
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
@@ -523,27 +523,27 @@ DeprecatedTextureHostDIB::UpdateImpl(con
 
   gfxIntSize size = surf->GetSize();
   mSize = IntSize(size.width, size.height);
 
   uint32_t bpp = 0;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   switch (gfxPlatform::GetPlatform()->OptimalFormatForContent(surf->GetContentType())) {
-  case gfxImageSurface::ImageFormatRGB24:
+  case gfxImageFormatRGB24:
     mFormat = FORMAT_B8G8R8X8;
     format = D3DFMT_X8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageSurface::ImageFormatARGB32:
+  case gfxImageFormatARGB32:
     mFormat = FORMAT_B8G8R8A8;
     format = D3DFMT_A8R8G8B8;
     bpp = 4;
     break;
-  case gfxImageSurface::ImageFormatA8:
+  case gfxImageFormatA8:
     mFormat = FORMAT_A8;
     format = D3DFMT_A8;
     bpp = 1;
     break;
   default:
     NS_ERROR("Bad image format");
   }
 
@@ -588,17 +588,17 @@ DeprecatedTextureClientD3D9::~Deprecated
   Unlock();
   mDescriptor = SurfaceDescriptor();
 
   mDrawTarget = nullptr;
 }
 
 bool
 DeprecatedTextureClientD3D9::EnsureAllocated(gfx::IntSize aSize,
-                                   gfxASurface::gfxContentType aType)
+                                   gfxContentType aType)
 {
   if (mTexture) {
     D3DSURFACE_DESC desc;
     mTexture->GetLevelDesc(0, &desc);
 
     if (desc.Width == aSize.width &&
         desc.Height == aSize.height) {
       return true;
@@ -608,23 +608,23 @@ DeprecatedTextureClientD3D9::EnsureAlloc
     mD3D9Surface = nullptr;
     mTexture = nullptr;
   }
 
   mSize = aSize;
 
   _D3DFORMAT format = D3DFMT_A8R8G8B8;
   switch (aType) {
-  case gfxASurface::CONTENT_COLOR:
+  case GFX_CONTENT_COLOR:
     format = D3DFMT_X8R8G8B8;
     break;
-  case gfxASurface::CONTENT_COLOR_ALPHA:
+  case GFX_CONTENT_COLOR_ALPHA:
     // fallback to DIB texture client
     return false;
-  case gfxASurface::CONTENT_ALPHA:
+  case GFX_CONTENT_ALPHA:
     format = D3DFMT_A8;
     break;
   default:
     NS_ERROR("Bad image type");
   }
 
   IDirect3DDevice9 *device = gfxWindowsPlatform::GetPlatform()->GetD3D9Device();
   if (!device ||
@@ -734,17 +734,17 @@ DeprecatedTextureClientDIB::~DeprecatedT
   // It is OK not to dealloc the surface descriptor because it is only a pointer
   // to mSurface and we will release our strong reference to that automatically.
   mDescriptor = SurfaceDescriptor();
   mDrawTarget = nullptr;
 }
 
 bool
 DeprecatedTextureClientDIB::EnsureAllocated(gfx::IntSize aSize,
-                                            gfxASurface::gfxContentType aType)
+                                            gfxContentType aType)
 {
   if (mSurface) {
     gfxIntSize size = mSurface->GetSize();
     if (size.width == aSize.width &&
         size.height == aSize.height) {
       return true;
     }
 
--- a/gfx/layers/d3d9/TextureD3D9.h
+++ b/gfx/layers/d3d9/TextureD3D9.h
@@ -262,28 +262,28 @@ public:
   virtual ~DeprecatedTextureClientD3D9();
 
   virtual bool SupportsType(DeprecatedTextureClientType aType) MOZ_OVERRIDE
   {
     return aType == TEXTURE_CONTENT;
   }
 
   virtual bool EnsureAllocated(gfx::IntSize aSize,
-                               gfxASurface::gfxContentType aType) MOZ_OVERRIDE;
+                               gfxContentType aType) MOZ_OVERRIDE;
 
   virtual gfxASurface* LockSurface() MOZ_OVERRIDE;
   virtual gfx::DrawTarget* LockDrawTarget() MOZ_OVERRIDE;
   virtual gfx::BackendType BackendType() MOZ_OVERRIDE
   {
     return gfx::BACKEND_CAIRO;
   }
   virtual void Unlock() MOZ_OVERRIDE;
 
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
-  virtual gfxASurface::gfxContentType GetContentType() MOZ_OVERRIDE
+  virtual gfxContentType GetContentType() MOZ_OVERRIDE
   {
     return mContentType;
   }
 
 private:
   nsRefPtr<IDirect3DTexture9> mTexture;
   nsRefPtr<gfxASurface> mSurface;
   nsRefPtr<IDirect3DSurface9> mD3D9Surface;
@@ -303,29 +303,29 @@ public:
   virtual ~DeprecatedTextureClientDIB();
 
   virtual bool SupportsType(DeprecatedTextureClientType aType) MOZ_OVERRIDE
   {
     return aType == TEXTURE_CONTENT;
   }
 
   virtual bool EnsureAllocated(gfx::IntSize aSize,
-                               gfxASurface::gfxContentType aType) MOZ_OVERRIDE;
+                               gfxContentType aType) MOZ_OVERRIDE;
 
   virtual gfxASurface* LockSurface() MOZ_OVERRIDE;
   virtual gfx::DrawTarget* LockDrawTarget() MOZ_OVERRIDE;
   virtual gfx::BackendType BackendType() MOZ_OVERRIDE
   {
     return gfx::BACKEND_CAIRO;
   }
   virtual void Unlock() MOZ_OVERRIDE;
 
   virtual SurfaceDescriptor* LockSurfaceDescriptor() MOZ_OVERRIDE;
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
-  virtual gfxASurface::gfxContentType GetContentType() MOZ_OVERRIDE
+  virtual gfxContentType GetContentType() MOZ_OVERRIDE
   {
     return mContentType;
   }
 
 private:
   nsRefPtr<gfxWindowsSurface> mSurface;
   RefPtr<gfx::DrawTarget> mDrawTarget;
   gfx::IntSize mSize;
--- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp
@@ -445,17 +445,17 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion 
         ReportFailure(NS_LITERAL_CSTRING("Failed to create temporary texture in system memory."), hr);
         return;
       }
 
       // XXX - We may consider retaining a SYSTEMMEM texture texture the size
       // of our DEFAULT texture and then use UpdateTexture and add dirty rects
       // to update in a single call.
       nsRefPtr<gfxWindowsSurface> dest = new gfxWindowsSurface(
-          gfxIntSize(bounds.width, bounds.height), gfxASurface::ImageFormatARGB32);
+          gfxIntSize(bounds.width, bounds.height), gfxImageFormatARGB32);
       // If the contents of this layer don't require component alpha in the
       // end of rendering, it's safe to enable Cleartype since all the Cleartype
       // glyphs must be over (or under) opaque pixels.
       dest->SetSubpixelAntialiasingEnabled(!(mContentFlags & CONTENT_COMPONENT_ALPHA));
       destinationSurface = dest.forget();
       break;
     }
 
@@ -534,17 +534,17 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion 
       }
 
       D3DLOCKED_RECT r = textureLock.GetLockRect();
 
       nsRefPtr<gfxImageSurface> imgSurface =
         new gfxImageSurface((unsigned char *)r.pBits,
                             bounds.Size(),
                             r.Pitch,
-                            gfxASurface::ImageFormatARGB32);
+                            gfxImageFormatARGB32);
 
       if (destinationSurface) {
         nsRefPtr<gfxContext> context = new gfxContext(imgSurface);
         context->SetSource(destinationSurface);
         context->SetOperator(gfxContext::OPERATOR_SOURCE);
         context->Paint();
       }
 
--- a/gfx/layers/ipc/AutoOpenSurface.h
+++ b/gfx/layers/ipc/AutoOpenSurface.h
@@ -21,18 +21,18 @@ namespace layers {
  * Some surface types can be fairly expensive to open.  This helper
  * tries to put off opening surfaces as long as it can, until
  * ahsolutely necessary.  And after being forced to open, it remembers
  * the mapping so it doesn't need to be redone.
  */
 class MOZ_STACK_CLASS AutoOpenSurface
 {
 public:
-  typedef gfxASurface::gfxContentType gfxContentType;
-  typedef gfxASurface::gfxImageFormat gfxImageFormat;
+  typedef gfxContentType gfxContentType;
+  typedef gfxImageFormat gfxImageFormat;
 
   /** |aDescriptor| must be valid while AutoOpenSurface is
    * in scope. */
   AutoOpenSurface(OpenMode aMode, const SurfaceDescriptor& aDescriptor);
 
   ~AutoOpenSurface();
 
   /**
--- a/gfx/layers/ipc/CompositableForwarder.h
+++ b/gfx/layers/ipc/CompositableForwarder.h
@@ -40,17 +40,17 @@ class BasicTiledLayerBuffer;
  * additionally forward modifications of the Layer tree).
  * ImageBridgeChild is another CompositableForwarder.
  */
 class CompositableForwarder : public ISurfaceAllocator
 {
   friend class AutoOpenSurface;
   friend class DeprecatedTextureClientShmem;
 public:
-  typedef gfxASurface::gfxContentType gfxContentType;
+  typedef gfxContentType gfxContentType;
 
   CompositableForwarder()
     : mMultiProcess(false)
   {}
 
   /**
    * Setup the IPDL actor for aCompositable to be part of layers
    * transactions.
--- a/gfx/layers/ipc/ISurfaceAllocator.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -36,43 +36,43 @@ bool
 IsSurfaceDescriptorValid(const SurfaceDescriptor& aSurface)
 {
   return aSurface.type() != SurfaceDescriptor::T__None &&
          aSurface.type() != SurfaceDescriptor::Tnull_t;
 }
 
 bool
 ISurfaceAllocator::AllocSharedImageSurface(const gfxIntSize& aSize,
-                               gfxASurface::gfxContentType aContent,
+                               gfxContentType aContent,
                                gfxSharedImageSurface** aBuffer)
 {
   SharedMemory::SharedMemoryType shmemType = OptimalShmemType();
-  gfxASurface::gfxImageFormat format = gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent);
+  gfxImageFormat format = gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent);
 
   nsRefPtr<gfxSharedImageSurface> back =
     gfxSharedImageSurface::CreateUnsafe(this, aSize, format, shmemType);
   if (!back)
     return false;
 
   *aBuffer = nullptr;
   back.swap(*aBuffer);
   return true;
 }
 
 bool
 ISurfaceAllocator::AllocSurfaceDescriptor(const gfxIntSize& aSize,
-                                          gfxASurface::gfxContentType aContent,
+                                          gfxContentType aContent,
                                           SurfaceDescriptor* aBuffer)
 {
   return AllocSurfaceDescriptorWithCaps(aSize, aContent, DEFAULT_BUFFER_CAPS, aBuffer);
 }
 
 bool
 ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfxIntSize& aSize,
-                                                  gfxASurface::gfxContentType aContent,
+                                                  gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
   bool tryPlatformSurface = true;
 #ifdef DEBUG
   tryPlatformSurface = !PR_GetEnv("MOZ_LAYERS_FORCE_SHMEM_SURFACES");
 #endif
   if (tryPlatformSurface &&
@@ -86,17 +86,17 @@ ISurfaceAllocator::AllocSurfaceDescripto
     int32_t stride = gfxASurface::FormatStrideForWidth(format, aSize.width);
     uint8_t *data = new (std::nothrow) uint8_t[stride * aSize.height];
     if (!data) {
       return false;
     }
 #ifdef XP_MACOSX
     // Workaround a bug in Quartz where drawing an a8 surface to another a8
     // surface with OPERATOR_SOURCE still requires the destination to be clear.
-    if (format == gfxASurface::ImageFormatA8) {
+    if (format == gfxImageFormatA8) {
       memset(data, 0, stride * aSize.height);
     }
 #endif
     *aBuffer = MemoryImage((uintptr_t)data, aSize, stride, format);
     return true;
   }
 
   nsRefPtr<gfxSharedImageSurface> buffer;
@@ -144,17 +144,17 @@ ISurfaceAllocator::DestroySharedSurface(
       NS_RUNTIMEABORT("surface type not implemented!");
   }
   *aSurface = SurfaceDescriptor();
 }
 
 #if !defined(MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS)
 bool
 ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize&,
-                                                  gfxASurface::gfxContentType,
+                                                  gfxContentType,
                                                   uint32_t,
                                                   SurfaceDescriptor*)
 {
   return false;
 }
 #endif
 
 } // namespace
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -92,25 +92,25 @@ ISurfaceAllocator() {}
                                 ipc::Shmem* aShmem) = 0;
   /**
    * Deallocate memory allocated by either AllocShmem or AllocUnsafeShmem.
    */
   virtual void DeallocShmem(ipc::Shmem& aShmem) = 0;
 
   // was AllocBuffer
   virtual bool AllocSharedImageSurface(const gfxIntSize& aSize,
-                                       gfxASurface::gfxContentType aContent,
+                                       gfxContentType aContent,
                                        gfxSharedImageSurface** aBuffer);
   virtual bool AllocSurfaceDescriptor(const gfxIntSize& aSize,
-                                      gfxASurface::gfxContentType aContent,
+                                      gfxContentType aContent,
                                       SurfaceDescriptor* aBuffer);
 
   // was AllocBufferWithCaps
   virtual bool AllocSurfaceDescriptorWithCaps(const gfxIntSize& aSize,
-                                              gfxASurface::gfxContentType aContent,
+                                              gfxContentType aContent,
                                               uint32_t aCaps,
                                               SurfaceDescriptor* aBuffer);
 
   virtual void DestroySharedSurface(SurfaceDescriptor* aSurface);
 
   // method that does the actual allocation work
   virtual PGrallocBufferChild* AllocGrallocBuffer(const gfxIntSize& aSize,
                                                   uint32_t aFormat,
@@ -120,17 +120,17 @@ ISurfaceAllocator() {}
     return nullptr;
   }
 protected:
   // this method is needed for a temporary fix, will be removed after
   // DeprecatedTextureClient/Host rework.
   virtual bool IsOnCompositorSide() const = 0;
   static bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
   virtual bool PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
-                                              gfxASurface::gfxContentType aContent,
+                                              gfxContentType aContent,
                                               uint32_t aCaps,
                                               SurfaceDescriptor* aBuffer);
 
 
   ~ISurfaceAllocator() {}
 };
 
 } // namespace
--- a/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsD3D10.cpp
@@ -16,17 +16,17 @@ using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 // Platform-specific shadow-layers interfaces.  See ShadowLayers.h.
 // D3D10 doesn't need all these yet.
 bool
 ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize&,
-                                                  gfxASurface::gfxContentType,
+                                                  gfxContentType,
                                                   uint32_t,
                                                   SurfaceDescriptor*)
 {
   return false;
 }
 
 /*static*/ already_AddRefed<gfxASurface>
 ShadowLayerForwarder::PlatformOpenDescriptor(OpenMode,
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
@@ -108,50 +108,50 @@ namespace layers {
 MagicGrallocBufferHandle::MagicGrallocBufferHandle(const sp<GraphicBuffer>& aGraphicBuffer)
   : mGraphicBuffer(aGraphicBuffer)
 {
 }
 
 //-----------------------------------------------------------------------------
 // Parent process
 
-static gfxASurface::gfxImageFormat
+static gfxImageFormat
 ImageFormatForPixelFormat(android::PixelFormat aFormat)
 {
   switch (aFormat) {
   case PIXEL_FORMAT_RGBA_8888:
-    return gfxASurface::ImageFormatARGB32;
+    return gfxImageFormatARGB32;
   case PIXEL_FORMAT_RGBX_8888:
-    return gfxASurface::ImageFormatRGB24;
+    return gfxImageFormatRGB24;
   case PIXEL_FORMAT_RGB_565:
-    return gfxASurface::ImageFormatRGB16_565;
+    return gfxImageFormatRGB16_565;
   case PIXEL_FORMAT_A_8:
-    return gfxASurface::ImageFormatA8;
+    return gfxImageFormatA8;
   default:
     MOZ_CRASH("Unknown gralloc pixel format");
   }
-  return gfxASurface::ImageFormatARGB32;
+  return gfxImageFormatARGB32;
 }
 
 static android::PixelFormat
-PixelFormatForImageFormat(gfxASurface::gfxImageFormat aFormat)
+PixelFormatForImageFormat(gfxImageFormat aFormat)
 {
   switch (aFormat) {
-  case gfxASurface::ImageFormatARGB32:
+  case gfxImageFormatARGB32:
     return android::PIXEL_FORMAT_RGBA_8888;
-  case gfxASurface::ImageFormatRGB24:
+  case gfxImageFormatRGB24:
     return android::PIXEL_FORMAT_RGBX_8888;
-  case gfxASurface::ImageFormatRGB16_565:
+  case gfxImageFormatRGB16_565:
     return android::PIXEL_FORMAT_RGB_565;
-  case gfxASurface::ImageFormatA8:
+  case gfxImageFormatA8:
     return android::PIXEL_FORMAT_A_8;
   default:
     MOZ_CRASH("Unknown gralloc pixel format");
   }
-  return gfxASurface::ImageFormatARGB32;
+  return gfxImageFormatARGB32;
 }
 
 static size_t
 BytesPerPixelForPixelFormat(android::PixelFormat aFormat)
 {
   switch (aFormat) {
   case PIXEL_FORMAT_RGBA_8888:
   case PIXEL_FORMAT_RGBX_8888:
@@ -167,23 +167,23 @@ BytesPerPixelForPixelFormat(android::Pix
     return 1;
   default:
     return 0;
   }
   return 0;
 }
 
 static android::PixelFormat
-PixelFormatForContentType(gfxASurface::gfxContentType aContentType)
+PixelFormatForContentType(gfxContentType aContentType)
 {
   return PixelFormatForImageFormat(
     gfxPlatform::GetPlatform()->OptimalFormatForContent(aContentType));
 }
 
-static gfxASurface::gfxContentType
+static gfxContentType
 ContentTypeFromPixelFormat(android::PixelFormat aFormat)
 {
   return gfxASurface::ContentFromFormat(ImageFormatForPixelFormat(aFormat));
 }
 
 class GrallocReporter MOZ_FINAL : public MemoryUniReporter
 {
   friend class GrallocBufferActor;
@@ -361,17 +361,17 @@ ShadowLayerForwarder::AllocGrallocBuffer
                                          uint32_t aUsage,
                                          MaybeMagicGrallocBufferHandle* aHandle)
 {
   return mShadowManager->SendPGrallocBufferConstructor(aSize, aFormat, aUsage, aHandle);
 }
 
 bool
 ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
-                                                  gfxASurface::gfxContentType aContent,
+                                                  gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
 
   // Check for devices that have problems with gralloc. We only check for
   // this on ICS or earlier, in hopes that JB will work.
 #if ANDROID_VERSION <= 15
   static bool checkedDevice = false;
--- a/gfx/layers/ipc/ShadowLayerUtilsMac.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsMac.cpp
@@ -16,33 +16,33 @@
 
 using namespace mozilla::gl;
 
 namespace mozilla {
 namespace layers {
 
 bool
 ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
-                                                  gfxASurface::gfxContentType aContent,
+                                                  gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
   return false;
 }
 
 /*static*/ already_AddRefed<gfxASurface>
 ShadowLayerForwarder::PlatformOpenDescriptor(OpenMode aMode,
                                              const SurfaceDescriptor& aSurface)
 {
   if (aSurface.type() == SurfaceDescriptor::TShmem) {
     return gfxSharedQuartzSurface::Open(aSurface.get_Shmem());
   } else if (aSurface.type() == SurfaceDescriptor::TMemoryImage) {
     const MemoryImage& image = aSurface.get_MemoryImage();
-    gfxASurface::gfxImageFormat format
-      = static_cast<gfxASurface::gfxImageFormat>(image.format());
+    gfxImageFormat format
+      = static_cast<gfxImageFormat>(image.format());
 
     nsRefPtr<gfxASurface> surf =
       new gfxQuartzSurface((unsigned char*)image.data(),
                            image.size(),
                            image.stride(),
                            format);
     return surf.forget();
 
--- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
@@ -43,17 +43,17 @@ namespace layers {
 // Return true if we're likely compositing using X and so should use
 // Xlib surfaces in shadow layers.
 static bool
 UsingXCompositing()
 {
   if (!PR_GetEnv("MOZ_LAYERS_ENABLE_XLIB_SURFACES")) {
       return false;
   }
-  return (gfxASurface::SurfaceTypeXlib ==
+  return (gfxSurfaceTypeXlib ==
           gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType());
 }
 
 // LookReturn a pointer to |aFormat| that lives in the Xrender library.
 // All code using render formats assumes it doesn't need to copy.
 static XRenderPictFormat*
 GetXRenderPictFormatFromId(Display* aDisplay, PictFormat aFormatId)
 {
@@ -111,17 +111,17 @@ SurfaceDescriptorX11::OpenForeign() cons
 
     surf = new gfxXlibSurface(display, mId, visual, mSize);
   }
   return surf->CairoStatus() ? nullptr : surf.forget();
 }
 
 bool
 ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
-                                                  gfxASurface::gfxContentType aContent,
+                                                  gfxContentType aContent,
                                                   uint32_t aCaps,
                                                   SurfaceDescriptor* aBuffer)
 {
   if (!UsingXCompositing()) {
     // If we're not using X compositing, we're probably compositing on
     // the client side, in which case X surfaces would just slow
     // things down.  Use Shmem instead.
     return false;
@@ -130,17 +130,17 @@ ISurfaceAllocator::PlatformAllocSurfaceD
     // We can't efficiently map pixmaps as gfxImageSurface, in
     // general.  Fall back on Shmem.
     return false;
   }
 
   gfxPlatform* platform = gfxPlatform::GetPlatform();
   nsRefPtr<gfxASurface> buffer = platform->CreateOffscreenSurface(aSize, aContent);
   if (!buffer ||
-      buffer->GetType() != gfxASurface::SurfaceTypeXlib) {
+      buffer->GetType() != gfxSurfaceTypeXlib) {
     NS_ERROR("creating Xlib front/back surfaces failed!");
     return false;
   }
 
   gfxXlibSurface* bufferX = static_cast<gfxXlibSurface*>(buffer.get());
   // Release Pixmap ownership to the layers model
   bufferX->ReleasePixmap();
 
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -592,30 +592,30 @@ ShadowLayerForwarder::OpenDescriptor(Ope
   }
 
   switch (aSurface.type()) {
   case SurfaceDescriptor::TShmem: {
     surf = gfxSharedImageSurface::Open(aSurface.get_Shmem());
     return surf.forget();
   } case SurfaceDescriptor::TRGBImage: {
     const RGBImage& rgb = aSurface.get_RGBImage();
-    gfxASurface::gfxImageFormat rgbFormat
-      = static_cast<gfxASurface::gfxImageFormat>(rgb.rgbFormat());
+    gfxImageFormat rgbFormat
+      = static_cast<gfxImageFormat>(rgb.rgbFormat());
     uint32_t stride = gfxASurface::BytesPerPixel(rgbFormat) * rgb.picture().width;
     nsIntSize size(rgb.picture().width, rgb.picture().height);
     surf = new gfxImageSurface(rgb.data().get<uint8_t>(),
                                size,
                                stride,
                                rgbFormat);
     return surf.forget();
   }
   case SurfaceDescriptor::TMemoryImage: {
     const MemoryImage& image = aSurface.get_MemoryImage();
-    gfxASurface::gfxImageFormat format
-      = static_cast<gfxASurface::gfxImageFormat>(image.format());
+    gfxImageFormat format
+      = static_cast<gfxImageFormat>(image.format());
     surf = new gfxImageSurface((unsigned char *)image.data(),
                                image.size(),
                                image.stride(),
                                format);
     return surf.forget();
   }
   default:
     NS_ERROR("unexpected SurfaceDescriptor type!");
@@ -662,23 +662,23 @@ ShadowLayerForwarder::GetDescriptorSurfa
   gfxASurface** aSurface)
 {
   gfxImageFormat format;
   if (PlatformGetDescriptorSurfaceImageFormat(aDescriptor, aMode, &format, aSurface)) {
     return format;
   }
 
   nsRefPtr<gfxASurface> surface = OpenDescriptor(aMode, aDescriptor);
-  NS_ENSURE_TRUE(surface, gfxASurface::ImageFormatUnknown);
+  NS_ENSURE_TRUE(surface, gfxImageFormatUnknown);
 
   nsRefPtr<gfxImageSurface> img = surface->GetAsImageSurface();
-  NS_ENSURE_TRUE(img, gfxASurface::ImageFormatUnknown);
+  NS_ENSURE_TRUE(img, gfxImageFormatUnknown);
 
   format = img->Format();
-  NS_ASSERTION(format != gfxASurface::ImageFormatUnknown,
+  NS_ASSERTION(format != gfxImageFormatUnknown,
                "ImageSurface RGB format should be known");
 
   *aSurface = surface.forget().get();
   return format;
 }
 
 /*static*/ void
 ShadowLayerForwarder::CloseDescriptor(const SurfaceDescriptor& aDescriptor)
@@ -786,17 +786,17 @@ AutoOpenSurface::ContentType()
 
 gfxImageFormat
 AutoOpenSurface::ImageFormat()
 {
   if (mSurface) {
     nsRefPtr<gfxImageSurface> img = mSurface->GetAsImageSurface();
     if (img) {
       gfxImageFormat format = img->Format();
-      NS_ASSERTION(format != gfxASurface::ImageFormatUnknown,
+      NS_ASSERTION(format != gfxImageFormatUnknown,
                    "ImageSurface RGB format should be known");
 
       return format;
     }
   }
 
   return ShadowLayerForwarder::GetDescriptorSurfaceImageFormat(
     mDescriptor, mMode, getter_AddRefs(mSurface));
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -132,17 +132,17 @@ class Transaction;
  */
 
 class ShadowLayerForwarder : public CompositableForwarder
 {
   friend class AutoOpenSurface;
   friend class DeprecatedTextureClientShmem;
   friend class ContentClientIncremental;
 
-  typedef gfxASurface::gfxImageFormat gfxImageFormat;
+  typedef gfxImageFormat gfxImageFormat;
 
 public:
   virtual ~ShadowLayerForwarder();
 
   /**
    * Setup the IPDL actor for aCompositable to be part of layers
    * transactions.
    */
@@ -449,17 +449,17 @@ private:
                            OpenMode aMode,
                            gfxASurface** aSurface);
   static bool
   PlatformGetDescriptorSurfaceSize(const SurfaceDescriptor& aDescriptor,
                                    OpenMode aMode,
                                    gfxIntSize* aSize,
                                    gfxASurface** aSurface);
   // And again, for the image format.
-  // This function will return ImageFormatUnknown only if |aDescriptor|
+  // This function will return gfxImageFormatUnknown only if |aDescriptor|
   // describes a non-ImageSurface.
   static gfxImageFormat
   GetDescriptorSurfaceImageFormat(const SurfaceDescriptor& aDescriptor,
                                   OpenMode aMode,
                                   gfxASurface** aSurface);
   static bool
   PlatformGetDescriptorSurfaceImageFormat(const SurfaceDescriptor& aDescriptor,
                                           OpenMode aMode,
--- a/gfx/layers/ipc/SharedRGBImage.cpp
+++ b/gfx/layers/ipc/SharedRGBImage.cpp
@@ -47,19 +47,19 @@ DeprecatedSharedRGBImage::~DeprecatedSha
   delete mShmem;
 }
 
 already_AddRefed<Image>
 CreateSharedRGBImage(ImageContainer *aImageContainer,
                      nsIntSize aSize,
                      gfxImageFormat aImageFormat)
 {
-  NS_ASSERTION(aImageFormat == gfxASurface::ImageFormatARGB32 ||
-               aImageFormat == gfxASurface::ImageFormatRGB24 ||
-               aImageFormat == gfxASurface::ImageFormatRGB16_565,
+  NS_ASSERTION(aImageFormat == gfxImageFormatARGB32 ||
+               aImageFormat == gfxImageFormatRGB24 ||
+               aImageFormat == gfxImageFormatRGB16_565,
                "RGB formats supported only");
 
   if (!aImageContainer) {
     NS_WARNING("No ImageContainer to allocate DeprecatedSharedRGBImage");
     return nullptr;
   }
 
   ImageFormat format = SHARED_RGB;
--- a/gfx/layers/ipc/SharedRGBImage.h
+++ b/gfx/layers/ipc/SharedRGBImage.h
@@ -26,30 +26,30 @@ namespace layers {
 class BufferTextureClient;
 class ImageClient;
 class ISurfaceAllocator;
 class TextureClient;
 class SurfaceDescriptor;
 
 already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer,
                                              nsIntSize aSize,
-                                             gfxASurface::gfxImageFormat aImageFormat);
+                                             gfxImageFormat aImageFormat);
 
 /**
  * Stores RGB data in shared memory
  * It is assumed that the image width and stride are equal
  */
 class DeprecatedSharedRGBImage : public Image,
                                  public ISharedImage
 {
 friend already_AddRefed<Image> CreateSharedRGBImage(ImageContainer* aImageContainer,
                                                     nsIntSize aSize,
-                                                    gfxASurface::gfxImageFormat aImageFormat);
+                                                    gfxImageFormat aImageFormat);
 public:
-  typedef gfxASurface::gfxImageFormat gfxImageFormat;
+  typedef gfxImageFormat gfxImageFormat;
   struct Header {
     gfxImageFormat mImageFormat;
   };
 
   DeprecatedSharedRGBImage(ISurfaceAllocator *aAllocator);
   ~DeprecatedSharedRGBImage();
 
   virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
@@ -98,17 +98,17 @@ protected:
 
 /**
  * Stores RGB data in shared memory
  * It is assumed that the image width and stride are equal
  */
 class SharedRGBImage : public Image
                      , public ISharedImage
 {
-  typedef gfxASurface::gfxImageFormat gfxImageFormat;
+  typedef gfxImageFormat gfxImageFormat;
 public:
   SharedRGBImage(ImageClient* aCompositable);
   ~SharedRGBImage();
 
   virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
 
   virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
 
--- a/gfx/layers/opengl/CanvasLayerOGL.cpp
+++ b/gfx/layers/opengl/CanvasLayerOGL.cpp
@@ -124,17 +124,17 @@ CanvasLayerOGL::Initialize(const Data& a
   } else if (aData.mDrawTarget) {
     mDrawTarget = aData.mDrawTarget;
     mCanvasSurface = gfxPlatform::GetPlatform()->CreateThebesSurfaceAliasForDrawTarget_hack(mDrawTarget);
     mNeedsYFlip = false;
   } else if (aData.mSurface) {
     mCanvasSurface = aData.mSurface;
     mNeedsYFlip = false;
 #if defined(GL_PROVIDER_GLX)
-    if (aData.mSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
+    if (aData.mSurface->GetType() == gfxSurfaceTypeXlib) {
         gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(aData.mSurface);
         mPixmap = xsurf->GetGLXPixmap();
         if (mPixmap) {
             mLayerProgram = ShaderProgramFromContentType(aData.mSurface->GetContentType());
             MakeTextureIfNeeded(gl(), mUploadTexture);
         }
     }
 #endif
--- a/gfx/layers/opengl/CanvasLayerOGL.h
+++ b/gfx/layers/opengl/CanvasLayerOGL.h
@@ -83,20 +83,20 @@ protected:
   bool mForceReadback;
   GLuint mUploadTexture;
 #if defined(GL_PROVIDER_GLX)
   GLXPixmap mPixmap;
 #endif
 
   nsRefPtr<gfxImageSurface> mCachedTempSurface;
   gfxIntSize mCachedSize;
-  gfxASurface::gfxImageFormat mCachedFormat;
+  gfxImageFormat mCachedFormat;
 
   gfxImageSurface* GetTempSurface(const gfxIntSize& aSize,
-                                  const gfxASurface::gfxImageFormat aFormat)
+                                  const gfxImageFormat aFormat)
   {
     if (!mCachedTempSurface ||
         aSize.width != mCachedSize.width ||
         aSize.height != mCachedSize.height ||
         aFormat != mCachedFormat)
     {
       mCachedTempSurface = new gfxImageSurface(aSize, aFormat);
       mCachedSize = aSize;
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1256,17 +1256,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);
     }
-    nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(rect.Size(), gfxASurface::CONTENT_COLOR_ALPHA);
+    nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(rect.Size(), GFX_CONTENT_COLOR_ALPHA);
     nsRefPtr<gfxContext> ctx = new gfxContext(surf);
     CopyToTarget(ctx, mCurrentRenderTarget->GetTransform());
 
     WriteSnapshotToDumpFile(this, surf);
   }
 #endif
 
   mFrameInProgress = false;
@@ -1348,17 +1348,17 @@ CompositorOGL::CopyToTarget(gfxContext *
 
   if ((int64_t(width) * int64_t(height) * int64_t(4)) > PR_INT32_MAX) {
     NS_ERROR("Widget size too big - integer overflow!");
     return;
   }
 
   nsRefPtr<gfxImageSurface> imageSurface =
     new gfxImageSurface(gfxIntSize(width, height),
-                        gfxASurface::ImageFormatARGB32);
+                        gfxImageFormatARGB32);
 
   mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
 
   if (!mGLContext->IsGLES2()) {
     // GLES2 promises that binding to any custom FBO will attach
     // to GL_COLOR_ATTACHMENT0 attachment point.
     mGLContext->fReadBuffer(LOCAL_GL_BACK);
   }
--- a/gfx/layers/opengl/ImageLayerOGL.cpp
+++ b/gfx/layers/opengl/ImageLayerOGL.cpp
@@ -282,17 +282,17 @@ ImageLayerOGL::RenderLayer(int,
   } else if (image->GetFormat() == CAIRO_SURFACE) {
     CairoImage *cairoImage =
       static_cast<CairoImage*>(image);
 
     if (!cairoImage->mSurface) {
       return;
     }
 
-    NS_ASSERTION(cairoImage->mSurface->GetContentType() != gfxASurface::CONTENT_ALPHA,
+    NS_ASSERTION(cairoImage->mSurface->GetContentType() != GFX_CONTENT_ALPHA,
                  "Image layer has alpha image");
 
     CairoOGLBackendData *data =
       static_cast<CairoOGLBackendData*>(cairoImage->GetBackendData(LAYERS_OPENGL));
 
     if (data && data->mTexture.GetGLContext() != gl()) {
       // If this texture was allocated by another layer manager, clear
       // it out and re-allocate below.
@@ -396,32 +396,32 @@ UploadYUVToTexture(GLContext* gl, const 
                    GLTexture* aUTexture,
                    GLTexture* aVTexture)
 {
   nsIntRect size(0, 0, aData.mYSize.width, aData.mYSize.height);
   GLuint texture = aYTexture->GetTextureID();
   nsRefPtr<gfxASurface> surf = new gfxImageSurface(aData.mYChannel,
                                                    aData.mYSize,
                                                    aData.mYStride,
-                                                   gfxASurface::ImageFormatA8);
+                                                   gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
   
   size = nsIntRect(0, 0, aData.mCbCrSize.width, aData.mCbCrSize.height);
   texture = aUTexture->GetTextureID();
   surf = new gfxImageSurface(aData.mCbChannel,
                              aData.mCbCrSize,
                              aData.mCbCrStride,
-                             gfxASurface::ImageFormatA8);
+                             gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
 
   texture = aVTexture->GetTextureID();
   surf = new gfxImageSurface(aData.mCrChannel,
                              aData.mCbCrSize,
                              aData.mCbCrStride,
-                             gfxASurface::ImageFormatA8);
+                             gfxImageFormatA8);
   gl->UploadSurfaceToTexture(surf, size, texture, true);
 }
 
 ImageLayerOGL::ImageLayerOGL(LayerManagerOGL *aManager)
   : ImageLayer(aManager, nullptr)
   , LayerOGL(aManager)
   , mTextureRecycleBin(new TextureRecycleBin())
 { 
@@ -480,17 +480,17 @@ ImageLayerOGL::AllocateTexturesCairo(Cai
   gl->MakeCurrent();
 
   GLuint tex = texture.GetTextureID();
   gl->fActiveTexture(LOCAL_GL_TEXTURE0);
 
   SetClamping(gl, tex);
 
 #if defined(GL_PROVIDER_GLX)
-  if (aImage->mSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
+  if (aImage->mSurface->GetType() == gfxSurfaceTypeXlib) {
     gfxXlibSurface *xsurf =
       static_cast<gfxXlibSurface*>(aImage->mSurface.get());
     GLXPixmap pixmap = xsurf->GetGLXPixmap();
     if (pixmap) {
       backendData->mLayerProgram = ShaderProgramFromContentType(aImage->mSurface->GetContentType());
 
       aImage->SetBackendData(LAYERS_OPENGL, backendData.forget());
 
@@ -550,17 +550,17 @@ ImageLayerOGL::LoadAsTexture(GLuint aTex
   if (!cairoImage->mSurface) {
     return false;
   }
 
   CairoOGLBackendData *data = static_cast<CairoOGLBackendData*>(
     cairoImage->GetBackendData(LAYERS_OPENGL));
 
   if (!data) {
-    NS_ASSERTION(cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_ALPHA,
+    NS_ASSERTION(cairoImage->mSurface->GetContentType() == GFX_CONTENT_ALPHA,
                  "OpenGL mask layers must be backed by alpha surfaces");
 
     // allocate a new texture and save the details in the backend data
     data = new CairoOGLBackendData;
     data->mTextureSize = CalculatePOTSize(cairoImage->mSize, gl());
 
     GLTexture &texture = data->mTexture;
     texture.Allocate(mOGLManager->gl());
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -576,17 +576,17 @@ LayerManagerOGL::EndTransaction(DrawTheb
   MOZ_LAYERS_LOG(("]----- EndTransaction"));
 #endif
 }
 
 already_AddRefed<gfxASurface>
 LayerManagerOGL::CreateOptimalMaskSurface(const gfxIntSize &aSize)
 {
   return gfxPlatform::GetPlatform()->
-    CreateOffscreenImageSurface(aSize, gfxASurface::CONTENT_ALPHA);
+    CreateOffscreenImageSurface(aSize, GFX_CONTENT_ALPHA);
 }
 
 already_AddRefed<ThebesLayer>
 LayerManagerOGL::CreateThebesLayer()
 {
   if (mDestroyed) {
     NS_WARNING("Call on destroyed layer manager");
     return nullptr;
@@ -870,17 +870,17 @@ LayerManagerOGL::Render()
 #ifdef MOZ_DUMP_PAINTING
   if (gfxUtils::sDumpPainting) {
     nsIntRect rect;
     if (mIsRenderingToEGLSurface) {
       rect = nsIntRect(0, 0, mSurfaceSize.width, mSurfaceSize.height);
     } else {
       mWidget->GetClientBounds(rect);
     }
-    nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(rect.Size(), gfxASurface::CONTENT_COLOR_ALPHA);
+    nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(rect.Size(), GFX_CONTENT_COLOR_ALPHA);
     nsRefPtr<gfxContext> ctx = new gfxContext(surf);
     CopyToTarget(ctx);
 
     WriteSnapshotToDumpFile(this, surf);
   }
 #endif
 
   if (mTarget) {
@@ -1119,17 +1119,17 @@ LayerManagerOGL::CopyToTarget(gfxContext
 
   if ((int64_t(width) * int64_t(height) * int64_t(4)) > INT32_MAX) {
     NS_ERROR("Widget size too big - integer overflow!");
     return;
   }
 
   nsRefPtr<gfxImageSurface> imageSurface =
     new gfxImageSurface(gfxIntSize(width, height),
-                        gfxASurface::ImageFormatARGB32);
+                        gfxImageFormatARGB32);
 
   mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER,
                                mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO);
 
   if (!mGLContext->IsGLES2()) {
     // GLES2 promises that binding to any custom FBO will attach
     // to GL_COLOR_ATTACHMENT0 attachment point.
     if (mGLContext->IsDoubleBuffered()) {
--- a/gfx/layers/opengl/LayerManagerOGLProgram.h
+++ b/gfx/layers/opengl/LayerManagerOGLProgram.h
@@ -88,19 +88,19 @@ ShaderProgramFromTargetAndFormat(GLenum 
       else
         return RGBXRectLayerProgramType;
     default:
       return ShaderProgramFromSurfaceFormat(aFormat);
   }
 }
 
 static inline ShaderProgramType
-ShaderProgramFromContentType(gfxASurface::gfxContentType aContentType)
+ShaderProgramFromContentType(gfxContentType aContentType)
 {
-  if (aContentType == gfxASurface::CONTENT_COLOR_ALPHA)
+  if (aContentType == GFX_CONTENT_COLOR_ALPHA)
     return RGBALayerProgramType;
   return RGBXLayerProgramType;
 }
 
 /**
  * This struct represents the shaders that make up a program and the uniform
  * and attribute parmeters that those shaders take.
  * It is used by ShaderProgramOGL.
--- a/gfx/layers/opengl/TextureClientOGL.cpp
+++ b/gfx/layers/opengl/TextureClientOGL.cpp
@@ -81,17 +81,17 @@ DeprecatedTextureClientSharedOGL::Releas
   MOZ_ASSERT(mDescriptor.type() == SurfaceDescriptor::TSharedTextureDescriptor);
   mDescriptor = SurfaceDescriptor();
   // It's important our handle gets released! SharedDeprecatedTextureHostOGL will take
   // care of this for us though.
 }
 
 bool
 DeprecatedTextureClientSharedOGL::EnsureAllocated(gfx::IntSize aSize,
-                                        gfxASurface::gfxContentType aContentType)
+                                        gfxContentType aContentType)
 {
   mSize = aSize;
   return true;
 }
 
 
 } // namespace
 } // namespace
--- a/gfx/layers/opengl/TextureClientOGL.h
+++ b/gfx/layers/opengl/TextureClientOGL.h
@@ -60,19 +60,19 @@ protected:
 
 class DeprecatedTextureClientSharedOGL : public DeprecatedTextureClient
 {
 public:
   DeprecatedTextureClientSharedOGL(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo);
   ~DeprecatedTextureClientSharedOGL() { ReleaseResources(); }
 
   virtual bool SupportsType(DeprecatedTextureClientType aType) MOZ_OVERRIDE { return aType == TEXTURE_SHARED_GL; }
-  virtual bool EnsureAllocated(gfx::IntSize aSize, gfxASurface::gfxContentType aType);
+  virtual bool EnsureAllocated(gfx::IntSize aSize, gfxContentType aType);
   virtual void ReleaseResources();
-  virtual gfxASurface::gfxContentType GetContentType() MOZ_OVERRIDE { return gfxASurface::CONTENT_COLOR_ALPHA; }
+  virtual gfxContentType GetContentType() MOZ_OVERRIDE { return GFX_CONTENT_COLOR_ALPHA; }
 
 protected:
   gl::GLContext* mGL;
   gfx::IntSize mSize;
 
   friend class CompositingFactory;
 };
 
@@ -92,17 +92,17 @@ class DeprecatedTextureClientStreamOGL :
 {
 public:
   DeprecatedTextureClientStreamOGL(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo)
     : DeprecatedTextureClient(aForwarder, aTextureInfo)
   {}
   ~DeprecatedTextureClientStreamOGL() { ReleaseResources(); }
 
   virtual bool SupportsType(DeprecatedTextureClientType aType) MOZ_OVERRIDE { return aType == TEXTURE_STREAM_GL; }
-  virtual bool EnsureAllocated(gfx::IntSize aSize, gfxASurface::gfxContentType aType) { return true; }
+  virtual bool EnsureAllocated(gfx::IntSize aSize, gfxContentType aType) { return true; }
   virtual void ReleaseResources() { mDescriptor = SurfaceDescriptor(); }
-  virtual gfxASurface::gfxContentType GetContentType() MOZ_OVERRIDE { return gfxASurface::CONTENT_COLOR_ALPHA; }
+  virtual gfxContentType GetContentType() MOZ_OVERRIDE { return GFX_CONTENT_COLOR_ALPHA; }
 };
 
 } // namespace
 } // namespace
 
 #endif
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -522,17 +522,17 @@ TextureImageDeprecatedTextureHostOGL::Up
   AutoOpenSurface surf(OPEN_READ_ONLY, aImage);
   nsIntSize size = surf.Size();
   TextureImage::ImageFormat format = surf.ImageFormat();
 
   if (!mTexture ||
       (mTexture->GetSize() != size && !aOffset) ||
       mTexture->GetContentType() != surf.ContentType() ||
       (mTexture->GetImageFormat() != format &&
-       mTexture->GetImageFormat() != gfxASurface::ImageFormatUnknown)) {
+       mTexture->GetImageFormat() != gfxImageFormatUnknown)) {
 
     mTexture = mGL->CreateTextureImage(size,
                                        surf.ContentType(),
                                        WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                        FlagsToGLFlags(mFlags),
                                        format);
   }
 
@@ -843,44 +843,44 @@ YCbCrDeprecatedTextureHostOGL::UpdateImp
   YCbCrImageDataDeserializer deserializer(aImage.get_YCbCrImage().data().get<uint8_t>());
 
   gfxIntSize gfxSize = deserializer.GetYSize();
   gfxIntSize gfxCbCrSize = deserializer.GetCbCrSize();
 
   if (!mYTexture->mTexImage || mYTexture->mTexImage->GetSize() != gfxSize) {
     mYTexture->mTexImage = CreateBasicTextureImage(mGL,
                                                    gfxSize,
-                                                   gfxASurface::CONTENT_ALPHA,
+                                                   GFX_CONTENT_ALPHA,
                                                    WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                    FlagsToGLFlags(mFlags));
   }
   if (!mCbTexture->mTexImage || mCbTexture->mTexImage->GetSize() != gfxCbCrSize) {
     mCbTexture->mTexImage = CreateBasicTextureImage(mGL,
                                                     gfxCbCrSize,
-                                                    gfxASurface::CONTENT_ALPHA,
+                                                    GFX_CONTENT_ALPHA,
                                                     WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                     FlagsToGLFlags(mFlags));
   }
   if (!mCrTexture->mTexImage || mCrTexture->mTexImage->GetSize() != gfxCbCrSize) {
     mCrTexture->mTexImage = CreateBasicTextureImage(mGL,
                                                     gfxCbCrSize,
-                                                    gfxASurface::CONTENT_ALPHA,
+                                                    GFX_CONTENT_ALPHA,
                                                     WrapMode(mGL, mFlags & TEXTURE_ALLOW_REPEAT),
                                                     FlagsToGLFlags(mFlags));
   }
 
   RefPtr<gfxImageSurface> tempY = new gfxImageSurface(deserializer.GetYData(),
                                        gfxSize, deserializer.GetYStride(),
-                                       gfxASurface::ImageFormatA8);
+                                       gfxImageFormatA8);
   RefPtr<gfxImageSurface> tempCb = new gfxImageSurface(deserializer.GetCbData(),
                                        gfxCbCrSize, deserializer.GetCbCrStride(),
-                                       gfxASurface::ImageFormatA8);
+                                       gfxImageFormatA8);
   RefPtr<gfxImageSurface> tempCr = new gfxImageSurface(deserializer.GetCrData(),
                                        gfxCbCrSize, deserializer.GetCbCrStride(),
-                                       gfxASurface::ImageFormatA8);
+                                       gfxImageFormatA8);
 
   nsIntRegion yRegion(nsIntRect(0, 0, gfxSize.width, gfxSize.height));
   nsIntRegion cbCrRegion(nsIntRect(0, 0, gfxCbCrSize.width, gfxCbCrSize.height));
 
   mYTexture->mTexImage->DirectUpdate(tempY, yRegion);
   mCbTexture->mTexImage->DirectUpdate(tempCb, cbCrRegion);
   mCrTexture->mTexImage->DirectUpdate(tempCr, cbCrRegion);
 }
@@ -900,21 +900,21 @@ TiledDeprecatedTextureHostOGL::~TiledDep
 void
 TiledDeprecatedTextureHostOGL::BindTexture(GLenum aTextureUnit)
 {
   mGL->fActiveTexture(aTextureUnit);
   mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
 }
 
 static void
-GetFormatAndTileForImageFormat(gfxASurface::gfxImageFormat aFormat,
+GetFormatAndTileForImageFormat(gfxImageFormat aFormat,
                                GLenum& aOutFormat,
                                GLenum& aOutType)
 {
-  if (aFormat == gfxASurface::ImageFormatRGB16_565) {
+  if (aFormat == gfxImageFormatRGB16_565) {
     aOutFormat = LOCAL_GL_RGB;
     aOutType = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
   } else {
     aOutFormat = LOCAL_GL_RGBA;
     aOutType = LOCAL_GL_UNSIGNED_BYTE;
   }
 }
 
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -591,17 +591,17 @@ private:
   gl::GLContext* mGL;
 };
 
 
 class SharedDeprecatedTextureHostOGL : public DeprecatedTextureHost
                            , public TextureSourceOGL
 {
 public:
-  typedef gfxASurface::gfxContentType ContentType;
+  typedef gfxContentType ContentType;
   typedef mozilla::gl::GLContext GLContext;
   typedef mozilla::gl::TextureImage TextureImage;
 
   SharedDeprecatedTextureHostOGL()
     : mGL(nullptr)
     , mTextureHandle(0)
     , mWrapMode(LOCAL_GL_CLAMP_TO_EDGE)
     , mSharedHandle(0)
@@ -659,18 +659,18 @@ public:
     // Lock already bound us!
     MOZ_ASSERT(activetex == LOCAL_GL_TEXTURE0);
   }
   void UnbindTexture() MOZ_OVERRIDE {}
   GLuint GetTextureID() { return mTextureHandle; }
   ContentType GetContentType()
   {
     return (mFormat == gfx::FORMAT_B8G8R8A8) ?
-             gfxASurface::CONTENT_COLOR_ALPHA :
-             gfxASurface::CONTENT_COLOR;
+             GFX_CONTENT_COLOR_ALPHA :
+             GFX_CONTENT_COLOR;
   }
 
   virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE;
 
   virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual const char* Name() { return "SharedDeprecatedTextureHostOGL"; }
@@ -687,17 +687,17 @@ protected:
   gl::SharedTextureHandle mSharedHandle;
   gl::SharedTextureShareType mShareType;
 };
 
 class SurfaceStreamHostOGL : public DeprecatedTextureHost
                            , public TextureSourceOGL
 {
 public:
-  typedef gfxASurface::gfxContentType ContentType;
+  typedef gfxContentType ContentType;
   typedef mozilla::gl::GLContext GLContext;
   typedef mozilla::gl::TextureImage TextureImage;
 
   virtual ~SurfaceStreamHostOGL()
   {
     DeleteTextures();
   }
 
@@ -742,18 +742,18 @@ public:
 
   void BindTexture(GLenum activetex) MOZ_OVERRIDE;
 
   void UnbindTexture() MOZ_OVERRIDE {}
 
   GLuint GetTextureID() { return mTextureHandle; }
   ContentType GetContentType() {
     return (mFormat == gfx::FORMAT_B8G8R8A8) ?
-             gfxASurface::CONTENT_COLOR_ALPHA :
-             gfxASurface::CONTENT_COLOR;
+             GFX_CONTENT_COLOR_ALPHA :
+             GFX_CONTENT_COLOR;
   }
 
   virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual const char* Name() { return "SurfaceStreamHostOGL"; }
 #endif
 
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -69,17 +69,17 @@ CreateClampOrRepeatTextureImage(GLContex
 
   return aGl->CreateTextureImage(aSize, aContentType, WrapMode(aGl, aFlags));
 }
 
 static void
 SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget)
 {
   nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
-  if (surface->GetContentType() != gfxASurface::CONTENT_COLOR_ALPHA) {
+  if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) {
     // Destination doesn't have alpha channel; no need to set any special flags
     return;
   }
 
   surface->SetSubpixelAntialiasingEnabled(
       !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA));
 }
 
@@ -355,17 +355,17 @@ public:
   }
 
   // ThebesLayerBuffer interface
   void
   CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
                gfxASurface** aBlackSurface, gfxASurface** aWhiteSurface,
                RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE
   {
-    NS_ASSERTION(gfxASurface::CONTENT_ALPHA != aType,"ThebesBuffer has color");
+    NS_ASSERTION(GFX_CONTENT_ALPHA != aType,"ThebesBuffer has color");
 
     mTexImage = CreateClampOrRepeatTextureImage(gl(), aRect.Size(), aType, aFlags);
     nsRefPtr<gfxASurface> ret = mTexImage ? mTexImage->GetBackingSurface() : nullptr;
     *aBlackSurface = ret.forget().get();
   }
 
   virtual nsIntPoint GetOriginOffset() {
     return BufferRect().TopLeft() - BufferRotation();
@@ -481,29 +481,29 @@ BasicBufferOGL::BeginPaint(ContentType a
     }
 
     if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
       if (!gfxPlatform::ComponentAlphaEnabled() ||
           !mLayer->GetParent() ||
           !mLayer->GetParent()->SupportsComponentAlphaChildren()) {
         mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
       } else {
-        contentType = gfxASurface::CONTENT_COLOR;
+        contentType = GFX_CONTENT_COLOR;
       }
     }
  
     if ((aFlags & PAINT_WILL_RESAMPLE) &&
         (!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
          neededRegion.GetNumRects() > 1)) {
       // The area we add to neededRegion might not be painted opaquely
       if (mode == Layer::SURFACE_OPAQUE) {
-        contentType = gfxASurface::CONTENT_COLOR_ALPHA;
+        contentType = GFX_CONTENT_COLOR_ALPHA;
         mode = Layer::SURFACE_SINGLE_CHANNEL_ALPHA;
       }
-      // For component alpha layers, we leave contentType as CONTENT_COLOR.
+      // For component alpha layers, we leave contentType as GFX_CONTENT_COLOR.
 
       // We need to validate the entire buffer, to make sure that only valid
       // pixels are sampled
       neededRegion = destBufferRect;
     }
 
     if (mTexImage &&
         (mTexImage->GetContentType() != contentType ||
@@ -776,17 +776,17 @@ BasicBufferOGL::BeginPaint(ContentType a
       // be incorrect.
       surf->SetAllowUseAsSource(false);
       result.mContext = new gfxContext(surf);
     } else {
       result.mContext = nullptr;
     }
   } else {
     result.mContext = new gfxContext(mTexImage->BeginUpdate(result.mRegionToDraw));
-    if (mTexImage->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
+    if (mTexImage->GetContentType() == GFX_CONTENT_COLOR_ALPHA) {
       gfxUtils::ClipToRegion(result.mContext, result.mRegionToDraw);
       result.mContext->SetOperator(gfxContext::OPERATOR_CLEAR);
       result.mContext->Paint();
       result.mContext->SetOperator(gfxContext::OPERATOR_OVER);
     }
   }
   if (!result.mContext) {
     NS_WARNING("unable to get context for update");
@@ -873,18 +873,18 @@ ThebesLayerOGL::RenderLayer(int aPreviou
     return;
   }
   NS_ABORT_IF_FALSE(mBuffer, "should have a buffer here");
 
   mOGLManager->MakeCurrent();
   gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
 
   TextureImage::ContentType contentType =
-    CanUseOpaqueSurface() ? gfxASurface::CONTENT_COLOR :
-                            gfxASurface::CONTENT_COLOR_ALPHA;
+    CanUseOpaqueSurface() ? GFX_CONTENT_COLOR :
+                            GFX_CONTENT_COLOR_ALPHA;
 
   uint32_t flags = 0;
 #ifndef MOZ_GFX_OPTIMIZE_MOBILE
   if (MayResample()) {
     flags |= ThebesLayerBufferOGL::PAINT_WILL_RESAMPLE;
   }
 #endif
 
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -298,33 +298,33 @@ void
 nsDeviceContext::SetDPI()
 {
     float dpi = -1.0f;
 
     // PostScript, PDF and Mac (when printing) all use 72 dpi
     // Use a printing DC to determine the other dpi values
     if (mPrintingSurface) {
         switch (mPrintingSurface->GetType()) {
-        case gfxASurface::SurfaceTypePDF:
-        case gfxASurface::SurfaceTypePS:
-        case gfxASurface::SurfaceTypeQuartz:
+        case gfxSurfaceTypePDF:
+        case gfxSurfaceTypePS:
+        case gfxSurfaceTypeQuartz:
             dpi = 72.0f;
             break;
 #ifdef XP_WIN
-        case gfxASurface::SurfaceTypeWin32:
-        case gfxASurface::SurfaceTypeWin32Printing: {
+        case gfxSurfaceTypeWin32:
+        case gfxSurfaceTypeWin32Printing: {
             HDC dc = reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC();
             int32_t OSVal = GetDeviceCaps(dc, LOGPIXELSY);
             dpi = 144.0f;
             mPrintingScale = float(OSVal) / dpi;
             break;
         }
 #endif
 #ifdef XP_OS2
-        case gfxASurface::SurfaceTypeOS2: {
+        case gfxSurfaceTypeOS2: {
             LONG lDPI;
             HDC dc = GpiQueryDevice(reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetPS());
             if (DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &lDPI))
                 dpi = lDPI;
             break;
         }
 #endif
         default:
@@ -646,61 +646,61 @@ nsDeviceContext::CalcPrintingSize()
 {
     if (!mPrintingSurface)
         return;
 
     bool inPoints = true;
 
     gfxSize size(0, 0);
     switch (mPrintingSurface->GetType()) {
-    case gfxASurface::SurfaceTypeImage:
+    case gfxSurfaceTypeImage:
         inPoints = false;
         size = reinterpret_cast<gfxImageSurface*>(mPrintingSurface.get())->GetSize();
         break;
 
 #if defined(MOZ_PDF_PRINTING)
-    case gfxASurface::SurfaceTypePDF:
+    case gfxSurfaceTypePDF:
         inPoints = true;
         size = reinterpret_cast<gfxPDFSurface*>(mPrintingSurface.get())->GetSize();
         break;
 #endif
 
 #ifdef MOZ_WIDGET_GTK
-    case gfxASurface::SurfaceTypePS:
+    case gfxSurfaceTypePS:
         inPoints = true;
         size = reinterpret_cast<gfxPSSurface*>(mPrintingSurface.get())->GetSize();
         break;
 #endif
 
 #ifdef XP_MACOSX
-    case gfxASurface::SurfaceTypeQuartz:
+    case gfxSurfaceTypeQuartz:
         inPoints = true; // this is really only true when we're printing
         size = reinterpret_cast<gfxQuartzSurface*>(mPrintingSurface.get())->GetSize();
         break;
 #endif
 
 #ifdef XP_WIN
-    case gfxASurface::SurfaceTypeWin32:
-    case gfxASurface::SurfaceTypeWin32Printing:
+    case gfxSurfaceTypeWin32:
+    case gfxSurfaceTypeWin32Printing:
         {
             inPoints = false;
             HDC dc = reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC();
             if (!dc)
                 dc = GetDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET));
             size.width = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, HORZRES)/mPrintingScale, AppUnitsPerDevPixel());
             size.height = NSFloatPixelsToAppUnits(::GetDeviceCaps(dc, VERTRES)/mPrintingScale, AppUnitsPerDevPixel());
             mDepth = (uint32_t)::GetDeviceCaps(dc, BITSPIXEL);
             if (dc != reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC())
                 ReleaseDC((HWND)mWidget->GetNativeData(NS_NATIVE_WIDGET), dc);
             break;
         }
 #endif
 
 #ifdef XP_OS2
-    case gfxASurface::SurfaceTypeOS2:
+    case gfxSurfaceTypeOS2:
         {
             inPoints = false;
             // we already set the size in the surface constructor we set for
             // printing, so just get those values here
             size = reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetSize();
             // as they are in pixels we need to scale them to app units
             size.width = NSFloatPixelsToAppUnits(size.width, AppUnitsPerDevPixel());
             size.height = NSFloatPixelsToAppUnits(size.height, AppUnitsPerDevPixel());
--- a/gfx/tests/gtest/gfxFontSelectionTest.cpp
+++ b/gfx/tests/gtest/gfxFontSelectionTest.cpp
@@ -184,17 +184,17 @@ static already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
     surface = gfxPlatform::GetPlatform()->
         CreateOffscreenSurface(gfxIntSize(size, size),
-                               gfxASurface::ContentFromFormat(gfxASurface::ImageFormatRGB24));
+                               gfxASurface::ContentFromFormat(gfxImageFormatRGB24));
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     return ctx.forget();
 }
 
 TestEntry*
 AddTest (nsTArray<TestEntry>& testList,
          const char *utf8FamilyString,
          const gfxFontStyle& fontStyle,
--- a/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp
+++ b/gfx/tests/gtest/gfxSurfaceRefCountTest.cpp
@@ -39,17 +39,17 @@ SurfaceDestroyNotifier (void *data) {
     *(int *)data = 1;
 }
 
 int
 TestNewSurface () {
     int failures = 0;
     int destroyed = 0;
 
-    nsRefPtr<gfxASurface> s = new gfxImageSurface (gfxIntSize(10, 10), gfxASurface::ImageFormatARGB32);
+    nsRefPtr<gfxASurface> s = new gfxImageSurface (gfxIntSize(10, 10), gfxImageFormatARGB32);
     cairo_surface_t *cs = s->CairoSurface();
 
     cairo_surface_set_user_data (cs, &destruction_key, &destroyed, SurfaceDestroyNotifier);
 
     failures += CheckInt (GetASurfaceRefCount(s.get()), 1);
     failures += CheckInt (cairo_surface_get_reference_count(cs), 1);
     failures += CheckInt (destroyed, 0);
 
--- a/gfx/tests/gtest/gfxTextRunPerfTest.cpp
+++ b/gfx/tests/gtest/gfxTextRunPerfTest.cpp
@@ -36,17 +36,17 @@ static already_AddRefed<gfxContext>
 MakeContext ()
 {
     const int size = 200;
 
     nsRefPtr<gfxASurface> surface;
 
     surface = gfxPlatform::GetPlatform()->
         CreateOffscreenSurface(gfxIntSize(size, size),
-                               gfxASurface::ContentFromFormat(gfxASurface::ImageFormatRGB24));
+                               gfxASurface::ContentFromFormat(gfxImageFormatRGB24));
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     return ctx.forget();
 }
 
 const char* lastFamilies = nullptr;
 
 static void
 RunTest (TestEntry *test, gfxContext *ctx) {
--- a/gfx/tests/gtest/gfxWordCacheTest.cpp
+++ b/gfx/tests/gtest/gfxWordCacheTest.cpp
@@ -77,17 +77,17 @@ static already_AddRefed<gfxContext>
 MakeContext ()
 {
    const int size = 200;
 
    nsRefPtr<gfxASurface> surface;
 
    surface = gfxPlatform::GetPlatform()->
        CreateOffscreenSurface(gfxIntSize(size, size),
-                              gfxASurface::ContentFromFormat(gfxASurface::ImageFormatRGB24));
+                              gfxASurface::ContentFromFormat(gfxImageFormatRGB24));
    nsRefPtr<gfxContext> ctx = new gfxContext(surface);
    return ctx.forget();
 }
 
 TEST(Gfx, WordCache) {
    gTextRuns = new FrameTextRunCache();
 
    nsRefPtr<gfxContext> ctx = MakeContext();
--- a/gfx/thebes/gfx2DGlue.h
+++ b/gfx/thebes/gfx2DGlue.h
@@ -194,62 +194,62 @@ inline JoinStyle ToJoinStyle(gfxContext:
 }
 
 inline gfxMatrix ThebesMatrix(const Matrix &aMatrix)
 {
   return gfxMatrix(aMatrix._11, aMatrix._12, aMatrix._21,
                    aMatrix._22, aMatrix._31, aMatrix._32);
 }
 
-inline gfxASurface::gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
+inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
   case FORMAT_B8G8R8A8:
-    return gfxASurface::ImageFormatARGB32;
+    return gfxImageFormatARGB32;
   case FORMAT_B8G8R8X8:
-    return gfxASurface::ImageFormatRGB24;
+    return gfxImageFormatRGB24;
   case FORMAT_R5G6B5:
-    return gfxASurface::ImageFormatRGB16_565;
+    return gfxImageFormatRGB16_565;
   case FORMAT_A8:
-    return gfxASurface::ImageFormatA8;
+    return gfxImageFormatA8;
   default:
-    return gfxASurface::ImageFormatUnknown;
+    return gfxImageFormatUnknown;
   }
 }
 
-inline SurfaceFormat ImageFormatToSurfaceFormat(gfxASurface::gfxImageFormat aFormat)
+inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
 {
   switch (aFormat) {
-  case gfxASurface::ImageFormatARGB32:
+  case gfxImageFormatARGB32:
     return FORMAT_B8G8R8A8;
-  case gfxASurface::ImageFormatRGB24:
+  case gfxImageFormatRGB24:
     return FORMAT_B8G8R8X8;
-  case gfxASurface::ImageFormatRGB16_565:
+  case gfxImageFormatRGB16_565:
     return FORMAT_R5G6B5;
-  case gfxASurface::ImageFormatA8:
+  case gfxImageFormatA8:
     return FORMAT_A8;
   default:
-  case gfxASurface::ImageFormatUnknown:
+  case gfxImageFormatUnknown:
     return FORMAT_B8G8R8A8;
   }
 }
 
-inline gfxASurface::gfxContentType ContentForFormat(const SurfaceFormat &aFormat)
+inline gfxContentType ContentForFormat(const SurfaceFormat &aFormat)
 {
   switch (aFormat) {
   case FORMAT_R5G6B5:
   case FORMAT_B8G8R8X8:
   case FORMAT_R8G8B8X8:
-    return gfxASurface::CONTENT_COLOR;
+    return GFX_CONTENT_COLOR;
   case FORMAT_A8:
-    return gfxASurface::CONTENT_ALPHA;
+    return GFX_CONTENT_ALPHA;
   case FORMAT_B8G8R8A8:
   case FORMAT_R8G8B8A8:
   default:
-    return gfxASurface::CONTENT_COLOR_ALPHA;
+    return GFX_CONTENT_COLOR_ALPHA;
   }
 }
 
 inline CompositionOp CompositionOpForOp(gfxContext::GraphicsOperator aOp)
 {
   switch (aOp) {
   case gfxContext::OPERATOR_ADD:
     return OP_ADD;
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -222,26 +222,26 @@ gfxASurface::Init(cairo_surface_t* surfa
 #ifdef MOZ_TREE_CAIRO
         if (cairo_surface_get_content(surface) != CAIRO_CONTENT_COLOR) {
             cairo_surface_set_subpixel_antialiasing(surface, CAIRO_SUBPIXEL_ANTIALIASING_DISABLED);
         }
 #endif
     }
 }
 
-gfxASurface::gfxSurfaceType
+gfxSurfaceType
 gfxASurface::GetType() const
 {
     if (!mSurfaceValid)
         return (gfxSurfaceType)-1;
 
     return (gfxSurfaceType)cairo_surface_get_type(mSurface);
 }
 
-gfxASurface::gfxContentType
+gfxContentType
 gfxASurface::GetContentType() const
 {
     if (!mSurfaceValid)
         return (gfxContentType)-1;
 
     return (gfxContentType)cairo_surface_get_content(mSurface);
 }
 
@@ -338,32 +338,32 @@ gfxASurface::CreateSimilarSurface(gfxCon
     cairo_surface_destroy(surface);
     return result.forget();
 }
 
 already_AddRefed<gfxImageSurface>
 gfxASurface::GetAsReadableARGB32ImageSurface()
 {
     nsRefPtr<gfxImageSurface> imgSurface = GetAsImageSurface();
-    if (!imgSurface || imgSurface->Format() != gfxASurface::ImageFormatARGB32) {
+    if (!imgSurface || imgSurface->Format() != gfxImageFormatARGB32) {
       imgSurface = CopyToARGB32ImageSurface();
     }
     return imgSurface.forget();
 }
 
 already_AddRefed<gfxImageSurface>
 gfxASurface::CopyToARGB32ImageSurface()
 {
     if (!mSurface || !mSurfaceValid) {
       return nullptr;
     }
 
     const nsIntSize size = GetSize();
     nsRefPtr<gfxImageSurface> imgSurface =
-        new gfxImageSurface(size, gfxASurface::ImageFormatARGB32);
+        new gfxImageSurface(size, gfxImageFormatARGB32);
 
     gfxContext ctx(imgSurface);
     ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
     ctx.SetSource(this);
     ctx.Paint();
 
     return imgSurface.forget();
 }
@@ -452,32 +452,32 @@ gfxASurface::BeginPage()
 }
 
 nsresult
 gfxASurface::EndPage()
 {
     return NS_OK;
 }
 
-gfxASurface::gfxContentType
+gfxContentType
 gfxASurface::ContentFromFormat(gfxImageFormat format)
 {
     switch (format) {
-        case ImageFormatARGB32:
-            return CONTENT_COLOR_ALPHA;
-        case ImageFormatRGB24:
-        case ImageFormatRGB16_565:
-            return CONTENT_COLOR;
-        case ImageFormatA8:
-        case ImageFormatA1:
-            return CONTENT_ALPHA;
+        case gfxImageFormatARGB32:
+            return GFX_CONTENT_COLOR_ALPHA;
+        case gfxImageFormatRGB24:
+        case gfxImageFormatRGB16_565:
+            return GFX_CONTENT_COLOR;
+        case gfxImageFormatA8:
+        case gfxImageFormatA1:
+            return GFX_CONTENT_ALPHA;
 
-        case ImageFormatUnknown:
+        case gfxImageFormatUnknown:
         default:
-            return CONTENT_COLOR;
+            return GFX_CONTENT_COLOR;
     }
 }
 
 void
 gfxASurface::SetSubpixelAntialiasingEnabled(bool aEnabled)
 {
 #ifdef MOZ_TREE_CAIRO
     if (!mSurfaceValid)
@@ -494,32 +494,32 @@ gfxASurface::GetSubpixelAntialiasingEnab
       return false;
 #ifdef MOZ_TREE_CAIRO
     return cairo_surface_get_subpixel_antialiasing(mSurface) == CAIRO_SUBPIXEL_ANTIALIASING_ENABLED;
 #else
     return true;
 #endif
 }
 
-gfxASurface::MemoryLocation
+gfxMemoryLocation
 gfxASurface::GetMemoryLocation() const
 {
-    return MEMORY_IN_PROCESS_HEAP;
+    return GFX_MEMORY_IN_PROCESS_HEAP;
 }
 
 int32_t
 gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
 {
     switch (format) {
-        case ImageFormatARGB32:
-        case ImageFormatRGB24:
+        case gfxImageFormatARGB32:
+        case gfxImageFormatRGB24:
             return 4;
-        case ImageFormatRGB16_565:
+        case gfxImageFormatRGB16_565:
             return 2;
-        case ImageFormatA8:
+        case gfxImageFormatA8:
             return 1;
         default:
             NS_WARNING("Unknown byte per pixel value for Image format");
     }
     return 0;
 }
 
 void
@@ -606,27 +606,27 @@ static const SurfaceMemoryReporterAttrs 
     {"gfx-surface-tee", nullptr},
     {"gfx-surface-xml", nullptr},
     {"gfx-surface-skia", nullptr},
     {"gfx-surface-subsurface", nullptr},
     {"gfx-surface-d2d", nullptr},
 };
 
 PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceMemoryReporterAttrs) ==
-                 gfxASurface::SurfaceTypeMax);
+                 gfxSurfaceTypeMax);
 #ifdef CAIRO_HAS_D2D_SURFACE
 PR_STATIC_ASSERT(uint32_t(CAIRO_SURFACE_TYPE_D2D) ==
-                 uint32_t(gfxASurface::SurfaceTypeD2D));
+                 uint32_t(gfxSurfaceTypeD2D));
 #endif
 PR_STATIC_ASSERT(uint32_t(CAIRO_SURFACE_TYPE_SKIA) ==
-                 uint32_t(gfxASurface::SurfaceTypeSkia));
+                 uint32_t(gfxSurfaceTypeSkia));
 
 /* Surface size memory reporting */
 
-static int64_t gSurfaceMemoryUsed[gfxASurface::SurfaceTypeMax] = { 0 };
+static int64_t gSurfaceMemoryUsed[gfxSurfaceTypeMax] = { 0 };
 
 class SurfaceMemoryReporter MOZ_FINAL :
     public nsIMemoryReporter
 {
 public:
     SurfaceMemoryReporter()
     { }
 
@@ -663,20 +663,20 @@ public:
 
         return NS_OK;
     }
 };
 
 NS_IMPL_ISUPPORTS1(SurfaceMemoryReporter, nsIMemoryReporter)
 
 void
-gfxASurface::RecordMemoryUsedForSurfaceType(gfxASurface::gfxSurfaceType aType,
+gfxASurface::RecordMemoryUsedForSurfaceType(gfxSurfaceType aType,
                                             int32_t aBytes)
 {
-    if (aType < 0 || aType >= SurfaceTypeMax) {
+    if (aType < 0 || aType >= gfxSurfaceTypeMax) {
         NS_WARNING("Invalid type to RecordMemoryUsedForSurfaceType!");
         return;
     }
 
     static bool registered = false;
     if (!registered) {
         NS_RegisterMemoryReporter(new SurfaceMemoryReporter());
         registered = true;
@@ -713,27 +713,27 @@ gfxASurface::SizeOfIncludingThis(MallocS
 {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
 }
 
 /* static */ uint8_t
 gfxASurface::BytesPerPixel(gfxImageFormat aImageFormat)
 {
   switch (aImageFormat) {
-    case ImageFormatARGB32:
+    case gfxImageFormatARGB32:
       return 4;
-    case ImageFormatRGB24:
+    case gfxImageFormatRGB24:
       return 4;
-    case ImageFormatRGB16_565:
+    case gfxImageFormatRGB16_565:
       return 2;
-    case ImageFormatA8:
+    case gfxImageFormatA8:
       return 1;
-    case ImageFormatA1:
+    case gfxImageFormatA1:
       return 1; // Close enough
-    case ImageFormatUnknown:
+    case gfxImageFormatUnknown:
     default:
       NS_NOTREACHED("Not really sure what you want me to say here");
       return 0;
   }
 }
 
 void
 gfxASurface::WriteAsPNG(const char* aFile)
@@ -773,26 +773,26 @@ gfxASurface::CopyAsDataURL()
  */
 void
 gfxASurface::WriteAsPNG_internal(FILE* aFile, bool aBinary)
 {
   nsRefPtr<gfxImageSurface> imgsurf = GetAsImageSurface();
   nsIntSize size;
 
   // FIXME/bug 831898: hack r5g6b5 for now.
-  if (!imgsurf || imgsurf->Format() == ImageFormatRGB16_565) {
+  if (!imgsurf || imgsurf->Format() == gfxImageFormatRGB16_565) {
     size = GetSize();
     if (size.width == -1 && size.height == -1) {
       printf("Could not determine surface size\n");
       return;
     }
 
     imgsurf =
       new gfxImageSurface(nsIntSize(size.width, size.height),
-                          gfxASurface::ImageFormatARGB32);
+                          gfxImageFormatARGB32);
 
     if (!imgsurf || imgsurf->CairoStatus()) {
       printf("Could not allocate image surface\n");
       return;
     }
 
     nsRefPtr<gfxContext> ctx = new gfxContext(imgsurf);
     if (!ctx || ctx->HasError()) {
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -55,58 +55,58 @@ public:
 #endif
 
 public:
     /**
      * The format for an image surface. For all formats with alpha data, 0
      * means transparent, 1 or 255 means fully opaque.
      */
     typedef enum {
-        ImageFormatARGB32, ///< ARGB data in native endianness, using premultiplied alpha
-        ImageFormatRGB24,  ///< xRGB data in native endianness
-        ImageFormatA8,     ///< Only an alpha channel
-        ImageFormatA1,     ///< Packed transparency information (one byte refers to 8 pixels)
-        ImageFormatRGB16_565,  ///< RGB_565 data in native endianness
-        ImageFormatUnknown
+        gfxImageFormatARGB32, ///< ARGB data in native endianness, using premultiplied alpha
+        gfxImageFormatRGB24,  ///< xRGB data in native endianness
+        gfxImageFormatA8,     ///< Only an alpha channel
+        gfxImageFormatA1,     ///< Packed transparency information (one byte refers to 8 pixels)
+        gfxImageFormatRGB16_565,  ///< RGB_565 data in native endianness
+        gfxImageFormatUnknown
     } gfxImageFormat;
 
     typedef enum {
-        SurfaceTypeImage,
-        SurfaceTypePDF,
-        SurfaceTypePS,
-        SurfaceTypeXlib,
-        SurfaceTypeXcb,
-        SurfaceTypeGlitz,           // unused, but needed for cairo parity
-        SurfaceTypeQuartz,
-        SurfaceTypeWin32,
-        SurfaceTypeBeOS,
-        SurfaceTypeDirectFB,        // unused, but needed for cairo parity
-        SurfaceTypeSVG,
-        SurfaceTypeOS2,
-        SurfaceTypeWin32Printing,
-        SurfaceTypeQuartzImage,
-        SurfaceTypeScript,
-        SurfaceTypeQPainter,
-        SurfaceTypeRecording,
-        SurfaceTypeVG,
-        SurfaceTypeGL,
-        SurfaceTypeDRM,
-        SurfaceTypeTee,
-        SurfaceTypeXML,
-        SurfaceTypeSkia,
-        SurfaceTypeSubsurface,
-        SurfaceTypeD2D,
-        SurfaceTypeMax
+        gfxSurfaceTypeImage,
+        gfxSurfaceTypePDF,
+        gfxSurfaceTypePS,
+        gfxSurfaceTypeXlib,
+        gfxSurfaceTypeXcb,
+        gfxSurfaceTypeGlitz,           // unused, but needed for cairo parity
+        gfxSurfaceTypeQuartz,
+        gfxSurfaceTypeWin32,
+        gfxSurfaceTypeBeOS,
+        gfxSurfaceTypeDirectFB,        // unused, but needed for cairo parity
+        gfxSurfaceTypeSVG,
+        gfxSurfaceTypeOS2,
+        gfxSurfaceTypeWin32Printing,
+        gfxSurfaceTypeQuartzImage,
+        gfxSurfaceTypeScript,
+        gfxSurfaceTypeQPainter,
+        gfxSurfaceTypeRecording,
+        gfxSurfaceTypeVG,
+        gfxSurfaceTypeGL,
+        gfxSurfaceTypeDRM,
+        gfxSurfaceTypeTee,
+        gfxSurfaceTypeXML,
+        gfxSurfaceTypeSkia,
+        gfxSurfaceTypeSubsurface,
+        gfxSurfaceTypeD2D,
+        gfxSurfaceTypeMax
     } gfxSurfaceType;
 
     typedef enum {
-        CONTENT_COLOR       = 0x1000,
-        CONTENT_ALPHA       = 0x2000,
-        CONTENT_COLOR_ALPHA = 0x3000,
-        CONTENT_SENTINEL    = 0xffff
+        GFX_CONTENT_COLOR       = 0x1000,
+        GFX_CONTENT_ALPHA       = 0x2000,
+        GFX_CONTENT_COLOR_ALPHA = 0x3000,
+        GFX_CONTENT_SENTINEL    = 0xffff
     } gfxContentType;
 
     /** Wrap the given cairo surface and return a gfxASurface for it.
      * This adds a reference to csurf (owned by the returned gfxASurface).
      */
     static already_AddRefed<gfxASurface> Wrap(cairo_surface_t *csurf);
 
     /*** this DOES NOT addref the surface */
@@ -192,17 +192,17 @@ public:
 
     void SetSubpixelAntialiasingEnabled(bool aEnabled);
     bool GetSubpixelAntialiasingEnabled();
 
     /**
      * Record number of bytes for given surface type.  Use positive bytes
      * for allocations and negative bytes for deallocations.
      */
-    static void RecordMemoryUsedForSurfaceType(gfxASurface::gfxSurfaceType aType,
+    static void RecordMemoryUsedForSurfaceType(gfxSurfaceType aType,
                                                int32_t aBytes);
 
     /**
      * Same as above, but use current surface type as returned by GetType().
      * The bytes will be accumulated until RecordMemoryFreed is called,
      * in which case the value that was recorded for this surface will
      * be freed.
      */
@@ -223,19 +223,19 @@ public:
     virtual bool SizeOfIsMeasured() const { return false; }
 
     /**
      * The memory used by this surface (as reported by KnownMemoryUsed()) can
      * either live in this process's heap, in this process but outside the
      * heap, or in another process altogether.
      */
     enum MemoryLocation {
-      MEMORY_IN_PROCESS_HEAP,
-      MEMORY_IN_PROCESS_NONHEAP,
-      MEMORY_OUT_OF_PROCESS
+      GFX_MEMORY_IN_PROCESS_HEAP,
+      GFX_MEMORY_IN_PROCESS_NONHEAP,
+      GFX_MEMORY_OUT_OF_PROCESS
     };
 
     /**
      * Where does this surface's memory live?  By default, we say it's in this
      * process's heap.
      */
     virtual MemoryLocation GetMemoryLocation() const;
 
--- a/gfx/thebes/gfxAlphaRecovery.cpp
+++ b/gfx/thebes/gfxAlphaRecovery.cpp
@@ -13,20 +13,20 @@
 /* static */ bool
 gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
                                const gfxImageSurface* whiteSurf,
                                Analysis* analysis)
 {
     gfxIntSize size = blackSurf->GetSize();
 
     if (size != whiteSurf->GetSize() ||
-        (blackSurf->Format() != gfxASurface::ImageFormatARGB32 &&
-         blackSurf->Format() != gfxASurface::ImageFormatRGB24) ||
-        (whiteSurf->Format() != gfxASurface::ImageFormatARGB32 &&
-         whiteSurf->Format() != gfxASurface::ImageFormatRGB24))
+        (blackSurf->Format() != gfxImageFormatARGB32 &&
+         blackSurf->Format() != gfxImageFormatRGB24) ||
+        (whiteSurf->Format() != gfxImageFormatARGB32 &&
+         whiteSurf->Format() != gfxImageFormatRGB24))
         return false;
 
 #ifdef MOZILLA_MAY_SUPPORT_SSE2
     if (!analysis && mozilla::supports_sse2() &&
         RecoverAlphaSSE2(blackSurf, whiteSurf)) {
         return true;
     }
 #endif
--- a/gfx/thebes/gfxAlphaRecoverySSE2.cpp
+++ b/gfx/thebes/gfxAlphaRecoverySSE2.cpp
@@ -28,20 +28,20 @@ static uint32_t alphaMaski[] = { 0xff000
 
 bool
 gfxAlphaRecovery::RecoverAlphaSSE2(gfxImageSurface* blackSurf,
                                    const gfxImageSurface* whiteSurf)
 {
     gfxIntSize size = blackSurf->GetSize();
 
     if (size != whiteSurf->GetSize() ||
-        (blackSurf->Format() != gfxASurface::ImageFormatARGB32 &&
-         blackSurf->Format() != gfxASurface::ImageFormatRGB24) ||
-        (whiteSurf->Format() != gfxASurface::ImageFormatARGB32 &&
-         whiteSurf->Format() != gfxASurface::ImageFormatRGB24))
+        (blackSurf->Format() != gfxImageFormatARGB32 &&
+         blackSurf->Format() != gfxImageFormatRGB24) ||
+        (whiteSurf->Format() != gfxImageFormatARGB32 &&
+         whiteSurf->Format() != gfxImageFormatRGB24))
         return false;
 
     blackSurf->Flush();
     whiteSurf->Flush();
 
     unsigned char* blackData = blackSurf->Data();
     unsigned char* whiteData = whiteSurf->Data();
 
@@ -135,17 +135,17 @@ ByteAlignment(int32_t aAlignToLog2, int3
 {
     return (aX + aStride * aY) & ((1 << aAlignToLog2) - 1);
 }
 
 /*static*/ nsIntRect
 gfxAlphaRecovery::AlignRectForSubimageRecovery(const nsIntRect& aRect,
                                                gfxImageSurface* aSurface)
 {
-    NS_ASSERTION(gfxASurface::ImageFormatARGB32 == aSurface->Format(),
+    NS_ASSERTION(gfxImageFormatARGB32 == aSurface->Format(),
                  "Thebes grew support for non-ARGB32 COLOR_ALPHA?");
     static const int32_t kByteAlignLog2 = GoodAlignmentLog2();
     static const int32_t bpp = 4;
     static const int32_t pixPerAlign = (1 << kByteAlignLog2) / bpp;
     //
     // We're going to create a subimage of the surface with size
     // <sw,sh> for alpha recovery, and want a SIMD fast-path.  The
     // rect <x,y, w,h> /needs/ to be redrawn, but it might not be
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -101,38 +101,38 @@ gfxAndroidPlatform::gfxAndroidPlatform()
 
     nsCOMPtr<nsIScreenManager> screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1");
     nsCOMPtr<nsIScreen> screen;
     screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
     mScreenDepth = 24;
     screen->GetColorDepth(&mScreenDepth);
 
     mOffscreenFormat = mScreenDepth == 16
-                       ? gfxASurface::ImageFormatRGB16_565
-                       : gfxASurface::ImageFormatRGB24;
+                       ? gfxImageFormatRGB16_565
+                       : gfxImageFormatRGB24;
 
     if (Preferences::GetBool("gfx.android.rgb16.force", false)) {
-        mOffscreenFormat = gfxASurface::ImageFormatRGB16_565;
+        mOffscreenFormat = gfxImageFormatRGB16_565;
     }
 
 }
 
 gfxAndroidPlatform::~gfxAndroidPlatform()
 {
     cairo_debug_reset_static_data();
 
     NS_UnregisterMemoryReporter(mFreetypeReporter);
 
     FT_Done_Library(gPlatformFTLibrary);
     gPlatformFTLibrary = nullptr;
 }
 
 already_AddRefed<gfxASurface>
 gfxAndroidPlatform::CreateOffscreenSurface(const gfxIntSize& size,
-                                      gfxASurface::gfxContentType contentType)
+                                      gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface;
     newSurface = new gfxImageSurface(size, OptimalFormatForContent(contentType));
 
     return newSurface.forget();
 }
 
 static bool
--- a/gfx/thebes/gfxAndroidPlatform.h
+++ b/gfx/thebes/gfxAndroidPlatform.h
@@ -29,17 +29,17 @@ public:
     virtual ~gfxAndroidPlatform();
 
     static gfxAndroidPlatform *GetPlatform() {
         return (gfxAndroidPlatform*) gfxPlatform::GetPlatform();
     }
 
     virtual already_AddRefed<gfxASurface>
     CreateOffscreenSurface(const gfxIntSize& size,
-                           gfxASurface::gfxContentType contentType);
+                           gfxContentType contentType);
     
     virtual gfxImageFormat GetOffscreenFormat() { return mOffscreenFormat; }
     
     mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
 
     // to support IPC font list (sharing between chrome and content)
     void GetFontList(InfallibleTArray<FontListEntry>* retValue);
--- a/gfx/thebes/gfxBaseSharedMemorySurface.h
+++ b/gfx/thebes/gfxBaseSharedMemorySurface.h
@@ -51,17 +51,17 @@ public:
      *
      * NB: the *caller* is responsible for freeing the Shmem allocated
      * by this function.
      */
     template<class ShmemAllocator>
     static already_AddRefed<Sub>
     Create(ShmemAllocator* aAllocator,
            const gfxIntSize& aSize,
-           gfxASurface::gfxImageFormat aFormat,
+           gfxImageFormat aFormat,
            SharedMemory::SharedMemoryType aShmType = SharedMemory::TYPE_BASIC)
     {
         return Create<ShmemAllocator, false>(aAllocator, aSize, aFormat, aShmType);
     }
 
     /**
      * Return a new gfxSharedImageSurface that wraps a shmem segment
      * already created by the Create() above.  Bad things will happen
@@ -71,50 +71,50 @@ public:
     static already_AddRefed<Sub>
     Open(const Shmem& aShmem)
     {
         SharedImageInfo* shmInfo = GetShmInfoPtr(aShmem);
         gfxIntSize size(shmInfo->width, shmInfo->height);
         if (!gfxASurface::CheckSurfaceSize(size))
             return nullptr;
        
-        gfxASurface::gfxImageFormat format = (gfxASurface::gfxImageFormat)shmInfo->format;
+        gfxImageFormat format = (gfxImageFormat)shmInfo->format;
         long stride = gfxImageSurface::ComputeStride(size, format);
 
         nsRefPtr<Sub> s =
             new Sub(size,
                     stride,
                     format,
                     aShmem);
         // We didn't create this Shmem and so don't free it on errors
         return (s->CairoStatus() != 0) ? nullptr : s.forget();
     }
 
     template<class ShmemAllocator>
     static already_AddRefed<Sub>
     CreateUnsafe(ShmemAllocator* aAllocator,
                  const gfxIntSize& aSize,
-                 gfxASurface::gfxImageFormat aFormat,
+                 gfxImageFormat aFormat,
                  SharedMemory::SharedMemoryType aShmType = SharedMemory::TYPE_BASIC)
     {
         return Create<ShmemAllocator, true>(aAllocator, aSize, aFormat, aShmType);
     }
 
     Shmem& GetShmem() { return mShmem; }
 
     static bool IsSharedImage(gfxASurface *aSurface)
     {
         return (aSurface
-                && aSurface->GetType() == gfxASurface::SurfaceTypeImage
+                && aSurface->GetType() == gfxSurfaceTypeImage
                 && aSurface->GetData(&SHM_KEY));
     }
 
 protected:
     gfxBaseSharedMemorySurface(const gfxIntSize& aSize, long aStride, 
-                               gfxASurface::gfxImageFormat aFormat, 
+                               gfxImageFormat aFormat, 
                                const Shmem& aShmem)
       : Base(aShmem.get<unsigned char>(), aSize, aStride, aFormat)
     {
         MOZ_COUNT_CTOR(gfxBaseSharedMemorySurface);
 
         mShmem = aShmem;
         this->SetData(&SHM_KEY, this, nullptr);
     }
@@ -155,17 +155,17 @@ private:
         #define MOZ_ALIGN_WORD(x) (((x) + 3) & ~3)
         return MOZ_ALIGN_WORD(sizeof(SharedImageInfo) + aSize.height * aStride);
     }
 
     template<class ShmemAllocator, bool Unsafe>
     static already_AddRefed<Sub>
     Create(ShmemAllocator* aAllocator,
            const gfxIntSize& aSize,
-           gfxASurface::gfxImageFormat aFormat,
+           gfxImageFormat aFormat,
            SharedMemory::SharedMemoryType aShmType)
     {
         if (!gfxASurface::CheckSurfaceSize(aSize))
             return nullptr;
 
         Shmem shmem;
         long stride = gfxImageSurface::ComputeStride(aSize, aFormat);
         size_t size = GetAlignedSize(aSize, stride);
--- a/gfx/thebes/gfxBlur.cpp
+++ b/gfx/thebes/gfxBlur.cpp
@@ -52,17 +52,17 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRe
     if (blurDataSize <= 0)
         return nullptr;
 
     IntSize size = mBlur->GetSize();
 
     // Make an alpha-only surface to draw on. We will play with the data after
     // everything is drawn to create a blur effect.
     mImageSurface = new gfxImageSurface(gfxIntSize(size.width, size.height),
-                                        gfxASurface::ImageFormatA8,
+                                        gfxImageFormatA8,
                                         mBlur->GetStride(),
                                         blurDataSize,
                                         true);
     if (mImageSurface->CairoStatus())
         return nullptr;
 
     IntRect irect = mBlur->GetRect();
     gfxPoint topleft(irect.TopLeft().x, irect.TopLeft().y);
--- a/gfx/thebes/gfxCachedTempSurface.cpp
+++ b/gfx/thebes/gfxCachedTempSurface.cpp
@@ -61,17 +61,17 @@ CachedSurfaceExpirationTracker*
 CachedSurfaceExpirationTracker::sExpirationTracker = nullptr;
 
 gfxCachedTempSurface::~gfxCachedTempSurface()
 {
   CachedSurfaceExpirationTracker::RemoveSurface(this);
 }
 
 already_AddRefed<gfxContext>
-gfxCachedTempSurface::Get(gfxASurface::gfxContentType aContentType,
+gfxCachedTempSurface::Get(gfxContentType aContentType,
                           const gfxRect& aRect,
                           gfxASurface* aSimilarTo)
 {
   if (mSurface) {
     /* Verify the current buffer is valid for this purpose */
     if (mSize.width < aRect.width || mSize.height < aRect.height
         || mSurface->GetContentType() != aContentType
         || mType != aSimilarTo->GetType()) {
@@ -89,17 +89,17 @@ gfxCachedTempSurface::Get(gfxASurface::g
     cleared = true;
     mType = aSimilarTo->GetType();
   }
   mSurface->SetDeviceOffset(-aRect.TopLeft());
 
   nsRefPtr<gfxContext> ctx = new gfxContext(mSurface);
   ctx->Rectangle(aRect);
   ctx->Clip();
-  if (!cleared && aContentType != gfxASurface::CONTENT_COLOR) {
+  if (!cleared && aContentType != GFX_CONTENT_COLOR) {
     ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
     ctx->Paint();
     ctx->SetOperator(gfxContext::OPERATOR_OVER);
   }
 
   CachedSurfaceExpirationTracker::MarkSurfaceUsed(this);
 
   return ctx.forget();
--- a/gfx/thebes/gfxCachedTempSurface.h
+++ b/gfx/thebes/gfxCachedTempSurface.h
@@ -33,26 +33,26 @@ public:
    * For opaque surfaces, the initial surface contents are undefined.
    * When |aContentType| differs in different invocations this is handled
    * appropriately, creating a new surface if necessary.
    * 
    * Because the cached surface may have been created during a previous
    * invocation, this will not be efficient if the new |aSimilarTo| has a
    * different format, size, or gfxSurfaceType.
    */
-  already_AddRefed<gfxContext> Get(gfxASurface::gfxContentType aContentType,
+  already_AddRefed<gfxContext> Get(gfxContentType aContentType,
                                    const gfxRect& aRect,
                                    gfxASurface* aSimilarTo);
 
   void Expire() { mSurface = nullptr; }
   nsExpirationState* GetExpirationState() { return &mExpirationState; }
   ~gfxCachedTempSurface();
 
   bool IsSurface(gfxASurface* aSurface) { return mSurface == aSurface; }
 
 private:
   nsRefPtr<gfxASurface> mSurface;
   gfxIntSize mSize;
   nsExpirationState mExpirationState;
-  gfxASurface::gfxSurfaceType mType;
+  gfxSurfaceType mType;
 };
 
 #endif /* GFX_CACHED_TEMP_SURFACE_H */
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -1537,17 +1537,17 @@ gfxContext::Paint(gfxFloat alpha)
                     DrawOptions(Float(alpha), GetOp()));
     }
   }
 }
 
 // groups
 
 void
-gfxContext::PushGroup(gfxASurface::gfxContentType content)
+gfxContext::PushGroup(gfxContentType content)
 {
   if (mCairo) {
     cairo_push_group_with_content(mCairo, (cairo_content_t) content);
   } else {
     PushNewDT(content);
 
     PushClipsToDT(mDT);
     mDT->SetTransform(GetDTTransform());
@@ -1573,30 +1573,30 @@ CopySurface(gfxASurface* aSrc, gfxASurfa
   cairo_t *cr = cairo_create(aDest->CairoSurface());
   cairo_set_source_surface(cr, aSrc->CairoSurface(), aTranslation.x, aTranslation.y);
   cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
   cairo_paint(cr);
   cairo_destroy(cr);
 }
 
 void
-gfxContext::PushGroupAndCopyBackground(gfxASurface::gfxContentType content)
+gfxContext::PushGroupAndCopyBackground(gfxContentType content)
 {
   if (mCairo) {
-    if (content == gfxASurface::CONTENT_COLOR_ALPHA &&
+    if (content == GFX_CONTENT_COLOR_ALPHA &&
       !(GetFlags() & FLAG_DISABLE_COPY_BACKGROUND)) {
       nsRefPtr<gfxASurface> s = CurrentSurface();
-      if ((s->GetAllowUseAsSource() || s->GetType() == gfxASurface::SurfaceTypeTee) &&
-          (s->GetContentType() == gfxASurface::CONTENT_COLOR ||
+      if ((s->GetAllowUseAsSource() || s->GetType() == gfxSurfaceTypeTee) &&
+          (s->GetContentType() == GFX_CONTENT_COLOR ||
               s->GetOpaqueRect().Contains(GetRoundOutDeviceClipExtents(this)))) {
         cairo_push_group_with_content(mCairo, CAIRO_CONTENT_COLOR);
         nsRefPtr<gfxASurface> d = CurrentSurface();
 
-        if (d->GetType() == gfxASurface::SurfaceTypeTee) {
-          NS_ASSERTION(s->GetType() == gfxASurface::SurfaceTypeTee, "Mismatched types");
+        if (d->GetType() == gfxSurfaceTypeTee) {
+          NS_ASSERTION(s->GetType() == gfxSurfaceTypeTee, "Mismatched types");
           nsAutoTArray<nsRefPtr<gfxASurface>,2> ss;
           nsAutoTArray<nsRefPtr<gfxASurface>,2> ds;
           static_cast<gfxTeeSurface*>(s.get())->GetSurfaces(&ss);
           static_cast<gfxTeeSurface*>(d.get())->GetSurfaces(&ds);
           NS_ASSERTION(ss.Length() == ds.Length(), "Mismatched lengths");
           gfxPoint translation = d->GetDeviceOffset() - s->GetDeviceOffset();
           for (uint32_t i = 0; i < ss.Length(); ++i) {
               CopySurface(ss[i], ds[i], translation);
@@ -1615,17 +1615,17 @@ gfxContext::PushGroupAndCopyBackground(g
       clipExtents = IntRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
     }
     if (mDT->GetFormat() == FORMAT_B8G8R8X8 ||
         mDT->GetOpaqueRect().Contains(clipExtents)) {
       DrawTarget *oldDT = mDT;
       RefPtr<SourceSurface> source = mDT->Snapshot();
       Point oldDeviceOffset = CurrentState().deviceOffset;
 
-      PushNewDT(gfxASurface::CONTENT_COLOR);
+      PushNewDT(GFX_CONTENT_COLOR);
 
       Point offset = CurrentState().deviceOffset - oldDeviceOffset;
       Rect surfRect(0, 0, Float(mDT->GetSize().width), Float(mDT->GetSize().height));
       Rect sourceRect = surfRect;
       sourceRect.x += offset.x;
       sourceRect.y += offset.y;
 
       mDT->SetTransform(Matrix());
@@ -2274,17 +2274,17 @@ gfxContext::GetDTTransform() const
 {
   Matrix mat = mTransform;
   mat._31 -= CurrentState().deviceOffset.x;
   mat._32 -= CurrentState().deviceOffset.y;
   return mat;
 }
 
 void
-gfxContext::PushNewDT(gfxASurface::gfxContentType content)
+gfxContext::PushNewDT(gfxContentType content)
 {
   Rect clipBounds = GetAzureDeviceSpaceClipBounds();
   clipBounds.RoundOut();
 
   clipBounds.width = std::max(1.0f, clipBounds.width);
   clipBounds.height = std::max(1.0f, clipBounds.height);
 
   RefPtr<DrawTarget> newDT =
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -612,29 +612,29 @@ public:
      * This is conservative; it may return false even when the given rectangle is 
      * fully contained by the current clip.
      */
     bool ClipContainsRect(const gfxRect& aRect);
 
     /**
      * Groups
      */
-    void PushGroup(gfxASurface::gfxContentType content = gfxASurface::CONTENT_COLOR);
+    void PushGroup(gfxContentType content = GFX_CONTENT_COLOR);
     /**
-     * Like PushGroup, but if the current surface is CONTENT_COLOR and
-     * content is CONTENT_COLOR_ALPHA, makes the pushed surface CONTENT_COLOR
+     * Like PushGroup, but if the current surface is GFX_CONTENT_COLOR and
+     * content is GFX_CONTENT_COLOR_ALPHA, makes the pushed surface GFX_CONTENT_COLOR
      * instead and copies the contents of the current surface to the pushed
      * surface. This is good for pushing opacity groups, since blending the
      * group back to the current surface with some alpha applied will give
      * the correct results and using an opaque pushed surface gives better
      * quality and performance.
      * This API really only makes sense if you do a PopGroupToSource and
      * immediate Paint with OPERATOR_OVER.
      */
-    void PushGroupAndCopyBackground(gfxASurface::gfxContentType content = gfxASurface::CONTENT_COLOR);
+    void PushGroupAndCopyBackground(gfxContentType content = GFX_CONTENT_COLOR);
     already_AddRefed<gfxPattern> PopGroup();
     void PopGroupToSource();
 
     /**
      ** Hit Testing - check if given point is in the current path
      **/
     bool PointInFill(const gfxPoint& pt);
     bool PointInStroke(const gfxPoint& pt);
@@ -769,17 +769,17 @@ private:
   void EnsurePathBuilder();
   void FillAzure(mozilla::gfx::Float aOpacity);
   void PushClipsToDT(mozilla::gfx::DrawTarget *aDT);
   CompositionOp GetOp();
   void ChangeTransform(const mozilla::gfx::Matrix &aNewMatrix, bool aUpdatePatternTransform = true);
   Rect GetAzureDeviceSpaceClipBounds();
   Matrix GetDeviceTransform() const;
   Matrix GetDTTransform() const;
-  void PushNewDT(gfxASurface::gfxContentType content);
+  void PushNewDT(gfxContentType content);
 
   bool mPathIsRect;
   bool mTransformChanged;
   Matrix mPathTransform;
   Rect mRect;
   mozilla::RefPtr<PathBuilder> mPathBuilder;
   mozilla::RefPtr<Path> mPath;
   Matrix mTransform;
--- a/gfx/thebes/gfxD2DSurface.h
+++ b/gfx/thebes/gfxD2DSurface.h
@@ -16,17 +16,17 @@ struct nsIntRect;
 
 class gfxD2DSurface : public gfxASurface {
 public:
 
     gfxD2DSurface(HWND wnd,
                   gfxContentType aContent);
 
     gfxD2DSurface(const gfxIntSize& size,
-                  gfxImageFormat imageFormat = ImageFormatRGB24);
+                  gfxImageFormat imageFormat = gfxImageFormatRGB24);
 
     gfxD2DSurface(HANDLE handle, gfxContentType aContent);
 
     gfxD2DSurface(ID3D10Texture2D *texture, gfxContentType aContent);
 
     gfxD2DSurface(cairo_surface_t *csurf);
 
     void MovePixels(const nsIntRect& aSourceRect,
--- a/gfx/thebes/gfxDrawable.cpp
+++ b/gfx/thebes/gfxDrawable.cpp
@@ -49,17 +49,17 @@ PreparePatternForUntiledDrawing(gfxPatte
     }
 
     // In theory we can handle this using cairo's EXTEND_PAD,
     // but implementation limitations mean we have to consult
     // the surface type.
     switch (currentTarget->GetType()) {
 
 #ifdef MOZ_X11
-        case gfxASurface::SurfaceTypeXlib:
+        case gfxSurfaceTypeXlib:
         {
             // See bugs 324698, 422179, and 468496.  This is a workaround for
             // XRender's RepeatPad not being implemented correctly on old X
             // servers.
             //
             // In this situation, cairo avoids XRender and instead reads back
             // to perform EXTEND_PAD with pixman.  This is too slow so we
             // avoid EXTEND_PAD and set the filter to CAIRO_FILTER_FAST ---
@@ -146,17 +146,17 @@ gfxCallbackDrawable::gfxCallbackDrawable
  , mCallback(aCallback)
 {
 }
 
 already_AddRefed<gfxSurfaceDrawable>
 gfxCallbackDrawable::MakeSurfaceDrawable(const gfxPattern::GraphicsFilter aFilter)
 {
     nsRefPtr<gfxASurface> surface =
-        gfxPlatform::GetPlatform()->CreateOffscreenSurface(mSize, gfxASurface::CONTENT_COLOR_ALPHA);
+        gfxPlatform::GetPlatform()->CreateOffscreenSurface(mSize, GFX_CONTENT_COLOR_ALPHA);
     if (!surface || surface->CairoStatus() != 0)
         return nullptr;
 
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     Draw(ctx, gfxRect(0, 0, mSize.width, mSize.height), false, aFilter);
     nsRefPtr<gfxSurfaceDrawable> drawable = new gfxSurfaceDrawable(surface, mSize);
     return drawable.forget();
 }
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -5887,17 +5887,17 @@ struct BufferAlphaColor {
         mContext->Save();
         mContext->NewPath();
         mContext->Rectangle(gfxRect(aBounds.X() / appsPerDevUnit,
                     aBounds.Y() / appsPerDevUnit,
                     aBounds.Width() / appsPerDevUnit,
                     aBounds.Height() / appsPerDevUnit), true);
         mContext->Clip();
         mContext->SetColor(gfxRGBA(aAlphaColor.r, aAlphaColor.g, aAlphaColor.b));
-        mContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
+        mContext->PushGroup(GFX_CONTENT_COLOR_ALPHA);
         mAlpha = aAlphaColor.a;
     }
 
     void PopAlpha()
     {
         // pop the text, using the color alpha as the opacity
         mContext->PopGroupToSource();
         mContext->SetOperator(gfxContext::OPERATOR_OVER);
--- a/gfx/thebes/gfxImageSurface.cpp
+++ b/gfx/thebes/gfxImageSurface.cpp
@@ -13,17 +13,17 @@
 #include "gfx2DGlue.h"
 #include <algorithm>
 
 using namespace mozilla::gfx;
 
 gfxImageSurface::gfxImageSurface()
   : mSize(0, 0),
     mOwnsData(false),
-    mFormat(ImageFormatUnknown),
+    mFormat(gfxImageFormatUnknown),
     mStride(0)
 {
 }
 
 void
 gfxImageSurface::InitFromSurface(cairo_surface_t *csurf)
 {
     mSize.width = cairo_image_surface_get_width(csurf);
@@ -172,25 +172,25 @@ gfxImageSurface::~gfxImageSurface()
         free(mData);
 }
 
 /*static*/ long
 gfxImageSurface::ComputeStride(const gfxIntSize& aSize, gfxImageFormat aFormat)
 {
     long stride;
 
-    if (aFormat == ImageFormatARGB32)
+    if (aFormat == gfxImageFormatARGB32)
         stride = aSize.width * 4;
-    else if (aFormat == ImageFormatRGB24)
+    else if (aFormat == gfxImageFormatRGB24)
         stride = aSize.width * 4;
-    else if (aFormat == ImageFormatRGB16_565)
+    else if (aFormat == gfxImageFormatRGB16_565)
         stride = aSize.width * 2;
-    else if (aFormat == ImageFormatA8)
+    else if (aFormat == gfxImageFormatA8)
         stride = aSize.width;
-    else if (aFormat == ImageFormatA1) {
+    else if (aFormat == gfxImageFormatA1) {
         stride = (aSize.width + 7) / 8;
     } else {
         NS_WARNING("Unknown format specified to gfxImageSurface!");
         stride = aSize.width * 4;
     }
 
     stride = ((stride + 3) / 4) * 4;
 
@@ -233,23 +233,23 @@ CopyForStride(unsigned char* aDest, unsi
 
             memcpy (dst, src, lineSize);
         }
     }
 }
 
 // helper function for the CopyFrom methods
 static bool
-FormatsAreCompatible(gfxASurface::gfxImageFormat a1, gfxASurface::gfxImageFormat a2)
+FormatsAreCompatible(gfxImageFormat a1, gfxImageFormat a2)
 {
     if (a1 != a2 &&
-        !(a1 == gfxASurface::ImageFormatARGB32 &&
-          a2 == gfxASurface::ImageFormatRGB24) &&
-        !(a1 == gfxASurface::ImageFormatRGB24 &&
-          a2 == gfxASurface::ImageFormatARGB32)) {
+        !(a1 == gfxImageFormatARGB32 &&
+          a2 == gfxImageFormatRGB24) &&
+        !(a1 == gfxImageFormatRGB24 &&
+          a2 == gfxImageFormatARGB32)) {
         return false;
     }
 
     return true;
 }
 
 bool
 gfxImageSurface::CopyFrom (SourceSurface *aSurface)
@@ -300,19 +300,19 @@ gfxImageSurface::GetSubimage(const gfxRe
     MOZ_ASSERT(gfxRect(0, 0, mSize.width, mSize.height).Contains(r));
 
     gfxImageFormat format = Format();
 
     unsigned char* subData = Data() +
         (Stride() * (int)r.Y()) +
         (int)r.X() * gfxASurface::BytePerPixelFromFormat(Format());
 
-    if (format == ImageFormatARGB32 &&
+    if (format == gfxImageFormatARGB32 &&
         GetOpaqueRect().Contains(aRect)) {
-        format = ImageFormatRGB24;
+        format = gfxImageFormatRGB24;
     }
 
     nsRefPtr<gfxSubimageSurface> image =
         new gfxSubimageSurface(this, subData,
                                gfxIntSize((int)r.Width(), (int)r.Height()),
                                format);
 
     return image.forget();
--- a/gfx/thebes/gfxOS2Platform.cpp
+++ b/gfx/thebes/gfxOS2Platform.cpp
@@ -45,31 +45,31 @@ gfxOS2Platform::~gfxOS2Platform()
     cairo_os2_fini();
 #ifdef DEBUG_thebes
     printf("  cairo_os2_fini() was called\n");
 #endif
 }
 
 already_AddRefed<gfxASurface>
 gfxOS2Platform::CreateOffscreenSurface(const gfxIntSize& aSize,
-                                       gfxASurface::gfxContentType contentType)
+                                       gfxContentType contentType)
 {
 #ifdef DEBUG_thebes_2
     printf("gfxOS2Platform::CreateOffscreenSurface(%d/%d, %d)\n",
            aSize.width, aSize.height, aImageFormat);
 #endif
     gfxASurface *newSurface = nullptr;
 
-    // we only ever seem to get aImageFormat=0 or ImageFormatARGB32 but
+    // we only ever seem to get aImageFormat=0 or gfxImageFormatARGB32 but
     // I don't really know if we need to differ between ARGB32 and RGB24 here
-    if (contentType == gfxASurface::CONTENT_COLOR_ALPHA ||
-        contentType == gfxASurface::CONTENT_COLOR)
+    if (contentType == GFX_CONTENT_COLOR_ALPHA ||
+        contentType == GFX_CONTENT_COLOR)
     {
         newSurface = new gfxOS2Surface(aSize, OptimalFormatForContent(contentType));
-    } else if (contentType == gfxASurface::CONTENT_ALPHA) {
+    } else if (contentType == GFX_CONTENT_ALPHA) {
         newSurface = new gfxImageSurface(aSize, OptimalFormatForContent(contentType));
     } else {
         return nullptr;
     }
 
     NS_IF_ADDREF(newSurface);
     return newSurface;
 }
--- a/gfx/thebes/gfxOS2Platform.h
+++ b/gfx/thebes/gfxOS2Platform.h
@@ -23,17 +23,17 @@ public:
     virtual ~gfxOS2Platform();
 
     static gfxOS2Platform *GetPlatform() {
         return (gfxOS2Platform*) gfxPlatform::GetPlatform();
     }
 
     already_AddRefed<gfxASurface>
         CreateOffscreenSurface(const gfxIntSize& size,
-                               gfxASurface::gfxContentType contentType);
+                               gfxContentType contentType);
 
     nsresult GetFontList(nsIAtom *aLangGroup,
                          const nsACString& aGenericFamily,
                          nsTArray<nsString>& aListOfFonts);
     nsresult UpdateFontList();
     nsresult ResolveFontName(const nsAString& aFontName,
                              FontResolverCallback aCallback,
                              void *aClosure, bool& aAborted);
--- a/gfx/thebes/gfxOS2Surface.cpp
+++ b/gfx/thebes/gfxOS2Surface.cpp
@@ -7,17 +7,17 @@
 
 #include <stdio.h>
 
 /**********************************************************************
  * class gfxOS2Surface
  **********************************************************************/
 
 gfxOS2Surface::gfxOS2Surface(const gfxIntSize& aSize,
-                             gfxASurface::gfxImageFormat aImageFormat)
+                             gfxImageFormat aImageFormat)
     : mWnd(0), mSize(aSize)
 {
 #ifdef DEBUG_thebes_2
     printf("gfxOS2Surface[%#x]::gfxOS2Surface(Size=%dx%d, %d)\n", (unsigned int)this,
            aSize.width, aSize.height, aImageFormat);
 #endif
     // in this case we don't have a window, so we create a memory presentation
     // space to construct the cairo surface on
--- a/gfx/thebes/gfxOS2Surface.h
+++ b/gfx/thebes/gfxOS2Surface.h
@@ -12,17 +12,17 @@
 #include <os2.h>
 #include <cairo-os2.h>
 
 class gfxOS2Surface : public gfxASurface {
 
 public:
     // constructor used to create a memory surface of given size
     gfxOS2Surface(const gfxIntSize& aSize,
-                  gfxASurface::gfxImageFormat aImageFormat);
+                  gfxImageFormat aImageFormat);
     // constructor for surface connected to an onscreen window
     gfxOS2Surface(HWND aWnd);
     // constructor for surface connected to a printing device context
     gfxOS2Surface(HDC aDC, const gfxIntSize& aSize);
     virtual ~gfxOS2Surface();
 
     // Special functions that only make sense for the OS/2 port of cairo:
 
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -387,17 +387,17 @@ gfxPlatform::Init()
     rv = gfxPlatformFontList::Init();
     if (NS_FAILED(rv)) {
         NS_RUNTIMEABORT("Could not initialize gfxPlatformFontList");
     }
 #endif
 
     gPlatform->mScreenReferenceSurface =
         gPlatform->CreateOffscreenSurface(gfxIntSize(1,1),
-                                          gfxASurface::CONTENT_COLOR_ALPHA);
+                                          GFX_CONTENT_COLOR_ALPHA);
     if (!gPlatform->mScreenReferenceSurface) {
         NS_RUNTIMEABORT("Could not initialize mScreenReferenceSurface");
     }
 
     rv = gfxFontCache::Init();
     if (NS_FAILED(rv)) {
         NS_RUNTIMEABORT("Could not initialize gfxFontCache");
     }
@@ -535,27 +535,27 @@ gfxPlatform::~gfxPlatform()
 bool
 gfxPlatform::PreferMemoryOverShmem() const {
   MOZ_ASSERT(!CompositorParent::IsInCompositorThread());
   return mLayersPreferMemoryOverShmem;
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatform::CreateOffscreenImageSurface(const gfxIntSize& aSize,
-                                         gfxASurface::gfxContentType aContentType)
+                                         gfxContentType aContentType)
 {
   nsRefPtr<gfxASurface> newSurface;
   newSurface = new gfxImageSurface(aSize, OptimalFormatForContent(aContentType));
 
   return newSurface.forget();
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatform::OptimizeImage(gfxImageSurface *aSurface,
-                           gfxASurface::gfxImageFormat format)
+                           gfxImageFormat format)
 {
     const gfxIntSize& surfaceSize = aSurface->GetSize();
 
 #ifdef XP_WIN
     if (gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
         gfxWindowsPlatform::RENDER_DIRECT2D) {
         return nullptr;
     }
@@ -586,17 +586,17 @@ gfxPlatform::CreateDrawTargetForSurface(
 // around the gfxASurface. This should eventually be replaced by plumbing
 // the DrawTarget through directly
 RefPtr<DrawTarget>
 gfxPlatform::CreateDrawTargetForUpdateSurface(gfxASurface *aSurface, const IntSize& aSize)
 {
 #ifdef XP_MACOSX
   // this is a bit of a hack that assumes that the buffer associated with the CGContext
   // will live around long enough that nothing bad will happen.
-  if (aSurface->GetType() == gfxASurface::SurfaceTypeQuartz) {
+  if (aSurface->GetType() == gfxSurfaceTypeQuartz) {
     return Factory::CreateDrawTargetForCairoCGContext(static_cast<gfxQuartzSurface*>(aSurface)->GetCGContext(), aSize);
   }
 #endif
   MOZ_CRASH();
   return nullptr;
 }
 
 
@@ -653,28 +653,28 @@ gfxPlatform::GetSourceSurfaceForSurface(
     if (surf->mSrcSurface->IsValid() && surf->mBackendType == aTarget->GetType()) {
       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() == gfxASurface::CONTENT_ALPHA) {
+  if (aSurface->GetContentType() == GFX_CONTENT_ALPHA) {
     format = FORMAT_A8;
-  } else if (aSurface->GetContentType() == gfxASurface::CONTENT_COLOR) {
+  } else if (aSurface->GetContentType() == GFX_CONTENT_COLOR) {
     format = FORMAT_B8G8R8X8;
   } else {
     format = FORMAT_B8G8R8A8;
   }
 
   RefPtr<SourceSurface> srcBuffer;
 
 #ifdef XP_WIN
-  if (aSurface->GetType() == gfxASurface::SurfaceTypeD2D &&
+  if (aSurface->GetType() == gfxSurfaceTypeD2D &&
       format != FORMAT_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();
@@ -697,38 +697,38 @@ gfxPlatform::GetSourceSurfaceForSurface(
       return srcBuffer;
     }
   }
 
   if (!srcBuffer) {
     nsRefPtr<gfxImageSurface> imgSurface = aSurface->GetAsImageSurface();
 
     bool isWin32ImageSurf = imgSurface &&
-                            aSurface->GetType() == gfxASurface::SurfaceTypeWin32;
+                            aSurface->GetType() == gfxSurfaceTypeWin32;
 
     if (!imgSurface) {
       imgSurface = new gfxImageSurface(aSurface->GetSize(), OptimalFormatForContent(aSurface->GetContentType()));
       nsRefPtr<gfxContext> ctx = new gfxContext(imgSurface);
       ctx->SetSource(aSurface);
       ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
       ctx->Paint();
     }
 
     gfxImageFormat cairoFormat = imgSurface->Format();
     switch(cairoFormat) {
-      case gfxASurface::ImageFormatARGB32:
+      case gfxImageFormatARGB32:
         format = FORMAT_B8G8R8A8;
         break;
-      case gfxASurface::ImageFormatRGB24:
+      case gfxImageFormatRGB24:
         format = FORMAT_B8G8R8X8;
         break;
-      case gfxASurface::ImageFormatA8:
+      case gfxImageFormatA8:
         format = FORMAT_A8;
         break;
-      case gfxASurface::ImageFormatRGB16_565:
+      case gfxImageFormatRGB16_565:
         format = FORMAT_R5G6B5;
         break;
       default:
         NS_RUNTIMEABORT("Invalid surface format!");
     }
 
     IntSize size = IntSize(imgSurface->GetSize().width, imgSurface->GetSize().height);
     srcBuffer = aTarget->CreateSourceSurfaceFromData(imgSurface->Data(),
@@ -836,17 +836,17 @@ gfxPlatform::GetThebesSurfaceForDrawTarg
   RefPtr<SourceSurface> source = aTarget->Snapshot();
   RefPtr<DataSourceSurface> data = source->GetDataSurface();
 
   if (!data) {
     return nullptr;
   }
 
   IntSize size = data->GetSize();
-  gfxASurface::gfxImageFormat format = OptimalFormatForContent(ContentForFormat(data->GetFormat()));
+  gfxImageFormat format = OptimalFormatForContent(ContentForFormat(data->GetFormat()));
 
 
   nsRefPtr<gfxASurface> surf =
     new gfxImageSurface(data->GetData(), gfxIntSize(size.width, size.height),
                         data->Stride(), format);
 
   surf->SetData(&kDrawSourceSurface, data.forget().drop(), DataSourceSurfaceDestroy);
   // keep the draw target alive as long as we need its data
@@ -1871,54 +1871,54 @@ gfxPlatform::GetLog(eGfxLog aWhichLog)
 int
 gfxPlatform::GetScreenDepth() const
 {
     NS_WARNING("GetScreenDepth not implemented on this platform -- returning 0!");
     return 0;
 }
 
 mozilla::gfx::SurfaceFormat
-gfxPlatform::Optimal2DFormatForContent(gfxASurface::gfxContentType aContent)
+gfxPlatform::Optimal2DFormatForContent(gfxContentType aContent)
 {
   switch (aContent) {
-  case gfxASurface::CONTENT_COLOR:
+  case GFX_CONTENT_COLOR:
     switch (GetOffscreenFormat()) {
-    case gfxASurface::ImageFormatARGB32:
+    case gfxImageFormatARGB32:
       return mozilla::gfx::FORMAT_B8G8R8A8;
-    case gfxASurface::ImageFormatRGB24:
+    case gfxImageFormatRGB24:
       return mozilla::gfx::FORMAT_B8G8R8X8;
-    case gfxASurface::ImageFormatRGB16_565:
+    case gfxImageFormatRGB16_565:
       return mozilla::gfx::FORMAT_R5G6B5;
     default:
-      NS_NOTREACHED("unknown gfxImageFormat for CONTENT_COLOR");
+      NS_NOTREACHED("unknown gfxImageFormat for GFX_CONTENT_COLOR");
       return mozilla::gfx::FORMAT_B8G8R8A8;
     }
-  case gfxASurface::CONTENT_ALPHA:
+  case GFX_CONTENT_ALPHA:
     return mozilla::gfx::FORMAT_A8;
-  case gfxASurface::CONTENT_COLOR_ALPHA:
+  case GFX_CONTENT_COLOR_ALPHA:
     return mozilla::gfx::FORMAT_B8G8R8A8;
   default:
     NS_NOTREACHED("unknown gfxContentType");
     return mozilla::gfx::FORMAT_B8G8R8A8;
   }
 }
 
 gfxImageFormat
-gfxPlatform::OptimalFormatForContent(gfxASurface::gfxContentType aContent)
+gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
 {
   switch (aContent) {
-  case gfxASurface::CONTENT_COLOR:
+  case GFX_CONTENT_COLOR:
     return GetOffscreenFormat();
-  case gfxASurface::CONTENT_ALPHA:
-    return gfxASurface::ImageFormatA8;
-  case gfxASurface::CONTENT_COLOR_ALPHA:
-    return gfxASurface::ImageFormatARGB32;
+  case GFX_CONTENT_ALPHA:
+    return gfxImageFormatA8;
+  case GFX_CONTENT_COLOR_ALPHA:
+    return gfxImageFormatARGB32;
   default:
     NS_NOTREACHED("unknown gfxContentType");
-    return gfxASurface::ImageFormatARGB32;
+    return gfxImageFormatARGB32;
   }
 }
 
 void
 gfxPlatform::OrientationSyncPrefsObserverChanged()
 {
   mOrientationSyncMillis = Preferences::GetUint("layers.orientation.sync.timeout", (uint32_t)0);
 }
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -116,17 +116,17 @@ enum eGfxLog {
     eGfxLog_cmapdata         = 4
 };
 
 // when searching through pref langs, max number of pref langs
 const uint32_t kMaxLenPrefLangList = 32;
 
 #define UNINITIALIZED_VALUE  (-1)
 
-typedef gfxASurface::gfxImageFormat gfxImageFormat;
+typedef gfxImageFormat gfxImageFormat;
 
 inline const char*
 GetBackendName(mozilla::gfx::BackendType aBackend)
 {
   switch (aBackend) {
       case mozilla::gfx::BACKEND_DIRECT2D:
         return "direct2d";
       case mozilla::gfx::BACKEND_COREGRAPHICS_ACCELERATED:
@@ -163,32 +163,32 @@ public:
      */
     static void Shutdown();
 
     /**
      * Create an offscreen surface of the given dimensions
      * and image format.
      */
     virtual already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                                 gfxASurface::gfxContentType contentType) = 0;
+                                                                 gfxContentType contentType) = 0;
 
     /**
      * Create an offscreen surface of the given dimensions and image format which
      * can be converted to a gfxImageSurface without copying. If we can provide
      * a platform-hosted surface, then we will return that instead of an actual
      * gfxImageSurface.
      * Sub-classes should override this method if CreateOffscreenSurface returns a
      * surface which implements GetAsImageSurface
      */
     virtual already_AddRefed<gfxASurface>
       CreateOffscreenImageSurface(const gfxIntSize& aSize,
-                                  gfxASurface::gfxContentType aContentType);
+                                  gfxContentType aContentType);
 
     virtual already_AddRefed<gfxASurface> OptimizeImage(gfxImageSurface *aSurface,
-                                                        gfxASurface::gfxImageFormat format);
+                                                        gfxImageFormat format);
 
     /**
      * Beware that these methods may return DrawTargets which are not fully supported
      * on the current platform and might fail silently in subtle ways. This is a massive
      * potential footgun. You should only use these methods for canvas drawing really.
      * Use extreme caution if you use them for content where you are not 100% sure we
      * support the DrawTarget we get back.
      * See SupportsAzureContentForDrawTarget.
@@ -570,22 +570,22 @@ public:
     int32_t GetBidiNumeralOption();
 
     /**
      * Returns a 1x1 surface that can be used to create graphics contexts
      * for measuring text etc as if they will be rendered to the screen
      */
     gfxASurface* ScreenReferenceSurface() { return mScreenReferenceSurface; }
 
-    virtual mozilla::gfx::SurfaceFormat Optimal2DFormatForContent(gfxASurface::gfxContentType aContent);
+    virtual mozilla::gfx::SurfaceFormat Optimal2DFormatForContent(gfxContentType aContent);
 
-    virtual gfxImageFormat OptimalFormatForContent(gfxASurface::gfxContentType aContent);
+    virtual gfxImageFormat OptimalFormatForContent(gfxContentType aContent);
 
     virtual gfxImageFormat GetOffscreenFormat()
-    { return gfxASurface::ImageFormatRGB24; }
+    { return gfxImageFormatRGB24; }
 
     /**
      * Returns a logger if one is available and logging is enabled
      */
     static PRLogModuleInfo* GetLog(eGfxLog aWhichLog);
 
     bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
 
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -130,21 +130,21 @@ gfxPlatformGtk::~gfxPlatformGtk()
     // idempotent.  But it has fatal assertions that fire if stuff is
     // leaked, and we hit them.
     FcFini();
 #endif
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
-                                       gfxASurface::gfxContentType contentType)
+                                       gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface;
     bool needsClear = true;
-    gfxASurface::gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
+    gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
 #ifdef MOZ_X11
     // XXX we really need a different interface here, something that passes
     // in more context, including the display and/or target surface type that
     // we should try to match
     GdkScreen *gdkScreen = gdk_screen_get_default();
     if (gdkScreen) {
         if (UseXRender()) {
             Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen);
@@ -470,20 +470,20 @@ gfxPlatformGtk::GetDPI()
 }
 
 gfxImageFormat
 gfxPlatformGtk::GetOffscreenFormat()
 {
     // Make sure there is a screen
     GdkScreen *screen = gdk_screen_get_default();
     if (screen && gdk_visual_get_depth(gdk_visual_get_system()) == 16) {
-        return gfxASurface::ImageFormatRGB16_565;
+        return gfxImageFormatRGB16_565;
     }
 
-    return gfxASurface::ImageFormatRGB24;
+    return gfxImageFormatRGB24;
 }
 
 static int sDepth = 0;
 
 int
 gfxPlatformGtk::GetScreenDepth() const
 {
     if (!sDepth) {
@@ -745,17 +745,17 @@ gfxPlatformGtk::GetGdkDrawable(gfxASurfa
     GdkDrawable *result;
 
     result = (GdkDrawable*) cairo_surface_get_user_data (target->CairoSurface(),
                                                          &cairo_gdk_drawable_key);
     if (result)
         return result;
 
 #ifdef MOZ_X11
-    if (target->GetType() != gfxASurface::SurfaceTypeXlib)
+    if (target->GetType() != gfxSurfaceTypeXlib)
         return nullptr;
 
     gfxXlibSurface *xs = static_cast<gfxXlibSurface*>(target);
 
     // try looking it up in gdk's table
     result = (GdkDrawable*) gdk_xid_table_lookup(xs->XDrawable());
     if (result) {
         SetGdkDrawable(target, result);
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -28,17 +28,17 @@ public:
     gfxPlatformGtk();
     virtual ~gfxPlatformGtk();
 
     static gfxPlatformGtk *GetPlatform() {
         return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
     }
 
     already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxASurface::gfxContentType contentType);
+                                                         gfxContentType contentType);
 
     mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
 
     nsresult GetFontList(nsIAtom *aLangGroup,
                          const nsACString& aGenericFamily,
                          nsTArray<nsString>& aListOfFonts);
 
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -88,39 +88,39 @@ gfxPlatformMac::CreatePlatformFontList()
         return list;
     }
     gfxPlatformFontList::Shutdown();
     return nullptr;
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformMac::CreateOffscreenSurface(const gfxIntSize& size,
-                                       gfxASurface::gfxContentType contentType)
+                                       gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface =
       new gfxQuartzSurface(size, OptimalFormatForContent(contentType));
     return newSurface.forget();
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformMac::CreateOffscreenImageSurface(const gfxIntSize& aSize,
-                                            gfxASurface::gfxContentType aContentType)
+                                            gfxContentType aContentType)
 {
     nsRefPtr<gfxASurface> surface = CreateOffscreenSurface(aSize, aContentType);
 #ifdef DEBUG
     nsRefPtr<gfxImageSurface> imageSurface = surface->GetAsImageSurface();
     NS_ASSERTION(imageSurface, "Surface cannot be converted to a gfxImageSurface");
 #endif
     return surface.forget();
 }
 
 
 already_AddRefed<gfxASurface>
 gfxPlatformMac::OptimizeImage(gfxImageSurface *aSurface,
-                              gfxASurface::gfxImageFormat format)
+                              gfxImageFormat format)
 {
     const gfxIntSize& surfaceSize = aSurface->GetSize();
     nsRefPtr<gfxImageSurface> isurf = aSurface;
 
     if (format != aSurface->Format()) {
         isurf = new gfxImageSurface (surfaceSize, format);
         if (!isurf->CopyFrom (aSurface)) {
             // don't even bother doing anything more
@@ -378,18 +378,18 @@ gfxPlatformMac::CreateThebesSurfaceAlias
 {
   if (aTarget->GetType() == BACKEND_COREGRAPHICS) {
     CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT));
     unsigned char* data = (unsigned char*)CGBitmapContextGetData(cg);
     size_t bpp = CGBitmapContextGetBitsPerPixel(cg);
     size_t stride = CGBitmapContextGetBytesPerRow(cg);
     gfxIntSize size(aTarget->GetSize().width, aTarget->GetSize().height);
     nsRefPtr<gfxImageSurface> imageSurface = new gfxImageSurface(data, size, stride, bpp == 2
-                                                                                     ? gfxASurface::ImageFormatRGB16_565
-                                                                                     : gfxASurface::ImageFormatARGB32);
+                                                                                     ? gfxImageFormatRGB16_565
+                                                                                     : gfxImageFormatARGB32);
     // Here we should return a gfxQuartzImageSurface but quartz will assumes that image surfaces
     // don't change which wont create a proper alias to the draw target, therefore we have to
     // return a plain image surface.
     return imageSurface.forget();
   } else {
     return GetThebesSurfaceForDrawTarget(aTarget);
   }
 }
@@ -397,19 +397,19 @@ gfxPlatformMac::CreateThebesSurfaceAlias
 already_AddRefed<gfxASurface>
 gfxPlatformMac::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
 {
   if (aTarget->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
     RefPtr<SourceSurface> source = aTarget->Snapshot();
     RefPtr<DataSourceSurface> sourceData = source->GetDataSurface();
     unsigned char* data = sourceData->GetData();
     nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(data, ThebesIntSize(sourceData->GetSize()), sourceData->Stride(),
-                                                         gfxImageSurface::ImageFormatARGB32);
+                                                         gfxImageFormatARGB32);
     // We could fix this by telling gfxImageSurface it owns data.
-    nsRefPtr<gfxImageSurface> cpy = new gfxImageSurface(ThebesIntSize(sourceData->GetSize()), gfxImageSurface::ImageFormatARGB32);
+    nsRefPtr<gfxImageSurface> cpy = new gfxImageSurface(ThebesIntSize(sourceData->GetSize()), gfxImageFormatARGB32);
     cpy->CopyFrom(surf);
     return cpy.forget();
   } else if (aTarget->GetType() == BACKEND_COREGRAPHICS) {
     CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT));
 
     //XXX: it would be nice to have an implicit conversion from IntSize to gfxIntSize
     IntSize intSize = aTarget->GetSize();
     gfxIntSize size(intSize.width, intSize.height);
--- a/gfx/thebes/gfxPlatformMac.h
+++ b/gfx/thebes/gfxPlatformMac.h
@@ -24,23 +24,23 @@ public:
     gfxPlatformMac();
     virtual ~gfxPlatformMac();
 
     static gfxPlatformMac *GetPlatform() {
         return (gfxPlatformMac*) gfxPlatform::GetPlatform();
     }
 
     already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxASurface::gfxContentType contentType);
+                                                         gfxContentType contentType);
     virtual already_AddRefed<gfxASurface>
       CreateOffscreenImageSurface(const gfxIntSize& aSize,
-                                  gfxASurface::gfxContentType aContentType);
+                                  gfxContentType aContentType);
 
     already_AddRefed<gfxASurface> OptimizeImage(gfxImageSurface *aSurface,
-                                                gfxASurface::gfxImageFormat format);
+                                                gfxImageFormat format);
 
     mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
 
     nsresult ResolveFontName(const nsAString& aFontName,
                              FontResolverCallback aCallback,
                              void *aClosure, bool& aAborted);
 
--- a/gfx/thebes/gfxQtPlatform.cpp
+++ b/gfx/thebes/gfxQtPlatform.cpp
@@ -68,17 +68,17 @@ static QPaintEngine::Type sDefaultQtPain
 gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nullptr;
 static cairo_user_data_key_t cairo_qt_pixmap_key;
 static void do_qt_pixmap_unref (void *data)
 {
     QPixmap *pmap = (QPixmap*)data;
     delete pmap;
 }
 
-static gfxImageFormat sOffscreenFormat = gfxASurface::ImageFormatRGB24;
+static gfxImageFormat sOffscreenFormat = gfxImageFormatRGB24;
 
 #ifndef MOZ_PANGO
 typedef nsDataHashtable<nsStringHashKey, nsRefPtr<FontFamily> > FontTable;
 typedef nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<FontEntry> > > PrefFontTable;
 static FontTable *gPlatformFonts = nullptr;
 static FontTable *gPlatformFontAliases = nullptr;
 static PrefFontTable *gPrefFonts = nullptr;
 static gfxSparseBitSet *gCodepointsWithNoFonts = nullptr;
@@ -129,17 +129,17 @@ gfxQtPlatform::gfxQtPlatform()
         default:
             mRenderMode = RENDER_QPAINTER;
     }
 
     // Qt doesn't provide a public API to detect the graphicssystem type. We hack
     // around this by checking what type of graphicssystem a test QPixmap uses.
     QPixmap pixmap(1, 1);
     if (pixmap.depth() == 16) {
-        sOffscreenFormat = gfxASurface::ImageFormatRGB16_565;
+        sOffscreenFormat = gfxImageFormatRGB16_565;
     }
     mScreenDepth = pixmap.depth();
 #if (QT_VERSION < QT_VERSION_CHECK(4,8,0))
     if (pixmap.paintEngine())
         sDefaultQtPaintEngineType = pixmap.paintEngine()->type();
 #endif
 }
 
@@ -206,21 +206,21 @@ gfxQtPlatform::GetXScreen(QWidget* aWind
                            nativeResourceForWindow("screen",
                              aWindow ? aWindow->windowHandle() : nullptr));
 #endif
 }
 #endif
 
 already_AddRefed<gfxASurface>
 gfxQtPlatform::CreateOffscreenSurface(const gfxIntSize& size,
-                                      gfxASurface::gfxContentType contentType)
+                                      gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> newSurface = nullptr;
 
-    gfxASurface::gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
+    gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
 
 #ifdef CAIRO_HAS_QT_SURFACE
     if (mRenderMode == RENDER_QPAINTER) {
       newSurface = new gfxQPainterSurface(size, imageFormat);
       return newSurface.forget();
     }
 #endif
 
--- a/gfx/thebes/gfxQtPlatform.h
+++ b/gfx/thebes/gfxQtPlatform.h
@@ -40,17 +40,17 @@ public:
     gfxQtPlatform();
     virtual ~gfxQtPlatform();
 
     static gfxQtPlatform *GetPlatform() {
         return (gfxQtPlatform*) gfxPlatform::GetPlatform();
     }
 
     already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxASurface::gfxContentType contentType);
+                                                         gfxContentType contentType);
 
     nsresult GetFontList(nsIAtom *aLangGroup,
                          const nsACString& aGenericFamily,
                          nsTArray<nsString>& aListOfFonts);
 
     nsresult UpdateFontList();
 
     nsresult ResolveFontName(const nsAString& aFontName,
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -65,19 +65,19 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
     nsRefPtr<gfxASurface> surf = mContext->CurrentSurface(&deviceOffset.x, &deviceOffset.y);
     if (!surf || surf->CairoStatus())
         return nullptr;
 
     // if this is a native Quartz surface, we don't have to redirect
     // rendering to our own CGContextRef; in most cases, we are able to
     // use the CGContextRef from the surface directly.  we can extend
     // this to support offscreen drawing fairly easily in the future.
-    if (surf->GetType() == gfxASurface::SurfaceTypeQuartz &&
-        (surf->GetContentType() == gfxASurface::CONTENT_COLOR ||
-         (surf->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA))) {
+    if (surf->GetType() == gfxSurfaceTypeQuartz &&
+        (surf->GetContentType() == GFX_CONTENT_COLOR ||
+         (surf->GetContentType() == GFX_CONTENT_COLOR_ALPHA))) {
         mQuartzSurface = static_cast<gfxQuartzSurface*>(surf.get());
         mSurfaceContext = mContext;
 
         // grab the CGContextRef
         mCGContext = cairo_quartz_get_cg_context_with_clip(mSurfaceContext->GetCairo());
         if (!mCGContext)
             return nullptr;
 
@@ -104,17 +104,17 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
                                                              x0, y0));
 
         // bug 382049 - need to explicity set the composite operation to sourceOver
         CGContextSetCompositeOperation(mCGContext, kPrivateCGCompositeSourceOver);
     } else {
         nsIntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
                               NSToIntFloor(mNativeRect.height * mBackingScale));
         mQuartzSurface = new gfxQuartzSurface(backingSize,
-                                              gfxASurface::ImageFormatARGB32);
+                                              gfxImageFormatARGB32);
         if (mQuartzSurface->CairoStatus())
             return nullptr;
         mSurfaceContext = new gfxContext(mQuartzSurface);
 
         // grab the CGContextRef
         mCGContext = cairo_quartz_get_cg_context_with_clip(mSurfaceContext->GetCairo());
         CGContextScaleCTM(mCGContext, mBackingScale, mBackingScale);
         CGContextTranslateCTM(mCGContext, -mNativeRect.X(), -mNativeRect.Y());
--- a/gfx/thebes/gfxReusableImageSurfaceWrapper.cpp
+++ b/gfx/thebes/gfxReusableImageSurfaceWrapper.cpp
@@ -48,14 +48,14 @@ gfxReusableImageSurfaceWrapper::GetWrita
 }
 
 const unsigned char*
 gfxReusableImageSurfaceWrapper::GetReadOnlyData() const
 {
   return mSurface->Data();
 }
 
-gfxASurface::gfxImageFormat
+gfxImageFormat
 gfxReusableImageSurfaceWrapper::Format()
 {
   return mSurface->Format();
 }
 
--- a/gfx/thebes/gfxReusableImageSurfaceWrapper.h
+++ b/gfx/thebes/gfxReusableImageSurfaceWrapper.h
@@ -14,17 +14,17 @@ class gfxImageSurface;
  * on gfxImageSurface.
  */
 class gfxReusableImageSurfaceWrapper : public gfxReusableSurfaceWrapper {
 public:
   gfxReusableImageSurfaceWrapper(gfxImageSurface* aSurface);
   ~gfxReusableImageSurfaceWrapper();
 
   const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE;
-  gfxASurface::gfxImageFormat Format() MOZ_OVERRIDE;
+  gfxImageFormat Format() MOZ_OVERRIDE;
   gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE;
   void ReadLock() MOZ_OVERRIDE;
   void ReadUnlock() MOZ_OVERRIDE;
 
   Type GetType()
   {
     return TYPE_IMAGE;
   }
--- a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp
+++ b/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.cpp
@@ -70,17 +70,17 @@ gfxReusableSharedImageSurfaceWrapper::Ge
 
 const unsigned char*
 gfxReusableSharedImageSurfaceWrapper::GetReadOnlyData() const
 {
   NS_ABORT_IF_FALSE(mSurface->GetReadCount() > 0, "Should have read lock");
   return mSurface->Data();
 }
 
-gfxASurface::gfxImageFormat
+gfxImageFormat
 gfxReusableSharedImageSurfaceWrapper::Format()
 {
   return mSurface->Format();
 }
 
 Shmem&
 gfxReusableSharedImageSurfaceWrapper::GetShmem()
 {
--- a/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h
+++ b/gfx/thebes/gfxReusableSharedImageSurfaceWrapper.h
@@ -16,17 +16,17 @@ class gfxSharedImageSurface;
  */
 class gfxReusableSharedImageSurfaceWrapper : public gfxReusableSurfaceWrapper {
 public:
   gfxReusableSharedImageSurfaceWrapper(mozilla::layers::ISurfaceAllocator* aAllocator,
                                        gfxSharedImageSurface* aSurface);
   ~gfxReusableSharedImageSurfaceWrapper();
 
   const unsigned char* GetReadOnlyData() const MOZ_OVERRIDE;
-  gfxASurface::gfxImageFormat Format() MOZ_OVERRIDE;
+  gfxImageFormat Format() MOZ_OVERRIDE;
   gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) MOZ_OVERRIDE;
   void ReadLock() MOZ_OVERRIDE;
   void ReadUnlock() MOZ_OVERRIDE;
 
   Type GetType()
   {
     return TYPE_SHARED_IMAGE;
   }
--- a/gfx/thebes/gfxReusableSurfaceWrapper.h
+++ b/gfx/thebes/gfxReusableSurfaceWrapper.h
@@ -38,17 +38,17 @@ public:
   /**
    * Returns a read-only pointer to the image data.
    */
   virtual const unsigned char* GetReadOnlyData() const = 0;
 
   /**
    * Returns the image surface format.
    */
-  virtual gfxASurface::gfxImageFormat Format() = 0;
+  virtual gfxImageFormat Format() = 0;
 
   /**
    * Returns a writable copy of the image.
    * If necessary this will copy the wrapper. If there are no contention
    * the same wrapper will be returned. A ReadLock must be held when
    * calling this function, and calling it will give up this lock.
    */
   virtual gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface) = 0;
--- a/gfx/thebes/gfxSharedImageSurface.h
+++ b/gfx/thebes/gfxSharedImageSurface.h
@@ -10,15 +10,15 @@
 #include "gfxBaseSharedMemorySurface.h"
 
 class gfxSharedImageSurface : public gfxBaseSharedMemorySurface<gfxImageSurface, gfxSharedImageSurface>
 {
   typedef gfxBaseSharedMemorySurface<gfxImageSurface, gfxSharedImageSurface> Super;
   friend class gfxBaseSharedMemorySurface<gfxImageSurface, gfxSharedImageSurface>;
 private:
     gfxSharedImageSurface(const gfxIntSize& aSize, long aStride, 
-                          gfxASurface::gfxImageFormat aFormat, 
+                          gfxImageFormat aFormat, 
                           const mozilla::ipc::Shmem& aShmem)
       : Super(aSize, aStride, aFormat, aShmem)
     {}
 };
 
 #endif /* GFX_SHARED_IMAGESURFACE_H */
--- a/gfx/thebes/gfxSharedQuartzSurface.h
+++ b/gfx/thebes/gfxSharedQuartzSurface.h
@@ -11,15 +11,15 @@
 #include "gfxQuartzSurface.h"
 
 class gfxSharedQuartzSurface : public gfxBaseSharedMemorySurface<gfxQuartzSurface, gfxSharedQuartzSurface>
 {
   typedef gfxBaseSharedMemorySurface<gfxQuartzSurface, gfxSharedQuartzSurface> Super;
   friend class gfxBaseSharedMemorySurface<gfxQuartzSurface, gfxSharedQuartzSurface>;
 private:
     gfxSharedQuartzSurface(const gfxIntSize& aSize, long aStride, 
-                           gfxASurface::gfxImageFormat aFormat, 
+                           gfxImageFormat aFormat, 
                            const mozilla::ipc::Shmem& aShmem)
       : Super(aSize, aStride, aFormat, aShmem)
     {}
 };
 
 #endif /* GFX_SHARED_QUARTZSURFACE_H */
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -42,17 +42,17 @@ gfxUtils::PremultiplyImageSurface(gfxIma
                aSourceSurface->Height() == aDestSurface->Height() &&
                aSourceSurface->Stride() == aDestSurface->Stride(),
                "Source and destination surfaces don't have identical characteristics");
 
     MOZ_ASSERT(aSourceSurface->Stride() == aSourceSurface->Width() * 4,
                "Source surface stride isn't tightly packed");
 
     // Only premultiply ARGB32
-    if (aSourceSurface->Format() != gfxASurface::ImageFormatARGB32) {
+    if (aSourceSurface->Format() != gfxImageFormatARGB32) {
         if (aDestSurface != aSourceSurface) {
             memcpy(aDestSurface->Data(), aSourceSurface->Data(),
                    aSourceSurface->Stride() * aSourceSurface->Height());
         }
         return;
     }
 
     uint8_t *src = aSourceSurface->Data();
@@ -96,17 +96,17 @@ gfxUtils::UnpremultiplyImageSurface(gfxI
                aSourceSurface->Height() == aDestSurface->Height() &&
                aSourceSurface->Stride() == aDestSurface->Stride(),
                "Source and destination surfaces don't have identical characteristics");
 
     MOZ_ASSERT(aSourceSurface->Stride() == aSourceSurface->Width() * 4,
                "Source surface stride isn't tightly packed");
 
     // Only premultiply ARGB32
-    if (aSourceSurface->Format() != gfxASurface::ImageFormatARGB32) {
+    if (aSourceSurface->Format() != gfxImageFormatARGB32) {
         if (aDestSurface != aSourceSurface) {
             memcpy(aDestSurface->Data(), aSourceSurface->Data(),
                    aSourceSurface->Stride() * aSourceSurface->Height());
         }
         return;
     }
 
     uint8_t *src = aSourceSurface->Data();
@@ -148,17 +148,17 @@ gfxUtils::ConvertBGRAtoRGBA(gfxImageSurf
                aSourceSurface->Width()  == aDestSurface->Width() &&
                aSourceSurface->Height() == aDestSurface->Height() &&
                aSourceSurface->Stride() == aDestSurface->Stride(),
                "Source and destination surfaces don't have identical characteristics");
 
     MOZ_ASSERT(aSourceSurface->Stride() == aSourceSurface->Width() * 4,
                "Source surface stride isn't tightly packed");
 
-    MOZ_ASSERT(aSourceSurface->Format() == gfxASurface::ImageFormatARGB32 || aSourceSurface->Format() == gfxASurface::ImageFormatRGB24,
+    MOZ_ASSERT(aSourceSurface->Format() == gfxImageFormatARGB32 || aSourceSurface->Format() == gfxImageFormatRGB24,
                "Surfaces must be ARGB32 or RGB24");
 
     uint8_t *src = aSourceSurface->Data();
     uint8_t *dst = aDestSurface->Data();
 
     uint32_t dim = aSourceSurface->Width() * aSourceSurface->Height();
     uint8_t *srcEnd = src + 4*dim;
 
@@ -214,17 +214,17 @@ OptimalFillOperator()
 // EXTEND_PAD won't help us here; we have to create a temporary surface to hold
 // the subimage of pixels we're allowed to sample.
 static already_AddRefed<gfxDrawable>
 CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable,
                                  gfxContext* aContext,
                                  const gfxMatrix& aUserSpaceToImageSpace,
                                  const gfxRect& aSourceRect,
                                  const gfxRect& aSubimage,
-                                 const gfxImageSurface::gfxImageFormat aFormat)
+                                 const gfxImageFormat aFormat)
 {
     PROFILER_LABEL("gfxUtils", "CreateSamplingRestricedDrawable");
     gfxRect userSpaceClipExtents = aContext->GetClipExtents();
     // This isn't optimal --- if aContext has a rotation then GetClipExtents
     // will have to do a bounding-box computation, and TransformBounds might
     // too, so we could get a better result if we computed image space clip
     // extents in one go --- but it doesn't really matter and this is easier
     // to understand.
@@ -275,17 +275,17 @@ struct MOZ_STACK_CLASS AutoCairoPixmanBu
 {
     AutoCairoPixmanBugWorkaround(gfxContext*      aContext,
                                  const gfxMatrix& aDeviceSpaceToImageSpace,
                                  const gfxRect&   aFill,
                                  const gfxASurface* aSurface)
      : mContext(aContext), mSucceeded(true), mPushedGroup(false)
     {
         // Quartz's limits for matrix are much larger than pixman
-        if (!aSurface || aSurface->GetType() == gfxASurface::SurfaceTypeQuartz)
+        if (!aSurface || aSurface->GetType() == gfxSurfaceTypeQuartz)
             return;
 
         if (!IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.xx) ||
             !IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.xy) ||
             !IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.yx) ||
             !IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.yy)) {
             NS_WARNING("Scaling up too much, bailing out");
             mSucceeded = false;
@@ -304,17 +304,17 @@ struct MOZ_STACK_CLASS AutoCairoPixmanBu
         // Clip the rounded-out-to-device-pixels bounds of the
         // transformed fill area. This is the area for the group we
         // want to push.
         mContext->IdentityMatrix();
         gfxRect bounds = currentMatrix.TransformBounds(aFill);
         bounds.RoundOut();
         mContext->Clip(bounds);
         mContext->SetMatrix(currentMatrix);
-        mContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
+        mContext->PushGroup(GFX_CONTENT_COLOR_ALPHA);
         mContext->SetOperator(gfxContext::OPERATOR_OVER);
 
         mPushedGroup = true;
     }
 
     ~AutoCairoPixmanBugWorkaround()
     {
         if (mPushedGroup) {
@@ -416,17 +416,17 @@ static gfxPattern::GraphicsFilter Reduce
 /* static */ void
 gfxUtils::DrawPixelSnapped(gfxContext*      aContext,
                            gfxDrawable*     aDrawable,
                            const gfxMatrix& aUserSpaceToImageSpace,
                            const gfxRect&   aSubimage,
                            const gfxRect&   aSourceRect,
                            const gfxRect&   aImageRect,
                            const gfxRect&   aFill,
-                           const gfxImageSurface::gfxImageFormat aFormat,
+                           const gfxImageFormat aFormat,
                            gfxPattern::GraphicsFilter aFilter,
                            uint32_t         aImageFlags)
 {
     PROFILER_LABEL("gfxUtils", "DrawPixelSnapped");
     bool doTile = !aImageRect.Contains(aSourceRect) &&
                   !(aImageFlags & imgIContainer::FLAG_CLAMP);
 
     nsRefPtr<gfxASurface> currentTarget = aContext->CurrentSurface();
@@ -478,34 +478,34 @@ gfxUtils::DrawPixelSnapped(gfxContext*  
         // filled a surface with the tiled pattern; this surface can now be
         // drawn without tiling.
         doTile = false;
     }
 #endif
 
     gfxContext::GraphicsOperator op = aContext->CurrentOperator();
     if ((op == gfxContext::OPERATOR_OVER || workaround.PushedGroup()) &&
-        aFormat == gfxASurface::ImageFormatRGB24) {
+        aFormat == gfxImageFormatRGB24) {
         aContext->SetOperator(OptimalFillOperator());
     }
 
     drawable->Draw(aContext, aFill, doTile, aFilter, userSpaceToImageSpace);
 
     aContext->SetOperator(op);
 }
 
 /* static */ int
-gfxUtils::ImageFormatToDepth(gfxASurface::gfxImageFormat aFormat)
+gfxUtils::ImageFormatToDepth(gfxImageFormat aFormat)
 {
     switch (aFormat) {
-        case gfxASurface::ImageFormatARGB32:
+        case gfxImageFormatARGB32:
             return 32;
-        case gfxASurface::ImageFormatRGB24:
+        case gfxImageFormatRGB24:
             return 24;
-        case gfxASurface::ImageFormatRGB16_565:
+        case gfxImageFormatRGB16_565:
             return 16;
         default:
             break;
     }
     return 0;
 }
 
 static void
@@ -686,31 +686,31 @@ gfxUtils::GfxRectToIntRect(const gfxRect
 {
   *aOut = nsIntRect(int32_t(aIn.X()), int32_t(aIn.Y()),
   int32_t(aIn.Width()), int32_t(aIn.Height()));
   return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height).IsEqualEdges(aIn);
 }
 
 void
 gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrImage::Data& aData,
-                                         gfxASurface::gfxImageFormat& aSuggestedFormat,
+                                         gfxImageFormat& aSuggestedFormat,
                                          gfxIntSize& aSuggestedSize)
 {
   gfx::YUVType yuvtype =
     gfx::TypeFromSize(aData.mYSize.width,
                       aData.mYSize.height,
                       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 == gfxASurface::ImageFormatRGB16_565) {
+  if (aSuggestedFormat == gfxImageFormatRGB16_565) {
 #if defined(HAVE_YCBCR_TO_RGB565)
     if (prescale &&
         !gfx::IsScaleYCbCrToRGB565Fast(aData.mPicX,
                                        aData.mPicY,
                                        aData.mPicSize.width,
                                        aData.mPicSize.height,
                                        aSuggestedSize.width,
                                        aSuggestedSize.height,
@@ -720,37 +720,37 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize
                                         aData.mPicY,
                                         aData.mPicSize.width,
                                         aData.mPicSize.height,
                                         yuvtype)) {
       prescale = false;
     }
 #else
     // yuv2rgb16 function not available
-    aSuggestedFormat = gfxASurface::ImageFormatRGB24;
+    aSuggestedFormat = gfxImageFormatRGB24;
 #endif
   }
-  else if (aSuggestedFormat != gfxASurface::ImageFormatRGB24) {
+  else if (aSuggestedFormat != gfxImageFormatRGB24) {
     // No other formats are currently supported.
-    aSuggestedFormat = gfxASurface::ImageFormatRGB24;
+    aSuggestedFormat = gfxImageFormatRGB24;
   }
-  if (aSuggestedFormat == gfxASurface::ImageFormatRGB24) {
+  if (aSuggestedFormat == gfxImageFormatRGB24) {
     /* 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 == gfx::YV24)
       prescale = false;
   }
   if (!prescale) {
     aSuggestedSize = aData.mPicSize;
   }
 }
 
 void
 gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrImage::Data& aData,
-                            const gfxASurface::gfxImageFormat& aDestFormat,
+                            const gfxImageFormat& aDestFormat,
                             const gfxIntSize& aDestSize,
                             unsigned char* aDestBuffer,
                             int32_t aStride)
 {
   // ConvertYCbCrToRGB et al. assume the chroma planes are rounded up if the
   // luma plane is odd sized.
   MOZ_ASSERT((aData.mCbCrSize.width == aData.mYSize.width ||
               aData.mCbCrSize.width == (aData.mYSize.width + 1) >> 1) &&
@@ -760,17 +760,17 @@ gfxUtils::ConvertYCbCrToRGB(const Planar
     gfx::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 == gfxASurface::ImageFormatRGB16_565) {
+    if (aDestFormat == gfxImageFormatRGB16_565) {
       gfx::ScaleYCbCrToRGB565(aData.mYChannel,
                               aData.mCbChannel,
                               aData.mCrChannel,
                               aDestBuffer,
                               aData.mPicX,
                               aData.mPicY,
                               aData.mPicSize.width,
                               aData.mPicSize.height,
@@ -794,30 +794,30 @@ gfxUtils::ConvertYCbCrToRGB(const Planar
                              aData.mYStride,
                              aData.mCbCrStride,
                              aStride,
                              yuvtype,
                              gfx::ROTATE_0,
                              gfx::FILTER_BILINEAR);
   } else { // no prescale
 #if defined(HAVE_YCBCR_TO_RGB565)
-    if (aDestFormat == gfxASurface::ImageFormatRGB16_565) {
+    if (aDestFormat == gfxImageFormatRGB16_565) {
       gfx::ConvertYCbCrToRGB565(aData.mYChannel,
                                 aData.mCbChannel,
                                 aData.mCrChannel,
                                 aDestBuffer,
                                 aData.mPicX,
                                 aData.mPicY,
                                 aData.mPicSize.width,
                                 aData.mPicSize.height,
                                 aData.mYStride,
                                 aData.mCbCrStride,
                                 aStride,
                                 yuvtype);
-    } else // aDestFormat != gfxASurface::ImageFormatRGB16_565
+    } else // aDestFormat != gfxImageFormatRGB16_565
 #endif
       gfx::ConvertYCbCrToRGB32(aData.mYChannel,
                                aData.mCbChannel,
                                aData.mCrChannel,
                                aDestBuffer,
                                aData.mPicX,
                                aData.mPicY,
                                aData.mPicSize.width,
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -21,17 +21,17 @@ class gfxUtils {
 public:
     /*
      * Premultiply or Unpremultiply aSourceSurface, writing the result
      * to aDestSurface or back into aSourceSurface if aDestSurface is null.
      *
      * If aDestSurface is given, it must have identical format, dimensions, and
      * stride as the source.
      *
-     * If the source is not ImageFormatARGB32, no operation is performed.  If
+     * If the source is not gfxImageFormatARGB32, no operation is performed.  If
      * aDestSurface is given, the data is copied over.
      */
     static void PremultiplyImageSurface(gfxImageSurface *aSourceSurface,
                                         gfxImageSurface *aDestSurface = nullptr);
     static void UnpremultiplyImageSurface(gfxImageSurface *aSurface,
                                           gfxImageSurface *aDestSurface = nullptr);
 
     static void ConvertBGRAtoRGBA(gfxImageSurface *aSourceSurface,
@@ -52,17 +52,17 @@ public:
      */
     static void DrawPixelSnapped(gfxContext*      aContext,
                                  gfxDrawable*     aDrawable,
                                  const gfxMatrix& aUserSpaceToImageSpace,
                                  const gfxRect&   aSubimage,
                                  const gfxRect&   aSourceRect,
                                  const gfxRect&   aImageRect,
                                  const gfxRect&   aFill,
-                                 const gfxImageSurface::gfxImageFormat aFormat,
+                                 const gfxImageFormat aFormat,
                                  gfxPattern::GraphicsFilter aFilter,
                                  uint32_t         aImageFlags = imgIContainer::FLAG_NONE);
 
     /**
      * Clip aContext to the region aRegion.
      */
     static void ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion);
 
@@ -89,17 +89,17 @@ public:
     /**
      * Create a path consisting of rectangles in |aRegion|, snapping the rectangles.
      */
     static void PathFromRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion);
 
     /*
      * Convert image format to depth value
      */
-    static int ImageFormatToDepth(gfxASurface::gfxImageFormat aFormat);
+    static int ImageFormatToDepth(gfxImageFormat aFormat);
 
     /**
      * Return the transform matrix that maps aFrom to the rectangle defined by
      * aToTopLeft/aToTopRight/aToBottomRight. aFrom must be
      * nonempty and the destination rectangle must be axis-aligned.
      */
     static gfxMatrix TransformRectToRect(const gfxRect& aFrom,
                                          const gfxPoint& aToTopLeft,
@@ -117,35 +117,35 @@ public:
      * Return the smallest power of kScaleResolution (2) greater than or equal to
      * aVal.
      */
     static gfxFloat ClampToScaleFactor(gfxFloat aVal);
 
     /**
      * Helper function for ConvertYCbCrToRGB that finds the
      * RGB buffer size and format for given YCbCrImage.
-     * @param aSuggestedFormat will be set to ImageFormatRGB24
+     * @param aSuggestedFormat will be set to gfxImageFormatRGB24
      *   if the desired format is not supported.
      * @param aSuggestedSize will be set to the picture size from aData
      *   if either the suggested size was {0,0}
      *   or simultaneous scaling and conversion is not supported.
      */
     static void
     GetYCbCrToRGBDestFormatAndSize(const mozilla::layers::PlanarYCbCrImage::Data& aData,
-                                   gfxASurface::gfxImageFormat& aSuggestedFormat,
+                                   gfxImageFormat& aSuggestedFormat,
                                    gfxIntSize& aSuggestedSize);
 
     /**
      * Convert YCbCrImage into RGB aDestBuffer
      * Format and Size parameters must have
      *   been passed to GetYCbCrToRGBDestFormatAndSize
      */
     static void
     ConvertYCbCrToRGB(const mozilla::layers::PlanarYCbCrImage::Data& aData,
-                      const gfxASurface::gfxImageFormat& aDestFormat,
+                      const gfxImageFormat& aDestFormat,
                       const gfxIntSize& aDestSize,
                       unsigned char* aDestBuffer,
                       int32_t aStride);
 
     static const uint8_t sUnpremultiplyTable[256*256];
     static const uint8_t sPremultiplyTable[256*256];
 #ifdef MOZ_DUMP_PAINTING
     /**
--- a/gfx/thebes/gfxWindowsNativeDrawing.cpp
+++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp
@@ -54,20 +54,20 @@ gfxWindowsNativeDrawing::BeginNativeDraw
             mTransformType = COMPLEX;
         else
             mTransformType = AXIS_ALIGNED_SCALE;
 
         // if this is a native win32 surface, we don't have to
         // redirect rendering to our own HDC; in some cases,
         // we may be able to use the HDC from the surface directly.
         if (surf &&
-            ((surf->GetType() == gfxASurface::SurfaceTypeWin32 ||
-              surf->GetType() == gfxASurface::SurfaceTypeWin32Printing) &&
-              (surf->GetContentType() == gfxASurface::CONTENT_COLOR ||
-               (surf->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA &&
+            ((surf->GetType() == gfxSurfaceTypeWin32 ||
+              surf->GetType() == gfxSurfaceTypeWin32Printing) &&
+              (surf->GetContentType() == GFX_CONTENT_COLOR ||
+               (surf->GetContentType() == GFX_CONTENT_COLOR_ALPHA &&
                (mNativeDrawFlags & CAN_DRAW_TO_COLOR_ALPHA)))))
         {
             // grab the DC. This can fail if there is a complex clipping path,
             // in which case we'll have to fall back.
             mWinSurface = static_cast<gfxWindowsSurface*>(static_cast<gfxASurface*>(surf.get()));
             mDC = mWinSurface->GetDCWithClip(mContext);
 
             if (mDC) {
@@ -187,22 +187,22 @@ gfxWindowsNativeDrawing::IsDoublePass()
         (mContext->GetDrawTarget()->GetType() != mozilla::gfx::BACKEND_CAIRO ||
          mContext->GetDrawTarget()->IsDualDrawTarget())) {
       return true;
     }
 
     nsRefPtr<gfxASurface> surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y);
     if (!surf || surf->CairoStatus())
         return false;
-    if (surf->GetType() != gfxASurface::SurfaceTypeWin32 &&
-        surf->GetType() != gfxASurface::SurfaceTypeWin32Printing) {
+    if (surf->GetType() != gfxSurfaceTypeWin32 &&
+        surf->GetType() != gfxSurfaceTypeWin32Printing) {
 	return true;
     }
-    if ((surf->GetContentType() != gfxASurface::CONTENT_COLOR ||
-         (surf->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA &&
+    if ((surf->GetContentType() != GFX_CONTENT_COLOR ||
+         (surf->GetContentType() == GFX_CONTENT_COLOR_ALPHA &&
           !(mNativeDrawFlags & CAN_DRAW_TO_COLOR_ALPHA))))
         return true;
     return false;
 }
 
 bool
 gfxWindowsNativeDrawing::ShouldRenderAgain()
 {
@@ -264,17 +264,17 @@ gfxWindowsNativeDrawing::PaintToContext(
         nsRefPtr<gfxImageSurface> white = mWhiteSurface->GetAsImageSurface();
         if (!gfxAlphaRecovery::RecoverAlpha(black, white)) {
             NS_ERROR("Alpha recovery failure");
             return;
         }
         nsRefPtr<gfxImageSurface> alphaSurface =
             new gfxImageSurface(black->Data(), black->GetSize(),
                                 black->Stride(),
-                                gfxASurface::ImageFormatARGB32);
+                                gfxImageFormatARGB32);
 
         mContext->Save();
         mContext->Translate(mNativeRect.TopLeft());
         mContext->NewPath();
         mContext->Rectangle(gfxRect(gfxPoint(0.0, 0.0), mNativeRect.Size()));
 
         nsRefPtr<gfxPattern> pat = new gfxPattern(alphaSurface);
 
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -671,17 +671,17 @@ gfxWindowsPlatform::CreatePlatformFontLi
     }
 
     gfxPlatformFontList::Shutdown();
     return nullptr;
 }
 
 already_AddRefed<gfxASurface>
 gfxWindowsPlatform::CreateOffscreenSurface(const gfxIntSize& size,
-                                           gfxASurface::gfxContentType contentType)
+                                           gfxContentType contentType)
 {
     nsRefPtr<gfxASurface> surf = nullptr;
 
 #ifdef CAIRO_HAS_WIN32_SURFACE
     if (mRenderMode == RENDER_GDI)
         surf = new gfxWindowsSurface(size, OptimalFormatForContent(contentType));
 #endif
 
@@ -694,17 +694,17 @@ gfxWindowsPlatform::CreateOffscreenSurfa
         surf = new gfxImageSurface(size, OptimalFormatForContent(contentType));
     }
 
     return surf.forget();
 }
 
 already_AddRefed<gfxASurface>
 gfxWindowsPlatform::CreateOffscreenImageSurface(const gfxIntSize& aSize,
-                                                gfxASurface::gfxContentType aContentType)
+                                                gfxContentType aContentType)
 {
 #ifdef CAIRO_HAS_D2D_SURFACE
     if (mRenderMode == RENDER_DIRECT2D) {
         nsRefPtr<gfxASurface> surface =
           new gfxImageSurface(aSize, OptimalFormatForContent(aContentType));
         return surface.forget();
     }
 #endif
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -57,18 +57,18 @@ class nsIMemoryReporter;
 // Utility to get a Windows HDC from a thebes context,
 // used by both GDI and Uniscribe font shapers
 struct DCFromContext {
     DCFromContext(gfxContext *aContext) {
         dc = nullptr;
         nsRefPtr<gfxASurface> aSurface = aContext->CurrentSurface();
         NS_ASSERTION(aSurface || !aContext->IsCairo(), "DCFromContext: null surface");
         if (aSurface &&
-            (aSurface->GetType() == gfxASurface::SurfaceTypeWin32 ||
-             aSurface->GetType() == gfxASurface::SurfaceTypeWin32Printing))
+            (aSurface->GetType() == gfxSurfaceTypeWin32 ||
+             aSurface->GetType() == gfxSurfaceTypeWin32Printing))
         {
             dc = static_cast<gfxWindowsSurface*>(aSurface.get())->GetDC();
             needsRelease = false;
             SaveDC(dc);
             cairo_scaled_font_t* scaled =
                 cairo_get_scaled_font(aContext->GetCairo());
             cairo_win32_scaled_font_select_font(scaled, dc);
         }
@@ -121,20 +121,20 @@ public:
     virtual ~gfxWindowsPlatform();
     static gfxWindowsPlatform *GetPlatform() {
         return (gfxWindowsPlatform*) gfxPlatform::GetPlatform();
     }
 
     virtual gfxPlatformFontList* CreatePlatformFontList();
 
     already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
-                                                         gfxASurface::gfxContentType contentType);
+                                                         gfxContentType contentType);
     virtual already_AddRefed<gfxASurface>
       CreateOffscreenImageSurface(const gfxIntSize& aSize,
-                                  gfxASurface::gfxContentType aContentType);
+                                  gfxContentType aContentType);
 
     virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
     virtual already_AddRefed<gfxASurface>
       GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget);
 
     enum RenderMode {
         /* Use GDI and windows surfaces */
--- a/gfx/thebes/gfxWindowsSurface.cpp
+++ b/gfx/thebes/gfxWindowsSurface.cpp
@@ -77,17 +77,17 @@ gfxWindowsSurface::gfxWindowsSurface(HDC
 
     cairo_surface_t *surf = cairo_win32_surface_create_with_ddb(dc, (cairo_format_t)imageFormat,
                                                                 size.width, size.height);
 
     Init(surf);
 
     if (mSurfaceValid) {
         // DDBs will generally only use 3 bytes per pixel when RGB24
-        int bytesPerPixel = ((imageFormat == gfxASurface::ImageFormatRGB24) ? 3 : 4);
+        int bytesPerPixel = ((imageFormat == gfxImageFormatRGB24) ? 3 : 4);
         RecordMemoryUsed(size.width * size.height * bytesPerPixel + sizeof(gfxWindowsSurface));
     }
 
     if (CairoStatus() == 0)
         mDC = cairo_win32_surface_get_dc(CairoSurface());
     else
         mDC = nullptr;
 }
@@ -120,23 +120,23 @@ already_AddRefed<gfxASurface>
 gfxWindowsSurface::CreateSimilarSurface(gfxContentType aContent,
                                         const gfxIntSize& aSize)
 {
     if (!mSurface || !mSurfaceValid) {
         return nullptr;
     }
 
     cairo_surface_t *surface;
-    if (GetContentType() == CONTENT_COLOR_ALPHA) {
+    if (GetContentType() == GFX_CONTENT_COLOR_ALPHA) {
         // When creating a similar surface to a transparent surface, ensure
         // the new surface uses a DIB. cairo_surface_create_similar won't
-        // use  a DIB for a CONTENT_COLOR surface if this surface doesn't
+        // use  a DIB for a GFX_CONTENT_COLOR surface if this surface doesn't
         // have a DIB (e.g. if we're a transparent window surface). But
         // we need a DIB to perform well if the new surface is composited into
-        // a surface that's the result of create_similar(CONTENT_COLOR_ALPHA)
+        // a surface that's the result of create_similar(GFX_CONTENT_COLOR_ALPHA)
         // (e.g. a backbuffer for the window) --- that new surface *would*
         // have a DIB.
         surface =
           cairo_win32_surface_create_with_dib(cairo_format_t(gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent)),
                                               aSize.width, aSize.height);
     } else {
         surface =
           cairo_surface_create_similar(mSurface, cairo_content_t(aContent),
@@ -200,17 +200,17 @@ gfxWindowsSurface::GetAsImageSurface()
 }
 
 already_AddRefed<gfxWindowsSurface>
 gfxWindowsSurface::OptimizeToDDB(HDC dc, const gfxIntSize& size, gfxImageFormat format)
 {
     if (mForPrinting)
         return nullptr;
 
-    if (format != ImageFormatRGB24)
+    if (format != gfxImageFormatRGB24)
         return nullptr;
 
     nsRefPtr<gfxWindowsSurface> wsurf = new gfxWindowsSurface(dc, size, format);
     if (wsurf->CairoStatus() != 0)
         return nullptr;
 
     gfxContext tmpCtx(wsurf);
     tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
@@ -328,13 +328,13 @@ gfxWindowsSurface::GetSize() const
     }
 
     NS_ASSERTION(mSurface != nullptr, "CairoSurface() shouldn't be nullptr when mSurfaceValid is TRUE!");
 
     return gfxIntSize(cairo_win32_surface_get_width(mSurface),
                       cairo_win32_surface_get_height(mSurface));
 }
 
-gfxASurface::MemoryLocation
+gfxMemoryLocation
 gfxWindowsSurface::GetMemoryLocation() const
 {
-    return MEMORY_IN_PROCESS_NONHEAP;
+    return GFX_MEMORY_IN_PROCESS_NONHEAP;
 }
--- a/gfx/thebes/gfxWindowsSurface.h
+++ b/gfx/thebes/gfxWindowsSurface.h
@@ -30,22 +30,22 @@ public:
     gfxWindowsSurface(HWND wnd, uint32_t flags = 0);
     gfxWindowsSurface(HDC dc, uint32_t flags = 0);
 
     // Create from a shared d3d9surface
     gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0);
 
     // Create a DIB surface
     gfxWindowsSurface(const gfxIntSize& size,
-                      gfxImageFormat imageFormat = ImageFormatRGB24);
+                      gfxImageFormat imageFormat = gfxImageFormatRGB24);
 
     // Create a DDB surface; dc may be nullptr to use the screen DC
     gfxWindowsSurface(HDC dc,
                       const gfxIntSize& size,
-                      gfxImageFormat imageFormat = ImageFormatRGB24);
+                      gfxImageFormat imageFormat = gfxImageFormatRGB24);
 
     gfxWindowsSurface(cairo_surface_t *csurf);
 
     virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
                                                                const gfxIntSize& aSize);
 
     void InitWithDC(uint32_t flags);
 
@@ -74,17 +74,17 @@ public:
     void MovePixels(const nsIntRect& aSourceRect,
                     const nsIntPoint& aDestTopLeft)
     {
         FastMovePixels(aSourceRect, aDestTopLeft);
     }
 
     // The memory used by this surface lives in this process's address space,
     // but not in the heap.
-    virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
+    virtual gfxMemoryLocation GetMemoryLocation() const;
 
 private:
     void MakeInvalid(gfxIntSize& size);
 
     bool mOwnsDC;
     bool mForPrinting;
 
     HDC mDC;
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -348,17 +348,17 @@ CreateTempXlibSurface (gfxASurface *dest
         Visual *target_visual = nullptr;
         XRenderPictFormat *target_format = nullptr;
         switch (target_type) {
         case CAIRO_SURFACE_TYPE_XLIB:
             target_visual = cairo_xlib_surface_get_visual (target);
             target_format = cairo_xlib_surface_get_xrender_format (target);
             break;
         case CAIRO_SURFACE_TYPE_IMAGE: {
-            gfxASurface::gfxImageFormat imageFormat =
+            gfxImageFormat imageFormat =
                 static_cast<gfxImageSurface*>(destination)->Format();
             target_visual = gfxXlibSurface::FindVisual(screen, imageFormat);
             Display *dpy = DisplayOfScreen(screen);
             if (target_visual) {
                 target_format = XRenderFindVisualFormat(dpy, target_visual);
             } else {
                 target_format =
                     gfxXlibSurface::FindRenderFormat(dpy, imageFormat);
@@ -390,44 +390,44 @@ CreateTempXlibSurface (gfxASurface *dest
     if (supportsAlternateVisual && !drawIsOpaque &&
         (screen != target_screen ||
          !(doCopyBackground || VisualHasAlpha(screen, visual)))) {
         // Try to find a visual with an alpha channel.
         Screen *visualScreen =
             supportsAlternateScreen ? target_screen : screen;
         Visual *argbVisual =
             gfxXlibSurface::FindVisual(visualScreen,
-                                       gfxASurface::ImageFormatARGB32);
+                                       gfxImageFormatARGB32);
         if (argbVisual) {
             visual = argbVisual;
             screen = visualScreen;
         } else if (!doCopyBackground &&
                    gfxXlibSurface::DepthOfVisual(screen, visual) != 24) {
             // Will need to do alpha extraction; prefer a 24-bit visual.
             // No advantage in using the target screen.
             Visual *rgb24Visual =
                 gfxXlibSurface::FindVisual(screen,
-                                           gfxASurface::ImageFormatRGB24);
+                                           gfxImageFormatRGB24);
             if (rgb24Visual) {
                 visual = rgb24Visual;
             }
         }
     }
 
     Drawable drawable =
         (screen == target_screen && target_type == CAIRO_SURFACE_TYPE_XLIB) ?
         cairo_xlib_surface_get_drawable (target) : RootWindowOfScreen(screen);
 
     nsRefPtr<gfxXlibSurface> surface =
         gfxXlibSurface::Create(screen, visual,
                                gfxIntSize(size.width, size.height),
                                drawable);
 
     if (drawIsOpaque ||
-        surface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
+        surface->GetContentType() == GFX_CONTENT_COLOR_ALPHA) {
         NATIVE_DRAWING_NOTE(drawIsOpaque ?
                             ", SIMPLE OPAQUE\n" : ", SIMPLE WITH ALPHA");
         *method = eSimple;
     } else if (doCopyBackground) {
         NATIVE_DRAWING_NOTE(", COPY BACKGROUND\n");
         *method = eCopyBackground;
     } else {
         NATIVE_DRAWING_NOTE(", SLOW ALPHA EXTRACTION\n");
@@ -446,17 +446,17 @@ gfxXlibNativeRenderer::DrawOntoTempSurfa
        surface anyway */
     nsresult rv = DrawWithXlib(tempXlibSurface, offset, nullptr, 0);
     tempXlibSurface->MarkDirty();
     return NS_SUCCEEDED(rv);
 }
 
 static already_AddRefed<gfxImageSurface>
 CopyXlibSurfaceToImage(gfxXlibSurface *tempXlibSurface,
-                       gfxASurface::gfxImageFormat format)
+                       gfxImageFormat format)
 {
     nsRefPtr<gfxImageSurface> result =
         new gfxImageSurface(tempXlibSurface->GetSize(), format);
 
     gfxContext copyCtx(result);
     copyCtx.SetSource(tempXlibSurface);
     copyCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
     copyCtx.Paint();
@@ -580,17 +580,17 @@ gfxXlibNativeRenderer::DrawFallback(Draw
         if (method == eCopyBackground) {
             tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
             tmpCtx->SetSource(target, -(offset + ctx->CurrentMatrix().GetTranslation()));
             // The copy from the tempXlibSurface to the target context should
             // use operator SOURCE, but that would need a mask to bound the
             // operation.  Here we only copy opaque backgrounds so operator
             // OVER will behave like SOURCE masked by the surface.
             NS_ASSERTION(tempXlibSurface->GetContentType()
-                         == gfxASurface::CONTENT_COLOR,
+                         == GFX_CONTENT_COLOR,
                          "Don't copy background with a transparent surface");
         } else {
             tmpCtx->SetOperator(gfxContext::OPERATOR_CLEAR);
         }
         tmpCtx->Paint();
     }
 
     if (!DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft())) {
@@ -614,24 +614,24 @@ gfxXlibNativeRenderer::DrawFallback(Draw
                assumption was */
             result->mUniformAlpha = true;
             result->mColor.a = 1.0;
         }
         return;
     }
     
     nsRefPtr<gfxImageSurface> blackImage =
-        CopyXlibSurfaceToImage(tempXlibSurface, gfxASurface::ImageFormatARGB32);
+        CopyXlibSurfaceToImage(tempXlibSurface, gfxImageFormatARGB32);
     
     tmpCtx->SetDeviceColor(gfxRGBA(1.0, 1.0, 1.0));
     tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
     tmpCtx->Paint();
     DrawOntoTempSurface(tempXlibSurface, -drawingRect.TopLeft());
     nsRefPtr<gfxImageSurface> whiteImage =
-        CopyXlibSurfaceToImage(tempXlibSurface, gfxASurface::ImageFormatRGB24);
+        CopyXlibSurfaceToImage(tempXlibSurface, gfxImageFormatRGB24);
   
     if (blackImage->CairoStatus() == CAIRO_STATUS_SUCCESS &&
         whiteImage->CairoStatus() == CAIRO_STATUS_SUCCESS) {
         gfxAlphaRecovery::Analysis analysis;
         if (!gfxAlphaRecovery::RecoverAlpha(blackImage, whiteImage,
                                             result ? &analysis : nullptr))
             return;
 
@@ -649,17 +649,17 @@ gfxXlibNativeRenderer::DrawFallback(Draw
             }
             if (analysis.uniformColor) {
                 result->mUniformColor = true;
                 result->mColor.r = analysis.r;
                 result->mColor.g = analysis.g;
                 result->mColor.b = analysis.b;
             } else {
                 result->mSurface = target->
-                    CreateSimilarSurface(gfxASurface::CONTENT_COLOR_ALPHA,
+                    CreateSimilarSurface(GFX_CONTENT_COLOR_ALPHA,
                                          gfxIntSize(size.width, size.height));
 
                 gfxContext copyCtx(result->mSurface);
                 copyCtx.SetSource(blackImage);
                 copyCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
                 copyCtx.Paint();
 
                 paintSurface = result->mSurface;
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -184,17 +184,17 @@ static bool GetForce24bppPref()
 already_AddRefed<gfxASurface>
 gfxXlibSurface::CreateSimilarSurface(gfxContentType aContent,
                                      const gfxIntSize& aSize)
 {
     if (!mSurface || !mSurfaceValid) {
       return nullptr;
     }
 
-    if (aContent == CONTENT_COLOR) {
+    if (aContent == GFX_CONTENT_COLOR) {
         // cairo_surface_create_similar will use a matching visual if it can.
         // However, systems with 16-bit or indexed default visuals may benefit
         // from rendering with 24-bit formats.
         static bool force24bpp = GetForce24bppPref();
         if (force24bpp
             && cairo_xlib_surface_get_depth(CairoSurface()) != 24) {
             XRenderPictFormat* format =
                 XRenderFindStandardFormat(mDisplay, PictStandardRGB24);
@@ -433,36 +433,36 @@ gfxXlibSurface::DepthOfVisual(const Scre
     
 /* static */
 Visual*
 gfxXlibSurface::FindVisual(Screen *screen, gfxImageFormat format)
 {
     int depth;
     unsigned long red_mask, green_mask, blue_mask;
     switch (format) {
-        case ImageFormatARGB32:
+        case gfxImageFormatARGB32:
             depth = 32;
             red_mask = 0xff0000;
             green_mask = 0xff00;
             blue_mask = 0xff;
             break;
-        case ImageFormatRGB24:
+        case gfxImageFormatRGB24:
             depth = 24;
             red_mask = 0xff0000;
             green_mask = 0xff00;
             blue_mask = 0xff;
             break;
-        case ImageFormatRGB16_565:
+        case gfxImageFormatRGB16_565:
             depth = 16;
             red_mask = 0xf800;
             green_mask = 0x7e0;
             blue_mask = 0x1f;
             break;
-        case ImageFormatA8:
-        case ImageFormatA1:
+        case gfxImageFormatA8:
+        case gfxImageFormatA1:
         default:
             return nullptr;
     }
 
     for (int d = 0; d < screen->ndepths; d++) {
         const Depth& d_info = screen->depths[d];
         if (d_info.depth != depth)
             continue;
@@ -481,32 +481,32 @@ gfxXlibSurface::FindVisual(Screen *scree
     return nullptr;
 }
 
 /* static */
 XRenderPictFormat*
 gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
 {
     switch (format) {
-        case ImageFormatARGB32:
+        case gfxImageFormatARGB32:
             return XRenderFindStandardFormat (dpy, PictStandardARGB32);
-        case ImageFormatRGB24:
+        case gfxImageFormatRGB24:
             return XRenderFindStandardFormat (dpy, PictStandardRGB24);
-        case ImageFormatRGB16_565: {
+        case gfxImageFormatRGB16_565: {
             // PictStandardRGB16_565 is not standard Xrender format
             // we should try to find related visual
             // and find xrender format by visual
             Visual *visual = FindVisual(DefaultScreenOfDisplay(dpy), format);
             if (!visual)
                 return nullptr;
             return XRenderFindVisualFormat(dpy, visual);
         }
-        case ImageFormatA8:
+        case gfxImageFormatA8:
             return XRenderFindStandardFormat (dpy, PictStandardA8);
-        case ImageFormatA1:
+        case gfxImageFormatA1:
             return XRenderFindStandardFormat (dpy, PictStandardA1);
         default:
             break;
     }
 
     return nullptr;
 }
 
@@ -536,13 +536,13 @@ gfxXlibSurface::GetGLXPixmap()
             "GetGLXPixmap called after surface finished");
 #endif
         mGLXPixmap = gl::sDefGLXLib.CreatePixmap(this);
     }
     return mGLXPixmap;
 }
 #endif
 
-gfxASurface::MemoryLocation
+gfxMemoryLocation
 gfxXlibSurface::GetMemoryLocation() const
 {
-    return MEMORY_OUT_OF_PROCESS;
+    return GFX_MEMORY_OUT_OF_PROCESS;
 }
--- a/gfx/thebes/gfxXlibSurface.h
+++ b/gfx/thebes/gfxXlibSurface.h
@@ -71,17 +71,17 @@ public:
     // on those created by a Create() factory method.
     Drawable ReleasePixmap();
 
     // Find a visual and colormap pair suitable for rendering to this surface.
     bool GetColormapAndVisual(Colormap* colormap, Visual **visual);
 
     // This surface is a wrapper around X pixmaps, which are stored in the X
     // server, not the main application.
-    virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
+    virtual gfxMemoryLocation GetMemoryLocation() const;
 
 #if defined(GL_PROVIDER_GLX)
     GLXPixmap GetGLXPixmap();
 #endif
 
     // Return true if cairo will take its slow path when this surface is used
     // in a pattern with EXTEND_PAD.  As a workaround for XRender's RepeatPad
     // not being implemented correctly on old X servers, cairo avoids XRender
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -154,21 +154,21 @@ void nsGIFDecoder2::BeginGIF()
   mGIFOpen = true;
 
   PostSize(mGIFStruct.screen_width, mGIFStruct.screen_height);
 }
 
 //******************************************************************************
 void nsGIFDecoder2::BeginImageFrame(uint16_t aDepth)
 {
-  gfxASurface::gfxImageFormat format;
+  gfxImageFormat format;
   if (mGIFStruct.is_transparent)
-    format = gfxASurface::ImageFormatARGB32;
+    format = gfxImageFormatARGB32;
   else
-    format = gfxASurface::ImageFormatRGB24;
+    format = gfxImageFormatRGB24;
 
   MOZ_ASSERT(HasSize());
 
   // Use correct format, RGB for first frame, PAL for following frames
   // and include transparency to allow for optimization of opaque images
   if (mGIFStruct.images_decoded) {
     // Image data is stored with original depth and palette
     NeedNewFrame(mGIFStruct.images_decoded, mGIFStruct.x_offset,
@@ -183,17 +183,17 @@ void nsGIFDecoder2::BeginImageFrame(uint
                                                                 mGIFStruct.width,
                                                                 mGIFStruct.height))) {
     // Regardless of depth of input, image is decoded into 24bit RGB
     NeedNewFrame(mGIFStruct.images_decoded, mGIFStruct.x_offset,
                  mGIFStruct.y_offset, mGIFStruct.width, mGIFStruct.height,
                  format);
   } else {
     // Our preallocated frame matches up, with the possible exception of alpha.
-    if (format == gfxASurface::ImageFormatRGB24) {
+    if (format == gfxImageFormatRGB24) {
       GetCurrentFrame()->SetHasNoAlpha();
     }
   }
 
   mCurrentFrame = mGIFStruct.images_decoded;
 }
 
 
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -133,27 +133,27 @@ nsPNGDecoder::~nsPNGDecoder()
     if (mTransform)
       qcms_transform_release(mTransform);
   }
 }
 
 // CreateFrame() is used for both simple and animated images
 void nsPNGDecoder::CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
                                int32_t width, int32_t height,
-                               gfxASurface::gfxImageFormat format)
+                               gfxImageFormat format)
 {
   // Our first full frame is automatically created by the image decoding
   // infrastructure. Just use it as long as it matches up.
   MOZ_ASSERT(HasSize());
   if (mNumFrames != 0 ||
       !GetCurrentFrame()->GetRect().IsEqualEdges(nsIntRect(x_offset, y_offset, width, height))) {
     NeedNewFrame(mNumFrames, x_offset, y_offset, width, height, format);
   } else if (mNumFrames == 0) {
     // Our preallocated frame matches up, with the possible exception of alpha.
-    if (format == gfxASurface::ImageFormatRGB24) {
+    if (format == gfxImageFormatRGB24) {
       GetCurrentFrame()->SetHasNoAlpha();
     }
   }
 
   mFrameRect.x = x_offset;
   mFrameRect.y = y_offset;
   mFrameRect.width = width;
   mFrameRect.height = height;
@@ -622,19 +622,19 @@ nsPNGDecoder::info_callback(png_structp 
       }
     } else {
       alpha_bits = 8;
     }
   }
 #endif
 
   if (channels == 1 || channels == 3)
-    decoder->format = gfxASurface::ImageFormatRGB24;
+    decoder->format = gfxImageFormatRGB24;
   else if (channels == 2 || channels == 4)
-    decoder->format = gfxASurface::ImageFormatARGB32;
+    decoder->format = gfxImageFormatARGB32;
 
 #ifdef PNG_APNG_SUPPORTED
   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_acTL))
     png_set_progressive_frame_fn(png_ptr, nsPNGDecoder::frame_info_callback,
                                  nullptr);
 
   if (png_get_first_frame_is_hidden(png_ptr, info_ptr)) {
     decoder->mFrameIsHidden = true;
@@ -738,17 +738,17 @@ nsPNGDecoder::row_callback(png_structp p
         }
         line = decoder->mCMSLine;
       } else {
         qcms_transform_data(decoder->mTransform, line, line, iwidth);
        }
      }
 
     switch (decoder->format) {
-      case gfxASurface::ImageFormatRGB24:
+      case gfxImageFormatRGB24:
       {
         // counter for while() loops below
         uint32_t idx = iwidth;
 
         // copy as bytes until source pointer is 32-bit-aligned
         for (; (NS_PTR_TO_UINT32(line) & 0x3) && idx; --idx) {
           *cptr32++ = gfxPackedPixel(0xFF, line[0], line[1], line[2]);
           line += 3;
@@ -765,17 +765,17 @@ nsPNGDecoder::row_callback(png_structp p
         // copy remaining pixel(s)
         while (idx--) {
           // 32-bit read of final pixel will exceed buffer, so read bytes
           *cptr32++ = gfxPackedPixel(0xFF, line[0], line[1], line[2]);
           line += 3;
         }
       }
       break;
-      case gfxASurface::ImageFormatARGB32:
+      case gfxImageFormatARGB32:
       {
         if (!decoder->mDisablePremultipliedAlpha) {
           for (uint32_t x=width; x>0; --x) {
             *cptr32++ = gfxPackedPixel(line[3], line[0], line[1], line[2]);
             if (line[3] != 0xff)
               rowHasNoAlpha = false;
             line += 4;
           }
--- a/image/decoders/nsPNGDecoder.h
+++ b/image/decoders/nsPNGDecoder.h
@@ -28,17 +28,17 @@ public:
   virtual ~nsPNGDecoder();
 
   virtual void InitInternal();
   virtual void WriteInternal(const char* aBuffer, uint32_t aCount);
   virtual Telemetry::ID SpeedHistogram();
 
   void CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
                    int32_t width, int32_t height,
-                   gfxASurface::gfxImageFormat format);
+                   gfxImageFormat format);
   void EndImageFrame();
 
   // Check if PNG is valid ICO (32bpp RGBA)
   // http://blogs.msdn.com/b/oldnewthing/archive/2010/10/22/10079192.aspx
   bool IsValidICO() const
   {
     // If there are errors in the call to png_get_IHDR, the error_callback in
     // nsPNGDecoder.cpp is called.  In this error callback we do a longjmp, so
@@ -71,17 +71,17 @@ public:
   png_structp mPNG;
   png_infop mInfo;
   nsIntRect mFrameRect;
   uint8_t *mCMSLine;
   uint8_t *interlacebuf;
   qcms_profile *mInProfile;
   qcms_transform *mTransform;
 
-  gfxASurface::gfxImageFormat format;
+  gfxImageFormat format;
 
   // For size decodes
   uint8_t mSizeBytes[8]; // Space for width and height, both 4 bytes
   uint32_t mHeaderBytesRead;
 
   // whether CMS or premultiplied alpha are forced off
   uint32_t mCMSMode;
 
--- a/image/src/ClippedImage.cpp
+++ b/image/src/ClippedImage.cpp
@@ -244,17 +244,17 @@ ClippedImage::GetFrameInternal(const nsI
     nsRefPtr<gfxDrawable> drawable =
       new gfxCallbackDrawable(drawTileCallback, mClip.Size());
 
     // Actually draw. The callback will end up invoking DrawSingleTile.
     nsRefPtr<gfxContext> ctx = new gfxContext(surface);
     gfxRect imageRect(0, 0, mClip.width, mClip.height);
     gfxUtils::DrawPixelSnapped(ctx, drawable, gfxMatrix(),
                                imageRect, imageRect, imageRect, imageRect,
-                               gfxASurface::ImageFormatARGB32,
+                               gfxImageFormatARGB32,
                                gfxPattern::FILTER_FAST);
 
     // Cache the resulting surface.
     mCachedSurface = new ClippedImageCachedSurface(target,
                                                    aViewportSize,
                                                    aSVGContext,
                                                    frameToDraw,
                                                    aFlags);
@@ -331,17 +331,17 @@ ClippedImage::Draw(gfxContext* aContext,
     nsRefPtr<gfxSurfaceDrawable> drawable =
       new gfxSurfaceDrawable(surface, gfxIntSize(mClip.width, mClip.height));
 
     // Draw.
     gfxRect imageRect(0, 0, mClip.width, mClip.height);
     gfxRect subimage(aSubimage.x, aSubimage.y, aSubimage.width, aSubimage.height);
     gfxUtils::DrawPixelSnapped(aContext, drawable, aUserSpaceToImageSpace,
                                subimage, sourceRect, imageRect, aFill,
-                               gfxASurface::ImageFormatARGB32, aFilter);
+                               gfxImageFormatARGB32, aFilter);
 
     return NS_OK;
   }
 
   // Determine the appropriate subimage for the inner image.
   nsIntRect innerSubimage(aSubimage);
   innerSubimage.MoveBy(mClip.x, mClip.y);
   innerSubimage.Intersect(mClip);
--- a/image/src/Decoder.cpp
+++ b/image/src/Decoder.cpp
@@ -410,17 +410,17 @@ Decoder::PostDecoderError(nsresult aFail
   // XXXbholley - we should report the image URI here, but imgContainer
   // needs to know its URI first
   NS_WARNING("Image decoding error - This is probably a bug!");
 }
 
 void
 Decoder::NeedNewFrame(uint32_t framenum, uint32_t x_offset, uint32_t y_offset,
                       uint32_t width, uint32_t height,
-                      gfxASurface::gfxImageFormat format,
+                      gfxImageFormat format,
                       uint8_t palette_depth /* = 0 */)
 {
   // Decoders should never call NeedNewFrame without yielding back to Write().
   MOZ_ASSERT(!mNeedsNewFrame);
 
   // We don't want images going back in time or skipping frames.
   MOZ_ASSERT(framenum == mFrameCount || framenum == (mFrameCount - 1));
 
--- a/image/src/Decoder.h
+++ b/image/src/Decoder.h
@@ -155,17 +155,17 @@ public:
   // is created as an ARGB frame with no offset and with size width * height.
   // If decoders need something different, they must ask for it.
   // This is called by decoders when they need a new frame. These decoders
   // must then save the data they have been sent but not yet processed and
   // return from WriteInternal. When the new frame is created, WriteInternal
   // will be called again with nullptr and 0 as arguments.
   void NeedNewFrame(uint32_t frameNum, uint32_t x_offset, uint32_t y_offset,
                     uint32_t width, uint32_t height,
-                    gfxASurface::gfxImageFormat format,
+                    gfxImageFormat format,
                     uint8_t palette_depth = 0);
 
   virtual bool NeedsNewFrame() const { return mNeedsNewFrame; }
 
   // Try to allocate a frame as described in mNewFrameData and return the
   // status code from that attempt. Clears mNewFrameData.
   virtual nsresult AllocateFrame();
 
@@ -254,31 +254,31 @@ private:
 
   struct NewFrameData
   {
     NewFrameData()
     {}
 
     NewFrameData(uint32_t num, uint32_t offsetx, uint32_t offsety,
                  uint32_t width, uint32_t height,
-                 gfxASurface::gfxImageFormat format, uint8_t paletteDepth)
+                 gfxImageFormat format, uint8_t paletteDepth)
       : mFrameNum(num)
       , mOffsetX(offsetx)
       , mOffsetY(offsety)
       , mWidth(width)
       , mHeight(height)
       , mFormat(format)
       , mPaletteDepth(paletteDepth)
     {}
     uint32_t mFrameNum;
     uint32_t mOffsetX;
     uint32_t mOffsetY;
     uint32_t mWidth;
     uint32_t mHeight;
-    gfxASurface::gfxImageFormat mFormat;
+    gfxImageFormat mFormat;
     uint8_t mPaletteDepth;
   };
   NewFrameData mNewFrameData;
   bool mNeedsNewFrame;
   bool mInitialized;
   bool mSizeDecode;
   bool mInFrame;
   bool mIsAnimated;
--- a/image/src/FrameBlender.cpp
+++ b/image/src/FrameBlender.cpp
@@ -221,17 +221,17 @@ FrameBlender::DoBlend(nsIntRect* aDirtyR
   }
 
   bool needToBlankComposite = false;
 
   // Create the Compositing Frame
   if (!mAnim->compositingFrame) {
     mAnim->compositingFrame.SetFrame(new imgFrame());
     nsresult rv = mAnim->compositingFrame->Init(0, 0, mSize.width, mSize.height,
-                                                gfxASurface::ImageFormatARGB32);
+                                                gfxImageFormatARGB32);
     if (NS_FAILED(rv)) {
       mAnim->compositingFrame.SetFrame(nullptr);
       return false;
     }
     mAnim->compositingFrame.LockAndGetData();
     needToBlankComposite = true;
   } else if (int32_t(aNextFrameIndex) != mAnim->lastCompositedFrameIndex+1) {
 
@@ -351,17 +351,17 @@ FrameBlender::DoBlend(nsIntRect* aDirtyR
   if ((nextFrameDisposalMethod == FrameBlender::kDisposeRestorePrevious) &&
       (prevFrameDisposalMethod != FrameBlender::kDisposeRestorePrevious)) {
     // We are storing the whole image.
     // It would be better if we just stored the area that nextFrame is going to
     // overwrite.
     if (!mAnim->compositingPrevFrame) {
       mAnim->compositingPrevFrame.SetFrame(new imgFrame());
       nsresult rv = mAnim->compositingPrevFrame->Init(0, 0, mSize.width, mSize.height,
-                                                      gfxASurface::ImageFormatARGB32);
+                                                      gfxImageFormatARGB32);
       if (NS_FAILED(rv)) {
         mAnim->compositingPrevFrame.SetFrame(nullptr);
         return false;
       }
 
       mAnim->compositingPrevFrame.LockAndGetData();
     }
 
@@ -544,17 +544,17 @@ FrameBlender::Discard()
   // timers are cancelled.
   NS_ABORT_IF_FALSE(!mAnim, "Asked to discard for animated image!");
 
   // Delete all the decoded frames, then clear the array.
   ClearFrames();
 }
 
 size_t
-FrameBlender::SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation,
+FrameBlender::SizeOfDecodedWithComputedFallbackIfHeap(gfxMemoryLocation aLocation,
                                                       MallocSizeOf aMallocSizeOf) const
 {
   size_t n = mFrames->SizeOfDecodedWithComputedFallbackIfHeap(aLocation, aMallocSizeOf);
 
   if (mAnim) {
     if (mAnim->compositingFrame) {
       n += mAnim->compositingFrame->SizeOfExcludingThisWithComputedFallbackIfHeap(aLocation, aMallocSizeOf);
     }
--- a/image/src/FrameBlender.h
+++ b/image/src/FrameBlender.h
@@ -58,17 +58,17 @@ public:
 
   /* The total number of frames in this image. */
   uint32_t GetNumFrames() const;
 
   void Discard();
 
   void SetSize(nsIntSize aSize) { mSize = aSize; }
 
-  size_t SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation,
+  size_t SizeOfDecodedWithComputedFallbackIfHeap(gfxMemoryLocation aLocation,
                                                  mozilla::MallocSizeOf aMallocSizeOf) const;
 
   void ResetAnimation();
 
   // "Blend" method indicates how the current image is combined with the
   // previous image.
   enum FrameBlendMethod {
     // All color components of the frame, including alpha, overwrite the current
--- a/image/src/FrameSequence.cpp
+++ b/image/src/FrameSequence.cpp
@@ -84,17 +84,17 @@ FrameSequence::SwapFrame(uint32_t framen
   } else {
     mFrames.RemoveElementAt(framenum);
   }
 
   return ret.Forget();
 }
 
 size_t
-FrameSequence::SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation,
+FrameSequence::SizeOfDecodedWithComputedFallbackIfHeap(gfxMemoryLocation aLocation,
                                                        MallocSizeOf aMallocSizeOf) const
 {
   size_t n = 0;
   for (uint32_t i = 0; i < mFrames.Length(); ++i) {
     imgFrame* frame = mFrames.SafeElementAt(i, FrameDataPair());
     NS_ABORT_IF_FALSE(frame, "Null frame in frame array!");
     n += frame->SizeOfExcludingThisWithComputedFallbackIfHeap(aLocation, aMallocSizeOf);
   }
--- a/image/src/FrameSequence.h
+++ b/image/src/FrameSequence.h
@@ -168,17 +168,17 @@ public:
   /**
    * Remove (and delete) all frames.
    */
   void ClearFrames();
 
   /* The total number of frames in this image. */
   uint32_t GetNumFrames() const;
 
-  size_t SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation,
+  size_t SizeOfDecodedWithComputedFallbackIfHeap(gfxMemoryLocation aLocation,
                                                  mozilla::MallocSizeOf aMallocSizeOf) const;
 
 private: // data
   //! All the frames of the image
   nsTArray<FrameDataPair> mFrames;
 };
 
 } // namespace image
--- a/image/src/OrientedImage.cpp
+++ b/image/src/OrientedImage.cpp
@@ -97,20 +97,20 @@ OrientedImage::GetFrame(uint32_t aWhichF
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Determine an appropriate format for the surface.
   gfx::SurfaceFormat surfaceFormat;
   gfxImageFormat imageFormat;
   if (InnerImage()->FrameIsOpaque(aWhichFrame)) {
     surfaceFormat = gfx::FORMAT_B8G8R8X8;
-    imageFormat = gfxASurface::ImageFormatARGB32;
+    imageFormat = gfxImageFormatARGB32;
   } else {
     surfaceFormat = gfx::FORMAT_B8G8R8A8;
-    imageFormat = gfxASurface::ImageFormatARGB32;
+    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()->
     GetThebesSurfaceForDrawTarget(target);
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -317,17 +317,17 @@ public:
   ScaleRunner(RasterImage* aImage, const gfxSize& aScale, imgFrame* aSrcFrame)
   {
     nsAutoPtr<ScaleRequest> request(new ScaleRequest(aImage, aScale, aSrcFrame));
 
     // Destination is unconditionally ARGB32 because that's what the scaler
     // outputs.
     request->dstFrame = new imgFrame();
     nsresult rv = request->dstFrame->Init(0, 0, request->dstSize.width, request->dstSize.height,
-                                          gfxASurface::ImageFormatARGB32);
+                                          gfxImageFormatARGB32);
 
     if (NS_FAILED(rv) || !request->GetSurfaces(aSrcFrame)) {
       return;
     }
 
     aImage->ScalingStart(request);
 
     mScaleRequest = request;
@@ -850,17 +850,17 @@ RasterImage::CopyFrame(uint32_t aWhichFr
   nsRefPtr<gfxPattern> pattern;
   frame->GetPattern(getter_AddRefs(pattern));
   nsIntRect intframerect = frame->GetRect();
   gfxRect framerect(intframerect.x, intframerect.y, intframerect.width, intframerect.height);
 
   // Create a 32-bit image surface of our size, but draw using the frame's
   // rect, implicitly padding the frame out to the image's size.
   nsRefPtr<gfxImageSurface> imgsurface = new gfxImageSurface(gfxIntSize(mSize.width, mSize.height),
-                                                             gfxASurface::ImageFormatARGB32);
+                                                             gfxImageFormatARGB32);
   gfxContext ctx(imgsurface);
   ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
   ctx.Rectangle(framerect);
   ctx.Translate(framerect.TopLeft());
   ctx.SetPattern(pattern);
   ctx.Fill();
 
   *_retval = imgsurface.forget().get();
@@ -1025,46 +1025,46 @@ RasterImage::HeapSizeOfSourceWithCompute
   size_t n = mSourceData.SizeOfExcludingThis(aMallocSizeOf);
   if (n == 0) {
     n = mSourceData.Length();
   }
   return n;
 }
 
 size_t
-RasterImage::SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation,
+Raste