mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1416864 - Synchronize how snapshots detach in DrawTargetD2D1. r=bas
This commit is contained in:
parent
5485f27c35
commit
4d9d8d5d59
@ -57,6 +57,7 @@ DrawTargetD2D1::~DrawTargetD2D1()
|
||||
PopAllClips();
|
||||
|
||||
if (mSnapshot) {
|
||||
MutexAutoLock lock(*mSnapshotLock);
|
||||
// We may hold the only reference. MarkIndependent will clear mSnapshot;
|
||||
// keep the snapshot object alive so it doesn't get destroyed while
|
||||
// MarkIndependent is running.
|
||||
@ -90,6 +91,9 @@ DrawTargetD2D1::~DrawTargetD2D1()
|
||||
already_AddRefed<SourceSurface>
|
||||
DrawTargetD2D1::Snapshot()
|
||||
{
|
||||
if (!mSnapshotLock) {
|
||||
mSnapshotLock = make_shared<Mutex>("DrawTargetD2D1::mSnapshotLock");
|
||||
}
|
||||
if (mSnapshot) {
|
||||
RefPtr<SourceSurface> snapshot(mSnapshot);
|
||||
return snapshot.forget();
|
||||
@ -1274,6 +1278,7 @@ void
|
||||
DrawTargetD2D1::MarkChanged()
|
||||
{
|
||||
if (mSnapshot) {
|
||||
MutexAutoLock lock(*mSnapshotLock);
|
||||
if (mSnapshot->hasOneRef()) {
|
||||
// Just destroy it, since no-one else knows about it.
|
||||
mSnapshot = nullptr;
|
||||
|
@ -280,6 +280,7 @@ private:
|
||||
// The latest snapshot of this surface. This needs to be told when this
|
||||
// target is modified. We keep it alive as a cache.
|
||||
RefPtr<SourceSurfaceD2D1> mSnapshot;
|
||||
std::shared_ptr<Mutex> mSnapshotLock;
|
||||
// A list of targets we need to flush when we're modified.
|
||||
TargetSet mDependentTargets;
|
||||
// A list of targets which have this object in their mDependentTargets set
|
||||
|
@ -23,6 +23,9 @@ SourceSurfaceD2D1::SourceSurfaceD2D1(ID2D1Image *aImage, ID2D1DeviceContext *aDC
|
||||
|
||||
mFormat = aFormat;
|
||||
mSize = aSize;
|
||||
if (aDT) {
|
||||
mSnapshotLock = aDT->mSnapshotLock;
|
||||
}
|
||||
}
|
||||
|
||||
SourceSurfaceD2D1::~SourceSurfaceD2D1()
|
||||
@ -109,6 +112,9 @@ SourceSurfaceD2D1::EnsureRealizedBitmap()
|
||||
void
|
||||
SourceSurfaceD2D1::DrawTargetWillChange()
|
||||
{
|
||||
MOZ_ASSERT(mSnapshotLock);
|
||||
mSnapshotLock->AssertCurrentThreadOwns();
|
||||
|
||||
// At this point in time this should always be true here.
|
||||
MOZ_ASSERT(mRealizedBitmap);
|
||||
|
||||
|
@ -62,6 +62,7 @@ private:
|
||||
SurfaceFormat mFormat;
|
||||
IntSize mSize;
|
||||
DrawTargetD2D1* mDrawTarget;
|
||||
std::shared_ptr<Mutex> mSnapshotLock;
|
||||
};
|
||||
|
||||
class DataSourceSurfaceD2D1 : public DataSourceSurface
|
||||
|
Loading…
Reference in New Issue
Block a user