Bug 1341521 - Remove the retaining buffer machanism when setting the same canvas dimension on a CLOSED TREE. r=nical a=jcristau
authorEthan Lin <ethlin@mozilla.com>
Thu, 23 Feb 2017 01:20:00 -0500
changeset 369496 a058f3e17dcf5ea2dfe7431d4f238dd352c473d2
parent 369495 68157e467e6c5e7b14cac0002610d271ac2d9610
child 369497 4bd2e5d2ac0d0b15b4446fca5647bfa821b52d46
push id1369
push userjlorenzo@mozilla.com
push dateMon, 27 Feb 2017 14:59:41 +0000
treeherdermozilla-release@d75a1dba431f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, jcristau
bugs1341521
milestone52.0
Bug 1341521 - Remove the retaining buffer machanism when setting the same canvas dimension on a CLOSED TREE. r=nical a=jcristau
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1836,21 +1836,17 @@ int32_t
 CanvasRenderingContext2D::GetHeight() const
 {
   return mHeight;
 }
 
 NS_IMETHODIMP
 CanvasRenderingContext2D::SetDimensions(int32_t aWidth, int32_t aHeight)
 {
-  bool retainBuffer = false;
-  if (aWidth == mWidth && aHeight == mHeight) {
-    retainBuffer = true;
-  }
-  ClearTarget(retainBuffer);
+  ClearTarget();
 
   // Zero sized surfaces can cause problems.
   mZero = false;
   if (aHeight == 0) {
     aHeight = 1;
     mZero = true;
   }
   if (aWidth == 0) {
@@ -1859,33 +1855,20 @@ CanvasRenderingContext2D::SetDimensions(
   }
   mWidth = aWidth;
   mHeight = aHeight;
 
   return NS_OK;
 }
 
 void
-CanvasRenderingContext2D::ClearTarget(bool aRetainBuffer)
-{
-  RefPtr<PersistentBufferProvider> provider = mBufferProvider;
-  if (aRetainBuffer && provider) {
-    // We should reset the buffer data before reusing the buffer.
-    if (mTarget) {
-      mTarget->SetTransform(Matrix());
-    }
-    ClearRect(0, 0, mWidth, mHeight);
-  }
-
+CanvasRenderingContext2D::ClearTarget()
+{
   Reset();
 
-  if (aRetainBuffer) {
-    mBufferProvider = provider;
-  }
-
   mResetLayer = true;
 
   SetInitialState();
 
   // For vertical writing-mode, unless text-orientation is sideways,
   // we'll modify the initial value of textBaseline to 'middle'.
   RefPtr<nsStyleContext> canvasStyle;
   if (mCanvasElement && mCanvasElement->IsInUncomposedDoc()) {
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -665,17 +665,17 @@ protected:
   /**
    * Cf. OnStableState.
    */
   void ScheduleStableStateCallback();
 
   /**
    * Disposes an old target and prepares to lazily create a new target.
    */
-  void ClearTarget(bool aRetainBuffer = false);
+  void ClearTarget();
 
   /*
    * Returns the target to the buffer provider. i.e. this will queue a frame for
    * rendering.
    */
   void ReturnTarget(bool aForceReset = false);
 
   /**