mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1699352 - Fix DrawTargetD2D1::mVRAMUsageSS handling r=jrmuizel
Implementation is borrowed from SourceSurfaceD2DTarget::mOwnsCopy that existed in the past. Differential Revision: https://phabricator.services.mozilla.com/D108906
This commit is contained in:
parent
3888581ee0
commit
6f9594cf0a
@ -17,17 +17,22 @@ SourceSurfaceD2D1::SourceSurfaceD2D1(ID2D1Image* aImage,
|
||||
: mImage(aImage),
|
||||
mDC(aDC),
|
||||
mDevice(Factory::GetD2D1Device()),
|
||||
mDrawTarget(aDT) {
|
||||
mFormat(aFormat),
|
||||
mSize(aSize),
|
||||
mDrawTarget(aDT),
|
||||
mOwnsCopy(false) {
|
||||
aImage->QueryInterface((ID2D1Bitmap1**)getter_AddRefs(mRealizedBitmap));
|
||||
|
||||
mFormat = aFormat;
|
||||
mSize = aSize;
|
||||
if (aDT) {
|
||||
mSnapshotLock = aDT->mSnapshotLock;
|
||||
}
|
||||
}
|
||||
|
||||
SourceSurfaceD2D1::~SourceSurfaceD2D1() {}
|
||||
SourceSurfaceD2D1::~SourceSurfaceD2D1() {
|
||||
if (mOwnsCopy) {
|
||||
DrawTargetD2D1::mVRAMUsageSS -=
|
||||
mSize.width * mSize.height * BytesPerPixel(mFormat);
|
||||
}
|
||||
}
|
||||
|
||||
bool SourceSurfaceD2D1::IsValid() const {
|
||||
return mDevice == Factory::GetD2D1Device();
|
||||
@ -145,6 +150,7 @@ void SourceSurfaceD2D1::DrawTargetWillChange() {
|
||||
|
||||
DrawTargetD2D1::mVRAMUsageSS +=
|
||||
mSize.width * mSize.height * BytesPerPixel(mFormat);
|
||||
mOwnsCopy = true;
|
||||
|
||||
// Ensure the object stays alive for the duration of MarkIndependent.
|
||||
RefPtr<SourceSurfaceD2D1> deathGrip = this;
|
||||
|
@ -62,10 +62,11 @@ class SourceSurfaceD2D1 : public SourceSurface {
|
||||
// Keep this around to verify whether out image is still valid in the future.
|
||||
RefPtr<ID2D1Device> mDevice;
|
||||
|
||||
SurfaceFormat mFormat;
|
||||
IntSize mSize;
|
||||
const SurfaceFormat mFormat;
|
||||
const IntSize mSize;
|
||||
DrawTargetD2D1* mDrawTarget;
|
||||
std::shared_ptr<Mutex> mSnapshotLock;
|
||||
bool mOwnsCopy;
|
||||
};
|
||||
|
||||
class DataSourceSurfaceD2D1 : public DataSourceSurface {
|
||||
|
Loading…
Reference in New Issue
Block a user