Bug 1711061 - Part 1. Remove SourceSurfaceMappedData surface deduplication from memory reports. r=tnikkel

We no longer use SourceSurfaceMappedData because we only support
SourceSurfaceSharedData-backed imgFrame in the SurfaceCache now.

Differential Revision: https://phabricator.services.mozilla.com/D126595
This commit is contained in:
Andrew Osmond
2021-10-26 13:28:23 +00:00
parent a95448e1a7
commit b2e2d3ac42
5 changed files with 8 additions and 37 deletions

View File

@@ -381,40 +381,16 @@ void ImageResource::CollectSizeOfSurfaces(
continue;
}
// The surface might be wrapping another.
bool isMappedSurface = surface->GetType() == gfx::SurfaceType::DATA_MAPPED;
const gfx::SourceSurface* actualSurface =
isMappedSurface
? static_cast<gfx::SourceSurfaceMappedData*>(surface.get())
->GetScopedSurface()
: surface.get();
// Check if the surface is already in the report. Ignore if so.
bool found = false;
for (const auto& counter : aCounters) {
if (counter.Surface() == actualSurface) {
found = true;
break;
}
}
if (found) {
continue;
}
// The surface isn't in the report, so it isn't stored in SurfaceCache. We
// need to add our own entry here so that it will be included in the memory
// report.
gfx::SourceSurface::SizeOfInfo info;
surface->SizeOfExcludingThis(aMallocSizeOf, info);
uint32_t heapBytes = aMallocSizeOf(actualSurface);
if (isMappedSurface) {
heapBytes += aMallocSizeOf(surface.get());
}
uint32_t heapBytes = aMallocSizeOf(surface);
SurfaceKey key = ContainerSurfaceKey(surface->GetSize(), entry.mSVGContext,
ToSurfaceFlags(entry.mFlags));
SurfaceMemoryCounter counter(key, actualSurface, /* aIsLocked */ false,
SurfaceMemoryCounter counter(key, /* aIsLocked */ false,
/* aCannotSubstitute */ false,
/* aIsFactor2 */ false, /* aFinished */ true,
SurfaceMemoryCounterType::CONTAINER);

View File

@@ -89,11 +89,10 @@ enum class SurfaceMemoryCounterType { NORMAL, CONTAINER };
struct SurfaceMemoryCounter {
SurfaceMemoryCounter(
const SurfaceKey& aKey, const gfx::SourceSurface* aSurface,
bool aIsLocked, bool aCannotSubstitute, bool aIsFactor2, bool aFinished,
const SurfaceKey& aKey, bool aIsLocked, bool aCannotSubstitute,
bool aIsFactor2, bool aFinished,
SurfaceMemoryCounterType aType = SurfaceMemoryCounterType::NORMAL)
: mKey(aKey),
mSurface(aSurface),
mType(aType),
mIsLocked(aIsLocked),
mCannotSubstitute(aCannotSubstitute),
@@ -101,7 +100,6 @@ struct SurfaceMemoryCounter {
mFinished(aFinished) {}
const SurfaceKey& Key() const { return mKey; }
const gfx::SourceSurface* Surface() const { return mSurface; }
MemoryCounter& Values() { return mValues; }
const MemoryCounter& Values() const { return mValues; }
SurfaceMemoryCounterType Type() const { return mType; }
@@ -112,7 +110,6 @@ struct SurfaceMemoryCounter {
private:
const SurfaceKey mKey;
const gfx::SourceSurface* MOZ_NON_OWNING_REF mSurface;
MemoryCounter mValues;
const SurfaceMemoryCounterType mType;
const bool mIsLocked;

View File

@@ -193,10 +193,10 @@ class CachedSurface {
// for surfaces with PlaybackType::eAnimated.)
aCachedSurface->mProvider->AddSizeOfExcludingThis(
mMallocSizeOf, [&](ISurfaceProvider::AddSizeOfCbData& aMetadata) {
SurfaceMemoryCounter counter(
aCachedSurface->GetSurfaceKey(), aMetadata.mSurface,
aCachedSurface->IsLocked(), aCachedSurface->CannotSubstitute(),
aIsFactor2, aMetadata.mFinished);
SurfaceMemoryCounter counter(aCachedSurface->GetSurfaceKey(),
aCachedSurface->IsLocked(),
aCachedSurface->CannotSubstitute(),
aIsFactor2, aMetadata.mFinished);
counter.Values().SetDecodedHeap(aMetadata.mHeapBytes);
counter.Values().SetDecodedNonHeap(aMetadata.mNonHeapBytes);

View File

@@ -680,7 +680,6 @@ void imgFrame::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
MonitorAutoLock lock(mMonitor);
AddSizeOfCbData metadata;
metadata.mSurface = mOptSurface ? mOptSurface.get() : mRawSurface.get();
metadata.mFinished = mFinished;
if (mOptSurface) {

View File

@@ -168,7 +168,6 @@ class imgFrame {
AddSizeOfCbData()
: SourceSurface::SizeOfInfo(), mIndex(0), mFinished(false) {}
const gfx::SourceSurface* mSurface;
size_t mIndex;
bool mFinished;
};