Bug 959380 - 3/5 - Make gfxSurfaceType a typed enum - r=jrmuizel
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 23 Jan 2014 13:26:40 -0500
changeset 180948 14829d658500244b55a1df02ed6b182f45d65237
parent 180947 cfecc1e799529437cf2657d0d0ff87617d6ef6df
child 180949 93f99d0518c7bc218df9d9154370345a13426827
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs959380
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 959380 - 3/5 - Make gfxSurfaceType a typed enum - r=jrmuizel find . -type f | grep -v '\./obj' | grep -v '\.hg' | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)gfxSurfaceType\(Image\|PDF\|PS\|Xlib\|Xcb\|Glitz\|Quartz\|Win32\|BeOS\|DirectFB\|SVG\|OS2\|Win32Printing\|QuartzImage\|Script\|QPainter\|Recording\|VG\|GL\|DRM\|Tee\|XML\|Skia\|Subsurface\|D2D\|Max\)\($\|[^A-Za-z0-9_]\)/\1gfxSurfaceType::\2\3/g'
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/TextureImageEGL.cpp
gfx/ipc/GfxMessageUtils.h
gfx/ipc/SharedDIBSurface.cpp
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d10/ImageLayerD3D10.cpp
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/ipc/ShadowLayerUtilsX11.cpp
gfx/src/nsDeviceContext.cpp
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxBaseSharedMemorySurface.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxDrawable.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxQuartzNativeDrawing.cpp
gfx/thebes/gfxTypes.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxWindowsNativeDrawing.cpp
gfx/thebes/gfxWindowsPlatform.h
layout/base/nsCSSRenderingBorders.cpp
widget/gtk/nsImageToPixbuf.cpp
widget/gtk/nsWindow.cpp
widget/qt/nsNativeThemeQt.cpp
widget/qt/nsWindow.cpp
widget/shared/nsShmImage.cpp
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -132,17 +132,17 @@ PluginInstanceChild::PluginInstanceChild
 #endif
     , mLayersRendering(false)
 #ifdef XP_WIN
     , mCurrentSurfaceActor(nullptr)
     , mBackSurfaceActor(nullptr)
 #endif
     , mAccumulatedInvalidRect(0,0,0,0)
     , mIsTransparent(false)
-    , mSurfaceType(gfxSurfaceTypeMax)
+    , mSurfaceType(gfxSurfaceType::Max)
     , mCurrentInvalidateTask(nullptr)
     , mCurrentAsyncSetWindowTask(nullptr)
     , mPendingPluginCall(false)
     , mDoAlphaExtraction(false)
     , mHasPainted(false)
     , mSurfaceDifferenceRect(0,0,0,0)
 {
     memset(&mWindow, 0, sizeof(mWindow));
@@ -2768,17 +2768,17 @@ 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 != gfxSurfaceTypeMax,
+    NS_ABORT_IF_FALSE(mSurfaceType != gfxSurfaceType::Max,
                       "Need a valid surface type here");
     NS_ASSERTION(!mCurrentSurface, "mCurrentSurfaceActor can get out of sync.");
 
     nsRefPtr<gfxASurface> retsurf;
     // Use an opaque surface unless we're transparent and *don't* have
     // a background to source from.
     gfxImageFormat format =
         (mIsTransparent && !mBackground) ? gfxImageFormat::ARGB32 :
@@ -2787,17 +2787,17 @@ PluginInstanceChild::CreateOptSurface(vo
 #ifdef MOZ_X11
     Display* dpy = mWsInfo.display;
     Screen* screen = DefaultScreenOfDisplay(dpy);
     if (format == gfxImageFormat::RGB24 &&
         DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
         format = gfxImageFormat::RGB16_565;
     }
 
-    if (mSurfaceType == gfxSurfaceTypeXlib) {
+    if (mSurfaceType == gfxSurfaceType::Xlib) {
         if (!mIsTransparent  || mBackground) {
             Visual* defaultVisual = DefaultVisualOfScreen(screen);
             mCurrentSurface =
                 gfxXlibSurface::Create(screen, defaultVisual,
                                        gfxIntSize(mWindow.width,
                                                   mWindow.height));
             return mCurrentSurface != nullptr;
         }
@@ -2811,18 +2811,18 @@ PluginInstanceChild::CreateOptSurface(vo
             gfxXlibSurface::Create(screen, xfmt,
                                    gfxIntSize(mWindow.width,
                                               mWindow.height));
         return mCurrentSurface != nullptr;
     }
 #endif
 
 #ifdef XP_WIN
-    if (mSurfaceType == gfxSurfaceTypeWin32 ||
-        mSurfaceType == gfxSurfaceTypeD2D) {
+    if (mSurfaceType == gfxSurfaceType::Win32 ||
+        mSurfaceType == gfxSurfaceType::D2D) {
         bool willHaveTransparentPixels = mIsTransparent && !mBackground;
 
         SharedDIBSurface* s = new SharedDIBSurface();
         if (!s->Create(reinterpret_cast<HDC>(mWindow.window),
                        mWindow.width, mWindow.height,
                        willHaveTransparentPixels))
             return false;
 
@@ -2851,27 +2851,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() == gfxSurfaceTypeXlib) {
+    if (mCurrentSurface->GetType() == gfxSurfaceType::Xlib) {
         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() == gfxSurfaceTypeImage) {
+    } else if (mCurrentSurface->GetType() == gfxSurfaceType::Image) {
         // 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;
@@ -3009,17 +3009,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() == gfxSurfaceTypeXlib) {
+    if (curSurface && curSurface->GetType() == gfxSurfaceType::Xlib) {
         static_cast<gfxXlibSurface*>(curSurface.get())->
             GetColormapAndVisual(&colormap, &visual);
         if (visual != mWsInfo.visual || colormap != mWsInfo.colormap) {
             mWsInfo.visual = visual;
             mWsInfo.colormap = colormap;
             needWindowUpdate = true;
         }
     }
@@ -3101,17 +3101,17 @@ PluginInstanceChild::UpdateWindowAttribu
 void
 PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect,
                                                 gfxASurface* aSurface)
 {
     UpdateWindowAttributes();
 
 #ifdef MOZ_X11
     {
-        NS_ASSERTION(aSurface->GetType() == gfxSurfaceTypeXlib,
+        NS_ASSERTION(aSurface->GetType() == gfxSurfaceType::Xlib,
                      "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;
@@ -3203,17 +3203,17 @@ PluginInstanceChild::PaintRectWithAlphaE
     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 (gfxSurfaceTypeImage == aSurface->GetType()) {
+    if (gfxSurfaceType::Image == aSurface->GetType()) {
         gfxImageSurface* surfaceAsImage =
             static_cast<gfxImageSurface*>(aSurface);
         useSurfaceSubimageForBlack =
             (surfaceAsImage->Format() == gfxImageFormat::ARGB32);
         // If we're going to use a subimage, nudge the rect so that we
         // can use optimal alpha recovery.  If we're not using a
         // subimage, the temporaries should automatically get
         // fast-path alpha recovery so we don't need to do anything.
@@ -3479,17 +3479,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() == gfxSurfaceTypeXlib) {
+    if (mCurrentSurface->GetType() == gfxSurfaceType::Xlib) {
         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
@@ -3531,17 +3531,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() != gfxSurfaceTypeXlib &&
+    if (mBackSurface->GetType() != gfxSurfaceType::Xlib &&
         !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
@@ -606,17 +606,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() == gfxSurfaceTypeXlib) {
+        if (mFrontSurface->GetType() == gfxSurfaceType::Xlib) {
             // 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
         {
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -252,17 +252,17 @@ GLXLibrary::EnsureInitialized()
 
 bool
 GLXLibrary::SupportsTextureFromPixmap(gfxASurface* aSurface)
 {
     if (!EnsureInitialized()) {
         return false;
     }
 
-    if (aSurface->GetType() != gfxSurfaceTypeXlib || !mUseTextureFromPixmap) {
+    if (aSurface->GetType() != gfxSurfaceType::Xlib || !mUseTextureFromPixmap) {
         return false;
     }
 
     return true;
 }
 
 GLXPixmap
 GLXLibrary::CreatePixmap(gfxASurface* aSurface)
--- a/gfx/gl/TextureImageEGL.cpp
+++ b/gfx/gl/TextureImageEGL.cpp
@@ -154,17 +154,17 @@ TextureImageEGL::EndUpdate()
     // 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() == gfxSurfaceTypeImage &&
+    NS_ASSERTION(mUpdateSurface->GetType() == gfxSurfaceType::Image &&
                   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;
     }
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -191,19 +191,19 @@ template <>
 struct ParamTraits<gfxContentType>
   : public EnumSerializer<gfxContentType,
                           GFX_CONTENT_COLOR,
                           GFX_CONTENT_SENTINEL>
 {};
 
 template <>
 struct ParamTraits<gfxSurfaceType>
-  : public EnumSerializer<gfxSurfaceType,
-                          gfxSurfaceTypeImage,
-                          gfxSurfaceTypeMax>
+  : public TypedEnumSerializer<gfxSurfaceType,
+                               gfxSurfaceType::Image,
+                               gfxSurfaceType::Max>
 {};
 
 template <>
 struct ParamTraits<mozilla::GraphicsFilterType>
   : public EnumSerializer<mozilla::GraphicsFilterType,
                           GraphicsFilter::FILTER_FAST,
                           GraphicsFilter::FILTER_SENTINEL>
 {};
--- a/gfx/ipc/SharedDIBSurface.cpp
+++ b/gfx/ipc/SharedDIBSurface.cpp
@@ -52,14 +52,14 @@ SharedDIBSurface::InitSurface(uint32_t a
 
   cairo_surface_set_user_data(mSurface, &SHAREDDIB_KEY, this, nullptr);
 }
 
 bool
 SharedDIBSurface::IsSharedDIBSurface(gfxASurface* aSurface)
 {
   return aSurface &&
-    aSurface->GetType() == gfxSurfaceTypeImage &&
+    aSurface->GetType() == gfxSurfaceType::Image &&
     aSurface->GetData(&SHAREDDIB_KEY);
 }
 
 } // namespace gfx
 } // namespace mozilla
--- 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() == gfxSurfaceTypeXlib &&
+    if (target->GetType() == gfxSurfaceType::Xlib &&
         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/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -94,17 +94,17 @@ 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() == gfxSurfaceTypeD2D) {
+  if (mSurface && mSurface->GetType() == gfxSurfaceType::D2D) {
     void *data = mSurface->GetData(&gKeyD3D10Texture);
     if (data) {
       mTexture = static_cast<ID3D10Texture2D*>(data);
       mIsD2DTexture = true;
       device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView));
       mHasAlpha =
         mSurface->GetContentType() == GFX_CONTENT_COLOR_ALPHA;
       return;
--- a/gfx/layers/d3d10/ImageLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp
@@ -52,17 +52,17 @@ static already_AddRefed<ID3D10Texture2D>
 SurfaceToTexture(ID3D10Device *aDevice,
                  gfxASurface *aSurface,
                  const IntSize &aSize)
 {
   if (!aSurface) {
     return nullptr;
   }
 
-  if (aSurface->GetType() == gfxSurfaceTypeD2D) {
+  if (aSurface->GetType() == gfxSurfaceType::D2D) {
     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();
       }
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -127,19 +127,19 @@ CanvasLayerD3D9::UpdateSurface()
       NS_WARNING("Failed to lock CanvasLayer texture.");
       return;
     }
 
     D3DLOCKED_RECT lockedRect = textureLock.GetLockRect();
 
     nsRefPtr<gfxImageSurface> sourceSurface;
 
-    if (mSurface->GetType() == gfxSurfaceTypeWin32) {
+    if (mSurface->GetType() == gfxSurfaceType::Win32) {
       sourceSurface = mSurface->GetAsImageSurface();
-    } else if (mSurface->GetType() == gfxSurfaceTypeImage) {
+    } else if (mSurface->GetType() == gfxSurfaceType::Image) {
       sourceSurface = static_cast<gfxImageSurface*>(mSurface.get());
       if (sourceSurface->Format() != gfxImageFormat::ARGB32 &&
           sourceSurface->Format() != gfxImageFormat::RGB24)
       {
         return;
       }
     } else {
       sourceSurface = new gfxImageSurface(gfxIntSize(mBounds.width, mBounds.height),
--- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
@@ -44,17 +44,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 (gfxSurfaceTypeXlib ==
+  return (gfxSurfaceType::Xlib ==
           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)
 {
@@ -132,17 +132,17 @@ ISurfaceAllocator::PlatformAllocSurfaceD
     // general.  Fall back on Shmem.
     return false;
   }
 
   gfxPlatform* platform = gfxPlatform::GetPlatform();
   nsRefPtr<gfxASurface> buffer =
     platform->CreateOffscreenSurface(gfx::ThebesIntSize(aSize), aContent);
   if (!buffer ||
-      buffer->GetType() != gfxSurfaceTypeXlib) {
+      buffer->GetType() != gfxSurfaceType::Xlib) {
     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/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -302,33 +302,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 gfxSurfaceTypePDF:
-        case gfxSurfaceTypePS:
-        case gfxSurfaceTypeQuartz:
+        case gfxSurfaceType::PDF:
+        case gfxSurfaceType::PS:
+        case gfxSurfaceType::Quartz:
             dpi = 72.0f;
             break;
 #ifdef XP_WIN
-        case gfxSurfaceTypeWin32:
-        case gfxSurfaceTypeWin32Printing: {
+        case gfxSurfaceType::Win32:
+        case gfxSurfaceType::Win32Printing: {
             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 gfxSurfaceTypeOS2: {
+        case gfxSurfaceType::OS2: {
             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:
@@ -650,61 +650,61 @@ nsDeviceContext::CalcPrintingSize()
 {
     if (!mPrintingSurface)
         return;
 
     bool inPoints = true;
 
     gfxSize size(0, 0);
     switch (mPrintingSurface->GetType()) {
-    case gfxSurfaceTypeImage:
+    case gfxSurfaceType::Image:
         inPoints = false;
         size = reinterpret_cast<gfxImageSurface*>(mPrintingSurface.get())->GetSize();
         break;
 
 #if defined(MOZ_PDF_PRINTING)
-    case gfxSurfaceTypePDF:
+    case gfxSurfaceType::PDF:
         inPoints = true;
         size = reinterpret_cast<gfxPDFSurface*>(mPrintingSurface.get())->GetSize();
         break;
 #endif
 
 #ifdef MOZ_WIDGET_GTK
-    case gfxSurfaceTypePS:
+    case gfxSurfaceType::PS:
         inPoints = true;
         size = reinterpret_cast<gfxPSSurface*>(mPrintingSurface.get())->GetSize();
         break;
 #endif
 
 #ifdef XP_MACOSX
-    case gfxSurfaceTypeQuartz:
+    case gfxSurfaceType::Quartz:
         inPoints = true; // this is really only true when we're printing
         size = reinterpret_cast<gfxQuartzSurface*>(mPrintingSurface.get())->GetSize();
         break;
 #endif
 
 #ifdef XP_WIN
-    case gfxSurfaceTypeWin32:
-    case gfxSurfaceTypeWin32Printing:
+    case gfxSurfaceType::Win32:
+    case gfxSurfaceType::Win32Printing:
         {
             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 gfxSurfaceTypeOS2:
+    case gfxSurfaceType::OS2:
         {
             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/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -614,27 +614,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) ==
-                 gfxSurfaceTypeMax);
+                 size_t(gfxSurfaceType::Max));
 #ifdef CAIRO_HAS_D2D_SURFACE
 PR_STATIC_ASSERT(uint32_t(CAIRO_SURFACE_TYPE_D2D) ==
-                 uint32_t(gfxSurfaceTypeD2D));
+                 uint32_t(gfxSurfaceType::D2D));
 #endif
 PR_STATIC_ASSERT(uint32_t(CAIRO_SURFACE_TYPE_SKIA) ==
-                 uint32_t(gfxSurfaceTypeSkia));
+                 uint32_t(gfxSurfaceType::Skia));
 
 /* Surface size memory reporting */
 
-static int64_t gSurfaceMemoryUsed[gfxSurfaceTypeMax] = { 0 };
+static int64_t gSurfaceMemoryUsed[size_t(gfxSurfaceType::Max)] = { 0 };
 
 class SurfaceMemoryReporter MOZ_FINAL : public nsIMemoryReporter
 {
 public:
     NS_DECL_ISUPPORTS
 
     NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCb,
                               nsISupports *aClosure)
@@ -663,28 +663,28 @@ public:
 };
 
 NS_IMPL_ISUPPORTS1(SurfaceMemoryReporter, nsIMemoryReporter)
 
 void
 gfxASurface::RecordMemoryUsedForSurfaceType(gfxSurfaceType aType,
                                             int32_t aBytes)
 {
-    if (aType < 0 || aType >= gfxSurfaceTypeMax) {
+    if (int(aType) < 0 || aType >= gfxSurfaceType::Max) {
         NS_WARNING("Invalid type to RecordMemoryUsedForSurfaceType!");
         return;
     }
 
     static bool registered = false;
     if (!registered) {
         RegisterStrongMemoryReporter(new SurfaceMemoryReporter());
         registered = true;
     }
 
-    gSurfaceMemoryUsed[aType] += aBytes;
+    gSurfaceMemoryUsed[size_t(aType)] += aBytes;
 }
 
 void
 gfxASurface::RecordMemoryUsed(int32_t aBytes)
 {
     RecordMemoryUsedForSurfaceType(GetType(), aBytes);
     mBytesRecorded += aBytes;
 }
--- a/gfx/thebes/gfxBaseSharedMemorySurface.h
+++ b/gfx/thebes/gfxBaseSharedMemorySurface.h
@@ -99,17 +99,17 @@ public:
         return Create<ShmemAllocator, true>(aAllocator, aSize, aFormat, aShmType);
     }
 
     Shmem& GetShmem() { return mShmem; }
 
     static bool IsSharedImage(gfxASurface *aSurface)
     {
         return (aSurface
-                && aSurface->GetType() == gfxSurfaceTypeImage
+                && aSurface->GetType() == gfxSurfaceType::Image
                 && aSurface->GetData(&SHM_KEY));
     }
 
 protected:
     gfxBaseSharedMemorySurface(const gfxIntSize& aSize, long aStride, 
                                gfxImageFormat aFormat, 
                                const Shmem& aShmem)
       : Base(aShmem.get<unsigned char>(), aSize, aStride, aFormat)
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -1606,24 +1606,24 @@ CopySurface(gfxASurface* aSrc, gfxASurfa
 
 void
 gfxContext::PushGroupAndCopyBackground(gfxContentType content)
 {
   if (mCairo) {
     if (content == GFX_CONTENT_COLOR_ALPHA &&
       !(GetFlags() & FLAG_DISABLE_COPY_BACKGROUND)) {
       nsRefPtr<gfxASurface> s = CurrentSurface();
-      if ((s->GetAllowUseAsSource() || s->GetType() == gfxSurfaceTypeTee) &&
+      if ((s->GetAllowUseAsSource() || s->GetType() == gfxSurfaceType::Tee) &&
           (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() == gfxSurfaceTypeTee) {
-          NS_ASSERTION(s->GetType() == gfxSurfaceTypeTee, "Mismatched types");
+        if (d->GetType() == gfxSurfaceType::Tee) {
+          NS_ASSERTION(s->GetType() == gfxSurfaceType::Tee, "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);
--- a/gfx/thebes/gfxDrawable.cpp
+++ b/gfx/thebes/gfxDrawable.cpp
@@ -70,17 +70,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 gfxSurfaceTypeXlib:
+        case gfxSurfaceType::Xlib:
         {
             // 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 ---
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -663,17 +663,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() == gfxSurfaceTypeQuartz) {
+  if (aSurface->GetType() == gfxSurfaceType::Quartz) {
     return Factory::CreateDrawTargetForCairoCGContext(static_cast<gfxQuartzSurface*>(aSurface)->GetCGContext(), aSize);
   }
 #endif
   MOZ_CRASH();
   return nullptr;
 }
 
 
@@ -753,17 +753,17 @@ gfxPlatform::GetSourceSurfaceForSurface(
     format = SurfaceFormat::B8G8R8X8;
   } else {
     format = SurfaceFormat::B8G8R8A8;
   }
 
   RefPtr<SourceSurface> srcBuffer;
 
 #ifdef XP_WIN
-  if (aSurface->GetType() == gfxSurfaceTypeD2D &&
+  if (aSurface->GetType() == gfxSurfaceType::D2D &&
       format != SurfaceFormat::A8) {
     NativeSurface surf;
     surf.mFormat = format;
     surf.mType = NativeSurfaceType::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();
@@ -786,17 +786,17 @@ gfxPlatform::GetSourceSurfaceForSurface(
       return srcBuffer;
     }
   }
 
   if (!srcBuffer) {
     nsRefPtr<gfxImageSurface> imgSurface = aSurface->GetAsImageSurface();
 
     bool isWin32ImageSurf = imgSurface &&
-                            aSurface->GetType() == gfxSurfaceTypeWin32;
+                            aSurface->GetType() == gfxSurfaceType::Win32;
 
     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();
     }
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -69,17 +69,17 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
     }
     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() == gfxSurfaceTypeQuartz &&
+    if (surf->GetType() == gfxSurfaceType::Quartz &&
         (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)
--- a/gfx/thebes/gfxTypes.h
+++ b/gfx/thebes/gfxTypes.h
@@ -53,44 +53,44 @@ MOZ_BEGIN_ENUM_CLASS(gfxImageFormat)
   ARGB32, ///< ARGB data in native endianness, using premultiplied alpha
   RGB24,  ///< xRGB data in native endianness
   A8,     ///< Only an alpha channel
   A1,     ///< Packed transparency information (one byte refers to 8 pixels)
   RGB16_565,  ///< RGB_565 data in native endianness
   Unknown
 MOZ_END_ENUM_CLASS(gfxImageFormat)
 
-    enum gfxSurfaceType {
-        gfxSurfaceTypeImage,
-        gfxSurfaceTypePDF,
-        gfxSurfaceTypePS,
-        gfxSurfaceTypeXlib,
-        gfxSurfaceTypeXcb,
-        gfxSurfaceTypeGlitz,           // unused, but needed for cairo parity
-        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
-    };
+MOZ_BEGIN_ENUM_CLASS(gfxSurfaceType)
+  Image,
+  PDF,
+  PS,
+  Xlib,
+  Xcb,
+  Glitz,           // unused, but needed for cairo parity
+  Quartz,
+  Win32,
+  BeOS,
+  DirectFB,        // unused, but needed for cairo parity
+  SVG,
+  OS2,
+  Win32Printing,
+  QuartzImage,
+  Script,
+  QPainter,
+  Recording,
+  VG,
+  GL,
+  DRM,
+  Tee,
+  XML,
+  Skia,
+  Subsurface,
+  D2D,
+  Max
+MOZ_END_ENUM_CLASS(gfxSurfaceType)
 
     enum gfxContentType {
         GFX_CONTENT_COLOR       = 0x1000,
         GFX_CONTENT_ALPHA       = 0x2000,
         GFX_CONTENT_COLOR_ALPHA = 0x3000,
         GFX_CONTENT_SENTINEL    = 0xffff
     };
 
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -278,17 +278,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() == gfxSurfaceTypeQuartz)
+        if (!aSurface || aSurface->GetType() == gfxSurfaceType::Quartz)
             return;
 
         if (!IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.xx) ||
             !IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.xy) ||
             !IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.yx) ||
             !IsSafeImageTransformComponent(aDeviceSpaceToImageSpace.yy)) {
             NS_WARNING("Scaling up too much, bailing out");
             mSucceeded = false;
--- a/gfx/thebes/gfxWindowsNativeDrawing.cpp
+++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp
@@ -54,18 +54,18 @@ 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() == gfxSurfaceTypeWin32 ||
-              surf->GetType() == gfxSurfaceTypeWin32Printing) &&
+            ((surf->GetType() == gfxSurfaceType::Win32 ||
+              surf->GetType() == gfxSurfaceType::Win32Printing) &&
               (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);
@@ -187,18 +187,18 @@ gfxWindowsNativeDrawing::IsDoublePass()
         (mContext->GetDrawTarget()->GetType() != mozilla::gfx::BackendType::CAIRO ||
          mContext->GetDrawTarget()->IsDualDrawTarget())) {
       return true;
     }
 
     nsRefPtr<gfxASurface> surf = mContext->CurrentSurface(&mDeviceOffset.x, &mDeviceOffset.y);
     if (!surf || surf->CairoStatus())
         return false;
-    if (surf->GetType() != gfxSurfaceTypeWin32 &&
-        surf->GetType() != gfxSurfaceTypeWin32Printing) {
+    if (surf->GetType() != gfxSurfaceType::Win32 &&
+        surf->GetType() != gfxSurfaceType::Win32Printing) {
 	return true;
     }
     if ((surf->GetContentType() != GFX_CONTENT_COLOR ||
          (surf->GetContentType() == GFX_CONTENT_COLOR_ALPHA &&
           !(mNativeDrawFlags & CAN_DRAW_TO_COLOR_ALPHA))))
         return true;
     return false;
 }
--- 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() == gfxSurfaceTypeWin32 ||
-             aSurface->GetType() == gfxSurfaceTypeWin32Printing))
+            (aSurface->GetType() == gfxSurfaceType::Win32 ||
+             aSurface->GetType() == gfxSurfaceType::Win32Printing))
         {
             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);
         }
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -1068,18 +1068,18 @@ nsCSSBorderRenderer::CreateCornerGradien
   pat2.x = cornerOrigin.x -
     mBorderWidths[cornerHeight[aCorner]] * gradientCoeff[aCorner].a;
   pat2.y = cornerOrigin.y -
     mBorderWidths[cornerWidth[aCorner]]  * gradientCoeff[aCorner].b;
 
   float gradientOffset;
   
   if (mContext->IsCairo() &&
-      (mContext->OriginalSurface()->GetType() == gfxSurfaceTypeD2D ||
-       mContext->OriginalSurface()->GetType() == gfxSurfaceTypeQuartz))
+      (mContext->OriginalSurface()->GetType() == gfxSurfaceType::D2D ||
+       mContext->OriginalSurface()->GetType() == gfxSurfaceType::Quartz))
   {
     // On quarz this doesn't do exactly the right thing, but it does do what
     // most other browsers do and doing the 'right' thing seems to be
     // hard with the quartz cairo backend.
     gradientOffset = 0;
   } else {
     // When cairo/Azure does the gradient drawing this gives us pretty nice behavior!
     gradientOffset = 0.25 / sqrt(pow(mBorderWidths[cornerHeight[aCorner]], 2) +
--- a/widget/gtk/nsImageToPixbuf.cpp
+++ b/widget/gtk/nsImageToPixbuf.cpp
@@ -133,17 +133,17 @@ GdkPixbuf*
 nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, int32_t aWidth, int32_t aHeight)
 {
     if (aSurface->CairoStatus()) {
         NS_ERROR("invalid surface");
         return nullptr;
     }
 
     nsRefPtr<gfxImageSurface> imgSurface;
-    if (aSurface->GetType() == gfxSurfaceTypeImage) {
+    if (aSurface->GetType() == gfxSurfaceType::Image) {
         imgSurface = static_cast<gfxImageSurface*>
                                 (static_cast<gfxASurface*>(aSurface));
     } else {
         imgSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight),
 					 gfxImageFormat::ARGB32);
                                        
         if (!imgSurface)
             return nullptr;
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2155,17 +2155,17 @@ nsWindow::OnExposeEvent(cairo_t *cr)
     nsRefPtr<gfxContext> ctx;
     if (gfxPlatform::GetPlatform()->
             SupportsAzureContentForType(BackendType::CAIRO)) {
         IntSize intSize(surf->GetSize().width, surf->GetSize().height);
         ctx = new gfxContext(gfxPlatform::GetPlatform()->
             CreateDrawTargetForSurface(surf, intSize));
     } else if (gfxPlatform::GetPlatform()->
                    SupportsAzureContentForType(BackendType::SKIA) &&
-               surf->GetType() != gfxSurfaceTypeImage) {
+               surf->GetType() != gfxSurfaceType::Image) {
        gfxImageSurface* imgSurf = static_cast<gfxImageSurface*>(surf);
        SurfaceFormat format = ImageFormatToSurfaceFormat(imgSurf->Format());
        IntSize intSize(surf->GetSize().width, surf->GetSize().height);
        ctx = new gfxContext(gfxPlatform::GetPlatform()->CreateDrawTargetForData(
            imgSurf->Data(), intSize, imgSurf->Stride(), format));
     }  else {
         ctx = new gfxContext(surf);
     }
--- a/widget/qt/nsNativeThemeQt.cpp
+++ b/widget/qt/nsNativeThemeQt.cpp
@@ -88,41 +88,41 @@ nsNativeThemeQt::DrawWidgetBackground(ns
                                       uint8_t aWidgetType,
                                       const nsRect& aRect,
                                       const nsRect& aClipRect)
 {
     gfxContext* context = aContext->ThebesContext();
     nsRefPtr<gfxASurface> surface = context->CurrentSurface();
 
 #ifdef CAIRO_HAS_QT_SURFACE
-    if (surface->GetType() == gfxSurfaceTypeQPainter) {
+    if (surface->GetType() == gfxSurfaceType::QPainter) {
         gfxQPainterSurface* qSurface = (gfxQPainterSurface*) (surface.get());
         QPainter *painter = qSurface->GetQPainter();
         NS_ASSERTION(painter, "Where'd my QPainter go?");
         if (!painter)
             return NS_ERROR_FAILURE;
         return DrawWidgetBackground(painter, aContext,
                                     aFrame, aWidgetType,
                                     aRect, aClipRect);
     } else
 #endif
-    if (surface->GetType() == gfxSurfaceTypeImage) {
+    if (surface->GetType() == gfxSurfaceType::Image) {
         gfxImageSurface* qSurface = (gfxImageSurface*) (surface.get());
         QImage tempQImage(qSurface->Data(),
                           qSurface->Width(),
                           qSurface->Height(),
                           qSurface->Stride(),
                           _qimage_from_gfximage_format(qSurface->Format()));
         QPainter painter(&tempQImage);
         return DrawWidgetBackground(&painter, aContext,
                                     aFrame, aWidgetType,
                                     aRect, aClipRect);
     }
 #if defined(MOZ_X11) && defined(Q_WS_X11)
-    else if (surface->GetType() == gfxSurfaceTypeXlib) {
+    else if (surface->GetType() == gfxSurfaceType::Xlib) {
         gfxXlibSurface* qSurface = (gfxXlibSurface*) (surface.get());
         QPixmap pixmap(QPixmap::fromX11Pixmap(qSurface->XDrawable()));
         QPainter painter(&pixmap);
         return DrawWidgetBackground(&painter, aContext,
                                     aFrame, aWidgetType,
                                     aRect, aClipRect);
     }
 #endif
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -284,17 +284,17 @@ UpdateOffScreenBuffers(int aDepth, QSize
 
     // Use fallback RGB24 format, Qt will do conversion for us
     if (format == gfxImageFormat::Unknown)
         format = gfxImageFormat::RGB24;
 
 #ifdef MOZ_HAVE_SHMIMAGE
     if (aWidget) {
         if (gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType() ==
-            gfxSurfaceTypeImage) {
+            gfxSurfaceType::Image) {
             gShmImage = nsShmImage::Create(gBufferMaxSize,
                                            DefaultVisualOfScreen(gfxQtPlatform::GetXScreen(aWidget)),
                                            aDepth);
             gBufferSurface = gShmImage->AsSurface();
             return true;
         }
     }
 #endif
@@ -1092,52 +1092,52 @@ nsWindow::DoPaint(QPainter* aPainter, co
     if (!painted)
         return false;
 
     LOGDRAW(("[%p] draw done\n", this));
 
     // Handle buffered painting mode
     if (renderMode == gfxQtPlatform::RENDER_BUFFERED) {
 #if defined(MOZ_X11) && defined(Q_WS_X11)
-        if (gBufferSurface->GetType() == gfxSurfaceTypeXlib) {
+        if (gBufferSurface->GetType() == gfxSurfaceType::Xlib) {
             // Paint offscreen pixmap to QPainter
             static QPixmap gBufferPixmap;
             Drawable draw = static_cast<gfxXlibSurface*>(gBufferSurface.get())->XDrawable();
             if (gBufferPixmap.handle() != draw)
                 gBufferPixmap = QPixmap::fromX11Pixmap(draw, QPixmap::ExplicitlyShared);
             XSync(static_cast<gfxXlibSurface*>(gBufferSurface.get())->XDisplay(), False);
             aPainter->drawPixmap(QPoint(rect.x, rect.y), gBufferPixmap,
                                  QRect(0, 0, rect.width, rect.height));
 
         } else
 #endif
-        if (gBufferSurface->GetType() == gfxSurfaceTypeImage) {
+        if (gBufferSurface->GetType() == gfxSurfaceType::Image) {
             // in raster mode we can just wrap gBufferImage as QImage and paint directly
             gfxImageSurface *imgs = static_cast<gfxImageSurface*>(gBufferSurface.get());
             QImage img(imgs->Data(),
                        imgs->Width(),
                        imgs->Height(),
                        imgs->Stride(),
                        _gfximage_to_qformat(imgs->Format()));
             aPainter->drawImage(QPoint(rect.x, rect.y), img,
                                 QRect(0, 0, rect.width, rect.height));
         }
     } else if (renderMode == gfxQtPlatform::RENDER_DIRECT) {
         QRect trans = aPainter->transform().mapRect(r).toRect();
 #ifdef MOZ_X11
-        if (gBufferSurface->GetType() == gfxSurfaceTypeXlib) {
+        if (gBufferSurface->GetType() == gfxSurfaceType::Xlib) {
             nsRefPtr<gfxASurface> widgetSurface = GetSurfaceForQWidget(aWidget);
             nsRefPtr<gfxContext> ctx = new gfxContext(widgetSurface);
             ctx->SetSource(gBufferSurface);
             ctx->Rectangle(gfxRect(trans.x(), trans.y(), trans.width(), trans.height()), true);
             ctx->Clip();
             ctx->Fill();
         } else
 #endif
-        if (gBufferSurface->GetType() == gfxSurfaceTypeImage) {
+        if (gBufferSurface->GetType() == gfxSurfaceType::Image) {
 #ifdef MOZ_HAVE_SHMIMAGE
             if (gShmImage) {
                 gShmImage->Put(aWidget, trans);
             } else
 #endif
             {
                 // Qt should take care about optimized rendering on QImage into painter device (gl/fb/image et.c.)
                 gfxImageSurface *imgs = static_cast<gfxImageSurface*>(gBufferSurface.get());
--- a/widget/shared/nsShmImage.cpp
+++ b/widget/shared/nsShmImage.cpp
@@ -20,17 +20,17 @@
 using namespace mozilla::ipc;
 
 // If XShm isn't available to our client, we'll try XShm once, fail,
 // set this to false and then never try again.
 static bool gShmAvailable = true;
 bool nsShmImage::UseShm()
 {
     return gfxPlatform::GetPlatform()->
-        ScreenReferenceSurface()->GetType() == gfxSurfaceTypeImage
+        ScreenReferenceSurface()->GetType() == gfxSurfaceType::Image
         && gShmAvailable;
 }
 
 already_AddRefed<nsShmImage>
 nsShmImage::Create(const gfxIntSize& aSize,
                    Visual* aVisual, unsigned int aDepth)
 {
     Display* dpy = DISPLAY();