Bug 1559437: Don't explicitly return DataSourceSurface from CanvasRenderingContext2D::GetSurfaceSnapshot. r=mattwoodrow
authorBob Owen <bobowencode@gmail.com>
Wed, 19 Jun 2019 12:37:40 +0000
changeset 479202 5fc7054fc05d67438c05a9adab43c6a7a217a07e
parent 479201 b16a957f53f7be1b7414ba1c00d74328f640e7e2
child 479203 10e3ed789e2b5736f5e85b825c8f2e51a9556db4
child 479204 be881e8aa8d9e12d4a78e2116c9750f1d8d24049
push id36173
push userrgurzau@mozilla.com
push dateWed, 19 Jun 2019 15:50:11 +0000
treeherdermozilla-central@10e3ed789e2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1559437
milestone69.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 1559437: Don't explicitly return DataSourceSurface from CanvasRenderingContext2D::GetSurfaceSnapshot. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D35152
dom/canvas/CanvasRenderingContext2D.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1674,25 +1674,23 @@ CanvasRenderingContext2D::GetSurfaceSnap
     if (!EnsureTarget()) {
       MOZ_ASSERT(
           mTarget == sErrorTarget,
           "On EnsureTarget failure mTarget should be set to sErrorTarget.");
       return mTarget->Snapshot();
     }
   }
 
+  // The concept of BorrowSnapshot seems a bit broken here, but the original
+  // code in GetSurfaceSnapshot just returned a snapshot from mTarget, which
+  // amounts to breaking the concept implicitly.
   RefPtr<SourceSurface> snapshot = mBufferProvider->BorrowSnapshot();
-  if (!snapshot) {
-    return nullptr;
-  }
-
-  RefPtr<DataSourceSurface> dataSurface = snapshot->GetDataSurface();
+  RefPtr<SourceSurface> retSurface = snapshot;
   mBufferProvider->ReturnSnapshot(snapshot.forget());
-
-  return dataSurface.forget();
+  return retSurface.forget();
 }
 
 SurfaceFormat CanvasRenderingContext2D::GetSurfaceFormat() const {
   return mOpaque ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8;
 }
 
 //
 // state