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),
|
: mImage(aImage),
|
||||||
mDC(aDC),
|
mDC(aDC),
|
||||||
mDevice(Factory::GetD2D1Device()),
|
mDevice(Factory::GetD2D1Device()),
|
||||||
mDrawTarget(aDT) {
|
mFormat(aFormat),
|
||||||
|
mSize(aSize),
|
||||||
|
mDrawTarget(aDT),
|
||||||
|
mOwnsCopy(false) {
|
||||||
aImage->QueryInterface((ID2D1Bitmap1**)getter_AddRefs(mRealizedBitmap));
|
aImage->QueryInterface((ID2D1Bitmap1**)getter_AddRefs(mRealizedBitmap));
|
||||||
|
|
||||||
mFormat = aFormat;
|
|
||||||
mSize = aSize;
|
|
||||||
if (aDT) {
|
if (aDT) {
|
||||||
mSnapshotLock = aDT->mSnapshotLock;
|
mSnapshotLock = aDT->mSnapshotLock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceSurfaceD2D1::~SourceSurfaceD2D1() {}
|
SourceSurfaceD2D1::~SourceSurfaceD2D1() {
|
||||||
|
if (mOwnsCopy) {
|
||||||
|
DrawTargetD2D1::mVRAMUsageSS -=
|
||||||
|
mSize.width * mSize.height * BytesPerPixel(mFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SourceSurfaceD2D1::IsValid() const {
|
bool SourceSurfaceD2D1::IsValid() const {
|
||||||
return mDevice == Factory::GetD2D1Device();
|
return mDevice == Factory::GetD2D1Device();
|
||||||
@ -145,6 +150,7 @@ void SourceSurfaceD2D1::DrawTargetWillChange() {
|
|||||||
|
|
||||||
DrawTargetD2D1::mVRAMUsageSS +=
|
DrawTargetD2D1::mVRAMUsageSS +=
|
||||||
mSize.width * mSize.height * BytesPerPixel(mFormat);
|
mSize.width * mSize.height * BytesPerPixel(mFormat);
|
||||||
|
mOwnsCopy = true;
|
||||||
|
|
||||||
// Ensure the object stays alive for the duration of MarkIndependent.
|
// Ensure the object stays alive for the duration of MarkIndependent.
|
||||||
RefPtr<SourceSurfaceD2D1> deathGrip = this;
|
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.
|
// Keep this around to verify whether out image is still valid in the future.
|
||||||
RefPtr<ID2D1Device> mDevice;
|
RefPtr<ID2D1Device> mDevice;
|
||||||
|
|
||||||
SurfaceFormat mFormat;
|
const SurfaceFormat mFormat;
|
||||||
IntSize mSize;
|
const IntSize mSize;
|
||||||
DrawTargetD2D1* mDrawTarget;
|
DrawTargetD2D1* mDrawTarget;
|
||||||
std::shared_ptr<Mutex> mSnapshotLock;
|
std::shared_ptr<Mutex> mSnapshotLock;
|
||||||
|
bool mOwnsCopy;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataSourceSurfaceD2D1 : public DataSourceSurface {
|
class DataSourceSurfaceD2D1 : public DataSourceSurface {
|
||||||
|
Loading…
Reference in New Issue
Block a user