gecko-dev/image/RecyclingSourceSurface.h
Andrew Osmond 52c022a178 Bug 1612589 - Improve image memory reporting even further. r=tnikkel
This patch adds reporting the surface types used by the image frame in a
bit mask (such if it is a CAPTURE including a DATA_SHARED, the mask will
be 1 << CAPTURE | 1 << DATA_SHARED), as well as an estimated size
included in the report as decoded-unknown for when we do not know if the
surface is on the heap or the non-heap specifically. This is the default
implementation for a SourceSurface as well, so we should no longer have
the case where surfaces appear empty despite being in the cache. It also
makes requests being validated as always notable for reporting purposes.

Differential Revision: https://phabricator.services.mozilla.com/D61458

--HG--
extra : moz-landing-system : lando
2020-02-05 22:22:13 +00:00

66 lines
2.2 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_image_RecyclingSourceSurface_h
#define mozilla_image_RecyclingSourceSurface_h
#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace image {
class imgFrame;
/**
* This surface subclass will prevent the underlying surface from being recycled
* as long as it is still alive. We will create this surface to wrap imgFrame's
* mLockedSurface, if we are accessing it on a path that will keep the surface
* alive for an indeterminate period of time (e.g. imgFrame::GetSourceSurface,
* imgFrame::Draw with a recording or capture DrawTarget).
*/
class RecyclingSourceSurface final : public gfx::DataSourceSurface {
public:
RecyclingSourceSurface(imgFrame* aParent, gfx::DataSourceSurface* aSurface);
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(RecyclingSourceSurface, override);
uint8_t* GetData() override { return mSurface->GetData(); }
int32_t Stride() override { return mSurface->Stride(); }
gfx::SurfaceType GetType() const override { return mType; }
gfx::IntSize GetSize() const override { return mSurface->GetSize(); }
gfx::SurfaceFormat GetFormat() const override {
return mSurface->GetFormat();
}
bool OnHeap() const override { return mSurface->OnHeap(); }
bool Map(MapType aType, MappedSurface* aMappedSurface) override {
return mSurface->Map(aType, aMappedSurface);
}
void Unmap() override { mSurface->Unmap(); }
void SizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
SizeOfInfo& aInfo) const override {
aInfo.AddType(mType);
mSurface->SizeOfExcludingThis(aMallocSizeOf, aInfo);
}
gfx::DataSourceSurface* GetChildSurface() const { return mSurface; }
protected:
void GuaranteePersistance() override {}
~RecyclingSourceSurface() override;
RefPtr<imgFrame> mParent;
RefPtr<DataSourceSurface> mSurface;
gfx::SurfaceType mType;
};
} // namespace image
} // namespace mozilla
#endif // mozilla_image_RecyclingSourceSurface_h