Bug 887927 - Hold a ref to DrawTargetSkia within SourceSurfaceSkia r=mattwoodrow
authorJames Willcox <jwillcox@mozilla.com>
Fri, 28 Jun 2013 22:59:19 -0400
changeset 149633 295946bd016ad2bcb623a2fd83b71d45a92516c8
parent 149632 2315e78bd4e26487196856f282b5d5254e70206d
child 149634 3e1ed95df35ac3ce9ef20bf80aef616b31d43fa2
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs887927
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 887927 - Hold a ref to DrawTargetSkia within SourceSurfaceSkia r=mattwoodrow
gfx/2d/DrawTargetSkia.cpp
gfx/2d/SourceSurfaceSkia.cpp
gfx/2d/SourceSurfaceSkia.h
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -82,24 +82,17 @@ public:
 };
 
 DrawTargetSkia::DrawTargetSkia()
 {
 }
 
 DrawTargetSkia::~DrawTargetSkia()
 {
-  if (mSnapshots.size()) {
-    for (std::vector<SourceSurfaceSkia*>::iterator iter = mSnapshots.begin();
-         iter != mSnapshots.end(); iter++) {
-      (*iter)->DrawTargetDestroyed();
-    }
-    // All snapshots will now have copied data.
-    mSnapshots.clear();
-  }
+  MOZ_ASSERT(mSnapshots.size() == 0);
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetSkia::Snapshot()
 {
   RefPtr<SourceSurfaceSkia> source = new SourceSurfaceSkia();
 
   if (!source->InitFromCanvas(mCanvas.get(), mFormat, this))
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -104,22 +104,16 @@ SourceSurfaceSkia::DrawTargetWillChange(
     mDrawTarget = nullptr;
     SkBitmap temp = mBitmap;
     mBitmap.reset();
     temp.copyTo(&mBitmap, temp.getConfig());
   }
 }
 
 void
-SourceSurfaceSkia::DrawTargetDestroyed()
-{
-  mDrawTarget = nullptr;
-}
-
-void
 SourceSurfaceSkia::MarkIndependent()
 {
   if (mDrawTarget) {
     mDrawTarget->RemoveSnapshot(this);
     mDrawTarget = nullptr;
   }
 }
 
--- a/gfx/2d/SourceSurfaceSkia.h
+++ b/gfx/2d/SourceSurfaceSkia.h
@@ -48,16 +48,16 @@ private:
   void DrawTargetDestroyed();
   void MarkIndependent();
   void MaybeUnlock();
 
   SkBitmap mBitmap;
   SurfaceFormat mFormat;
   IntSize mSize;
   int32_t mStride;
-  DrawTargetSkia* mDrawTarget;
+  RefPtr<DrawTargetSkia> mDrawTarget;
   bool mLocked;
 };
 
 }
 }
 
 #endif /* MOZILLA_GFX_SOURCESURFACESKIA_H_ */