Bug 1418791 - Ensure mSnapshot access is protected by mutex. r=dvander, a=jcristau
authorpeter chang <pchang@mozilla.com>
Tue, 05 Dec 2017 15:35:16 +0800
changeset 442806 f36855025582c0c6c88b41d3b207c462769ad839
parent 442805 d4455df557afa84b651b2529fc4aa84bfef02b0c
child 442807 1cc170b6689afc4fea4518128c59c72dcd88a122
push id8343
push userryanvm@gmail.com
push dateThu, 07 Dec 2017 13:36:26 +0000
treeherdermozilla-beta@1cc170b6689a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander, jcristau
bugs1418791
milestone58.0
Bug 1418791 - Ensure mSnapshot access is protected by mutex. r=dvander, a=jcristau MozReview-Commit-ID: 3NPzv6VftxZ
gfx/2d/DrawTargetD2D1.cpp
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -41,16 +41,17 @@ StaticRefPtr<ID2D1Factory1> DrawTargetD2
 
 RefPtr<ID2D1Factory1> D2DFactory()
 {
   return DrawTargetD2D1::factory();
 }
 
 DrawTargetD2D1::DrawTargetD2D1()
   : mPushedLayers(1)
+  , mSnapshotLock(make_shared<Mutex>("DrawTargetD2D1::mSnapshotLock"))
   , mUsedCommandListsSincePurge(0)
   , mComplexBlendsWithListInList(0)
   , mDeviceSeq(0)
 {
 }
 
 DrawTargetD2D1::~DrawTargetD2D1()
 {
@@ -86,19 +87,17 @@ DrawTargetD2D1::~DrawTargetD2D1()
        iter != mDependingOnTargets.end(); iter++) {
     (*iter)->mDependentTargets.erase(this);
   }
 }
 
 already_AddRefed<SourceSurface>
 DrawTargetD2D1::Snapshot()
 {
-  if (!mSnapshotLock) {
-    mSnapshotLock = make_shared<Mutex>("DrawTargetD2D1::mSnapshotLock");
-  }
+  MutexAutoLock lock(*mSnapshotLock);
   if (mSnapshot) {
     RefPtr<SourceSurface> snapshot(mSnapshot);
     return snapshot.forget();
   }
   PopAllClips();
 
   Flush();