mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-07 15:12:28 +00:00
Bug 711901 - When possible, measure, don't compute, the size of imgFrame::mImageSurface. r=joedrew.
--HG-- extra : rebase_source : 72dc61c2618166262ec6d83778d7bd2a3a7b5d61
This commit is contained in:
parent
26ca8d2f6a
commit
65cbbd034d
@ -649,6 +649,19 @@ gfxASurface::RecordMemoryFreed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
gfxASurface::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
||||||
|
{
|
||||||
|
// We don't measure mSurface because cairo doesn't allow it.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
gfxASurface::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
||||||
|
{
|
||||||
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MOZ_DUMP_IMAGES
|
#ifdef MOZ_DUMP_IMAGES
|
||||||
void
|
void
|
||||||
gfxASurface::WriteAsPNG(const char* aFile)
|
gfxASurface::WriteAsPNG(const char* aFile)
|
||||||
|
@ -197,6 +197,9 @@ public:
|
|||||||
|
|
||||||
virtual int32_t KnownMemoryUsed() { return mBytesRecorded; }
|
virtual int32_t KnownMemoryUsed() { return mBytesRecorded; }
|
||||||
|
|
||||||
|
virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||||
|
virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The memory used by this surface (as reported by KnownMemoryUsed()) can
|
* The memory used by this surface (as reported by KnownMemoryUsed()) can
|
||||||
* either live in this process's heap, in this process but outside the
|
* either live in this process's heap, in this process but outside the
|
||||||
|
@ -174,6 +174,22 @@ gfxImageSurface::ComputeStride(const gfxIntSize& aSize, gfxImageFormat aFormat)
|
|||||||
return stride;
|
return stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
gfxImageSurface::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
||||||
|
{
|
||||||
|
size_t n = gfxASurface::SizeOfExcludingThis(aMallocSizeOf);
|
||||||
|
if (mOwnsData) {
|
||||||
|
n += aMallocSizeOf(mData);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
gfxImageSurface::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
||||||
|
{
|
||||||
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
||||||
|
}
|
||||||
|
|
||||||
// helper function for the CopyFrom methods
|
// helper function for the CopyFrom methods
|
||||||
static void
|
static void
|
||||||
CopyForStride(unsigned char* aDest, unsigned char* aSrc, const gfxIntSize& aSize, long aDestStride, long aSrcStride)
|
CopyForStride(unsigned char* aDest, unsigned char* aSrc, const gfxIntSize& aSize, long aDestStride, long aSrcStride)
|
||||||
|
@ -93,6 +93,12 @@ public:
|
|||||||
const nsIntPoint& aDestTopLeft) MOZ_OVERRIDE;
|
const nsIntPoint& aDestTopLeft) MOZ_OVERRIDE;
|
||||||
|
|
||||||
static long ComputeStride(const gfxIntSize&, gfxImageFormat);
|
static long ComputeStride(const gfxIntSize&, gfxImageFormat);
|
||||||
|
|
||||||
|
virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
||||||
|
MOZ_OVERRIDE;
|
||||||
|
virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
||||||
|
MOZ_OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
gfxImageSurface();
|
gfxImageSurface();
|
||||||
void InitWithData(unsigned char *aData, const gfxIntSize& aSize,
|
void InitWithData(unsigned char *aData, const gfxIntSize& aSize,
|
||||||
|
@ -790,6 +790,9 @@ void imgFrame::SetCompositingFailed(bool val)
|
|||||||
mCompositingFailed = val;
|
mCompositingFailed = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
size_t
|
||||||
imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, nsMallocSizeOfFun aMallocSizeOf) const
|
imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, nsMallocSizeOfFun aMallocSizeOf) const
|
||||||
{
|
{
|
||||||
@ -803,11 +806,11 @@ imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxASurface::MemoryLocat
|
|||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
if (mPalettedImageData && aLocation == gfxASurface::MEMORY_IN_PROCESS_HEAP) {
|
if (mPalettedImageData && aLocation == gfxASurface::MEMORY_IN_PROCESS_HEAP) {
|
||||||
size_t usable = aMallocSizeOf(mPalettedImageData);
|
size_t n2 = aMallocSizeOf(mPalettedImageData);
|
||||||
if (!usable) {
|
if (n2 == 0) {
|
||||||
usable = GetImageDataLength() + PaletteDataLength();
|
n2 = GetImageDataLength() + PaletteDataLength();
|
||||||
}
|
}
|
||||||
n += usable;
|
n += n2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: should pass aMallocSizeOf here. See bug 723827.
|
// XXX: should pass aMallocSizeOf here. See bug 723827.
|
||||||
@ -822,7 +825,14 @@ imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxASurface::MemoryLocat
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (mImageSurface && aLocation == mImageSurface->GetMemoryLocation()) {
|
if (mImageSurface && aLocation == mImageSurface->GetMemoryLocation()) {
|
||||||
n += mImageSurface->KnownMemoryUsed();
|
size_t n2 = 0;
|
||||||
|
if (aLocation == gfxASurface::MEMORY_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()) {
|
if (mOptSurface && aLocation == mOptSurface->GetMemoryLocation()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user