зеркало из https://github.com/mozilla/gecko-dev.git
Bug 664659 - Fix about:memory image reporters. r=joe
This commit is contained in:
Родитель
9d7d97c0a9
Коммит
de9cb8f577
|
@ -502,6 +502,12 @@ gfxASurface::GetSubpixelAntialiasingEnabled()
|
|||
#endif
|
||||
}
|
||||
|
||||
gfxASurface::MemoryLocation
|
||||
gfxASurface::GetMemoryLocation() const
|
||||
{
|
||||
return MEMORY_IN_PROCESS_HEAP;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
|
||||
{
|
||||
|
@ -561,39 +567,54 @@ gfxASurface::MovePixels(const nsIntRect& aSourceRect,
|
|||
|
||||
/** Memory reporting **/
|
||||
|
||||
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 char *sDefaultSurfaceDescription =
|
||||
"Memory used by gfx surface of the given type.";
|
||||
|
||||
struct SurfaceMemoryReporterAttrs {
|
||||
const char *name;
|
||||
const char *description;
|
||||
};
|
||||
|
||||
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceNamesForSurfaceType) == gfxASurface::SurfaceTypeMax);
|
||||
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);
|
||||
#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)
|
||||
|
@ -602,7 +623,17 @@ SurfaceMemoryReporterPathForType(gfxASurface::gfxSurfaceType aType)
|
|||
aType >= gfxASurface::SurfaceTypeMax)
|
||||
return "gfx-surface-unknown";
|
||||
|
||||
return sSurfaceNamesForSurfaceType[aType];
|
||||
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;
|
||||
}
|
||||
|
||||
/* Surface size memory reporting */
|
||||
|
@ -645,7 +676,7 @@ public:
|
|||
}
|
||||
|
||||
NS_IMETHOD GetDescription(nsACString &desc) {
|
||||
desc.AssignLiteral("Memory used by gfx surface of the given type.");
|
||||
desc.Assign(SurfaceMemoryReporterDescriptionForType(mType));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,24 @@ public:
|
|||
void RecordMemoryUsed(PRInt32 aBytes);
|
||||
void RecordMemoryFreed();
|
||||
|
||||
PRInt32 KnownMemoryUsed() { return mBytesRecorded; }
|
||||
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;
|
||||
|
||||
static PRInt32 BytePerPixelFromFormat(gfxImageFormat format);
|
||||
|
||||
|
|
|
@ -58,6 +58,17 @@ 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()
|
||||
{
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
virtual ~gfxQuartzImageSurface();
|
||||
|
||||
already_AddRefed<gfxImageSurface> GetAsImageSurface();
|
||||
virtual PRInt32 KnownMemoryUsed();
|
||||
};
|
||||
|
||||
#endif /* GFX_QUARTZIMAGESURFACE_H */
|
||||
|
|
|
@ -328,3 +328,9 @@ gfxWindowsSurface::GetDefaultContextFlags() const
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gfxASurface::MemoryLocation
|
||||
gfxWindowsSurface::GetMemoryLocation() const
|
||||
{
|
||||
return MEMORY_IN_PROCESS_NONHEAP;
|
||||
}
|
||||
|
|
|
@ -98,6 +98,10 @@ public:
|
|||
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;
|
||||
|
|
|
@ -104,6 +104,7 @@ gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
|
|||
|
||||
gfxXlibSurface::~gfxXlibSurface()
|
||||
{
|
||||
// gfxASurface's destructor calls RecordMemoryFreed().
|
||||
if (mPixmapTaken) {
|
||||
XFreePixmap (mDisplay, mDrawable);
|
||||
}
|
||||
|
@ -127,6 +128,26 @@ CreatePixmap(Screen *screen, const gfxIntSize& size, unsigned int depth,
|
|||
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,
|
||||
|
@ -502,3 +523,8 @@ gfxXlibSurface::XRenderFormat()
|
|||
return cairo_xlib_surface_get_xrender_format(CairoSurface());
|
||||
}
|
||||
|
||||
gfxASurface::MemoryLocation
|
||||
gfxXlibSurface::GetMemoryLocation() const
|
||||
{
|
||||
return MEMORY_OUT_OF_PROCESS;
|
||||
}
|
||||
|
|
|
@ -90,23 +90,20 @@ public:
|
|||
|
||||
// take ownership of a passed-in Pixmap, calling XFreePixmap on it
|
||||
// when the gfxXlibSurface is destroyed.
|
||||
void TakePixmap() {
|
||||
NS_ASSERTION(!mPixmapTaken, "I already own the Pixmap!");
|
||||
mPixmapTaken = PR_TRUE;
|
||||
}
|
||||
void TakePixmap();
|
||||
|
||||
// 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() {
|
||||
NS_ASSERTION(mPixmapTaken, "I don't own the Pixmap!");
|
||||
mPixmapTaken = PR_FALSE;
|
||||
return mDrawable;
|
||||
}
|
||||
Drawable ReleasePixmap();
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -63,7 +63,7 @@ Image::GetDataSize()
|
|||
if (mError)
|
||||
return 0;
|
||||
|
||||
return GetSourceDataSize() + GetDecodedDataSize();
|
||||
return GetSourceHeapSize() + GetDecodedHeapSize() + GetDecodedNonheapSize();
|
||||
}
|
||||
|
||||
// Translates a mimetype into a concrete decoder
|
||||
|
|
|
@ -102,8 +102,9 @@ public:
|
|||
/**
|
||||
* The components that make up GetDataSize().
|
||||
*/
|
||||
virtual PRUint32 GetDecodedDataSize() = 0;
|
||||
virtual PRUint32 GetSourceDataSize() = 0;
|
||||
virtual PRUint32 GetDecodedHeapSize() = 0;
|
||||
virtual PRUint32 GetDecodedNonheapSize() = 0;
|
||||
virtual PRUint32 GetSourceHeapSize() = 0;
|
||||
|
||||
// Mimetype translation
|
||||
enum eDecoderType {
|
||||
|
|
|
@ -745,21 +745,45 @@ RasterImage::GetFrame(PRUint32 aWhichFrame,
|
|||
return rv;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
enum DecodedSizeType {
|
||||
DECODED_SIZE_HEAP,
|
||||
DECODED_SIZE_NONHEAP
|
||||
};
|
||||
|
||||
PRUint32
|
||||
RasterImage::GetDecodedDataSize()
|
||||
GetDecodedSize(const nsTArray<imgFrame *> &aFrames, DecodedSizeType aType)
|
||||
{
|
||||
PRUint32 val = 0;
|
||||
for (PRUint32 i = 0; i < mFrames.Length(); ++i) {
|
||||
imgFrame *frame = mFrames.SafeElementAt(i, nsnull);
|
||||
for (PRUint32 i = 0; i < aFrames.Length(); ++i) {
|
||||
imgFrame *frame = aFrames.SafeElementAt(i, nsnull);
|
||||
NS_ABORT_IF_FALSE(frame, "Null frame in frame array!");
|
||||
val += frame->EstimateMemoryUsed();
|
||||
if (aType == DECODED_SIZE_HEAP)
|
||||
val += frame->EstimateHeapMemoryUsed();
|
||||
else
|
||||
val += frame->EstimateNonheapMemoryUsed();
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
PRUint32
|
||||
RasterImage::GetSourceDataSize()
|
||||
RasterImage::GetDecodedNonheapSize()
|
||||
{
|
||||
return GetDecodedSize(mFrames, DECODED_SIZE_NONHEAP);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
RasterImage::GetDecodedHeapSize()
|
||||
{
|
||||
return GetDecodedSize(mFrames, DECODED_SIZE_HEAP);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
RasterImage::GetSourceHeapSize()
|
||||
{
|
||||
PRUint32 sourceDataSize = mSourceData.Length();
|
||||
|
||||
|
|
|
@ -209,8 +209,9 @@ public:
|
|||
/* The total number of frames in this image. */
|
||||
PRUint32 GetNumFrames();
|
||||
|
||||
PRUint32 GetDecodedDataSize();
|
||||
PRUint32 GetSourceDataSize();
|
||||
virtual PRUint32 GetDecodedHeapSize();
|
||||
virtual PRUint32 GetDecodedNonheapSize();
|
||||
virtual PRUint32 GetSourceHeapSize();
|
||||
|
||||
/* Triggers discarding. */
|
||||
void Discard(bool force = false);
|
||||
|
|
|
@ -249,14 +249,20 @@ VectorImage::GetCurrentFrameRect(nsIntRect& aRect)
|
|||
}
|
||||
|
||||
PRUint32
|
||||
VectorImage::GetDecodedDataSize()
|
||||
VectorImage::GetDecodedHeapSize()
|
||||
{
|
||||
// XXXdholbert TODO: return num bytes used by helper SVG doc. (bug 590790)
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
VectorImage::GetSourceDataSize()
|
||||
VectorImage::GetDecodedNonheapSize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
VectorImage::GetSourceHeapSize()
|
||||
{
|
||||
// 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.
|
||||
|
|
|
@ -87,8 +87,10 @@ public:
|
|||
const char* aURIString,
|
||||
PRUint32 aFlags);
|
||||
void GetCurrentFrameRect(nsIntRect& aRect);
|
||||
PRUint32 GetDecodedDataSize();
|
||||
PRUint32 GetSourceDataSize();
|
||||
|
||||
virtual PRUint32 GetDecodedHeapSize();
|
||||
virtual PRUint32 GetDecodedNonheapSize();
|
||||
virtual PRUint32 GetSourceHeapSize();
|
||||
|
||||
// Callback for SVGRootRenderingObserver
|
||||
void InvalidateObserver();
|
||||
|
|
|
@ -778,7 +778,7 @@ void imgFrame::SetCompositingFailed(PRBool val)
|
|||
mCompositingFailed = val;
|
||||
}
|
||||
|
||||
PRUint32 imgFrame::EstimateMemoryUsed() const
|
||||
PRUint32 imgFrame::EstimateHeapMemoryUsed() const
|
||||
{
|
||||
PRUint32 size = 0;
|
||||
|
||||
|
@ -791,7 +791,8 @@ PRUint32 imgFrame::EstimateMemoryUsed() const
|
|||
}
|
||||
|
||||
#ifdef USE_WIN_SURFACE
|
||||
if (mWinSurface) {
|
||||
if (mWinSurface && mWinSurface->GetMemoryLocation() ==
|
||||
gfxASurface::MEMORY_IN_PROCESS_HEAP) {
|
||||
size += mWinSurface->KnownMemoryUsed();
|
||||
} else
|
||||
#endif
|
||||
|
@ -800,18 +801,38 @@ PRUint32 imgFrame::EstimateMemoryUsed() const
|
|||
size += mSize.width * mSize.height * 4;
|
||||
} else
|
||||
#endif
|
||||
if (mImageSurface) {
|
||||
if (mImageSurface && mImageSurface->GetMemoryLocation() ==
|
||||
gfxASurface::MEMORY_IN_PROCESS_HEAP) {
|
||||
size += mImageSurface->KnownMemoryUsed();
|
||||
}
|
||||
|
||||
if (mOptSurface) {
|
||||
if (mOptSurface && mOptSurface->GetMemoryLocation() ==
|
||||
gfxASurface::MEMORY_IN_PROCESS_HEAP) {
|
||||
size += mOptSurface->KnownMemoryUsed();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// fall back to pessimistic/approximate size
|
||||
if (size == 0) {
|
||||
size = mSize.width * mSize.height * 4;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -135,8 +135,12 @@ public:
|
|||
return mImageSurface;
|
||||
}
|
||||
|
||||
// returns an estimate of the memory used by this imgFrame
|
||||
PRUint32 EstimateMemoryUsed() const;
|
||||
// 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;
|
||||
|
||||
PRUint8 GetPaletteDepth() const { return mPaletteDepth; }
|
||||
|
||||
|
|
|
@ -143,20 +143,30 @@ public:
|
|||
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,
|
||||
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
|
||||
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
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
|
@ -170,27 +180,40 @@ public:
|
|||
{
|
||||
if (mType == ChromeUsedRaw) {
|
||||
path.AssignLiteral("explicit/images/chrome/used/raw");
|
||||
} else if (mType == ChromeUsedUncompressed) {
|
||||
path.AssignLiteral("explicit/images/chrome/used/uncompressed");
|
||||
} 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 == ChromeUnusedRaw) {
|
||||
path.AssignLiteral("explicit/images/chrome/unused/raw");
|
||||
} else if (mType == ChromeUnusedUncompressed) {
|
||||
path.AssignLiteral("explicit/images/chrome/unused/uncompressed");
|
||||
} 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 == ContentUsedRaw) {
|
||||
path.AssignLiteral("explicit/images/content/used/raw");
|
||||
} else if (mType == ContentUsedUncompressed) {
|
||||
path.AssignLiteral("explicit/images/content/used/uncompressed");
|
||||
} 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 == ContentUnusedRaw) {
|
||||
path.AssignLiteral("explicit/images/content/unused/raw");
|
||||
} else if (mType == ContentUnusedUncompressed) {
|
||||
path.AssignLiteral("explicit/images/content/unused/uncompressed");
|
||||
} else if (mType == ContentUnusedUncompressedHeap) {
|
||||
path.AssignLiteral("explicit/images/content/unused/uncompressed-heap");
|
||||
} else if (mType == ContentUnusedUncompressedNonheap) {
|
||||
path.AssignLiteral("explicit/images/content/unused/uncompressed-nonheap");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetKind(PRInt32 *kind)
|
||||
{
|
||||
*kind = KIND_HEAP;
|
||||
if (mType & HEAP_BIT) {
|
||||
*kind = KIND_HEAP;
|
||||
}
|
||||
else {
|
||||
*kind = KIND_MAPPED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -230,9 +253,11 @@ public:
|
|||
return PL_DHASH_NEXT;
|
||||
|
||||
if (rtype & RAW_BIT) {
|
||||
arg->value += image->GetSourceDataSize();
|
||||
arg->value += image->GetSourceHeapSize();
|
||||
} else if (rtype & HEAP_BIT) {
|
||||
arg->value += image->GetDecodedHeapSize();
|
||||
} else {
|
||||
arg->value += image->GetDecodedDataSize();
|
||||
arg->value += image->GetDecodedNonheapSize();
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
|
@ -255,19 +280,27 @@ public:
|
|||
{
|
||||
if (mType == ChromeUsedRaw) {
|
||||
desc.AssignLiteral("Memory used by in-use chrome images (compressed data).");
|
||||
} else if (mType == ChromeUsedUncompressed) {
|
||||
} else if (mType == ChromeUsedUncompressedHeap) {
|
||||
desc.AssignLiteral("Memory used by in-use chrome images (uncompressed data).");
|
||||
} else if (mType == ChromeUsedUncompressedNonheap) {
|
||||
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 == ChromeUnusedUncompressed) {
|
||||
} else if (mType == ChromeUnusedUncompressedHeap) {
|
||||
desc.AssignLiteral("Memory used by not in-use chrome images (uncompressed data).");
|
||||
} else if (mType == ChromeUnusedUncompressedNonheap) {
|
||||
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 == ContentUsedUncompressed) {
|
||||
} else if (mType == ContentUsedUncompressedHeap) {
|
||||
desc.AssignLiteral("Memory used by in-use content images (uncompressed data).");
|
||||
} else if (mType == ContentUsedUncompressedNonheap) {
|
||||
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 == ContentUnusedUncompressed) {
|
||||
} else if (mType == ContentUnusedUncompressedHeap) {
|
||||
desc.AssignLiteral("Memory used by not in-use content images (uncompressed data).");
|
||||
} else if (mType == ContentUnusedUncompressedNonheap) {
|
||||
desc.AssignLiteral("Memory used by not in-use content images (uncompressed data).");
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -881,13 +914,17 @@ nsresult imgLoader::InitCache()
|
|||
sCacheMaxSize = 5 * 1024 * 1024;
|
||||
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedRaw));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressed));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressedHeap));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressedNonheap));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedRaw));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressed));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressedHeap));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressedNonheap));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedRaw));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressed));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressedHeap));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressedNonheap));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedRaw));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressed));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressedHeap));
|
||||
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressedNonheap));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче