Backout changeset 984e656becec (Bug 664659) due to regressions in Tp5 XRES and RSS.
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 01 Aug 2011 10:20:18 +0200
changeset 73996 f4415470040ae76e50f83d55bd57e9cbe45e2fe8
parent 73995 86e9d6953e504d9a505e2cb68b36b5fa59e6ec79
child 73997 f0c42de49a10f6ea7a3c51109ae2a19709f92ea8
push idunknown
push userunknown
push dateunknown
bugs664659
milestone8.0a1
backs out984e656becec82ca202aafa9361bbac74ed247ad
Backout changeset 984e656becec (Bug 664659) due to regressions in Tp5 XRES and RSS.
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxASurface.h
gfx/thebes/gfxQuartzImageSurface.cpp
gfx/thebes/gfxQuartzImageSurface.h
gfx/thebes/gfxWindowsSurface.cpp
gfx/thebes/gfxWindowsSurface.h
gfx/thebes/gfxXlibSurface.cpp
gfx/thebes/gfxXlibSurface.h
modules/libpr0n/src/Image.cpp
modules/libpr0n/src/Image.h
modules/libpr0n/src/RasterImage.cpp
modules/libpr0n/src/RasterImage.h
modules/libpr0n/src/VectorImage.cpp
modules/libpr0n/src/VectorImage.h
modules/libpr0n/src/imgFrame.cpp
modules/libpr0n/src/imgFrame.h
modules/libpr0n/src/imgLoader.cpp
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -497,22 +497,16 @@ gfxASurface::GetSubpixelAntialiasingEnab
       return PR_FALSE;
 #ifdef MOZ_TREE_CAIRO
     return cairo_surface_get_subpixel_antialiasing(mSurface) == CAIRO_SUBPIXEL_ANTIALIASING_ENABLED;
 #else
     return PR_TRUE;
 #endif
 }
 
-gfxASurface::MemoryLocation
-gfxASurface::GetMemoryLocation() const
-{
-    return MEMORY_IN_PROCESS_HEAP;
-}
-
 PRInt32
 gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
 {
     switch (format) {
         case ImageFormatARGB32:
         case ImageFormatRGB24:
             return 4;
         case ImageFormatRGB16_565:
@@ -562,83 +556,58 @@ gfxASurface::MovePixels(const nsIntRect&
                            aDestTopLeft.y, 
                            aSourceRect.width, 
                            aSourceRect.height));
     ctx->Fill();
 }
 
 /** Memory reporting **/
 
-static const char *sDefaultSurfaceDescription =
-    "Memory used by gfx surface of the given type.";
-
-struct SurfaceMemoryReporterAttrs {
-  const char *name;
-  const char *description;
+static const char *sSurfaceNamesForSurfaceType[] = {
+    "gfx-surface-image",
+    "gfx-surface-pdf",
+    "gfx-surface-ps",
+    "gfx-surface-xlib",
+    "gfx-surface-xcb",
+    "gfx-surface-glitz",
+    "gfx-surface-quartz",
+    "gfx-surface-win32",
+    "gfx-surface-beos",
+    "gfx-surface-directfb",
+    "gfx-surface-svg",
+    "gfx-surface-os2",
+    "gfx-surface-win32printing",
+    "gfx-surface-quartzimage",
+    "gfx-surface-script",
+    "gfx-surface-qpainter",
+    "gfx-surface-recording",
+    "gfx-surface-vg",
+    "gfx-surface-gl",
+    "gfx-surface-drm",
+    "gfx-surface-tee",
+    "gfx-surface-xml",
+    "gfx-surface-skia",
+    "gfx-surface-subsurface",
+    "gfx-surface-d2d"
 };
 
-static const SurfaceMemoryReporterAttrs sSurfaceMemoryReporterAttrs[] = {
-    {"gfx-surface-image", nsnull},
-    {"gfx-surface-pdf", nsnull},
-    {"gfx-surface-ps", nsnull},
-    {"gfx-surface-xlib",
-     "Memory used by xlib surfaces to store pixmaps. This memory lives in "
-     "the X server's process rather than in this application, so the bytes "
-     "accounted for here aren't counted in vsize, resident, explicit, or any of "
-     "the other measurements on this page."},
-    {"gfx-surface-xcb", nsnull},
-    {"gfx-surface-glitz", nsnull},
-    {"gfx-surface-quartz", nsnull},
-    {"gfx-surface-win32", nsnull},
-    {"gfx-surface-beos", nsnull},
-    {"gfx-surface-directfb", nsnull},
-    {"gfx-surface-svg", nsnull},
-    {"gfx-surface-os2", nsnull},
-    {"gfx-surface-win32printing", nsnull},
-    {"gfx-surface-quartzimage", nsnull},
-    {"gfx-surface-script", nsnull},
-    {"gfx-surface-qpainter", nsnull},
-    {"gfx-surface-recording", nsnull},
-    {"gfx-surface-vg", nsnull},
-    {"gfx-surface-gl", nsnull},
-    {"gfx-surface-drm", nsnull},
-    {"gfx-surface-tee", nsnull},
-    {"gfx-surface-xml", nsnull},
-    {"gfx-surface-skia", nsnull},
-    {"gfx-surface-subsurface", nsnull},
-    {"gfx-surface-d2d", nsnull},
-};
-
-PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceMemoryReporterAttrs) ==
-                 gfxASurface::SurfaceTypeMax);
+PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceNamesForSurfaceType) == gfxASurface::SurfaceTypeMax);
 #ifdef CAIRO_HAS_D2D_SURFACE
-PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_D2D) ==
-                 PRUint32(gfxASurface::SurfaceTypeD2D));
+PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_D2D) == PRUint32(gfxASurface::SurfaceTypeD2D));
 #endif
-PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_SKIA) ==
-                 PRUint32(gfxASurface::SurfaceTypeSkia));
+PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_SKIA) == PRUint32(gfxASurface::SurfaceTypeSkia));
 
 static const char *
 SurfaceMemoryReporterPathForType(gfxASurface::gfxSurfaceType aType)
 {
     if (aType < 0 ||
         aType >= gfxASurface::SurfaceTypeMax)
         return "gfx-surface-unknown";
 
-    return sSurfaceMemoryReporterAttrs[aType].name;
-}
-
-static const char *
-SurfaceMemoryReporterDescriptionForType(gfxASurface::gfxSurfaceType aType)
-{
-    if (aType >= 0 && aType < gfxASurface::SurfaceTypeMax &&
-        sSurfaceMemoryReporterAttrs[aType].description)
-        return sSurfaceMemoryReporterAttrs[aType].description;
-
-    return sDefaultSurfaceDescription;
+    return sSurfaceNamesForSurfaceType[aType];
 }
 
 /* Surface size memory reporting */
 static nsIMemoryReporter *gSurfaceMemoryReporters[gfxASurface::SurfaceTypeMax] = { 0 };
 static PRInt64 gSurfaceMemoryUsed[gfxASurface::SurfaceTypeMax] = { 0 };
 
 class SurfaceMemoryReporter :
     public nsIMemoryReporter
@@ -671,17 +640,17 @@ public:
     }
 
     NS_IMETHOD GetAmount(PRInt64 *amount) {
         *amount = gSurfaceMemoryUsed[mType];
         return NS_OK;
     }
 
     NS_IMETHOD GetDescription(nsACString &desc) {
-        desc.Assign(SurfaceMemoryReporterDescriptionForType(mType));
+        desc.AssignLiteral("Memory used by gfx surface of the given type.");
         return NS_OK;
     }
 
     gfxASurface::gfxSurfaceType mType;
 };
 
 NS_IMPL_ISUPPORTS1(SurfaceMemoryReporter, nsIMemoryReporter)
 
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -201,34 +201,17 @@ public:
      * Same as above, but use current surface type as returned by GetType().
      * The bytes will be accumulated until RecordMemoryFreed is called,
      * in which case the value that was recorded for this surface will
      * be freed.
      */
     void RecordMemoryUsed(PRInt32 aBytes);
     void RecordMemoryFreed();
 
-    virtual PRInt32 KnownMemoryUsed() { return mBytesRecorded; }
-
-    /**
-     * The memory used by this surface (as reported by KnownMemoryUsed()) can
-     * either live in this process's heap, in this process but outside the
-     * heap, or in another process altogether.
-     */
-    enum MemoryLocation {
-      MEMORY_IN_PROCESS_HEAP,
-      MEMORY_IN_PROCESS_NONHEAP,
-      MEMORY_OUT_OF_PROCESS
-    };
-
-    /**
-     * Where does this surface's memory live?  By default, we say it's in this
-     * process's heap.
-     */
-    virtual MemoryLocation GetMemoryLocation() const;
+    PRInt32 KnownMemoryUsed() { return mBytesRecorded; }
 
     static PRInt32 BytePerPixelFromFormat(gfxImageFormat format);
 
     virtual const gfxIntSize GetSize() const { return gfxIntSize(-1, -1); }
 
     void DumpAsDataURL();
 
     void SetOpaqueRect(const gfxRect& aRect) {
--- a/gfx/thebes/gfxQuartzImageSurface.cpp
+++ b/gfx/thebes/gfxQuartzImageSurface.cpp
@@ -53,27 +53,16 @@ gfxQuartzImageSurface::gfxQuartzImageSur
 {
     Init (csurf, PR_TRUE);
 }
 
 gfxQuartzImageSurface::~gfxQuartzImageSurface()
 {
 }
 
-PRInt32
-gfxQuartzImageSurface::KnownMemoryUsed()
-{
-  // This surface doesn't own any memory itself, but we want to report here the
-  // amount of memory that the surface it wraps uses.
-  nsRefPtr<gfxImageSurface> imgSurface = GetAsImageSurface();
-  if (imgSurface)
-    return imgSurface->KnownMemoryUsed();
-  return 0;
-}
-
 already_AddRefed<gfxImageSurface>
 gfxQuartzImageSurface::GetAsImageSurface()
 {
     if (!mSurfaceValid)
         return nsnull;
 
     cairo_surface_t *isurf = cairo_quartz_image_surface_get_image (CairoSurface());
     if (!isurf) {
--- a/gfx/thebes/gfxQuartzImageSurface.h
+++ b/gfx/thebes/gfxQuartzImageSurface.h
@@ -44,12 +44,11 @@
 class THEBES_API gfxQuartzImageSurface : public gfxASurface {
 public:
     gfxQuartzImageSurface(gfxImageSurface *imageSurface);
     gfxQuartzImageSurface(cairo_surface_t *csurf);
 
     virtual ~gfxQuartzImageSurface();
 
     already_AddRefed<gfxImageSurface> GetAsImageSurface();
-    virtual PRInt32 KnownMemoryUsed();
 };
 
 #endif /* GFX_QUARTZIMAGESURFACE_H */
--- a/gfx/thebes/gfxWindowsSurface.cpp
+++ b/gfx/thebes/gfxWindowsSurface.cpp
@@ -323,14 +323,8 @@ gfxWindowsSurface::GetDefaultContextFlag
 {
     if (mForPrinting)
         return gfxContext::FLAG_SIMPLIFY_OPERATORS |
                gfxContext::FLAG_DISABLE_SNAPPING |
                gfxContext::FLAG_DISABLE_COPY_BACKGROUND;
 
     return 0;
 }
-
-gfxASurface::MemoryLocation
-gfxWindowsSurface::GetMemoryLocation() const
-{
-    return MEMORY_IN_PROCESS_NONHEAP;
-}
--- a/gfx/thebes/gfxWindowsSurface.h
+++ b/gfx/thebes/gfxWindowsSurface.h
@@ -93,20 +93,16 @@ public:
     virtual PRInt32 GetDefaultContextFlags() const;
 
     void MovePixels(const nsIntRect& aSourceRect,
                     const nsIntPoint& aDestTopLeft)
     {
         FastMovePixels(aSourceRect, aDestTopLeft);
     }
 
-    // The memory used by this surface lives in this process's address space,
-    // but not in the heap.
-    virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
-
 private:
     PRPackedBool mOwnsDC;
     PRPackedBool mForPrinting;
 
     HDC mDC;
     HWND mWnd;
 };
 
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -99,17 +99,16 @@ gfxXlibSurface::gfxXlibSurface(cairo_sur
     mDrawable = cairo_xlib_surface_get_drawable(csurf);
     mDisplay = cairo_xlib_surface_get_display(csurf);
 
     Init(csurf, PR_TRUE);
 }
 
 gfxXlibSurface::~gfxXlibSurface()
 {
-    // gfxASurface's destructor calls RecordMemoryFreed().
     if (mPixmapTaken) {
         XFreePixmap (mDisplay, mDrawable);
     }
 }
 
 static Drawable
 CreatePixmap(Screen *screen, const gfxIntSize& size, unsigned int depth,
              Drawable relatedDrawable)
@@ -123,36 +122,16 @@ CreatePixmap(Screen *screen, const gfxIn
     Display *dpy = DisplayOfScreen(screen);
     // X gives us a fatal error if we try to create a pixmap of width
     // or height 0
     return XCreatePixmap(dpy, relatedDrawable,
                          NS_MAX(1, size.width), NS_MAX(1, size.height),
                          depth);
 }
 
-void
-gfxXlibSurface::TakePixmap()
-{
-    NS_ASSERTION(!mPixmapTaken, "I already own the Pixmap!");
-    mPixmapTaken = PR_TRUE;
-
-    // Divide by 8 because surface_get_depth gives us the number of *bits* per
-    // pixel.
-    RecordMemoryUsed(mSize.width * mSize.height *
-        cairo_xlib_surface_get_depth(CairoSurface()) / 8);
-}
-
-Drawable
-gfxXlibSurface::ReleasePixmap() {
-    NS_ASSERTION(mPixmapTaken, "I don't own the Pixmap!");
-    mPixmapTaken = PR_FALSE;
-    RecordMemoryFreed();
-    return mDrawable;
-}
-
 /* static */
 already_AddRefed<gfxXlibSurface>
 gfxXlibSurface::Create(Screen *screen, Visual *visual,
                        const gfxIntSize& size, Drawable relatedDrawable)
 {
     Drawable drawable =
         CreatePixmap(screen, size, DepthOfVisual(screen, visual),
                      relatedDrawable);
@@ -518,13 +497,8 @@ gfxXlibSurface::XScreen()
 }
 
 XRenderPictFormat*
 gfxXlibSurface::XRenderFormat()
 {
     return cairo_xlib_surface_get_xrender_format(CairoSurface());
 }
 
-gfxASurface::MemoryLocation
-gfxXlibSurface::GetMemoryLocation() const
-{
-    return MEMORY_OUT_OF_PROCESS;
-}
--- a/gfx/thebes/gfxXlibSurface.h
+++ b/gfx/thebes/gfxXlibSurface.h
@@ -85,30 +85,33 @@ public:
     XRenderPictFormat* XRenderFormat();
 
     static int DepthOfVisual(const Screen* screen, const Visual* visual);
     static Visual* FindVisual(Screen* screen, gfxImageFormat format);
     static XRenderPictFormat *FindRenderFormat(Display *dpy, gfxImageFormat format);
 
     // take ownership of a passed-in Pixmap, calling XFreePixmap on it
     // when the gfxXlibSurface is destroyed.
-    void TakePixmap();
+    void TakePixmap() {
+        NS_ASSERTION(!mPixmapTaken, "I already own the Pixmap!");
+        mPixmapTaken = PR_TRUE;
+    }
 
     // Release ownership of this surface's Pixmap.  This is only valid
     // on gfxXlibSurfaces for which the user called TakePixmap(), or
     // on those created by a Create() factory method.
-    Drawable ReleasePixmap();
+    Drawable ReleasePixmap() {
+        NS_ASSERTION(mPixmapTaken, "I don't own the Pixmap!");
+        mPixmapTaken = PR_FALSE;
+        return mDrawable;
+    }
 
     // Find a visual and colormap pair suitable for rendering to this surface.
     PRBool GetColormapAndVisual(Colormap* colormap, Visual **visual);
 
-    // This surface is a wrapper around X pixmaps, which are stored in the X
-    // server, not the main application.
-    virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
-
 protected:
     // if TakePixmap() has been called on this
     PRBool mPixmapTaken;
     
     Display *mDisplay;
     Drawable mDrawable;
 
     void DoSizeQuery();
--- a/modules/libpr0n/src/Image.cpp
+++ b/modules/libpr0n/src/Image.cpp
@@ -58,17 +58,17 @@ Image::Image(imgStatusTracker* aStatusTr
 }
 
 PRUint32
 Image::GetDataSize()
 {
   if (mError)
     return 0;
   
-  return GetSourceHeapSize() + GetDecodedHeapSize() + GetDecodedNonheapSize();
+  return GetSourceDataSize() + GetDecodedDataSize();
 }
 
 // Translates a mimetype into a concrete decoder
 Image::eDecoderType
 Image::GetDecoderType(const char *aMimeType)
 {
   // By default we don't know
   eDecoderType rv = eDecoderType_unknown;
--- a/modules/libpr0n/src/Image.h
+++ b/modules/libpr0n/src/Image.h
@@ -97,19 +97,18 @@ public:
    * The size, in bytes, occupied by the significant data portions of the image.
    * This includes both compressed source data and decoded frames.
    */
   PRUint32 GetDataSize();
 
   /**
    * The components that make up GetDataSize().
    */      
-  virtual PRUint32 GetDecodedHeapSize() = 0;
-  virtual PRUint32 GetDecodedNonheapSize() = 0;
-  virtual PRUint32 GetSourceHeapSize() = 0;
+  virtual PRUint32 GetDecodedDataSize() = 0;
+  virtual PRUint32 GetSourceDataSize() = 0;
 
   // Mimetype translation
   enum eDecoderType {
     eDecoderType_png     = 0,
     eDecoderType_gif     = 1,
     eDecoderType_jpeg    = 2,
     eDecoderType_bmp     = 3,
     eDecoderType_ico     = 4,
--- a/modules/libpr0n/src/RasterImage.cpp
+++ b/modules/libpr0n/src/RasterImage.cpp
@@ -740,55 +740,31 @@ RasterImage::GetFrame(PRUint32 aWhichFra
     framesurf = imgsurf;
   }
 
   *_retval = framesurf.forget().get();
 
   return rv;
 }
 
-namespace {
-
-enum DecodedSizeType {
-  DECODED_SIZE_HEAP,
-  DECODED_SIZE_NONHEAP
-};
-
 PRUint32
-GetDecodedSize(const nsTArray<imgFrame *> &aFrames, DecodedSizeType aType)
+RasterImage::GetDecodedDataSize()
 {
   PRUint32 val = 0;
-  for (PRUint32 i = 0; i < aFrames.Length(); ++i) {
-    imgFrame *frame = aFrames.SafeElementAt(i, nsnull);
+  for (PRUint32 i = 0; i < mFrames.Length(); ++i) {
+    imgFrame *frame = mFrames.SafeElementAt(i, nsnull);
     NS_ABORT_IF_FALSE(frame, "Null frame in frame array!");
-    if (aType == DECODED_SIZE_HEAP)
-      val += frame->EstimateHeapMemoryUsed();
-    else
-      val += frame->EstimateNonheapMemoryUsed();
+    val += frame->EstimateMemoryUsed();
   }
 
   return val;
 }
 
-} // anonymous namespace
-
 PRUint32
-RasterImage::GetDecodedNonheapSize()
-{
-  return GetDecodedSize(mFrames, DECODED_SIZE_NONHEAP);
-}
-
-PRUint32
-RasterImage::GetDecodedHeapSize()
-{
-  return GetDecodedSize(mFrames, DECODED_SIZE_HEAP);
-}
-
-PRUint32
-RasterImage::GetSourceHeapSize()
+RasterImage::GetSourceDataSize()
 {
   PRUint32 sourceDataSize = mSourceData.Length();
   
   NS_ABORT_IF_FALSE(StoringSourceData() || (sourceDataSize == 0),
                     "Non-zero source data size when we aren't storing it?");
   return sourceDataSize;
 }
 
--- a/modules/libpr0n/src/RasterImage.h
+++ b/modules/libpr0n/src/RasterImage.h
@@ -204,19 +204,18 @@ public:
 
   /* The index of the current frame that would be drawn if the image was to be
    * drawn now. */
   PRUint32 GetCurrentFrameIndex();
 
   /* The total number of frames in this image. */
   PRUint32 GetNumFrames();
 
-  virtual PRUint32 GetDecodedHeapSize();
-  virtual PRUint32 GetDecodedNonheapSize();
-  virtual PRUint32 GetSourceHeapSize();
+  PRUint32 GetDecodedDataSize();
+  PRUint32 GetSourceDataSize();
 
   /* Triggers discarding. */
   void Discard(bool force = false);
   void ForceDiscard() { Discard(/* force = */ true); }
 
   /* Callbacks for decoders */
   nsresult SetFrameDisposalMethod(PRUint32 aFrameNum,
                                   PRInt32 aDisposalMethod);
--- a/modules/libpr0n/src/VectorImage.cpp
+++ b/modules/libpr0n/src/VectorImage.cpp
@@ -244,30 +244,24 @@ VectorImage::Init(imgIDecoderObserver* a
 
 void
 VectorImage::GetCurrentFrameRect(nsIntRect& aRect)
 {
   aRect = nsIntRect::GetMaxSizedIntRect();
 }
 
 PRUint32
-VectorImage::GetDecodedHeapSize()
+VectorImage::GetDecodedDataSize()
 {
   // XXXdholbert TODO: return num bytes used by helper SVG doc. (bug 590790)
   return sizeof(*this);
 }
 
 PRUint32
-VectorImage::GetDecodedNonheapSize()
-{
-  return 0;
-}
-
-PRUint32
-VectorImage::GetSourceHeapSize()
+VectorImage::GetSourceDataSize()
 {
   // We're not storing the source data -- we just feed that directly to
   // our helper SVG document as we receive it, for it to parse.
   // So 0 is an appropriate return value here.
   return 0;
 }
 
 nsresult
--- a/modules/libpr0n/src/VectorImage.h
+++ b/modules/libpr0n/src/VectorImage.h
@@ -82,20 +82,18 @@ public:
   virtual ~VectorImage();
 
   // Methods inherited from Image
   nsresult Init(imgIDecoderObserver* aObserver,
                 const char* aMimeType,
                 const char* aURIString,
                 PRUint32 aFlags);
   void GetCurrentFrameRect(nsIntRect& aRect);
-
-  virtual PRUint32 GetDecodedHeapSize();
-  virtual PRUint32 GetDecodedNonheapSize();
-  virtual PRUint32 GetSourceHeapSize();
+  PRUint32 GetDecodedDataSize();
+  PRUint32 GetSourceDataSize();
 
   // Callback for SVGRootRenderingObserver
   void InvalidateObserver();
 
 protected:
   virtual nsresult StartAnimation();
   virtual nsresult StopAnimation();
   virtual PRBool   ShouldAnimate();
--- a/modules/libpr0n/src/imgFrame.cpp
+++ b/modules/libpr0n/src/imgFrame.cpp
@@ -773,66 +773,45 @@ PRBool imgFrame::GetCompositingFailed() 
   return mCompositingFailed;
 }
 
 void imgFrame::SetCompositingFailed(PRBool val)
 {
   mCompositingFailed = val;
 }
 
-PRUint32 imgFrame::EstimateHeapMemoryUsed() const
+PRUint32 imgFrame::EstimateMemoryUsed() const
 {
   PRUint32 size = 0;
 
   if (mSinglePixel) {
     size += sizeof(gfxRGBA);
   }
 
   if (mPalettedImageData) {
     size += GetImageDataLength() + PaletteDataLength();
   }
 
 #ifdef USE_WIN_SURFACE
-  if (mWinSurface && mWinSurface->GetMemoryLocation() ==
-                     gfxASurface::MEMORY_IN_PROCESS_HEAP) {
+  if (mWinSurface) {
     size += mWinSurface->KnownMemoryUsed();
   } else
 #endif
 #ifdef XP_MACOSX
   if (mQuartzSurface) {
     size += mSize.width * mSize.height * 4;
   } else
 #endif
-  if (mImageSurface && mImageSurface->GetMemoryLocation() ==
-                       gfxASurface::MEMORY_IN_PROCESS_HEAP) {
+  if (mImageSurface) {
     size += mImageSurface->KnownMemoryUsed();
   }
 
-  if (mOptSurface && mOptSurface->GetMemoryLocation() ==
-                     gfxASurface::MEMORY_IN_PROCESS_HEAP) {
+  if (mOptSurface) {
     size += mOptSurface->KnownMemoryUsed();
   }
 
+  // fall back to pessimistic/approximate size
+  if (size == 0) {
+    size = mSize.width * mSize.height * 4;
+  }
+
   return size;
 }
-
-PRUint32 imgFrame::EstimateNonheapMemoryUsed() const
-{
-  PRUint32 size = 0;
-
-#ifdef USE_WIN_SURFACE
-  if (mWinSurface && mWinSurface->GetMemoryLocation() ==
-                     gfxASurface::MEMORY_IN_PROCESS_NONHEAP) {
-    size += mWinSurface->KnownMemoryUsed();
-  } else
-#endif
-  if (mImageSurface && mImageSurface->GetMemoryLocation() ==
-                       gfxASurface::MEMORY_IN_PROCESS_NONHEAP) {
-    size += mImageSurface->KnownMemoryUsed();
-  }
-
-  if (mOptSurface && mOptSurface->GetMemoryLocation() ==
-                     gfxASurface::MEMORY_IN_PROCESS_NONHEAP) {
-    size += mOptSurface->KnownMemoryUsed();
-  }
-
-  return size;
-}
--- a/modules/libpr0n/src/imgFrame.h
+++ b/modules/libpr0n/src/imgFrame.h
@@ -130,22 +130,18 @@ public:
       return mWinSurface;
 #elif defined(XP_MACOSX)
     if (mQuartzSurface)
       return mQuartzSurface;
 #endif
     return mImageSurface;
   }
 
-  // These functions estimate how much heap and non-heap memory the imgFrame is
-  // using.  Note that these only report memory within the current process; an
-  // imgFrame's surface might be using memory outside the current process (e.g.
-  // gfxXlibSurface).
-  PRUint32 EstimateHeapMemoryUsed() const;
-  PRUint32 EstimateNonheapMemoryUsed() const;
+  // returns an estimate of the memory used by this imgFrame
+  PRUint32 EstimateMemoryUsed() const;
 
   PRUint8 GetPaletteDepth() const { return mPaletteDepth; }
 
 private: // methods
   PRUint32 PaletteDataLength() const {
     return ((1 << mPaletteDepth) * sizeof(PRUint32));
   }
 
--- a/modules/libpr0n/src/imgLoader.cpp
+++ b/modules/libpr0n/src/imgLoader.cpp
@@ -138,87 +138,64 @@ static void PrintImageDecoders()
 class imgMemoryReporter :
   public nsIMemoryReporter
 {
 public:
   enum ReporterType {
     CHROME_BIT = PR_BIT(0),
     USED_BIT   = PR_BIT(1),
     RAW_BIT    = PR_BIT(2),
-    HEAP_BIT   = PR_BIT(3),
 
-    ChromeUsedRaw                     = CHROME_BIT | USED_BIT | RAW_BIT | HEAP_BIT,
-    ChromeUsedUncompressedHeap        = CHROME_BIT | USED_BIT | HEAP_BIT,
-    ChromeUsedUncompressedNonheap     = CHROME_BIT | USED_BIT,
-    ChromeUnusedRaw                   = CHROME_BIT | RAW_BIT | HEAP_BIT,
-    ChromeUnusedUncompressedHeap      = CHROME_BIT | HEAP_BIT,
-    ChromeUnusedUncompressedNonheap   = CHROME_BIT,
-    ContentUsedRaw                    = USED_BIT | RAW_BIT | HEAP_BIT,
-    ContentUsedUncompressedHeap       = USED_BIT | HEAP_BIT,
-    ContentUsedUncompressedNonheap    = USED_BIT,
-    ContentUnusedRaw                  = RAW_BIT | HEAP_BIT,
-    ContentUnusedUncompressedHeap     = HEAP_BIT,
-    ContentUnusedUncompressedNonheap  = 0
+    ChromeUsedRaw             = CHROME_BIT | USED_BIT | RAW_BIT,
+    ChromeUsedUncompressed    = CHROME_BIT | USED_BIT,
+    ChromeUnusedRaw           = CHROME_BIT | RAW_BIT,
+    ChromeUnusedUncompressed  = CHROME_BIT,
+    ContentUsedRaw            = USED_BIT | RAW_BIT,
+    ContentUsedUncompressed   = USED_BIT,
+    ContentUnusedRaw          = RAW_BIT,
+    ContentUnusedUncompressed = 0
   };
 
   imgMemoryReporter(ReporterType aType)
     : mType(aType)
-  {
-    // If the RAW bit is set, HEAP should also be set, because we don't
-    // currently understand storing compressed image data off the heap.
-    NS_ASSERTION(!(aType & RAW_BIT) || (aType & HEAP_BIT),
-                 "RAW bit should imply HEAP bit.");
-  }
+  { }
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD GetProcess(nsACString &process)
   {
     process.Truncate();
     return NS_OK;
   }
 
   NS_IMETHOD GetPath(nsACString &path)
   {
     if (mType == ChromeUsedRaw) {
       path.AssignLiteral("explicit/images/chrome/used/raw");
-    } else if (mType == ChromeUsedUncompressedHeap) {
-      path.AssignLiteral("explicit/images/chrome/used/uncompressed-heap");
-    } else if (mType == ChromeUsedUncompressedNonheap) {
-      path.AssignLiteral("explicit/images/chrome/used/uncompressed-nonheap");
+    } else if (mType == ChromeUsedUncompressed) {
+      path.AssignLiteral("explicit/images/chrome/used/uncompressed");
     } else if (mType == ChromeUnusedRaw) {
       path.AssignLiteral("explicit/images/chrome/unused/raw");
-    } else if (mType == ChromeUnusedUncompressedHeap) {
-      path.AssignLiteral("explicit/images/chrome/unused/uncompressed-heap");
-    } else if (mType == ChromeUnusedUncompressedNonheap) {
-      path.AssignLiteral("explicit/images/chrome/unused/uncompressed-nonheap");
+    } else if (mType == ChromeUnusedUncompressed) {
+      path.AssignLiteral("explicit/images/chrome/unused/uncompressed");
     } else if (mType == ContentUsedRaw) {
       path.AssignLiteral("explicit/images/content/used/raw");
-    } else if (mType == ContentUsedUncompressedHeap) {
-      path.AssignLiteral("explicit/images/content/used/uncompressed-heap");
-    } else if (mType == ContentUsedUncompressedNonheap) {
-      path.AssignLiteral("explicit/images/content/used/uncompressed-nonheap");
+    } else if (mType == ContentUsedUncompressed) {
+      path.AssignLiteral("explicit/images/content/used/uncompressed");
     } else if (mType == ContentUnusedRaw) {
       path.AssignLiteral("explicit/images/content/unused/raw");
-    } else if (mType == ContentUnusedUncompressedHeap) {
-      path.AssignLiteral("explicit/images/content/unused/uncompressed-heap");
-    } else if (mType == ContentUnusedUncompressedNonheap) {
-      path.AssignLiteral("explicit/images/content/unused/uncompressed-nonheap");
+    } else if (mType == ContentUnusedUncompressed) {
+      path.AssignLiteral("explicit/images/content/unused/uncompressed");
     }
     return NS_OK;
   }
 
   NS_IMETHOD GetKind(PRInt32 *kind)
   {
-    if (mType & HEAP_BIT) {
-      *kind = KIND_HEAP;
-    }
-    else {
-      *kind = KIND_MAPPED;
-    }
+    *kind = KIND_HEAP;
     return NS_OK;
   }
 
   NS_IMETHOD GetUnits(PRInt32 *units)
   {
     *units = UNITS_BYTES;
     return NS_OK;
   }
@@ -248,21 +225,19 @@ public:
     }
 
     nsRefPtr<imgRequest> req = entry->GetRequest();
     Image *image = static_cast<Image*>(req->mImage.get());
     if (!image)
       return PL_DHASH_NEXT;
 
     if (rtype & RAW_BIT) {
-      arg->value += image->GetSourceHeapSize();
-    } else if (rtype & HEAP_BIT) {
-      arg->value += image->GetDecodedHeapSize();
+      arg->value += image->GetSourceDataSize();
     } else {
-      arg->value += image->GetDecodedNonheapSize();
+      arg->value += image->GetDecodedDataSize();
     }
 
     return PL_DHASH_NEXT;
   }
 
   NS_IMETHOD GetAmount(PRInt64 *amount)
   {
     EnumArg arg(mType);
@@ -275,37 +250,29 @@ public:
     *amount = arg.value;
     return NS_OK;
   }
 
   NS_IMETHOD GetDescription(nsACString &desc)
   {
     if (mType == ChromeUsedRaw) {
       desc.AssignLiteral("Memory used by in-use chrome images (compressed data).");
-    } else if (mType == ChromeUsedUncompressedHeap) {
-      desc.AssignLiteral("Memory used by in-use chrome images (uncompressed data).");
-    } else if (mType == ChromeUsedUncompressedNonheap) {
+    } else if (mType == ChromeUsedUncompressed) {
       desc.AssignLiteral("Memory used by in-use chrome images (uncompressed data).");
     } else if (mType == ChromeUnusedRaw) {
       desc.AssignLiteral("Memory used by not in-use chrome images (compressed data).");
-    } else if (mType == ChromeUnusedUncompressedHeap) {
-      desc.AssignLiteral("Memory used by not in-use chrome images (uncompressed data).");
-    } else if (mType == ChromeUnusedUncompressedNonheap) {
+    } else if (mType == ChromeUnusedUncompressed) {
       desc.AssignLiteral("Memory used by not in-use chrome images (uncompressed data).");
     } else if (mType == ContentUsedRaw) {
       desc.AssignLiteral("Memory used by in-use content images (compressed data).");
-    } else if (mType == ContentUsedUncompressedHeap) {
-      desc.AssignLiteral("Memory used by in-use content images (uncompressed data).");
-    } else if (mType == ContentUsedUncompressedNonheap) {
+    } else if (mType == ContentUsedUncompressed) {
       desc.AssignLiteral("Memory used by in-use content images (uncompressed data).");
     } else if (mType == ContentUnusedRaw) {
       desc.AssignLiteral("Memory used by not in-use content images (compressed data).");
-    } else if (mType == ContentUnusedUncompressedHeap) {
-      desc.AssignLiteral("Memory used by not in-use content images (uncompressed data).");
-    } else if (mType == ContentUnusedUncompressedNonheap) {
+    } else if (mType == ContentUnusedUncompressed) {
       desc.AssignLiteral("Memory used by not in-use content images (uncompressed data).");
     }
     return NS_OK;
   }
 
   ReporterType mType;
 };
 
@@ -909,27 +876,23 @@ nsresult imgLoader::InitCache()
   PRInt32 cachesize;
   rv = Preferences::GetInt("image.cache.size", &cachesize);
   if (NS_SUCCEEDED(rv))
     sCacheMaxSize = cachesize;
   else
     sCacheMaxSize = 5 * 1024 * 1024;
 
   NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedRaw));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressedHeap));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressedNonheap));
+  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressed));
   NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedRaw));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressedHeap));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressedNonheap));
+  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressed));
   NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedRaw));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressedHeap));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressedNonheap));
+  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressed));
   NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedRaw));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressedHeap));
-  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressedNonheap));
+  NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressed));
   
   return NS_OK;
 }
 
 nsresult imgLoader::Init()
 {
   ReadAcceptHeaderPref();