Bug 958375 - 6/9 - Make BackendType and NativeSurfaceType typed enums - r=Bas
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 10 Jan 2014 14:06:16 -0500
changeset 167279 12e72f2f90e3e6031e94d6b29bf78e0a979513d3
parent 167278 82472493052dd05e4ab183b28d304fc6b48cf9b7
child 167280 a605e6378301c38ce4ee81260cc5b6c9779161b5
push idunknown
push userunknown
push dateunknown
reviewersBas
bugs958375
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 958375 - 6/9 - Make BackendType and NativeSurfaceType typed enums - r=Bas Specifically: r=Bas for manual changes f=Bas for automatic changes See attachments on the bug for the specific breakdown.
gfx/2d/DrawTargetCG.cpp
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetCairo.h
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetD2D.h
gfx/2d/DrawTargetD2D1.cpp
gfx/2d/DrawTargetD2D1.h
gfx/2d/DrawTargetRecording.cpp
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
gfx/2d/Factory.cpp
gfx/2d/FilterNodeD2D1.cpp
gfx/2d/FilterNodeSoftware.cpp
gfx/2d/GradientStopsD2D.h
gfx/2d/PathCG.h
gfx/2d/PathCairo.h
gfx/2d/PathD2D.h
gfx/2d/PathRecording.h
gfx/2d/PathSkia.h
gfx/2d/RecordedEvent.cpp
gfx/2d/ScaledFontBase.cpp
gfx/2d/ScaledFontDWrite.cpp
gfx/2d/ScaledFontMac.cpp
gfx/2d/SourceSurfaceCG.cpp
gfx/2d/Types.h
gfx/2d/unittest/TestBugs.cpp
gfx/2d/unittest/TestDrawTargetD2D.cpp
gfx/gl/GLReadTexImageHelper.cpp
gfx/layers/RotatedBuffer.cpp
gfx/layers/client/TextureClient.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/d3d10/CanvasLayerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d11/TextureD3D11.h
gfx/layers/d3d9/CanvasLayerD3D9.cpp
gfx/layers/d3d9/TextureD3D9.h
gfx/layers/d3d9/ThebesLayerD3D9.cpp
gfx/thebes/gfxAndroidPlatform.cpp
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxGradientCache.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxQuartzNativeDrawing.cpp
gfx/thebes/gfxWindowsNativeDrawing.cpp
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxXlibNativeRenderer.cpp
layout/base/FrameLayerBuilder.cpp
layout/base/nsLayoutUtils.cpp
widget/android/AndroidBridge.cpp
widget/cocoa/nsChildView.mm
widget/gtk/nsWindow.cpp
widget/windows/nsWindowGfx.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -156,19 +156,19 @@ DrawTargetCG::~DrawTargetCG()
 }
 
 BackendType
 DrawTargetCG::GetType() const
 {
   // It may be worth spliting Bitmap and IOSurface DrawTarget
   // into seperate classes.
   if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
-    return BACKEND_COREGRAPHICS_ACCELERATED;
+    return BackendType::COREGRAPHICS_ACCELERATED;
   } else {
-    return BACKEND_COREGRAPHICS;
+    return BackendType::COREGRAPHICS;
   }
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetCG::Snapshot()
 {
   if (!mSnapshot) {
     if (GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
@@ -385,19 +385,19 @@ class GradientStopsCG : public GradientS
       }
     }
 
   }
   virtual ~GradientStopsCG() {
     if (mGradient)
         CGGradientRelease(mGradient);
   }
-  // Will always report BACKEND_COREGRAPHICS, but it is compatible
-  // with BACKEND_COREGRAPHICS_ACCELERATED
-  BackendType GetBackendType() const { return BACKEND_COREGRAPHICS; }
+  // Will always report BackendType::COREGRAPHICS, but it is compatible
+  // with BackendType::COREGRAPHICS_ACCELERATED
+  BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
   // XXX this should be a union
   CGGradientRef mGradient;
   std::vector<GradientStop> mStops;
   ExtendMode mExtend;
 };
 
 TemporaryRef<GradientStops>
 DrawTargetCG::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops,
@@ -987,17 +987,17 @@ DrawTargetCG::Stroke(const Path *aPath, 
   CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
 
 
   CGContextBeginPath(cg);
 
-  assert(aPath->GetBackendType() == BACKEND_COREGRAPHICS);
+  assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
   const PathCG *cgPath = static_cast<const PathCG*>(aPath);
   CGContextAddPath(cg, cgPath->GetPath());
 
   SetStrokeOptions(cg, aStrokeOptions);
 
   if (isGradient(aPattern)) {
     CGContextReplacePathWithStrokedPath(cg);
     CGRect extents = CGContextGetPathBoundingBox(cg);
@@ -1015,17 +1015,17 @@ DrawTargetCG::Stroke(const Path *aPath, 
   CGContextRestoreGState(mCg);
 }
 
 void
 DrawTargetCG::Fill(const Path *aPath, const Pattern &aPattern, const DrawOptions &aDrawOptions)
 {
   MarkChanged();
 
-  assert(aPath->GetBackendType() == BACKEND_COREGRAPHICS);
+  assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
 
   CGContextSaveGState(mCg);
 
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(cg, aDrawOptions.mAlpha);
   CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
@@ -1276,35 +1276,35 @@ DrawTargetCG::Init(BackendType aType,
     return false;
   }
 
   //XXX: handle SurfaceFormat
 
   //XXX: we'd be better off reusing the Colorspace across draw targets
   mColorSpace = CGColorSpaceCreateDeviceRGB();
 
-  if (aData == nullptr && aType != BACKEND_COREGRAPHICS_ACCELERATED) {
+  if (aData == nullptr && aType != BackendType::COREGRAPHICS_ACCELERATED) {
     // XXX: Currently, Init implicitly clears, that can often be a waste of time
     mData.Realloc(aStride * aSize.height);
     aData = static_cast<unsigned char*>(mData);
     memset(aData, 0, aStride * aSize.height);
   }
 
   mSize = aSize;
 
-  if (aType == BACKEND_COREGRAPHICS_ACCELERATED) {
+  if (aType == BackendType::COREGRAPHICS_ACCELERATED) {
     RefPtr<MacIOSurface> ioSurface = MacIOSurface::CreateIOSurface(aSize.width, aSize.height);
     mCg = ioSurface->CreateIOSurfaceContext();
     // If we don't have the symbol for 'CreateIOSurfaceContext' mCg will be null
     // and we will fallback to software below
   }
 
   mFormat = SurfaceFormat::B8G8R8A8;
 
-  if (!mCg || aType == BACKEND_COREGRAPHICS) {
+  if (!mCg || aType == BackendType::COREGRAPHICS) {
     int bitsPerComponent = 8;
 
     CGBitmapInfo bitinfo;
     if (aFormat == SurfaceFormat::A8) {
       if (mColorSpace)
         CGColorSpaceRelease(mColorSpace);
       mColorSpace = nullptr;
       bitinfo = kCGImageAlphaOnly;
@@ -1339,17 +1339,17 @@ DrawTargetCG::Init(BackendType aType,
   // to have competitive performance with other canvas
   // implementation.
   // XXX: Create input parameter to control interpolation and
   //      use the default for content.
   CGContextSetInterpolationQuality(mCg, kCGInterpolationLow);
   CGContextSetShouldSmoothFonts(mCg, GetPermitSubpixelAA());
 
 
-  if (aType == BACKEND_COREGRAPHICS_ACCELERATED) {
+  if (aType == BackendType::COREGRAPHICS_ACCELERATED) {
     // The bitmap backend uses callac to clear, we can't do that without
     // reading back the surface. This should trigger something equivilent
     // to glClear.
     ClearRect(Rect(0, 0, mSize.width, mSize.height));
   }
 
   return true;
 }
@@ -1423,18 +1423,18 @@ DrawTargetCG::CreatePathBuilder(FillRule
 {
   RefPtr<PathBuilderCG> pb = new PathBuilderCG(aFillRule);
   return pb;
 }
 
 void*
 DrawTargetCG::GetNativeSurface(NativeSurfaceType aType)
 {
-  if ((aType == NATIVE_SURFACE_CGCONTEXT && GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP) ||
-      (aType == NATIVE_SURFACE_CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE)) {
+  if ((aType == NativeSurfaceType::CGCONTEXT && GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP) ||
+      (aType == NativeSurfaceType::CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE)) {
     return mCg;
   } else {
     return nullptr;
   }
 }
 
 void
 DrawTargetCG::Mask(const Pattern &aSource,
@@ -1485,17 +1485,17 @@ DrawTargetCG::PushClipRect(const Rect &a
 
 
 void
 DrawTargetCG::PushClip(const Path *aPath)
 {
   CGContextSaveGState(mCg);
 
   CGContextBeginPath(mCg);
-  assert(aPath->GetBackendType() == BACKEND_COREGRAPHICS);
+  assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
 
   const PathCG *cgPath = static_cast<const PathCG*>(aPath);
 
   // Weirdly, CoreGraphics clips empty paths as all shown
   // but emtpy rects as all clipped.  We detect this situation and
   // workaround it appropriately
   if (CGPathIsEmpty(cgPath->GetPath())) {
     // XXX: should we return here?
@@ -1539,17 +1539,17 @@ void
 DrawTargetCG::SetPermitSubpixelAA(bool aPermitSubpixelAA) {
   DrawTarget::SetPermitSubpixelAA(aPermitSubpixelAA);
   CGContextSetShouldSmoothFonts(mCg, aPermitSubpixelAA);
 }
 
 CGContextRef
 BorrowedCGContext::BorrowCGContextFromDrawTarget(DrawTarget *aDT)
 {
-  if (aDT->GetType() == BACKEND_COREGRAPHICS || aDT->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
+  if (aDT->GetType() == BackendType::COREGRAPHICS || aDT->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
     DrawTargetCG* cgDT = static_cast<DrawTargetCG*>(aDT);
     cgDT->MarkChanged();
 
     // swap out the context
     CGContextRef cg = cgDT->mCg;
     cgDT->mCg = nullptr;
 
     // save the state to make it easier for callers to avoid mucking with things
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -167,22 +167,22 @@ SupportsSelfCopy(cairo_surface_t* surfac
 static bool
 PatternIsCompatible(const Pattern& aPattern)
 {
   switch (aPattern.GetType())
   {
     case PATTERN_LINEAR_GRADIENT:
     {
       const LinearGradientPattern& pattern = static_cast<const LinearGradientPattern&>(aPattern);
-      return pattern.mStops->GetBackendType() == BACKEND_CAIRO;
+      return pattern.mStops->GetBackendType() == BackendType::CAIRO;
     }
     case PATTERN_RADIAL_GRADIENT:
     {
       const RadialGradientPattern& pattern = static_cast<const RadialGradientPattern&>(aPattern);
-      return pattern.mStops->GetBackendType() == BACKEND_CAIRO;
+      return pattern.mStops->GetBackendType() == BackendType::CAIRO;
     }
     default:
       return true;
   }
 }
 
 static cairo_user_data_key_t surfaceDataKey;
 
@@ -336,17 +336,17 @@ GfxPatternToCairoPattern(const Pattern& 
     }
     case PATTERN_LINEAR_GRADIENT:
     {
       const LinearGradientPattern& pattern = static_cast<const LinearGradientPattern&>(aPattern);
 
       pat = cairo_pattern_create_linear(pattern.mBegin.x, pattern.mBegin.y,
                                         pattern.mEnd.x, pattern.mEnd.y);
 
-      MOZ_ASSERT(pattern.mStops->GetBackendType() == BACKEND_CAIRO);
+      MOZ_ASSERT(pattern.mStops->GetBackendType() == BackendType::CAIRO);
       GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
       cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode()));
 
       matrix = &pattern.mMatrix;
 
       const std::vector<GradientStop>& stops = cairoStops->GetStops();
       for (size_t i = 0; i < stops.size(); ++i) {
         const GradientStop& stop = stops[i];
@@ -359,17 +359,17 @@ GfxPatternToCairoPattern(const Pattern& 
     }
     case PATTERN_RADIAL_GRADIENT:
     {
       const RadialGradientPattern& pattern = static_cast<const RadialGradientPattern&>(aPattern);
 
       pat = cairo_pattern_create_radial(pattern.mCenter1.x, pattern.mCenter1.y, pattern.mRadius1,
                                         pattern.mCenter2.x, pattern.mCenter2.y, pattern.mRadius2);
 
-      MOZ_ASSERT(pattern.mStops->GetBackendType() == BACKEND_CAIRO);
+      MOZ_ASSERT(pattern.mStops->GetBackendType() == BackendType::CAIRO);
       GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
       cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(cairoStops->GetExtendMode()));
 
       matrix = &pattern.mMatrix;
 
       const std::vector<GradientStop>& stops = cairoStops->GetStops();
       for (size_t i = 0; i < stops.size(); ++i) {
         const GradientStop& stop = stops[i];
@@ -829,33 +829,33 @@ DrawTargetCairo::StrokeLine(const Point 
 void
 DrawTargetCairo::Stroke(const Path *aPath,
                         const Pattern &aPattern,
                         const StrokeOptions &aStrokeOptions /* = StrokeOptions() */,
                         const DrawOptions &aOptions /* = DrawOptions() */)
 {
   AutoPrepareForDrawing prep(this, mContext, aPath);
 
-  if (aPath->GetBackendType() != BACKEND_CAIRO)
+  if (aPath->GetBackendType() != BackendType::CAIRO)
     return;
 
   PathCairo* path = const_cast<PathCairo*>(static_cast<const PathCairo*>(aPath));
   path->SetPathOnContext(mContext);
 
   DrawPattern(aPattern, aStrokeOptions, aOptions, DRAW_STROKE);
 }
 
 void
 DrawTargetCairo::Fill(const Path *aPath,
                       const Pattern &aPattern,
                       const DrawOptions &aOptions /* = DrawOptions() */)
 {
   AutoPrepareForDrawing prep(this, mContext, aPath);
 
-  if (aPath->GetBackendType() != BACKEND_CAIRO)
+  if (aPath->GetBackendType() != BackendType::CAIRO)
     return;
 
   PathCairo* path = const_cast<PathCairo*>(static_cast<const PathCairo*>(aPath));
   path->SetPathOnContext(mContext);
 
   DrawPattern(aPattern, StrokeOptions(), aOptions, DRAW_FILL);
 }
 
@@ -963,17 +963,17 @@ DrawTargetCairo::MaskSurface(const Patte
   cairo_surface_destroy(surf);
   cairo_pattern_destroy(mask);
   cairo_pattern_destroy(pat);
 }
 
 void
 DrawTargetCairo::PushClip(const Path *aPath)
 {
-  if (aPath->GetBackendType() != BACKEND_CAIRO) {
+  if (aPath->GetBackendType() != BackendType::CAIRO) {
     return;
   }
 
   WillChange(aPath);
   cairo_save(mContext);
 
   PathCairo* path = const_cast<PathCairo*>(static_cast<const PathCairo*>(aPath));
   path->SetPathOnContext(mContext);
@@ -1102,17 +1102,17 @@ TemporaryRef<SourceSurface>
 DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
   return aSurface;
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
-  if (aSurface.mType == NATIVE_SURFACE_CAIRO_SURFACE) {
+  if (aSurface.mType == NativeSurfaceType::CAIRO_SURFACE) {
     IntSize size;
     cairo_surface_t* surf = static_cast<cairo_surface_t*>(aSurface.mSurface);
     if (GetCairoSurfaceSize(surf, size)) {
       RefPtr<SourceSurfaceCairo> source =
         new SourceSurfaceCairo(surf, size, aSurface.mFormat);
       return source;
     }
   }
@@ -1235,20 +1235,20 @@ DrawTargetCairo::Init(unsigned char* aDa
                                         aSize.height,
                                         aStride);
   return InitAlreadyReferenced(surf, aSize);
 }
 
 void *
 DrawTargetCairo::GetNativeSurface(NativeSurfaceType aType)
 {
-  if (aType == NATIVE_SURFACE_CAIRO_SURFACE) {
+  if (aType == NativeSurfaceType::CAIRO_SURFACE) {
     return cairo_get_target(mContext);
   }
-  if (aType == NATIVE_SURFACE_CAIRO_CONTEXT) {
+  if (aType == NativeSurfaceType::CAIRO_CONTEXT) {
     return mContext;
   }
 
   return nullptr;
 }
 
 void
 DrawTargetCairo::MarkSnapshotIndependent()
@@ -1285,17 +1285,17 @@ DrawTargetCairo::GetUserSpaceClip()
   double clipX1, clipY1, clipX2, clipY2;
   cairo_clip_extents(mContext, &clipX1, &clipY1, &clipX2, &clipY2);
   return Rect(clipX1, clipY1, clipX2 - clipX1, clipY2 - clipY1); // Narrowing of doubles to floats
 }
 
 cairo_t*
 BorrowedCairoContext::BorrowCairoContextFromDrawTarget(DrawTarget* aDT)
 {
-  if (aDT->GetType() != BACKEND_CAIRO || aDT->IsDualDrawTarget()) {
+  if (aDT->GetType() != BackendType::CAIRO || aDT->IsDualDrawTarget()) {
     return nullptr;
   }
   DrawTargetCairo* cairoDT = static_cast<DrawTargetCairo*>(aDT);
 
   cairoDT->WillChange();
 
   // save the state to make it easier for callers to avoid mucking with things
   cairo_save(cairoDT->mContext);
@@ -1306,17 +1306,17 @@ BorrowedCairoContext::BorrowCairoContext
 
   return cairo;
 }
 
 void
 BorrowedCairoContext::ReturnCairoContextToDrawTarget(DrawTarget* aDT,
                                                      cairo_t* aCairo)
 {
-  if (aDT->GetType() != BACKEND_CAIRO || aDT->IsDualDrawTarget()) {
+  if (aDT->GetType() != BackendType::CAIRO || aDT->IsDualDrawTarget()) {
     return;
   }
   DrawTargetCairo* cairoDT = static_cast<DrawTargetCairo*>(aDT);
 
   cairo_restore(aCairo);
   cairoDT->mContext = aCairo;
 }
 
--- a/gfx/2d/DrawTargetCairo.h
+++ b/gfx/2d/DrawTargetCairo.h
@@ -36,32 +36,32 @@ class GradientStopsCairo : public Gradie
       return mStops;
     }
 
     ExtendMode GetExtendMode() const
     {
       return mExtendMode;
     }
 
-    virtual BackendType GetBackendType() const { return BACKEND_CAIRO; }
+    virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
 
   private:
     std::vector<GradientStop> mStops;
     ExtendMode mExtendMode;
 };
 
 class DrawTargetCairo : public DrawTarget
 {
 public:
   friend class BorrowedCairoContext;
 
   DrawTargetCairo();
   virtual ~DrawTargetCairo();
 
-  virtual BackendType GetType() const { return BACKEND_CAIRO; }
+  virtual BackendType GetType() const { return BackendType::CAIRO; }
   virtual TemporaryRef<SourceSurface> Snapshot();
   virtual IntSize GetSize();
 
   virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA);
 
   virtual bool LockBits(uint8_t** aData, IntSize* aSize,
                         int32_t* aStride, SurfaceFormat* aFormat);
   virtual void ReleaseBits(uint8_t* aData);
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -902,17 +902,17 @@ DrawTargetD2D::StrokeLine(const Point &a
 }
 
 void
 DrawTargetD2D::Stroke(const Path *aPath,
                       const Pattern &aPattern,
                       const StrokeOptions &aStrokeOptions,
                       const DrawOptions &aOptions)
 {
-  if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
+  if (aPath->GetBackendType() != BackendType::DIRECT2D) {
     gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
     return;
   }
 
   const PathD2D *d2dPath = static_cast<const PathD2D*>(aPath);
 
   ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
 
@@ -931,17 +931,17 @@ DrawTargetD2D::Stroke(const Path *aPath,
   FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, Rect(0, 0, Float(mSize.width), Float(mSize.height)));
 }
 
 void
 DrawTargetD2D::Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions)
 {
-  if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
+  if (aPath->GetBackendType() != BackendType::DIRECT2D) {
     gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
     return;
   }
 
   const PathD2D *d2dPath = static_cast<const PathD2D*>(aPath);
 
   ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
 
@@ -1081,17 +1081,17 @@ DrawTargetD2D::Mask(const Pattern &aSour
   PopCachedLayer(rt);
 
   FinalizeRTForOperation(aOptions.mCompositionOp, aSource, Rect(0, 0, (Float)mSize.width, (Float)mSize.height));
 }
 
 void
 DrawTargetD2D::PushClip(const Path *aPath)
 {
-  if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
+  if (aPath->GetBackendType() != BackendType::DIRECT2D) {
     gfxDebug() << *this << ": Ignoring clipping call for incompatible path.";
     return;
   }
 
   mCurrentClipMaskTexture = nullptr;
   mCurrentClippedGeometry = nullptr;
 
   RefPtr<PathD2D> pathD2D = static_cast<PathD2D*>(const_cast<Path*>(aPath));
@@ -1189,17 +1189,17 @@ DrawTargetD2D::OptimizeSourceSurface(Sou
 {
   // Unsupported!
   return nullptr;
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetD2D::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
 {
-  if (aSurface.mType != NATIVE_SURFACE_D3D10_TEXTURE) {
+  if (aSurface.mType != NativeSurfaceType::D3D10_TEXTURE) {
     gfxDebug() << *this << ": Failure to create source surface from non-D3D10 texture native surface.";
     return nullptr;
   }
   RefPtr<SourceSurfaceD2D> newSurf = new SourceSurfaceD2D();
 
   if (!newSurf->InitFromTexture(static_cast<ID3D10Texture2D*>(aSurface.mSurface),
                                 aSurface.mFormat,
                                 mRT))
@@ -1288,17 +1288,17 @@ DrawTargetD2D::CreateFilter(FilterType a
   }
 #endif
   return FilterNodeSoftware::Create(aType);
 }
 
 void*
 DrawTargetD2D::GetNativeSurface(NativeSurfaceType aType)
 {
-  if (aType != NATIVE_SURFACE_D3D10_TEXTURE) {
+  if (aType != NativeSurfaceType::D3D10_TEXTURE) {
     return nullptr;
   }
 
   return mTexture;
 }
 
 /*
  * Public functions
--- a/gfx/2d/DrawTargetD2D.h
+++ b/gfx/2d/DrawTargetD2D.h
@@ -41,17 +41,17 @@ struct PrivateD3D10DataD2D
 };
 
 class DrawTargetD2D : public DrawTarget
 {
 public:
   DrawTargetD2D();
   virtual ~DrawTargetD2D();
 
-  virtual BackendType GetType() const { return BACKEND_DIRECT2D; }
+  virtual BackendType GetType() const { return BackendType::DIRECT2D; }
   virtual TemporaryRef<SourceSurface> Snapshot();
   virtual IntSize GetSize() { return mSize; }
 
   virtual void Flush();
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(),
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -280,17 +280,17 @@ DrawTargetD2D1::StrokeLine(const Point &
 }
 
 void
 DrawTargetD2D1::Stroke(const Path *aPath,
                        const Pattern &aPattern,
                        const StrokeOptions &aStrokeOptions,
                        const DrawOptions &aOptions)
 {
-  if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
+  if (aPath->GetBackendType() != BackendType::DIRECT2D) {
     gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
     return;
   }
   const PathD2D *d2dPath = static_cast<const PathD2D*>(aPath);
 
   PrepareForDrawing(aOptions.mCompositionOp, aPattern);
 
   RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aPattern, aOptions.mAlpha);
@@ -301,17 +301,17 @@ DrawTargetD2D1::Stroke(const Path *aPath
   FinalizeDrawing(aOptions.mCompositionOp, aPattern);
 }
 
 void
 DrawTargetD2D1::Fill(const Path *aPath,
                      const Pattern &aPattern,
                      const DrawOptions &aOptions)
 {
-  if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
+  if (aPath->GetBackendType() != BackendType::DIRECT2D) {
     gfxDebug() << *this << ": Ignoring drawing call for incompatible path.";
     return;
   }
   const PathD2D *d2dPath = static_cast<const PathD2D*>(aPath);
 
   PrepareForDrawing(aOptions.mCompositionOp, aPattern);
 
   RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aPattern, aOptions.mAlpha);
@@ -425,17 +425,17 @@ DrawTargetD2D1::Mask(const Pattern &aSou
   mDC->PopLayer();
 
   FinalizeDrawing(aOptions.mCompositionOp, aSource);
 }
 
 void
 DrawTargetD2D1::PushClip(const Path *aPath)
 {
-  if (aPath->GetBackendType() != BACKEND_DIRECT2D) {
+  if (aPath->GetBackendType() != BackendType::DIRECT2D) {
     gfxDebug() << *this << ": Ignoring clipping call for incompatible path.";
     return;
   }
 
   RefPtr<PathD2D> pathD2D = static_cast<PathD2D*>(const_cast<Path*>(aPath));
 
   PushedClip clip;
   clip.mTransform = D2DMatrix(mTransform);
--- a/gfx/2d/DrawTargetD2D1.h
+++ b/gfx/2d/DrawTargetD2D1.h
@@ -33,17 +33,17 @@ class ScaledFontDWrite;
 const int32_t kLayerCacheSize1 = 5;
 
 class DrawTargetD2D1 : public DrawTarget
 {
 public:
   DrawTargetD2D1();
   virtual ~DrawTargetD2D1();
 
-  virtual BackendType GetType() const { return BACKEND_DIRECT2D1_1; }
+  virtual BackendType GetType() const { return BackendType::DIRECT2D1_1; }
   virtual TemporaryRef<SourceSurface> Snapshot();
   virtual IntSize GetSize() { return mSize; }
 
   virtual void Flush();
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions,
--- a/gfx/2d/DrawTargetRecording.cpp
+++ b/gfx/2d/DrawTargetRecording.cpp
@@ -44,17 +44,17 @@ public:
   {
   }
 
   ~GradientStopsRecording()
   {
     mRecorder->RecordEvent(RecordedGradientStopsDestruction(this));
   }
 
-  virtual BackendType GetBackendType() const { return BACKEND_RECORDING; }
+  virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
 
   RefPtr<GradientStops> mFinalGradientStops;
   RefPtr<DrawEventRecorderPrivate> mRecorder;
 };
 
 static SourceSurface *
 GetSourceSurface(SourceSurface *aSurface)
 {
@@ -63,17 +63,17 @@ GetSourceSurface(SourceSurface *aSurface
   }
 
   return static_cast<SourceSurfaceRecording*>(aSurface)->mFinalSurface;
 }
 
 static GradientStops *
 GetGradientStops(GradientStops *aStops)
 {
-  if (aStops->GetBackendType() != BACKEND_RECORDING) {
+  if (aStops->GetBackendType() != BackendType::RECORDING) {
     return aStops;
   }
 
   return static_cast<GradientStopsRecording*>(aStops)->mFinalGradientStops;
 }
 
 class FilterNodeRecording : public FilterNode
 {
@@ -260,17 +260,17 @@ DrawTargetRecording::StrokeLine(const Po
 {
   mRecorder->RecordEvent(RecordedStrokeLine(this, aBegin, aEnd, aPattern, aStrokeOptions, aOptions));
   mFinalDT->StrokeLine(aBegin, aEnd, *AdjustedPattern(aPattern), aStrokeOptions, aOptions);
 }
 
 Path*
 DrawTargetRecording::GetPathForPathRecording(const Path *aPath) const
 {
-  if (aPath->GetBackendType() != BACKEND_RECORDING) {
+  if (aPath->GetBackendType() != BackendType::RECORDING) {
     return nullptr;
   }
 
   return static_cast<const PathRecording*>(aPath)->mPath;
 }
 
 void
 DrawTargetRecording::Fill(const Path *aPath,
@@ -569,17 +569,17 @@ DrawTargetRecording::SetTransform(const 
   DrawTarget::SetTransform(aTransform);
   mFinalDT->SetTransform(aTransform);
 }
 
 void
 DrawTargetRecording::EnsureStored(const Path *aPath)
 {
   if (!mRecorder->HasStoredPath(aPath)) {
-    if (aPath->GetBackendType() != BACKEND_RECORDING) {
+    if (aPath->GetBackendType() != BackendType::RECORDING) {
       gfxWarning() << "Cannot record this fill path properly!";
     } else {
       PathRecording *recPath = const_cast<PathRecording*>(static_cast<const PathRecording*>(aPath));
       mRecorder->RecordEvent(RecordedPathCreation(recPath));
       mRecorder->AddStoredPath(aPath);
       recPath->mStoredRecorders.push_back(mRecorder);
     }
   }
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -64,17 +64,17 @@ public:
       mPositions[i + shift] = SkFloatToScalar(aStops[i].offset);
     }
     if (aStops[aNumStops-1].offset != 1) {
       mColors[mCount-1] = ColorToSkColor(aStops[aNumStops-1].color, 1.0);
       mPositions[mCount-1] = SK_Scalar1;
     }
   }
 
-  BackendType GetBackendType() const { return BACKEND_SKIA; }
+  BackendType GetBackendType() const { return BackendType::SKIA; }
 
   std::vector<SkColor> mColors;
   std::vector<SkScalar> mPositions;
   int mCount;
   ExtendMode mExtendMode;
 };
 
 #ifdef USE_SKIA_GPU
@@ -490,17 +490,17 @@ DrawTargetSkia::FillRect(const Rect &aRe
 void
 DrawTargetSkia::Stroke(const Path *aPath,
                        const Pattern &aPattern,
                        const StrokeOptions &aStrokeOptions,
                        const DrawOptions &aOptions)
 {
   MarkChanged();
   MOZ_ASSERT(aPath, "Null path");
-  if (aPath->GetBackendType() != BACKEND_SKIA) {
+  if (aPath->GetBackendType() != BackendType::SKIA) {
     return;
   }
 
   const PathSkia *skiaPath = static_cast<const PathSkia*>(aPath);
 
 
   AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
   if (!StrokeOptionsToPaint(paint.mPaint, aStrokeOptions)) {
@@ -544,17 +544,17 @@ DrawTargetSkia::StrokeLine(const Point &
 }
 
 void
 DrawTargetSkia::Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions)
 {
   MarkChanged();
-  if (aPath->GetBackendType() != BACKEND_SKIA) {
+  if (aPath->GetBackendType() != BackendType::SKIA) {
     return;
   }
 
   const PathSkia *skiaPath = static_cast<const PathSkia*>(aPath);
 
   AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
 
   mCanvas->drawPath(skiaPath->GetPath(), paint.mPaint);
@@ -861,17 +861,17 @@ DrawTargetSkia::ClearRect(const Rect &aR
   paint.setXfermodeMode(SkXfermode::kSrc_Mode);
   mCanvas->drawPaint(paint);
   mCanvas->restore();
 }
 
 void
 DrawTargetSkia::PushClip(const Path *aPath)
 {
-  if (aPath->GetBackendType() != BACKEND_SKIA) {
+  if (aPath->GetBackendType() != BackendType::SKIA) {
     return;
   }
 
   const PathSkia *skiaPath = static_cast<const PathSkia*>(aPath);
   mCanvas->save(SkCanvas::kClip_SaveFlag);
   mCanvas->clipPath(skiaPath->GetPath(), SkRegion::kIntersect_Op, true);
 }
 
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -24,17 +24,17 @@ namespace gfx {
 class SourceSurfaceSkia;
 
 class DrawTargetSkia : public DrawTarget
 {
 public:
   DrawTargetSkia();
   virtual ~DrawTargetSkia();
 
-  virtual BackendType GetType() const { return BACKEND_SKIA; }
+  virtual BackendType GetType() const { return BackendType::SKIA; }
   virtual TemporaryRef<SourceSurface> Snapshot();
   virtual IntSize GetSize() { return mSize; }
   virtual void Flush();
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(),
                            const DrawOptions &aOptions = DrawOptions());
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -182,61 +182,61 @@ Factory::HasSSE2()
 }
 
 TemporaryRef<DrawTarget>
 Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat)
 {
   RefPtr<DrawTarget> retVal;
   switch (aBackend) {
 #ifdef WIN32
-  case BACKEND_DIRECT2D:
+  case BackendType::DIRECT2D:
     {
       RefPtr<DrawTargetD2D> newTarget;
       newTarget = new DrawTargetD2D();
       if (newTarget->Init(aSize, aFormat)) {
         retVal = newTarget;
       }
       break;
     }
 #ifdef USE_D2D1_1
-  case BACKEND_DIRECT2D1_1:
+  case BackendType::DIRECT2D1_1:
     {
       RefPtr<DrawTargetD2D1> newTarget;
       newTarget = new DrawTargetD2D1();
       if (newTarget->Init(aSize, aFormat)) {
         retVal = newTarget;
       }
       break;
     }
 #endif
 #elif defined XP_MACOSX
-  case BACKEND_COREGRAPHICS:
-  case BACKEND_COREGRAPHICS_ACCELERATED:
+  case BackendType::COREGRAPHICS:
+  case BackendType::COREGRAPHICS_ACCELERATED:
     {
       RefPtr<DrawTargetCG> newTarget;
       newTarget = new DrawTargetCG();
       if (newTarget->Init(aBackend, aSize, aFormat)) {
         retVal = newTarget;
       }
       break;
     }
 #endif
 #ifdef USE_SKIA
-  case BACKEND_SKIA:
+  case BackendType::SKIA:
     {
       RefPtr<DrawTargetSkia> newTarget;
       newTarget = new DrawTargetSkia();
       if (newTarget->Init(aSize, aFormat)) {
         retVal = newTarget;
       }
       break;
     }
 #endif
 #ifdef USE_CAIRO
-  case BACKEND_CAIRO:
+  case BackendType::CAIRO:
     {
       RefPtr<DrawTargetCairo> newTarget;
       newTarget = new DrawTargetCairo();
       if (newTarget->Init(aSize, aFormat)) {
         retVal = newTarget;
       }
       break;
     }
@@ -249,17 +249,17 @@ Factory::CreateDrawTarget(BackendType aB
   if (mRecorder && retVal) {
     RefPtr<DrawTarget> recordDT;
     recordDT = new DrawTargetRecording(mRecorder, retVal);
     return recordDT;
   }
 
   if (!retVal) {
     // Failed
-    gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
+    gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
   }
   
   return retVal;
 }
 
 TemporaryRef<DrawTarget>
 Factory::CreateRecordingDrawTarget(DrawEventRecorder *aRecorder, DrawTarget *aDT)
 {
@@ -272,35 +272,35 @@ Factory::CreateDrawTargetForData(Backend
                                  const IntSize &aSize, 
                                  int32_t aStride, 
                                  SurfaceFormat aFormat)
 {
   RefPtr<DrawTarget> retVal;
 
   switch (aBackend) {
 #ifdef USE_SKIA
-  case BACKEND_SKIA:
+  case BackendType::SKIA:
     {
       RefPtr<DrawTargetSkia> newTarget;
       newTarget = new DrawTargetSkia();
       newTarget->Init(aData, aSize, aStride, aFormat);
       retVal = newTarget;
     }
 #endif
 #ifdef XP_MACOSX
-  case BACKEND_COREGRAPHICS:
+  case BackendType::COREGRAPHICS:
     {
       RefPtr<DrawTargetCG> newTarget = new DrawTargetCG();
       if (newTarget->Init(aBackend, aData, aSize, aStride, aFormat))
         return newTarget;
       break;
     }
 #endif
 #ifdef USE_CAIRO
-  case BACKEND_CAIRO:
+  case BackendType::CAIRO:
     {
       RefPtr<DrawTargetCairo> newTarget;
       newTarget = new DrawTargetCairo();
       if (newTarget->Init(aData, aSize, aStride, aFormat)) {
         retVal = newTarget;
       }
       break;
     }
@@ -311,17 +311,17 @@ Factory::CreateDrawTargetForData(Backend
   }
 
   if (mRecorder && retVal) {
     RefPtr<DrawTarget> recordDT = new DrawTargetRecording(mRecorder, retVal, true);
     return recordDT;
   }
 
   if (!retVal) {
-    gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
+    gfxDebug() << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize;
   }
 
   return retVal;
 }
 
 TemporaryRef<ScaledFont>
 Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize)
 {
--- a/gfx/2d/FilterNodeD2D1.cpp
+++ b/gfx/2d/FilterNodeD2D1.cpp
@@ -123,17 +123,17 @@ D2D1_CHANNEL_SELECTOR D2DChannelSelector
   }
 
   MOZ_CRASH("Unknown enum value!");
   return D2D1_CHANNEL_SELECTOR_R;
 }
 
 TemporaryRef<ID2D1Image> GetImageForSourceSurface(DrawTarget *aDT, SourceSurface *aSurface)
 {
-  if (aDT->GetType() == BACKEND_DIRECT2D1_1) {
+  if (aDT->GetType() == BackendType::DIRECT2D1_1) {
     return static_cast<DrawTargetD2D1*>(aDT)->GetImageForSurface(aSurface, EXTEND_CLAMP);
   }
   RefPtr<ID2D1Image> image;
   switch (aSurface->GetType()) {
   case SurfaceType::D2D1_1_IMAGE:
     image = static_cast<SourceSurfaceD2D1*>(aSurface)->GetImage();
     static_cast<SourceSurfaceD2D1*>(aSurface)->EnsureIndependent();
     break;
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -983,17 +983,17 @@ FilterNodeTransformSoftware::Render(cons
 
   Matrix transform = Matrix().Translate(srcRect.x, srcRect.y) * mMatrix *
                      Matrix().Translate(-aRect.x, -aRect.y);
   if (transform.IsIdentity() && srcRect.Size() == aRect.Size()) {
     return input;
   }
 
   RefPtr<DrawTarget> dt =
-    Factory::CreateDrawTarget(BACKEND_CAIRO, aRect.Size(), input->GetFormat());
+    Factory::CreateDrawTarget(BackendType::CAIRO, aRect.Size(), input->GetFormat());
   if (!dt) {
     return nullptr;
   }
 
   Rect r(0, 0, srcRect.width, srcRect.height);
   dt->SetTransform(transform);
   dt->DrawSurface(input, r, r, DrawSurfaceOptions(mFilter));
 
--- a/gfx/2d/GradientStopsD2D.h
+++ b/gfx/2d/GradientStopsD2D.h
@@ -15,17 +15,17 @@ namespace gfx {
 
 class GradientStopsD2D : public GradientStops
 {
 public:
   GradientStopsD2D(ID2D1GradientStopCollection *aStopCollection)
     : mStopCollection(aStopCollection)
   {}
 
-  virtual BackendType GetBackendType() const { return BACKEND_DIRECT2D; }
+  virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
 
 private:
   friend class DrawTargetD2D;
   friend class DrawTargetD2D1;
 
   mutable RefPtr<ID2D1GradientStopCollection> mStopCollection;
 };
 
--- a/gfx/2d/PathCG.h
+++ b/gfx/2d/PathCG.h
@@ -64,19 +64,19 @@ public:
   PathCG(CGMutablePathRef aPath, FillRule aFillRule)
     : mPath(aPath)
     , mFillRule(aFillRule)
   {
     CGPathRetain(mPath);
   }
   virtual ~PathCG() { CGPathRelease(mPath); }
 
-  // Paths will always return BACKEND_COREGRAPHICS, but note that they
-  // are compatible with BACKEND_COREGRAPHICS_ACCELERATED backend.
-  virtual BackendType GetBackendType() const { return BACKEND_COREGRAPHICS; }
+  // Paths will always return BackendType::COREGRAPHICS, but note that they
+  // are compatible with BackendType::COREGRAPHICS_ACCELERATED backend.
+  virtual BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
 
   virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
--- a/gfx/2d/PathCairo.h
+++ b/gfx/2d/PathCairo.h
@@ -47,17 +47,17 @@ private: // data
 
 class PathCairo : public Path
 {
 public:
   PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint);
   PathCairo(cairo_t *aContext);
   ~PathCairo();
 
-  virtual BackendType GetBackendType() const { return BACKEND_CAIRO; }
+  virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
 
   virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
 
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
--- a/gfx/2d/PathD2D.h
+++ b/gfx/2d/PathD2D.h
@@ -63,17 +63,17 @@ public:
   PathD2D(ID2D1PathGeometry *aGeometry, bool aEndedActive,
           const Point &aEndPoint, FillRule aFillRule)
     : mGeometry(aGeometry)
     , mEndedActive(aEndedActive)
     , mEndPoint(aEndPoint)
     , mFillRule(aFillRule)
   {}
   
-  virtual BackendType GetBackendType() const { return BACKEND_DIRECT2D; }
+  virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
 
   virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
 
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
--- a/gfx/2d/PathRecording.h
+++ b/gfx/2d/PathRecording.h
@@ -84,17 +84,17 @@ class PathRecording : public Path
 public:
   PathRecording(Path *aPath, const std::vector<PathOp> aOps, FillRule aFillRule)
     : mPath(aPath), mPathOps(aOps), mFillRule(aFillRule)
   {
   }
 
   ~PathRecording();
 
-  virtual BackendType GetBackendType() const { return BACKEND_RECORDING; }
+  virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
   virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FILL_WINDING) const;
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
   { return mPath->ContainsPoint(aPoint, aTransform); }
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const
--- a/gfx/2d/PathSkia.h
+++ b/gfx/2d/PathSkia.h
@@ -47,17 +47,17 @@ class PathSkia : public Path
 {
 public:
   PathSkia(SkPath& aPath, FillRule aFillRule)
     : mFillRule(aFillRule)
   {
     mPath.swap(aPath);
   }
   
-  virtual BackendType GetBackendType() const { return BACKEND_SKIA; }
+  virtual BackendType GetBackendType() const { return BackendType::SKIA; }
 
   virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
                                                              FillRule aFillRule = FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
   
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -12,19 +12,19 @@
 namespace mozilla {
 namespace gfx {
 
 using namespace std;
 
 static std::string NameFromBackend(BackendType aType)
 {
   switch (aType) {
-  case BACKEND_NONE:
+  case BackendType::NONE:
     return "None";
-  case BACKEND_DIRECT2D:
+  case BackendType::DIRECT2D:
     return "Direct2D";
   default:
     return "Unknown";
   }
 }
 
 #define LOAD_EVENT_TYPE(_typeenum, _class) \
   case _typeenum: return new _class(aStream)
--- a/gfx/2d/ScaledFontBase.cpp
+++ b/gfx/2d/ScaledFontBase.cpp
@@ -74,27 +74,27 @@ ScaledFontBase::GetSkiaPathForGlyphs(con
   return path;
 }
 #endif
 
 TemporaryRef<Path>
 ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
 #ifdef USE_SKIA
-  if (aTarget->GetType() == BACKEND_SKIA) {
+  if (aTarget->GetType() == BackendType::SKIA) {
     SkPath path = GetSkiaPathForGlyphs(aBuffer);
     return new PathSkia(path, FILL_WINDING);
   }
 #endif
 #ifdef USE_CAIRO
-  if (aTarget->GetType() == BACKEND_CAIRO) {
+  if (aTarget->GetType() == BackendType::CAIRO) {
     MOZ_ASSERT(mScaledFont);
 
     DrawTarget *dt = const_cast<DrawTarget*>(aTarget);
-    cairo_t *ctx = static_cast<cairo_t*>(dt->GetNativeSurface(NATIVE_SURFACE_CAIRO_CONTEXT));
+    cairo_t *ctx = static_cast<cairo_t*>(dt->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
 
     bool isNewContext = !ctx;
     if (!ctx) {
       ctx = cairo_create(DrawTargetCairo::GetDummySurface());
       cairo_matrix_t mat;
       GfxMatrixToCairoMatrix(aTarget->GetTransform(), mat);
       cairo_set_matrix(ctx, &mat);
     }
@@ -123,24 +123,24 @@ ScaledFontBase::GetPathForGlyphs(const G
 #endif
   return nullptr;
 }
 
 void
 ScaledFontBase::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint)
 {
 #ifdef USE_SKIA
-  if (aBackendType == BACKEND_SKIA) {
+  if (aBackendType == BackendType::SKIA) {
     PathBuilderSkia *builder = static_cast<PathBuilderSkia*>(aBuilder);
     builder->AppendPath(GetSkiaPathForGlyphs(aBuffer));
     return;
   }
 #endif
 #ifdef USE_CAIRO
-  if (aBackendType == BACKEND_CAIRO) {
+  if (aBackendType == BackendType::CAIRO) {
     MOZ_ASSERT(mScaledFont);
 
     PathBuilderCairo* builder = static_cast<PathBuilderCairo*>(aBuilder);
     cairo_t *ctx = cairo_create(DrawTargetCairo::GetDummySurface());
 
     if (aTransformHint) {
       cairo_matrix_t mat;
       GfxMatrixToCairoMatrix(*aTransformHint, mat);
--- a/gfx/2d/ScaledFontDWrite.cpp
+++ b/gfx/2d/ScaledFontDWrite.cpp
@@ -304,34 +304,34 @@ ScaledFontDWrite::ScaledFontDWrite(uint8
   if (FAILED(factory->CreateFontFace(DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &ff, aIndex, DWRITE_FONT_SIMULATIONS_NONE, byRef(mFontFace)))) {
     gfxWarning() << "Failed to create font face from font file data!";
   }
 }
 
 TemporaryRef<Path>
 ScaledFontDWrite::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
-  if (aTarget->GetType() != BACKEND_DIRECT2D) {
+  if (aTarget->GetType() != BackendType::DIRECT2D) {
     return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
   }
 
   RefPtr<PathBuilder> pathBuilder = aTarget->CreatePathBuilder();
 
   PathBuilderD2D *pathBuilderD2D =
     static_cast<PathBuilderD2D*>(pathBuilder.get());
 
   CopyGlyphsToSink(aBuffer, pathBuilderD2D->GetSink());
 
   return pathBuilder->Finish();
 }
 
 void
 ScaledFontDWrite::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint)
 {
-  if (aBackendType != BACKEND_DIRECT2D) {
+  if (aBackendType != BackendType::DIRECT2D) {
     ScaledFontBase::CopyGlyphsToBuilder(aBuffer, aBuilder, aBackendType, aTransformHint);
     return;
   }
 
   PathBuilderD2D *pathBuilderD2D =
     static_cast<PathBuilderD2D*>(aBuilder);
 
   CopyGlyphsToSink(aBuffer, pathBuilderD2D->GetSink());
--- a/gfx/2d/ScaledFontMac.cpp
+++ b/gfx/2d/ScaledFontMac.cpp
@@ -74,17 +74,17 @@ SkTypeface* ScaledFontMac::GetSkTypeface
 // ATSUGlyphGetCubicPaths
 // we've used this in cairo sucessfully for some time.
 // Note: cairo dlsyms it. We could do that but maybe it's
 // safe just to use?
 
 TemporaryRef<Path>
 ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
-  if (aTarget->GetType() == BACKEND_COREGRAPHICS || aTarget->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
+  if (aTarget->GetType() == BackendType::COREGRAPHICS || aTarget->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
       CGMutablePathRef path = CGPathCreateMutable();
 
       for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
           // XXX: we could probably fold both of these transforms together to avoid extra work
           CGAffineTransform flip = CGAffineTransformMakeScale(1, -1);
           CGPathRef glyphPath = ::CGFontGetGlyphPath(mFont, &flip, 0, aBuffer.mGlyphs[i].mIndex);
 
           CGAffineTransform matrix = CGAffineTransformMake(mSize, 0, 0, mSize,
@@ -99,17 +99,17 @@ ScaledFontMac::GetPathForGlyphs(const Gl
   } else {
       return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
   }
 }
 
 void
 ScaledFontMac::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint)
 {
-  if (!(aBackendType == BACKEND_COREGRAPHICS || aBackendType == BACKEND_COREGRAPHICS_ACCELERATED)) {
+  if (!(aBackendType == BackendType::COREGRAPHICS || aBackendType == BackendType::COREGRAPHICS_ACCELERATED)) {
     ScaledFontBase::CopyGlyphsToBuilder(aBuffer, aBuilder, aBackendType, aTransformHint);
     return;
   }
 
   PathBuilderCG *pathBuilderCG =
     static_cast<PathBuilderCG*>(aBuilder);
   // XXX: check builder type
   for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
--- a/gfx/2d/SourceSurfaceCG.cpp
+++ b/gfx/2d/SourceSurfaceCG.cpp
@@ -256,17 +256,17 @@ DataSourceSurfaceCG::GetData()
   // we need read-write for DataSourceSurfaces
   return (unsigned char*)mData;
 }
 
 SourceSurfaceCGBitmapContext::SourceSurfaceCGBitmapContext(DrawTargetCG *aDrawTarget)
 {
   mDrawTarget = aDrawTarget;
   mFormat = aDrawTarget->GetFormat();
-  mCg = (CGContextRef)aDrawTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT);
+  mCg = (CGContextRef)aDrawTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT);
   if (!mCg)
     abort();
 
   mSize.width = CGBitmapContextGetWidth(mCg);
   mSize.height = CGBitmapContextGetHeight(mCg);
   mStride = CGBitmapContextGetBytesPerRow(mCg);
   mData = CGBitmapContextGetData(mCg);
 
@@ -323,17 +323,17 @@ SourceSurfaceCGBitmapContext::DrawTarget
 SourceSurfaceCGBitmapContext::~SourceSurfaceCGBitmapContext()
 {
   if (mImage)
     CGImageRelease(mImage);
 }
 
 SourceSurfaceCGIOSurfaceContext::SourceSurfaceCGIOSurfaceContext(DrawTargetCG *aDrawTarget)
 {
-  CGContextRef cg = (CGContextRef)aDrawTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT_ACCELERATED);
+  CGContextRef cg = (CGContextRef)aDrawTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT_ACCELERATED);
 
   RefPtr<MacIOSurface> surf = MacIOSurface::IOSurfaceContextGetSurface(cg);
 
   mFormat = aDrawTarget->GetFormat();
   mSize.width = surf->GetWidth();
   mSize.height = surf->GetHeight();
 
   // TODO use CreateImageFromIOSurfaceContext instead of reading back the surface
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -66,46 +66,44 @@ MOZ_BEGIN_ENUM_CLASS(FilterType)
   SPOT_SPECULAR,
   DISTANT_DIFFUSE,
   DISTANT_SPECULAR,
   CROP,
   PREMULTIPLY,
   UNPREMULTIPLY
 MOZ_END_ENUM_CLASS(FilterType)
 
-enum BackendType
-{
-  BACKEND_NONE = 0,
-  BACKEND_DIRECT2D,
-  BACKEND_COREGRAPHICS,
-  BACKEND_COREGRAPHICS_ACCELERATED,
-  BACKEND_CAIRO,
-  BACKEND_SKIA,
-  BACKEND_RECORDING,
-  BACKEND_DIRECT2D1_1
-};
+MOZ_BEGIN_ENUM_CLASS(BackendType)
+  NONE = 0,
+  DIRECT2D,
+  COREGRAPHICS,
+  COREGRAPHICS_ACCELERATED,
+  CAIRO,
+  SKIA,
+  RECORDING,
+  DIRECT2D1_1
+MOZ_END_ENUM_CLASS(BackendType)
 
 enum FontType
 {
   FONT_DWRITE,
   FONT_GDI,
   FONT_MAC,
   FONT_SKIA,
   FONT_CAIRO,
   FONT_COREGRAPHICS
 };
 
-enum NativeSurfaceType
-{
-  NATIVE_SURFACE_D3D10_TEXTURE,
-  NATIVE_SURFACE_CAIRO_SURFACE,
-  NATIVE_SURFACE_CAIRO_CONTEXT,
-  NATIVE_SURFACE_CGCONTEXT,
-  NATIVE_SURFACE_CGCONTEXT_ACCELERATED
-};
+MOZ_BEGIN_ENUM_CLASS(NativeSurfaceType)
+  D3D10_TEXTURE,
+  CAIRO_SURFACE,
+  CAIRO_CONTEXT,
+  CGCONTEXT,
+  CGCONTEXT_ACCELERATED
+MOZ_END_ENUM_CLASS(NativeSurfaceType)
 
 enum NativeFontType
 {
   NATIVE_FONT_DWRITE_FONT_FACE,
   NATIVE_FONT_GDI_FONT_FACE,
   NATIVE_FONT_MAC_FONT_FACE,
   NATIVE_FONT_SKIA_FONT_FACE,
   NATIVE_FONT_CAIRO_FONT_FACE
--- a/gfx/2d/unittest/TestBugs.cpp
+++ b/gfx/2d/unittest/TestBugs.cpp
@@ -14,20 +14,20 @@ TestBugs::TestBugs()
 {
   REGISTER_TEST(TestBugs, CairoClip918671);
   REGISTER_TEST(TestBugs, PushPopClip950550);
 }
 
 void
 TestBugs::CairoClip918671()
 {
-  RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BACKEND_CAIRO,
+  RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BackendType::CAIRO,
                                                     IntSize(100, 100),
                                                     SurfaceFormat::B8G8R8A8);
-  RefPtr<DrawTarget> ref = Factory::CreateDrawTarget(BACKEND_CAIRO,
+  RefPtr<DrawTarget> ref = Factory::CreateDrawTarget(BackendType::CAIRO,
                                                      IntSize(100, 100),
                                                      SurfaceFormat::B8G8R8A8);
   // Create a path that extends around the center rect but doesn't intersect it.
   RefPtr<PathBuilder> pb1 = dt->CreatePathBuilder();
   pb1->MoveTo(Point(10, 10));
   pb1->LineTo(Point(90, 10));
   pb1->LineTo(Point(90, 20));
   pb1->LineTo(Point(10, 20));
@@ -66,17 +66,17 @@ TestBugs::CairoClip918671()
                   dataSurf1->GetSize().width * 4) == 0);
   }
 
 }
 
 void
 TestBugs::PushPopClip950550()
 {
-  RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BACKEND_CAIRO,
+  RefPtr<DrawTarget> dt = Factory::CreateDrawTarget(BackendType::CAIRO,
                                                     IntSize(500, 500),
                                                     SurfaceFormat::B8G8R8A8);
   dt->PushClipRect(Rect(0, 0, 100, 100));
   Matrix m(1, 0, 0, 1, 45, -100);
   dt->SetTransform(m);
   dt->PopClip();
 
   // We fail the test if we assert in this call because our draw target's
--- a/gfx/2d/unittest/TestDrawTargetD2D.cpp
+++ b/gfx/2d/unittest/TestDrawTargetD2D.cpp
@@ -14,10 +14,10 @@ TestDrawTargetD2D::TestDrawTargetD2D()
                        D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                        D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
                        D3D10_FEATURE_LEVEL_10_0,
                        D3D10_1_SDK_VERSION,
                        byRef(mDevice));
 
   Factory::SetDirect3D10Device(mDevice);
 
-  mDT = Factory::CreateDrawTarget(BACKEND_DIRECT2D, IntSize(DT_WIDTH, DT_HEIGHT), SurfaceFormat::B8G8R8A8);
+  mDT = Factory::CreateDrawTarget(BackendType::DIRECT2D, IntSize(DT_WIDTH, DT_HEIGHT), SurfaceFormat::B8G8R8A8);
 }
--- a/gfx/gl/GLReadTexImageHelper.cpp
+++ b/gfx/gl/GLReadTexImageHelper.cpp
@@ -406,17 +406,17 @@ ReadPixelsIntoImageSurface(GLContext* gl
 
 static TemporaryRef<DataSourceSurface> YInvertImageSurface(DataSourceSurface* aSurf)
 {
   RefPtr<DataSourceSurface> temp =
     Factory::CreateDataSourceSurfaceWithStride(aSurf->GetSize(),
                                                aSurf->GetFormat(),
                                                aSurf->Stride());
   RefPtr<DrawTarget> dt =
-    Factory::CreateDrawTargetForData(BACKEND_CAIRO,
+    Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                      temp->GetData(),
                                      temp->GetSize(),
                                      temp->Stride(),
                                      temp->GetFormat());
   nsRefPtr<gfxContext> ctx = new gfxContext(dt);
   ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
   ctx->Scale(1.0, -1.0);
   ctx->Translate(-gfxPoint(0.0, aSurf->GetSize().height));
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -96,17 +96,17 @@ RotatedBuffer::DrawBufferQuadrant(gfx::D
   gfx::Point quadrantTranslation(quadrantRect.x, quadrantRect.y);
 
   MOZ_ASSERT(aOperator == OP_OVER || aOperator == OP_SOURCE);
   // direct2d is much slower when using OP_SOURCE so use OP_OVER and
   // (maybe) a clear instead. Normally we need to draw in a single operation
   // (to avoid flickering) but direct2d is ok since it defers rendering.
   // We should try abstract this logic in a helper when we have other use
   // cases.
-  if (aTarget->GetType() == BACKEND_DIRECT2D && aOperator == OP_SOURCE) {
+  if (aTarget->GetType() == BackendType::DIRECT2D && aOperator == OP_SOURCE) {
     aOperator = OP_OVER;
     if (mDTBuffer->GetFormat() == SurfaceFormat::B8G8R8A8) {
       aTarget->ClearRect(ToRect(fillRect));
     }
   }
 
   RefPtr<gfx::SourceSurface> snapshot;
   if (aSource == BUFFER_BLACK) {
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -492,17 +492,17 @@ public:
   virtual gfxImageSurface* LockImageSurface() { return nullptr; }
   virtual gfxASurface* LockSurface() { return nullptr; }
   // If you implement LockDrawTarget, you MUST implement BackendType()
   virtual gfx::DrawTarget* LockDrawTarget() { return nullptr; }
 
   // The type of draw target returned by LockDrawTarget.
   virtual gfx::BackendType BackendType()
   {
-    return gfx::BACKEND_NONE;
+    return gfx::BackendType::NONE;
   }
 
   virtual void ReleaseResources() {}
   /**
    * This unlocks the current DrawableTexture and allows the host to composite
    * it directly.
    */
   virtual void Unlock() {}
@@ -585,17 +585,17 @@ public:
   {
     return aType == TEXTURE_SHMEM || aType == TEXTURE_CONTENT || aType == TEXTURE_FALLBACK;
   }
   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;
+    return gfx::BackendType::CAIRO;
   }
   virtual void Unlock() 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 gfxContentType GetContentType() MOZ_OVERRIDE { return mContentType; }
 private:
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -745,17 +745,17 @@ LayerManagerComposite::CreateDrawTarget(
   // We don't want to accelerate if the surface is too small which indicates
   // that it's likely used for an icon/static image. We also don't want to
   // accelerate anything that is above the maximum texture size of weakest gpu.
   // Safari uses 5000 area as the minimum for acceleration, we decided 64^2 is more logical.
   bool useAcceleration = aSize.width <= 4096 && aSize.height <= 4096 &&
                          aSize.width > 64 && aSize.height > 64 &&
                          gfxPlatformMac::GetPlatform()->UseAcceleratedCanvas();
   if (useAcceleration) {
-    return Factory::CreateDrawTarget(BACKEND_COREGRAPHICS_ACCELERATED,
+    return Factory::CreateDrawTarget(BackendType::COREGRAPHICS_ACCELERATED,
                                      aSize, aFormat);
   }
 #endif
   return LayerManager::CreateDrawTarget(aSize, aFormat);
 }
 
 LayerComposite::LayerComposite(LayerManagerComposite *aManager)
   : mCompositeManager(aManager)
--- a/gfx/layers/d3d10/CanvasLayerD3D10.cpp
+++ b/gfx/layers/d3d10/CanvasLayerD3D10.cpp
@@ -72,17 +72,17 @@ CanvasLayerD3D10::Initialize(const Data&
 
     if (factory) {
       screen->Morph(factory, streamType);
     }
   } else if (aData.mDrawTarget) {
     mDrawTarget = aData.mDrawTarget;
     mNeedsYFlip = false;
     mDataIsPremultiplied = true;
-    void *texture = mDrawTarget->GetNativeSurface(NATIVE_SURFACE_D3D10_TEXTURE);
+    void *texture = mDrawTarget->GetNativeSurface(NativeSurfaceType::D3D10_TEXTURE);
 
     if (texture) {
       mTexture = static_cast<ID3D10Texture2D*>(texture);
 
       NS_ASSERTION(!aData.mGLContext && !aData.mSurface,
                    "CanvasLayer can't have both surface and WebGLContext/Surface");
 
       mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
@@ -163,17 +163,17 @@ CanvasLayerD3D10::UpdateSurface()
         if (FAILED(hr)) {
           NS_WARNING("Failed to map CanvasLayer texture.");
           return;
         }
 
         DataSourceSurface* frameData = shareSurf->GetData();
         // Scope for gfxContext, so it's destroyed before Unmap.
         {
-          RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
+          RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                                                       (uint8_t*)map.pData,
                                                                       shareSurf->Size(),
                                                                       map.RowPitch,
                                                                       SurfaceFormat::B8G8R8A8);
 
           nsRefPtr<gfxImageSurface> thebesFrameData =
               new gfxImageSurface(frameData->GetData(),
                                   ThebesIntSize(frameData->GetSize()),
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -496,17 +496,17 @@ LayerManagerD3D10::CreateOptimalMaskSurf
 
 
 TemporaryRef<DrawTarget>
 LayerManagerD3D10::CreateDrawTarget(const IntSize &aSize,
                                     SurfaceFormat aFormat)
 {
   if ((aFormat != SurfaceFormat::B8G8R8A8 &&
        aFormat != SurfaceFormat::B8G8R8X8) ||
-       gfxPlatform::GetPlatform()->GetPreferredCanvasBackend() != BACKEND_DIRECT2D) {
+       gfxPlatform::GetPlatform()->GetPreferredCanvasBackend() != BackendType::DIRECT2D) {
     return LayerManager::CreateDrawTarget(aSize, aFormat);
   }
 
   nsRefPtr<ID3D10Texture2D> texture;
   
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, aSize.width, aSize.height, 1, 1);
   desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
   
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -230,17 +230,17 @@ public:
 
   virtual bool EnsureAllocated(gfx::IntSize aSize,
                                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;
+    return gfx::BackendType::DIRECT2D;
   }
 
   virtual void Unlock() MOZ_OVERRIDE;
 
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
   virtual gfxContentType GetContentType() MOZ_OVERRIDE
   {
     return mContentType;
--- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp
+++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp
@@ -99,17 +99,17 @@ CanvasLayerD3D9::UpdateSurface()
       return;
     }
 
     D3DLOCKED_RECT rect = textureLock.GetLockRect();
     
     DataSourceSurface* frameData = shareSurf->GetData();
     // Scope for gfxContext, so it's destroyed early.
     {
-      RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
+      RefPtr<DrawTarget> mapDt = Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                                                   (uint8_t*)rect.pBits,
                                                                   shareSurf->Size(),
                                                                   rect.Pitch,
                                                                   SurfaceFormat::B8G8R8A8);
 
       nsRefPtr<gfxImageSurface> thebesFrameData =
           new gfxImageSurface(frameData->GetData(),
                               ThebesIntSize(frameData->GetSize()),
--- a/gfx/layers/d3d9/TextureD3D9.h
+++ b/gfx/layers/d3d9/TextureD3D9.h
@@ -608,17 +608,17 @@ public:
 
   virtual bool EnsureAllocated(gfx::IntSize aSize,
                                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;
+    return gfx::BackendType::CAIRO;
   }
   virtual void Unlock() MOZ_OVERRIDE;
 
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
   virtual gfxContentType GetContentType() MOZ_OVERRIDE
   {
     return mContentType;
   }
@@ -649,17 +649,17 @@ public:
 
   virtual bool EnsureAllocated(gfx::IntSize aSize,
                                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;
+    return gfx::BackendType::CAIRO;
   }
   virtual void Unlock() MOZ_OVERRIDE;
 
   virtual SurfaceDescriptor* LockSurfaceDescriptor() MOZ_OVERRIDE;
   virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
   virtual gfxContentType GetContentType() MOZ_OVERRIDE
   {
     return mContentType;
--- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp
+++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp
@@ -475,17 +475,17 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion 
       break;
     }
   }
 
   if (!destinationSurface)
     return;
 
   nsRefPtr<gfxContext> context;
-  if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BACKEND_CAIRO)) {
+  if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BackendType::CAIRO)) {
      RefPtr<DrawTarget> dt =
         gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(destinationSurface,
                                                                IntSize(destinationSurface->GetSize().width,
                                                                        destinationSurface->GetSize().height));
 
     context = new gfxContext(dt);
   } else {
     context = new gfxContext(destinationSurface);
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -337,17 +337,17 @@ gfxAndroidPlatform::MakePlatformFont(con
                                                                      aFontData,
                                                                      aLength);
 }
 
 TemporaryRef<ScaledFont>
 gfxAndroidPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
 {
     NativeFont nativeFont;
-    if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
+    if (aTarget->GetType() == BackendType::CAIRO || aTarget->GetType() == BackendType::SKIA) {
         nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
         nativeFont.mFont = aFont->GetCairoScaledFont();
         return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
     }
 
     return nullptr;
 }
 
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -149,19 +149,19 @@ gfxContext::~gfxContext()
 
 gfxASurface *
 gfxContext::OriginalSurface()
 {
     if (mCairo || mSurface) {
         return mSurface;
     }
 
-    if (mOriginalDT && mOriginalDT->GetType() == BACKEND_CAIRO) {
+    if (mOriginalDT && mOriginalDT->GetType() == BackendType::CAIRO) {
         cairo_surface_t *s =
-            (cairo_surface_t*)mOriginalDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE);
+            (cairo_surface_t*)mOriginalDT->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE);
         if (s) {
             mSurface = gfxASurface::Wrap(s);
             return mSurface;
         }
     }
     return nullptr;
 }
 
@@ -176,19 +176,19 @@ gfxContext::CurrentSurface(gfxFloat *dx,
         nsRefPtr<gfxASurface> ret = mSurface;
         return ret.forget();
     }
 
     if (dx && dy)
         cairo_surface_get_device_offset(s, dx, dy);
     return gfxASurface::Wrap(s);
   } else {
-    if (mDT->GetType() == BACKEND_CAIRO) {
+    if (mDT->GetType() == BackendType::CAIRO) {
         cairo_surface_t *s =
-            (cairo_surface_t*)mDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE);
+            (cairo_surface_t*)mDT->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE);
         if (s) {
             if (dx && dy) {
                 *dx = -CurrentState().deviceOffset.x;
                 *dy = -CurrentState().deviceOffset.y;
             }
             return gfxASurface::Wrap(s);
         }
     }
@@ -203,19 +203,19 @@ gfxContext::CurrentSurface(gfxFloat *dx,
 
 cairo_t *
 gfxContext::GetCairo()
 {
   if (mCairo) {
     return mCairo;
   }
 
-  if (mDT->GetType() == BACKEND_CAIRO) {
+  if (mDT->GetType() == BackendType::CAIRO) {
     cairo_t *ctx =
-      (cairo_t*)mDT->GetNativeSurface(NATIVE_SURFACE_CAIRO_CONTEXT);
+      (cairo_t*)mDT->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT);
     if (ctx) {
       return ctx;
     }
   }
 
   if (mRefCairo) {
     // Set transform!
     return mRefCairo;
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -688,17 +688,17 @@ gfxDWriteFont::AddSizeOfIncludingThis(Ma
 {
     aSizes->mFontInstances += aMallocSizeOf(this);
     AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
 }
 
 TemporaryRef<ScaledFont>
 gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
 {
-  bool wantCairo = aTarget->GetType() == BACKEND_CAIRO;
+  bool wantCairo = aTarget->GetType() == BackendType::CAIRO;
   if (mAzureScaledFont && mAzureScaledFontIsCairo == wantCairo) {
     return mAzureScaledFont;
   }
 
   NativeFont nativeFont;
   nativeFont.mType = NATIVE_FONT_DWRITE_FONT_FACE;
   nativeFont.mFont = GetFontFace();
 
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2636,17 +2636,17 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint
         GetGlyphRenderingOptions();
 
       DrawOptions drawOptions;
       drawOptions.mAntialiasMode = Get2DAAMode(mAntialiasOption);
 
       // The cairo DrawTarget backend uses the cairo_scaled_font directly
       // and so has the font skew matrix applied already.
       if (mScaledFont &&
-          dt->GetType() != BACKEND_CAIRO) {
+          dt->GetType() != BackendType::CAIRO) {
         cairo_matrix_t matrix;
         cairo_scaled_font_get_font_matrix(mScaledFont, &matrix);
         if (matrix.xy != 0) {
           // If this matrix applies a skew, which can happen when drawing
           // oblique fonts, we will set the DrawTarget matrix to apply the
           // skew. We'll need to move the glyphs by the inverse of the skew to
           // get the glyphs positioned correctly in the new device space
           // though, since the font matrix should only be applied to drawing
--- a/gfx/thebes/gfxGradientCache.cpp
+++ b/gfx/thebes/gfxGradientCache.cpp
@@ -39,17 +39,17 @@ struct GradientCacheKey : public PLDHash
     uint32_t u;
   };
 
   static PLDHashNumber
   HashKey(const KeyTypePointer aKey)
   {
     PLDHashNumber hash = 0;
     FloatUint32 convert;
-    hash = AddToHash(hash, aKey->mBackendType);
+    hash = AddToHash(hash, int(aKey->mBackendType));
     hash = AddToHash(hash, aKey->mExtend);
     for (uint32_t i = 0; i < aKey->mStops.Length(); i++) {
       hash = AddToHash(hash, aKey->mStops[i].color.ToABGR());
       // Use the float bits as hash, except for the cases of 0.0 and -0.0 which both map to 0
       convert.f = aKey->mStops[i].offset;
       hash = AddToHash(hash, convert.f ? convert.u : 0);
     }
     return hash;
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -310,20 +310,20 @@ gfxPlatform::gfxPlatform()
                                  false);
     Preferences::AddBoolVarCache(&mDrawTileBorders,
                                  "layers.draw-tile-borders",
                                  false);
     Preferences::AddBoolVarCache(&mDrawBigImageBorders,
                                  "layers.draw-bigimage-borders",
                                  false);
 
-    uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
-    uint32_t contentMask = 1 << BACKEND_CAIRO;
-    InitBackendPrefs(canvasMask, BACKEND_CAIRO,
-                     contentMask, BACKEND_CAIRO);
+    uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
+    uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
+    InitBackendPrefs(canvasMask, BackendType::CAIRO,
+                     contentMask, BackendType::CAIRO);
 }
 
 gfxPlatform*
 gfxPlatform::GetPlatform()
 {
     if (!gPlatform) {
         Init();
     }
@@ -757,31 +757,31 @@ gfxPlatform::GetSourceSurfaceForSurface(
 
   RefPtr<SourceSurface> srcBuffer;
 
 #ifdef XP_WIN
   if (aSurface->GetType() == gfxSurfaceTypeD2D &&
       format != SurfaceFormat::A8) {
     NativeSurface surf;
     surf.mFormat = format;
-    surf.mType = NATIVE_SURFACE_D3D10_TEXTURE;
+    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();
     }
     srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
   } else
 #endif
-  if (aSurface->CairoSurface() && aTarget->GetType() == BACKEND_CAIRO) {
+  if (aSurface->CairoSurface() && aTarget->GetType() == BackendType::CAIRO) {
     // If this is an xlib cairo surface we don't want to fetch it into memory
     // because this is a major slow down.
     NativeSurface surf;
     surf.mFormat = format;
-    surf.mType = NATIVE_SURFACE_CAIRO_SURFACE;
+    surf.mType = NativeSurfaceType::CAIRO_SURFACE;
     surf.mSurface = aSurface->CairoSurface();
     srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
 
     if (srcBuffer) {
       // It's cheap enough to make a new one so we won't keep it around and
       // keeping it creates a cycle.
       return srcBuffer;
     }
@@ -896,17 +896,17 @@ gfxPlatform::SupportsAzureContentForDraw
 
   return SupportsAzureContentForType(aTarget->GetType());
 }
 
 bool
 gfxPlatform::UseAcceleratedSkiaCanvas()
 {
   return Preferences::GetBool("gfx.canvas.azure.accelerated", false) &&
-         mPreferredCanvasBackend == BACKEND_SKIA;
+         mPreferredCanvasBackend == BackendType::SKIA;
 }
 
 void
 gfxPlatform::InitializeSkiaCaches()
 {
 #ifdef USE_SKIA_GPU
   if (UseAcceleratedSkiaCanvas()) {
     bool usingDynamicCache = Preferences::GetBool("gfx.canvas.skiagl.dynamic-cache", false);
@@ -935,19 +935,19 @@ gfxPlatform::InitializeSkiaCaches()
     Factory::SetGlobalSkiaCacheLimits(cacheItemLimit, cacheSizeLimit);
   }
 #endif
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
 {
-  if (aTarget->GetType() == BACKEND_CAIRO) {
+  if (aTarget->GetType() == BackendType::CAIRO) {
     cairo_surface_t* csurf =
-      static_cast<cairo_surface_t*>(aTarget->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE));
+      static_cast<cairo_surface_t*>(aTarget->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE));
     if (csurf) {
       return gfxASurface::Wrap(csurf);
     }
   }
 
   // The semantics of this part of the function are sort of weird. If we
   // don't have direct support for the backend, we snapshot the first time
   // and then return the snapshotted surface for the lifetime of the draw
@@ -982,72 +982,72 @@ gfxPlatform::CreateDrawTargetForBackend(
   // There is a bunch of knowledge in the gfxPlatform heirarchy about how to
   // create the best offscreen surface for the current system and situation. We
   // can easily take advantage of this for the Cairo backend, so that's what we
   // do.
   // mozilla::gfx::Factory can get away without having all this knowledge for
   // now, but this might need to change in the future (using
   // CreateOffscreenSurface() and CreateDrawTargetForSurface() for all
   // backends).
-  if (aBackend == BACKEND_CAIRO) {
+  if (aBackend == BackendType::CAIRO) {
     nsRefPtr<gfxASurface> surf = CreateOffscreenSurface(ThebesIntSize(aSize),
                                                         ContentForFormat(aFormat));
     if (!surf || surf->CairoStatus()) {
       return nullptr;
     }
 
     return CreateDrawTargetForSurface(surf, aSize);
   } else {
     return Factory::CreateDrawTarget(aBackend, aSize, aFormat);
   }
 }
 
 RefPtr<DrawTarget>
 gfxPlatform::CreateOffscreenCanvasDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
 {
-  NS_ASSERTION(mPreferredCanvasBackend, "No backend.");
+  NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
   RefPtr<DrawTarget> target = CreateDrawTargetForBackend(mPreferredCanvasBackend, aSize, aFormat);
   if (target ||
-      mFallbackCanvasBackend == BACKEND_NONE) {
+      mFallbackCanvasBackend == BackendType::NONE) {
     return target;
   }
 
   return CreateDrawTargetForBackend(mFallbackCanvasBackend, aSize, aFormat);
 }
 
 RefPtr<DrawTarget>
 gfxPlatform::CreateOffscreenContentDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
 {
-  NS_ASSERTION(mContentBackend, "No backend.");
+  NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
   return CreateDrawTargetForBackend(mContentBackend, aSize, aFormat);
 }
 
 RefPtr<DrawTarget>
 gfxPlatform::CreateDrawTargetForData(unsigned char* aData, const IntSize& aSize, int32_t aStride, SurfaceFormat aFormat)
 {
-  NS_ASSERTION(mContentBackend, "No backend.");
-  if (mContentBackend == BACKEND_CAIRO) {
+  NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
+  if (mContentBackend == BackendType::CAIRO) {
     nsRefPtr<gfxImageSurface> image = new gfxImageSurface(aData, gfxIntSize(aSize.width, aSize.height), aStride, SurfaceFormatToImageFormat(aFormat)); 
     return Factory::CreateDrawTargetForCairoSurface(image->CairoSurface(), aSize);
   }
   return Factory::CreateDrawTargetForData(mContentBackend, aData, aSize, aStride, aFormat);
 }
 
 /* static */ BackendType
 gfxPlatform::BackendTypeForName(const nsCString& aName)
 {
   if (aName.EqualsLiteral("cairo"))
-    return BACKEND_CAIRO;
+    return BackendType::CAIRO;
   if (aName.EqualsLiteral("skia"))
-    return BACKEND_SKIA;
+    return BackendType::SKIA;
   if (aName.EqualsLiteral("direct2d"))
-    return BACKEND_DIRECT2D;
+    return BackendType::DIRECT2D;
   if (aName.EqualsLiteral("cg"))
-    return BACKEND_COREGRAPHICS;
-  return BACKEND_NONE;
+    return BackendType::COREGRAPHICS;
+  return BackendType::NONE;
 }
 
 nsresult
 gfxPlatform::GetFontList(nsIAtom *aLangGroup,
                          const nsACString& aGenericFamily,
                          nsTArray<nsString>& aListOfFonts)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
@@ -1513,25 +1513,25 @@ gfxPlatform::AppendPrefLang(eFontPrefLan
     }
 }
 
 void
 gfxPlatform::InitBackendPrefs(uint32_t aCanvasBitmask, BackendType aCanvasDefault,
                               uint32_t aContentBitmask, BackendType aContentDefault)
 {
     mPreferredCanvasBackend = GetCanvasBackendPref(aCanvasBitmask);
-    if (!mPreferredCanvasBackend) {
+    if (mPreferredCanvasBackend == BackendType::NONE) {
         mPreferredCanvasBackend = aCanvasDefault;
     }
     mFallbackCanvasBackend =
-        GetCanvasBackendPref(aCanvasBitmask & ~(1 << mPreferredCanvasBackend));
+        GetCanvasBackendPref(aCanvasBitmask & ~BackendTypeBit(mPreferredCanvasBackend));
 
     mContentBackendBitmask = aContentBitmask;
     mContentBackend = GetContentBackendPref(mContentBackendBitmask);
-    if (!mContentBackend) {
+    if (mContentBackend == BackendType::NONE) {
         mContentBackend = aContentDefault;
     }
 }
 
 /* static */ BackendType
 gfxPlatform::GetCanvasBackendPref(uint32_t aBackendBitmask)
 {
     return GetBackendPref("gfx.canvas.azure.backends", aBackendBitmask);
@@ -1548,22 +1548,22 @@ gfxPlatform::GetBackendPref(const char* 
 {
     nsTArray<nsCString> backendList;
     nsCString prefString;
     if (NS_SUCCEEDED(Preferences::GetCString(aBackendPrefName, &prefString))) {
         ParseString(prefString, ',', backendList);
     }
 
     uint32_t allowedBackends = 0;
-    BackendType result = BACKEND_NONE;
+    BackendType result = BackendType::NONE;
     for (uint32_t i = 0; i < backendList.Length(); ++i) {
         BackendType type = BackendTypeForName(backendList[i]);
-        if ((1 << type) & aBackendBitmask) {
-            allowedBackends |= (1 << type);
-            if (result == BACKEND_NONE) {
+        if (BackendTypeBit(type) & aBackendBitmask) {
+            allowedBackends |= BackendTypeBit(type);
+            if (result == BackendType::NONE) {
                 result = type;
             }
         }
     }
 
     aBackendBitmask = allowedBackends;
     return result;
 }
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -45,16 +45,22 @@ namespace mozilla {
 namespace gl {
 class GLContext;
 }
 namespace gfx {
 class DrawTarget;
 class SourceSurface;
 class ScaledFont;
 class DrawEventRecorder;
+
+inline uint32_t
+BackendTypeBit(BackendType b)
+{
+  return 1 << int(b);
+}
 }
 }
 
 extern cairo_user_data_key_t kDrawTarget;
 
 // pref lang id's for font prefs
 // !!! needs to match the list of pref font.default.xx entries listed in all.js !!!
 // !!! don't use as bit mask, this may grow larger !!!
@@ -125,31 +131,31 @@ enum eGfxLog {
 const uint32_t kMaxLenPrefLangList = 32;
 
 #define UNINITIALIZED_VALUE  (-1)
 
 inline const char*
 GetBackendName(mozilla::gfx::BackendType aBackend)
 {
   switch (aBackend) {
-      case mozilla::gfx::BACKEND_DIRECT2D:
+      case mozilla::gfx::BackendType::DIRECT2D:
         return "direct2d";
-      case mozilla::gfx::BACKEND_COREGRAPHICS_ACCELERATED:
+      case mozilla::gfx::BackendType::COREGRAPHICS_ACCELERATED:
         return "quartz accelerated";
-      case mozilla::gfx::BACKEND_COREGRAPHICS:
+      case mozilla::gfx::BackendType::COREGRAPHICS:
         return "quartz";
-      case mozilla::gfx::BACKEND_CAIRO:
+      case mozilla::gfx::BackendType::CAIRO:
         return "cairo";
-      case mozilla::gfx::BACKEND_SKIA:
+      case mozilla::gfx::BackendType::SKIA:
         return "skia";
-      case mozilla::gfx::BACKEND_RECORDING:
+      case mozilla::gfx::BackendType::RECORDING:
         return "recording";
-      case mozilla::gfx::BACKEND_DIRECT2D1_1:
+      case mozilla::gfx::BackendType::DIRECT2D1_1:
         return "direct2d 1.1";
-      case mozilla::gfx::BACKEND_NONE:
+      case mozilla::gfx::BackendType::NONE:
         return "none";
   }
   MOZ_CRASH("Incomplete switch");
 }
 
 class gfxPlatform {
 public:
     /**
@@ -256,30 +262,30 @@ public:
      * Prefer using SupportsAzureContentForDrawTarget or 
      * SupportsAzureContentForType.
      * This function is potentially misleading and dangerous because we might
      * support a certain Azure backend on the current platform, but when you
      * ask for a DrawTarget you get one for a different backend which is not
      * supported for content drawing.
      */
     bool SupportsAzureContent() {
-      return GetContentBackend() != mozilla::gfx::BACKEND_NONE;
+      return GetContentBackend() != mozilla::gfx::BackendType::NONE;
     }
 
     /**
      * Returns true if we should use Azure to render content with aTarget. For
      * example, it is possible that we are using Direct2D for rendering and thus
      * using Azure. But we want to render to a CairoDrawTarget, in which case
      * SupportsAzureContent will return true but SupportsAzureContentForDrawTarget
      * will return false.
      */
     bool SupportsAzureContentForDrawTarget(mozilla::gfx::DrawTarget* aTarget);
 
     bool SupportsAzureContentForType(mozilla::gfx::BackendType aType) {
-      return (1 << aType) & mContentBackendBitmask;
+      return BackendTypeBit(aType) & mContentBackendBitmask;
     }
 
     virtual bool UseAcceleratedSkiaCanvas();
 
     virtual void InitializeSkiaCaches();
 
     void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {
       aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend));
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -57,20 +57,20 @@ static cairo_user_data_key_t cairo_gdk_d
 gfxPlatformGtk::gfxPlatformGtk()
 {
     if (!sFontconfigUtils)
         sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
 #ifdef MOZ_X11
     sUseXRender = mozilla::Preferences::GetBool("gfx.xrender.enabled");
 #endif
 
-    uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
-    uint32_t contentMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA);
-    InitBackendPrefs(canvasMask, BACKEND_CAIRO,
-                     contentMask, BACKEND_CAIRO);
+    uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
+    uint32_t contentMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
+    InitBackendPrefs(canvasMask, BackendType::CAIRO,
+                     contentMask, BackendType::CAIRO);
 }
 
 gfxPlatformGtk::~gfxPlatformGtk()
 {
     gfxFontconfigUtils::Shutdown();
     sFontconfigUtils = nullptr;
 
     gfxPangoFontGroup::Shutdown();
@@ -448,17 +448,17 @@ gfxPlatformGtk::GetGdkDrawable(cairo_sur
 }
 #endif
 
 TemporaryRef<ScaledFont>
 gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
 {
     NativeFont nativeFont;
 
-    if (aTarget->GetType() == BACKEND_CAIRO || aTarget->GetType() == BACKEND_SKIA) {
+    if (aTarget->GetType() == BackendType::CAIRO || aTarget->GetType() == BackendType::SKIA) {
         nativeFont.mType = NATIVE_FONT_CAIRO_FONT_FACE;
         nativeFont.mFont = aFont->GetCairoScaledFont();
         return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
     }
 
     return nullptr;
 
 }
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -76,18 +76,18 @@ public:
                                GdkDrawable *drawable);
     static GdkDrawable *GetGdkDrawable(cairo_surface_t *target);
 #endif
 
     static int32_t GetDPI();
 
     bool UseXRender() {
 #if defined(MOZ_X11)
-        if (GetContentBackend() != mozilla::gfx::BACKEND_NONE &&
-            GetContentBackend() != mozilla::gfx::BACKEND_CAIRO)
+        if (GetContentBackend() != mozilla::gfx::BackendType::NONE &&
+            GetContentBackend() != mozilla::gfx::BackendType::CAIRO)
             return false;
 
         return sUseXRender;
 #else
         return false;
 #endif
     }
 
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -60,20 +60,22 @@ DisableFontActivation()
     }
 }
 
 gfxPlatformMac::gfxPlatformMac()
 {
     DisableFontActivation();
     mFontAntiAliasingThreshold = ReadAntiAliasingThreshold();
 
-    uint32_t canvasMask = (1 << BACKEND_CAIRO) | (1 << BACKEND_SKIA) | (1 << BACKEND_COREGRAPHICS);
-    uint32_t contentMask = (1 << BACKEND_COREGRAPHICS);
-    InitBackendPrefs(canvasMask, BACKEND_COREGRAPHICS,
-                     contentMask, BACKEND_COREGRAPHICS);
+    uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) |
+                          BackendTypeBit(BackendType::SKIA) |
+                          BackendTypeBit(BackendType::COREGRAPHICS);
+    uint32_t contentMask = BackendTypeBit(BackendType::COREGRAPHICS);
+    InitBackendPrefs(canvasMask, BackendType::COREGRAPHICS,
+                     contentMask, BackendType::COREGRAPHICS);
 }
 
 gfxPlatformMac::~gfxPlatformMac()
 {
     gfxCoreTextShaper::Shutdown();
 }
 
 gfxPlatformFontList*
@@ -358,18 +360,18 @@ gfxPlatformMac::ReadAntiAliasingThreshol
     }
 
     return threshold;
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformMac::CreateThebesSurfaceAliasForDrawTarget_hack(mozilla::gfx::DrawTarget *aTarget)
 {
-  if (aTarget->GetType() == BACKEND_COREGRAPHICS) {
-    CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NATIVE_SURFACE_CGCONTEXT));
+  if (aTarget->GetType() == BackendType::COREGRAPHICS) {
+    CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
     unsigned char* data = (unsigned char*)CGBitmapContextGetData(cg);
     size_t bpp = CGBitmapContextGetBitsPerPixel(cg);
     size_t stride = CGBitmapContextGetBytesPerRow(cg);
     gfxIntSize size(aTarget->GetSize().width, aTarget->GetSize().height);
     nsRefPtr<gfxImageSurface> imageSurface = new gfxImageSurface(data, size, stride, bpp == 2
                                                                                      ? gfxImageFormatRGB16_565
                                                                                      : gfxImageFormatARGB32);
     // Here we should return a gfxQuartzImageSurface but quartz will assumes that image surfaces
@@ -379,28 +381,28 @@ gfxPlatformMac::CreateThebesSurfaceAlias
   } else {
     return GetThebesSurfaceForDrawTarget(aTarget);
   }
 }
 
 already_AddRefed<gfxASurface>
 gfxPlatformMac::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
 {
-  if (aTarget->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
+  if (aTarget->GetType() == BackendType::COREGRAPHICS_ACCELERATED) {
     RefPtr<SourceSurface> source = aTarget->Snapshot();
     RefPtr<DataSourceSurface> sourceData = source->GetDataSurface();
     unsigned char* data = sourceData->GetData();
     nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(data, ThebesIntSize(sourceData->GetSize()), sourceData->Stride(),
                                                          gfxImageFormatARGB32);
     // We could fix this by telling gfxImageSurface it owns data.
     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));
+  } else if (aTarget->GetType() == BackendType::COREGRAPHICS) {
+    CGContextRef cg = static_cast<CGContextRef>(aTarget->GetNativeSurface(NativeSurfaceType::CGCONTEXT));
 
     //XXX: it would be nice to have an implicit conversion from IntSize to gfxIntSize
     IntSize intSize = aTarget->GetSize();
     gfxIntSize size(intSize.width, intSize.height);
 
     nsRefPtr<gfxASurface> surf =
       new gfxQuartzSurface(cg, size);
 
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -36,25 +36,25 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
 {
     NS_ASSERTION(!mQuartzSurface, "BeginNativeDrawing called when drawing already in progress");
 
     gfxPoint deviceOffset;
     nsRefPtr<gfxASurface> surf;
 
     if (!mContext->IsCairo()) {
       DrawTarget *dt = mContext->GetDrawTarget();
-      if (dt->GetType() == BACKEND_COREGRAPHICS) {
+      if (dt->GetType() == BackendType::COREGRAPHICS) {
         if (dt->IsDualDrawTarget()) {
           IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
                               NSToIntFloor(mNativeRect.height * mBackingScale));
 
          if (backingSize.IsEmpty())
             return nullptr;
 
-          mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, SurfaceFormat::B8G8R8A8);
+          mDrawTarget = Factory::CreateDrawTarget(BackendType::COREGRAPHICS, backingSize, SurfaceFormat::B8G8R8A8);
 
           Matrix transform;
           transform.Scale(mBackingScale, mBackingScale);
           transform.Translate(-mNativeRect.x, -mNativeRect.y);
 
           mDrawTarget->SetTransform(transform);
           dt = mDrawTarget;
         }
--- a/gfx/thebes/gfxWindowsNativeDrawing.cpp
+++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp
@@ -179,17 +179,17 @@ gfxWindowsNativeDrawing::BeginNativeDraw
         return nullptr;
     }
 }
 
 bool
 gfxWindowsNativeDrawing::IsDoublePass()
 {
     if (!mContext->IsCairo() &&
-        (mContext->GetDrawTarget()->GetType() != mozilla::gfx::BACKEND_CAIRO ||
+        (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 &&
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -488,25 +488,25 @@ gfxWindowsPlatform::UpdateRenderMode()
             SetupClearTypeParams();
 
             if (hr == S_OK)
               reporter.SetSuccessful();
         }
     }
 #endif
 
-    uint32_t canvasMask = 1 << BACKEND_CAIRO;
-    uint32_t contentMask = 1 << BACKEND_CAIRO;
-    BackendType defaultBackend = BACKEND_CAIRO;
+    uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO);
+    uint32_t contentMask = BackendTypeBit(BackendType::CAIRO);
+    BackendType defaultBackend = BackendType::CAIRO;
     if (mRenderMode == RENDER_DIRECT2D) {
-      canvasMask |= 1 << BACKEND_DIRECT2D;
-      contentMask |= 1 << BACKEND_DIRECT2D;
-      defaultBackend = BACKEND_DIRECT2D;
+      canvasMask |= BackendTypeBit(BackendType::DIRECT2D);
+      contentMask |= BackendTypeBit(BackendType::DIRECT2D);
+      defaultBackend = BackendType::DIRECT2D;
     } else {
-      canvasMask |= 1 << BACKEND_SKIA;
+      canvasMask |= BackendTypeBit(BackendType::SKIA);
     }
     InitBackendPrefs(canvasMask, defaultBackend,
                      contentMask, defaultBackend);
 }
 
 #ifdef CAIRO_HAS_D2D_SURFACE
 HRESULT
 gfxWindowsPlatform::CreateDevice(nsRefPtr<IDXGIAdapter1> &adapter1,
@@ -690,17 +690,17 @@ gfxWindowsPlatform::GetScaledFontForFont
 {
     if (aFont->GetType() == gfxFont::FONT_TYPE_DWRITE) {
         gfxDWriteFont *font = static_cast<gfxDWriteFont*>(aFont);
 
         NativeFont nativeFont;
         nativeFont.mType = NATIVE_FONT_DWRITE_FONT_FACE;
         nativeFont.mFont = font->GetFontFace();
 
-        if (aTarget->GetType() == BACKEND_CAIRO) {
+        if (aTarget->GetType() == BackendType::CAIRO) {
           return Factory::CreateScaledFontWithCairo(nativeFont,
                                                     font->GetAdjustedSize(),
                                                     font->GetCairoScaledFont());
         }
 
         return Factory::CreateScaledFontForNativeFont(nativeFont,
                                                       font->GetAdjustedSize());
     }
@@ -709,37 +709,37 @@ gfxWindowsPlatform::GetScaledFontForFont
         "Fonts on windows should be GDI or DWrite!");
 
     NativeFont nativeFont;
     nativeFont.mType = NATIVE_FONT_GDI_FONT_FACE;
     LOGFONT lf;
     GetObject(static_cast<gfxGDIFont*>(aFont)->GetHFONT(), sizeof(LOGFONT), &lf);
     nativeFont.mFont = &lf;
 
-    if (aTarget->GetType() == BACKEND_CAIRO) {
+    if (aTarget->GetType() == BackendType::CAIRO) {
       return Factory::CreateScaledFontWithCairo(nativeFont,
                                                 aFont->GetAdjustedSize(),
                                                 aFont->GetCairoScaledFont());
     }
 
     return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize());
 }
 
 already_AddRefed<gfxASurface>
 gfxWindowsPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
 {
 #ifdef XP_WIN
-  if (aTarget->GetType() == BACKEND_DIRECT2D) {
+  if (aTarget->GetType() == BackendType::DIRECT2D) {
     if (!GetD2DDevice()) {
       // We no longer have a D2D device, can't do this.
       return nullptr;
     }
 
     RefPtr<ID3D10Texture2D> texture =
-      static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NATIVE_SURFACE_D3D10_TEXTURE));
+      static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NativeSurfaceType::D3D10_TEXTURE));
 
     if (!texture) {
       return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
     }
 
     aTarget->Flush();
 
     nsRefPtr<gfxASurface> surf =
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -535,17 +535,17 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
     if (ctx->IsCairo()) {
         cairoTarget = cairo_get_group_target(ctx->GetCairo());
         deviceTranslation = ctx->CurrentMatrix().GetTranslation();
     } else {
         drawTarget = ctx->GetDrawTarget();
         Matrix dtTransform = drawTarget->GetTransform();
         deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32);
         cairoTarget = static_cast<cairo_surface_t*>
-            (drawTarget->GetNativeSurface(NATIVE_SURFACE_CAIRO_SURFACE));
+            (drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE));
     }
 
     cairo_surface_t* tempXlibSurface =
         CreateTempXlibSurface(cairoTarget, drawTarget, size,
                               canDrawOverBackground, flags, screen, visual,
                               &method);
     if (!tempXlibSurface)
         return;
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -3513,17 +3513,17 @@ static bool ShouldDrawRectsSeparately(gf
 
   if (!sPaintRectsSeparately ||
       aContext->IsCairo() ||
       aClip == CLIP_NONE) {
     return false;
   }
 
   DrawTarget *dt = aContext->GetDrawTarget();
-  return dt->GetType() == BACKEND_DIRECT2D;
+  return dt->GetType() == BackendType::DIRECT2D;
 }
 
 static void DrawForcedBackgroundColor(gfxContext* aContext, Layer* aLayer, nscolor aBackgroundColor)
 {
   if (NS_GET_A(aBackgroundColor) > 0) {
     nsIntRect r = aLayer->GetVisibleRegion().GetBounds();
     aContext->NewPath();
     aContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height));
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4851,17 +4851,17 @@ nsLayoutUtils::SurfaceFromElement(nsIIma
   nsresult rv2 = imgContainer->GetHeight(&imgHeight);
   if (NS_FAILED(rv) || NS_FAILED(rv2))
     return result;
 
   nsRefPtr<gfxASurface> gfxsurf = framesurf;
   if (wantImageSurface) {
     IntSize size(imgWidth, imgHeight);
     RefPtr<DataSourceSurface> output = Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8);
-    RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(BACKEND_CAIRO,
+    RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(BackendType::CAIRO,
                                                              output->GetData(),
                                                              size,
                                                              output->Stride(),
                                                              SurfaceFormat::B8G8R8A8);
     RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, gfxsurf);
 
     dt->CopySurface(source, IntRect(0, 0, imgWidth, imgHeight), IntPoint());
     dt->Flush();
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -1813,17 +1813,17 @@ nsresult AndroidBridge::CaptureThumbnail
                             is24bit ? gfxImageFormatRGB24 :
                                       gfxImageFormatRGB16_565);
     if (surf->CairoStatus() != 0) {
         ALOG_BRIDGE("Error creating gfxImageSurface");
         return NS_ERROR_FAILURE;
     }
 
     nsRefPtr<gfxContext> context;
-    if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BACKEND_CAIRO)) {
+    if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BackendType::CAIRO)) {
         RefPtr<DrawTarget> dt =
             gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf, IntSize(bufW, bufH));
 
         if (!dt) {
             ALOG_BRIDGE("Error creating DrawTarget");
             return NS_ERROR_FAILURE;
         }
         context = new gfxContext(dt);
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2629,17 +2629,17 @@ RectTextureImage::BeginUpdate(const nsIn
   if (mUpdateRegion.IsEmpty()) {
     return nullptr;
   }
 
   nsIntSize neededBufferSize = TextureSizeForSize(mUsedSize);
   if (!mUpdateDrawTarget || mBufferSize != neededBufferSize) {
     gfx::IntSize size(neededBufferSize.width, neededBufferSize.height);
     mUpdateDrawTarget =
-      gfx::Factory::CreateDrawTarget(gfx::BACKEND_COREGRAPHICS, size,
+      gfx::Factory::CreateDrawTarget(gfx::BackendType::COREGRAPHICS, size,
                                      gfx::SurfaceFormat::B8G8R8A8);
     mBufferSize = neededBufferSize;
   }
 
   mInUpdate = true;
 
   RefPtr<gfx::DrawTarget> drawTarget = mUpdateDrawTarget;
   return drawTarget;
@@ -3520,24 +3520,24 @@ NSEvent* gLastDragMouseDownEvent = nil;
   nsIntRegion region = [self nativeDirtyRegionWithBoundingRect:aRect];
 
   // Create Cairo objects.
   nsRefPtr<gfxQuartzSurface> targetSurface =
     new gfxQuartzSurface(aContext, backingSize);
   targetSurface->SetAllowUseAsSource(false);
 
   nsRefPtr<gfxContext> targetContext;
-  if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BACKEND_CAIRO)) {
+  if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::CAIRO)) {
     RefPtr<gfx::DrawTarget> dt =
       gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(targetSurface,
                                                              gfx::IntSize(backingSize.width,
                                                                           backingSize.height));
     dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
     targetContext = new gfxContext(dt);
-  } else if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BACKEND_COREGRAPHICS)) {
+  } else if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::COREGRAPHICS)) {
     RefPtr<gfx::DrawTarget> dt =
       gfx::Factory::CreateDrawTargetForCairoCGContext(aContext,
                                                       gfx::IntSize(backingSize.width,
                                                                    backingSize.height));
     dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
     targetContext = new gfxContext(dt);
   } else {
     targetContext = new gfxContext(targetSurface);
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2141,22 +2141,22 @@ nsWindow::OnExposeEvent(cairo_t *cr)
 #if (MOZ_WIDGET_GTK == 2)
     surf = GetThebesSurface();
 #else
     surf = GetThebesSurface(cr);
 #endif
 
     nsRefPtr<gfxContext> ctx;
     if (gfxPlatform::GetPlatform()->
-            SupportsAzureContentForType(BACKEND_CAIRO)) {
+            SupportsAzureContentForType(BackendType::CAIRO)) {
         IntSize intSize(surf->GetSize().width, surf->GetSize().height);
         ctx = new gfxContext(gfxPlatform::GetPlatform()->
             CreateDrawTargetForSurface(surf, intSize));
     } else if (gfxPlatform::GetPlatform()->
-                   SupportsAzureContentForType(BACKEND_SKIA) &&
+                   SupportsAzureContentForType(BackendType::SKIA) &&
                surf->GetType() != gfxSurfaceTypeImage) {
        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/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -382,17 +382,17 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
           }
 
           if (!targetSurface) {
             NS_ERROR("Invalid RenderMode!");
             return false;
           }
 
           nsRefPtr<gfxContext> thebesContext;
-          if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(mozilla::gfx::BACKEND_CAIRO)) {
+          if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(mozilla::gfx::BackendType::CAIRO)) {
             RECT paintRect;
             ::GetClientRect(mWnd, &paintRect);
             RefPtr<mozilla::gfx::DrawTarget> dt =
               gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(targetSurface,
                                                                      mozilla::gfx::IntSize(paintRect.right - paintRect.left,
                                                                                            paintRect.bottom - paintRect.top));
             thebesContext = new gfxContext(dt);
           } else {