Bug 1284721 - Flush CanvasRenderingContext2D's DrawTarget before handing it off to the BufferProvider. r=lsalzman
authorNicolas Silva <nsilva@mozilla.com>
Fri, 08 Jul 2016 19:26:48 +0200
changeset 304276 75f6c7e15d7641a294a00ec454e34866807a0f83
parent 304275 b7f2d54f39046516662b17faa0c8605d98eb3385
child 304277 b966ababca8d78c565c28214483e10a679f6c44e
push id30529
push userphilringnalda@gmail.com
push dateSat, 09 Jul 2016 15:59:57 +0000
treeherderautoland@679118259e91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1284721
milestone50.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 1284721 - Flush CanvasRenderingContext2D's DrawTarget before handing it off to the BufferProvider. r=lsalzman
dom/canvas/CanvasRenderingContext2D.cpp
gfx/layers/PersistentBufferProvider.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -899,19 +899,16 @@ public:
   static void PreTransactionCallback(void* aData)
   {
     CanvasRenderingContext2DUserData* self =
       static_cast<CanvasRenderingContext2DUserData*>(aData);
     CanvasRenderingContext2D* context = self->mContext;
     if (!context || !context->mTarget)
       return;
 
-    // Since SkiaGL default to store drawing command until flush
-    // We will have to flush it before present.
-    context->mTarget->Flush();
     context->ReturnTarget();
   }
 
   static void DidTransactionCallback(void* aData)
   {
     CanvasRenderingContext2DUserData* self =
       static_cast<CanvasRenderingContext2DUserData*>(aData);
     if (self->mContext) {
--- a/gfx/layers/PersistentBufferProvider.cpp
+++ b/gfx/layers/PersistentBufferProvider.cpp
@@ -35,16 +35,21 @@ PersistentBufferProviderBasic::BorrowDra
   return dt.forget();
 }
 
 bool
 PersistentBufferProviderBasic::ReturnDrawTarget(already_AddRefed<gfx::DrawTarget> aDT)
 {
   RefPtr<gfx::DrawTarget> dt(aDT);
   MOZ_ASSERT(mDrawTarget == dt);
+  if (dt) {
+    // Since SkiaGL default to storing drawing command until flush
+    // we have to flush it before present.
+    dt->Flush();
+  }
   return true;
 }
 
 already_AddRefed<gfx::SourceSurface>
 PersistentBufferProviderBasic::BorrowSnapshot()
 {
   mSnapshot = mDrawTarget->Snapshot();
   RefPtr<SourceSurface> snapshot = mSnapshot;
@@ -200,20 +205,22 @@ PersistentBufferProviderShared::ReturnDr
   MOZ_ASSERT(mDrawTarget == dt);
   MOZ_ASSERT(!mSnapshot);
 
   mDrawTarget = nullptr;
   dt = nullptr;
 
   mBack->Unlock();
 
-  if (!mBuffer && mFront && !mFront->IsLocked()) {
-    mBuffer.swap(mFront);
+  if (mFront != mBack && !mBuffers.Contains(mFront)) {
+    mBuffers.AppendElement(mFront);
   }
 
+  // Make mFront point to the now realized back buffer. mFront is what the next
+  // transaction will pick up and send to the compositor.
   mFront = mBack;
 
   return true;
 }
 
 already_AddRefed<gfx::SourceSurface>
 PersistentBufferProviderShared::BorrowSnapshot()
 {