Bug 959380 - 5/5 - Make gfxMemoryLocation a typed enum - r=jrmuizel
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 23 Jan 2014 13:26:40 -0500
changeset 164870 716111e4922a7cd6cc03d43a08920c63a64336a4
parent 164869 93f99d0518c7bc218df9d9154370345a13426827
child 164871 b9282cb0f9a7575e3189a3a0f5791334afb75db4
push id38839
push userbjacob@mozilla.com
push dateThu, 23 Jan 2014 18:27:27 +0000
treeherdermozilla-inbound@b9282cb0f9a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs959380
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 959380 - 5/5 - Make gfxMemoryLocation a typed enum - r=jrmuizel find . -type f | grep -v '\./obj' | grep -v '\.hg' | xargs sed -i 's/\(^\|[^A-Za-z0-9_]\)GFX_MEMORY_\(IN_PROCESS_HEAP\|IN_PROCESS_NONHEAP\|OUT_OF_PROCESS\)\($\|[^A-Za-z0-9_]\)/\1gfxMemoryLocation::\2\3/g'
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxTypes.h
gfx/thebes/gfxWindowsSurface.cpp
gfx/thebes/gfxXlibSurface.cpp
image/src/RasterImage.cpp
image/src/imgFrame.cpp
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -505,17 +505,17 @@ gfxASurface::GetSubpixelAntialiasingEnab
 #else
     return true;
 #endif
 }
 
 gfxMemoryLocation
 gfxASurface::GetMemoryLocation() const
 {
-    return GFX_MEMORY_IN_PROCESS_HEAP;
+    return gfxMemoryLocation::IN_PROCESS_HEAP;
 }
 
 int32_t
 gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
 {
     switch (format) {
         case gfxImageFormat::ARGB32:
         case gfxImageFormat::RGB24:
--- a/gfx/thebes/gfxTypes.h
+++ b/gfx/thebes/gfxTypes.h
@@ -89,20 +89,20 @@ MOZ_END_ENUM_CLASS(gfxSurfaceType)
 
 MOZ_BEGIN_ENUM_CLASS(gfxContentType)
   COLOR       = 0x1000,
   ALPHA       = 0x2000,
   COLOR_ALPHA = 0x3000,
   SENTINEL    = 0xffff
 MOZ_END_ENUM_CLASS(gfxContentType)
 
-    /**
-     * The memory used by this surface (as reported by KnownMemoryUsed()) can
-     * either live in this process's heap, in this process but outside the
-     * heap, or in another process altogether.
-     */
-    enum gfxMemoryLocation {
-      GFX_MEMORY_IN_PROCESS_HEAP,
-      GFX_MEMORY_IN_PROCESS_NONHEAP,
-      GFX_MEMORY_OUT_OF_PROCESS
-    };
+/**
+  * The memory used by a gfxASurface (as reported by KnownMemoryUsed()) can
+  * either live in this process's heap, in this process but outside the
+  * heap, or in another process altogether.
+  */
+MOZ_BEGIN_ENUM_CLASS(gfxMemoryLocation)
+  IN_PROCESS_HEAP,
+  IN_PROCESS_NONHEAP,
+  OUT_OF_PROCESS
+MOZ_END_ENUM_CLASS(gfxMemoryLocation)
 
 #endif /* GFX_TYPES_H */
--- a/gfx/thebes/gfxWindowsSurface.cpp
+++ b/gfx/thebes/gfxWindowsSurface.cpp
@@ -306,10 +306,10 @@ gfxWindowsSurface::GetSize() const
 
     return gfxIntSize(cairo_win32_surface_get_width(mSurface),
                       cairo_win32_surface_get_height(mSurface));
 }
 
 gfxMemoryLocation
 gfxWindowsSurface::GetMemoryLocation() const
 {
-    return GFX_MEMORY_IN_PROCESS_NONHEAP;
+    return gfxMemoryLocation::IN_PROCESS_NONHEAP;
 }
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -602,10 +602,10 @@ gfxXlibSurface::GetGLXPixmap()
     }
     return mGLXPixmap;
 }
 #endif
 
 gfxMemoryLocation
 gfxXlibSurface::GetMemoryLocation() const
 {
-    return GFX_MEMORY_OUT_OF_PROCESS;
+    return gfxMemoryLocation::OUT_OF_PROCESS;
 }
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -1041,31 +1041,31 @@ RasterImage::SizeOfDecodedWithComputedFa
   }
 
   return n;
 }
 
 size_t
 RasterImage::HeapSizeOfDecodedWithComputedFallback(MallocSizeOf aMallocSizeOf) const
 {
-  return SizeOfDecodedWithComputedFallbackIfHeap(GFX_MEMORY_IN_PROCESS_HEAP,
+  return SizeOfDecodedWithComputedFallbackIfHeap(gfxMemoryLocation::IN_PROCESS_HEAP,
                                                  aMallocSizeOf);
 }
 
 size_t
 RasterImage::NonHeapSizeOfDecoded() const
 {
-  return SizeOfDecodedWithComputedFallbackIfHeap(GFX_MEMORY_IN_PROCESS_NONHEAP,
+  return SizeOfDecodedWithComputedFallbackIfHeap(gfxMemoryLocation::IN_PROCESS_NONHEAP,
                                                  nullptr);
 }
 
 size_t
 RasterImage::OutOfProcessSizeOfDecoded() const
 {
-  return SizeOfDecodedWithComputedFallbackIfHeap(GFX_MEMORY_OUT_OF_PROCESS,
+  return SizeOfDecodedWithComputedFallbackIfHeap(gfxMemoryLocation::OUT_OF_PROCESS,
                                                  nullptr);
 }
 
 void
 RasterImage::EnsureAnimExists()
 {
   if (!mAnim) {
 
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -765,57 +765,57 @@ void imgFrame::SetCompositingFailed(bool
 }
 
 // If |aLocation| indicates this is heap memory, we try to measure things with
 // |aMallocSizeOf|.  If that fails (because the platform doesn't support it) or
 // it's non-heap memory, we fall back to computing the size analytically.
 size_t
 imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxMemoryLocation aLocation, mozilla::MallocSizeOf aMallocSizeOf) const
 {
-  // aMallocSizeOf is only used if aLocation==GFX_MEMORY_IN_PROCESS_HEAP.  It
+  // aMallocSizeOf is only used if aLocation==gfxMemoryLocation::IN_PROCESS_HEAP.  It
   // should be nullptr otherwise.
   NS_ABORT_IF_FALSE(
-    (aLocation == GFX_MEMORY_IN_PROCESS_HEAP &&  aMallocSizeOf) ||
-    (aLocation != GFX_MEMORY_IN_PROCESS_HEAP && !aMallocSizeOf),
+    (aLocation == gfxMemoryLocation::IN_PROCESS_HEAP &&  aMallocSizeOf) ||
+    (aLocation != gfxMemoryLocation::IN_PROCESS_HEAP && !aMallocSizeOf),
     "mismatch between aLocation and aMallocSizeOf");
 
   size_t n = 0;
 
-  if (mPalettedImageData && aLocation == GFX_MEMORY_IN_PROCESS_HEAP) {
+  if (mPalettedImageData && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
     size_t n2 = aMallocSizeOf(mPalettedImageData);
     if (n2 == 0) {
       n2 = GetImageDataLength() + PaletteDataLength();
     }
     n += n2;
   }
 
 #ifdef USE_WIN_SURFACE
   if (mWinSurface && aLocation == mWinSurface->GetMemoryLocation()) {
     n += mWinSurface->KnownMemoryUsed();
   } else
 #endif
 #ifdef XP_MACOSX
-  if (mQuartzSurface && aLocation == GFX_MEMORY_IN_PROCESS_HEAP) {
+  if (mQuartzSurface && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
     n += mSize.width * mSize.height * 4;
   } else
 #endif
   if (mImageSurface && aLocation == mImageSurface->GetMemoryLocation()) {
     size_t n2 = 0;
-    if (aLocation == GFX_MEMORY_IN_PROCESS_HEAP) { // HEAP: measure
+    if (aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) { // HEAP: measure
       n2 = mImageSurface->SizeOfIncludingThis(aMallocSizeOf);
     }
     if (n2 == 0) {  // non-HEAP or computed fallback for HEAP
       n2 = mImageSurface->KnownMemoryUsed();
     }
     n += n2;
   }
 
   if (mOptSurface && aLocation == mOptSurface->GetMemoryLocation()) {
     size_t n2 = 0;
-    if (aLocation == GFX_MEMORY_IN_PROCESS_HEAP &&
+    if (aLocation == gfxMemoryLocation::IN_PROCESS_HEAP &&
         mOptSurface->SizeOfIsMeasured()) {
       // HEAP: measure (but only if the sub-class is capable of measuring)
       n2 = mOptSurface->SizeOfIncludingThis(aMallocSizeOf);
     }
     if (n2 == 0) {  // non-HEAP or computed fallback for HEAP
       n2 = mOptSurface->KnownMemoryUsed();
     }
     n += n2;