Bug 1318283: UpdateFilter can sometimes invalidate the draw target. Back out the previous speculative patch. r=mstange draft
authorMilan Sreckovic <milan@mozilla.com>
Tue, 03 Jan 2017 12:01:11 -0500
changeset 455360 876ec3d4d2cd47d76fe57db645764eba281209d9
parent 455333 cad2ea346d06ec5a3a70eda912513201dff0c21e
child 540966 620de54df78cd7c19f9d4b93e1b97018c86021dc
push id40213
push userbmo:milan@mozilla.com
push dateTue, 03 Jan 2017 17:03:43 +0000
reviewersmstange
bugs1318283
milestone53.0a1
Bug 1318283: UpdateFilter can sometimes invalidate the draw target. Back out the previous speculative patch. r=mstange MozReview-Commit-ID: 8u2sjS9dyLu
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1869,20 +1869,19 @@ CanvasRenderingContext2D::GetHeight() co
 {
   return mHeight;
 }
 
 NS_IMETHODIMP
 CanvasRenderingContext2D::SetDimensions(int32_t aWidth, int32_t aHeight)
 {
   bool retainBuffer = false;
-  // See bug 1318283 as to why we are disabling this optimization.
-  // Based on the results of the investigation, this may go away
-  // completely or come back.
-  // retainBuffer = (aWidth == mWidth && aHeight == mHeight);
+  if (aWidth == mWidth && aHeight == mHeight) {
+    retainBuffer = true;
+  }
   ClearTarget(retainBuffer);
 
   // Zero sized surfaces can cause problems.
   mZero = false;
   if (aHeight == 0) {
     aHeight = 1;
     mZero = true;
   }
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -994,16 +994,17 @@ protected:
   /**
    * Calls UpdateFilter if the canvas's WriteOnly state has changed between the
    * last call to UpdateFilter and now.
    */
   const gfx::FilterDescription& EnsureUpdatedFilter() {
     bool isWriteOnly = mCanvasElement && mCanvasElement->IsWriteOnly();
     if (CurrentState().filterSourceGraphicTainted != isWriteOnly) {
       UpdateFilter();
+      EnsureTarget();
     }
     MOZ_ASSERT(CurrentState().filterSourceGraphicTainted == isWriteOnly);
     return CurrentState().filter;
   }
 
   bool NeedToCalculateBounds()
   {
     return NeedToDrawShadow() || NeedToApplyFilter();