mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1188705 (part 3) - Simplify imgFrame::SizeOfExcludingThis(). r=seth.
imgFrame::SizeOfExcludingThis() measures heap and non-heap memory in a very complex way. This patch simplifies it and removes gfxMemoryLocation in the process. (gfxMemoryLocation::OUT_OF_PROCESS was unused.) --HG-- extra : rebase_source : 72af38fa438b4b42df02231bcf2fa731d247b60d
This commit is contained in:
parent
03c7260391
commit
31ef869796
@ -92,15 +92,4 @@ enum class gfxContentType {
|
||||
SENTINEL = 0xffff
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
enum class gfxMemoryLocation {
|
||||
IN_PROCESS_HEAP,
|
||||
IN_PROCESS_NONHEAP,
|
||||
OUT_OF_PROCESS
|
||||
};
|
||||
|
||||
#endif /* GFX_TYPES_H */
|
||||
|
@ -334,12 +334,9 @@ DoCollectSizeOfCompositingSurfaces(const RawAccessFrameRef& aSurface,
|
||||
SurfaceMemoryCounter counter(key, /* aIsLocked = */ true, aType);
|
||||
|
||||
// Extract the surface's memory usage information.
|
||||
size_t heap = aSurface
|
||||
->SizeOfExcludingThis(gfxMemoryLocation::IN_PROCESS_HEAP, aMallocSizeOf);
|
||||
size_t heap = 0, nonHeap = 0;
|
||||
aSurface->AddSizeOfExcludingThis(aMallocSizeOf, heap, nonHeap);
|
||||
counter.Values().SetDecodedHeap(heap);
|
||||
|
||||
size_t nonHeap = aSurface
|
||||
->SizeOfExcludingThis(gfxMemoryLocation::IN_PROCESS_NONHEAP, nullptr);
|
||||
counter.Values().SetDecodedNonHeap(nonHeap);
|
||||
|
||||
// Record it.
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "gfx2DGlue.h" // for gfxMemoryLocation
|
||||
#include "gfx2DGlue.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "ImageURL.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
@ -207,13 +207,10 @@ public:
|
||||
if (aCachedSurface->mSurface) {
|
||||
counter.SubframeSize() = Some(aCachedSurface->mSurface->GetSize());
|
||||
|
||||
size_t heap = aCachedSurface->mSurface
|
||||
->SizeOfExcludingThis(gfxMemoryLocation::IN_PROCESS_HEAP,
|
||||
mMallocSizeOf);
|
||||
size_t heap = 0, nonHeap = 0;
|
||||
aCachedSurface->mSurface->AddSizeOfExcludingThis(mMallocSizeOf,
|
||||
heap, nonHeap);
|
||||
counter.Values().SetDecodedHeap(heap);
|
||||
|
||||
size_t nonHeap = aCachedSurface->mSurface
|
||||
->SizeOfExcludingThis(gfxMemoryLocation::IN_PROCESS_NONHEAP, nullptr);
|
||||
counter.Values().SetDecodedNonHeap(nonHeap);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "mozilla/Maybe.h" // for Maybe
|
||||
#include "mozilla/MemoryReporting.h" // for MallocSizeOf
|
||||
#include "mozilla/HashFunctions.h" // for HashGeneric and AddToHash
|
||||
#include "gfx2DGlue.h" // for gfxMemoryLocation
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxPoint.h" // for gfxSize
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "mozilla/gfx/Point.h" // for mozilla::gfx::IntSize
|
||||
|
@ -1115,42 +1115,28 @@ imgFrame::SetCompositingFailed(bool val)
|
||||
mCompositingFailed = val;
|
||||
}
|
||||
|
||||
size_t
|
||||
imgFrame::SizeOfExcludingThis(gfxMemoryLocation aLocation,
|
||||
MallocSizeOf aMallocSizeOf) const
|
||||
void
|
||||
imgFrame::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
size_t& aHeapSizeOut,
|
||||
size_t& aNonHeapSizeOut) const
|
||||
{
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
|
||||
// aMallocSizeOf is only used if aLocation is
|
||||
// gfxMemoryLocation::IN_PROCESS_HEAP. It
|
||||
// should be nullptr otherwise.
|
||||
MOZ_ASSERT(
|
||||
(aLocation == gfxMemoryLocation::IN_PROCESS_HEAP && aMallocSizeOf) ||
|
||||
(aLocation != gfxMemoryLocation::IN_PROCESS_HEAP && !aMallocSizeOf),
|
||||
"mismatch between aLocation and aMallocSizeOf");
|
||||
|
||||
size_t n = 0;
|
||||
|
||||
if (mPalettedImageData && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
||||
n += aMallocSizeOf(mPalettedImageData);
|
||||
if (mPalettedImageData) {
|
||||
aHeapSizeOut += aMallocSizeOf(mPalettedImageData);
|
||||
}
|
||||
if (mImageSurface && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
||||
n += aMallocSizeOf(mImageSurface);
|
||||
if (mImageSurface) {
|
||||
aHeapSizeOut += aMallocSizeOf(mImageSurface);
|
||||
}
|
||||
if (mOptSurface && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
||||
n += aMallocSizeOf(mOptSurface);
|
||||
if (mOptSurface) {
|
||||
aHeapSizeOut += aMallocSizeOf(mOptSurface);
|
||||
}
|
||||
|
||||
if (mVBuf && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
||||
n += aMallocSizeOf(mVBuf);
|
||||
n += mVBuf->HeapSizeOfExcludingThis(aMallocSizeOf);
|
||||
if (mVBuf) {
|
||||
aHeapSizeOut += aMallocSizeOf(mVBuf);
|
||||
aHeapSizeOut += mVBuf->HeapSizeOfExcludingThis(aMallocSizeOf);
|
||||
aNonHeapSizeOut += mVBuf->NonHeapSizeOfExcludingThis();
|
||||
}
|
||||
|
||||
if (mVBuf && aLocation == gfxMemoryLocation::IN_PROCESS_NONHEAP) {
|
||||
n += mVBuf->NonHeapSizeOfExcludingThis();
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
|
@ -264,8 +264,8 @@ public:
|
||||
already_AddRefed<SourceSurface> GetSurface();
|
||||
already_AddRefed<DrawTarget> GetDrawTarget();
|
||||
|
||||
size_t SizeOfExcludingThis(gfxMemoryLocation aLocation,
|
||||
MallocSizeOf aMallocSizeOf) const;
|
||||
void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut,
|
||||
size_t& aNonHeapSizeOut) const;
|
||||
|
||||
private: // methods
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user