Backed out changeset 61465f67b591 (bug 1167235)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 28 Jun 2016 20:28:22 +0200
changeset 382174 3267fb29a5e14feff10840dabbbcbeefe5ce1f58
parent 382173 d66eb486e0f1d1a297e0aafc7c9c00d962416aff
child 382175 1dcc4d0ee3d713b40bd3347430b78542a15ee1c5
push id21645
push userbmo:gasolin@mozilla.com
push dateWed, 29 Jun 2016 04:02:20 +0000
bugs1167235
milestone50.0a1
backs out61465f67b5911d7544cf6e3e13f60b7ffec05365
Backed out changeset 61465f67b591 (bug 1167235)
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -37,17 +37,16 @@
 
 #include "nsColor.h"
 #include "nsGfxCIID.h"
 #include "nsIDocShell.h"
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsDisplayList.h"
 #include "nsFocusManager.h"
-#include "nsContentUtils.h"
 
 #include "nsTArray.h"
 
 #include "ImageEncoder.h"
 #include "ImageRegion.h"
 
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
@@ -1061,17 +1060,16 @@ CanvasRenderingContext2D::CanvasRenderin
   , mVideoTexture(0)
 #endif
   // these are the default values from the Canvas spec
   , mWidth(0), mHeight(0)
   , mZero(false), mOpaque(false)
   , mResetLayer(true)
   , mIPC(false)
   , mIsSkiaGL(false)
-  , mHasPendingStableStateCallback(false)
   , mDrawObserver(nullptr)
   , mIsEntireFrameInvalid(false)
   , mPredictManyRedrawCalls(false)
   , mIsCapturedFrameInvalid(false)
   , mPathTransformWillUpdate(false)
   , mInvalidateCount(0)
 {
   sNumLivingContexts++;
@@ -1506,37 +1504,16 @@ CanvasRenderingContext2D::CheckSizeForSk
 
   double scale = gDefaultScale > 0 ? gDefaultScale : 1.0;
   int32_t threshold = ceil(scale * scale * gScreenPixels);
 
   // screen size acts as max threshold
   return threshold < 0 || (aSize.width * aSize.height) <= threshold;
 }
 
-void
-CanvasRenderingContext2D::ScheduleStableStateCallback()
-{
-  if (mHasPendingStableStateCallback) {
-    return;
-  }
-  mHasPendingStableStateCallback = true;
-
-  nsContentUtils::RunInStableState(
-    NewRunnableMethod(this, &CanvasRenderingContext2D::OnStableState)
-  );
-}
-
-void
-CanvasRenderingContext2D::OnStableState()
-{
-  ReturnTarget();
-
-  mHasPendingStableStateCallback = false;
-}
-
 CanvasRenderingContext2D::RenderingMode
 CanvasRenderingContext2D::EnsureTarget(const gfx::Rect* aCoveredRect,
                                        RenderingMode aRenderingMode)
 {
   if (AlreadyShutDown()) {
     gfxCriticalError() << "Attempt to render into a Canvas2d after shutdown.";
     EnsureErrorTarget();
     mTarget = sErrorTarget;
@@ -1555,18 +1532,16 @@ CanvasRenderingContext2D::EnsureTarget(c
   if (mBufferProvider && mode == mRenderingMode) {
     gfx::Rect rect(0, 0, mWidth, mHeight);
     if (aCoveredRect && CurrentState().transform.TransformBounds(*aCoveredRect).Contains(rect)) {
       mTarget = mBufferProvider->BorrowDrawTarget(IntRect());
     } else {
       mTarget = mBufferProvider->BorrowDrawTarget(IntRect(0, 0, mWidth, mHeight));
     }
 
-    ScheduleStableStateCallback();
-
     if (mTarget) {
       // Restore clip and transform.
       mTarget->SetTransform(CurrentState().transform);
       for (uint32_t i = 0; i < mStyleStack.Length(); i++) {
         for (uint32_t c = 0; c < mStyleStack[i].clipsPushed.Length(); c++) {
           mTarget->PushClip(mStyleStack[i].clipsPushed[c]);
         }
       }
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -636,29 +636,16 @@ protected:
    * be null so IsTargetValid() would still return null.
    *
    * Returns the actual rendering mode being used by the created target.
    */
   RenderingMode EnsureTarget(const gfx::Rect* aCoveredRect = nullptr,
                              RenderingMode aRenderMode = RenderingMode::DefaultBackendMode);
 
   /**
-   * This method is run at the end of the event-loop spin where
-   * ScheduleStableStateCallback was called.
-   *
-   * We use it to unlock resources that need to be locked while drawing.
-   */
-  void OnStableState();
-
-  /**
-   * Cf. OnStableState.
-   */
-  void ScheduleStableStateCallback();
-
-  /**
    * Disposes an old target and prepares to lazily create a new target.
    */
   void ClearTarget();
 
   /*
    * Returns the target to the buffer provider. i.e. this will queue a frame for
    * rendering.
    */
@@ -739,18 +726,16 @@ protected:
   // recreate it (i.e. our backing surface changed)
   bool mResetLayer;
   // This is needed for drawing in drawAsyncXULElement
   bool mIPC;
   // True if the current DrawTarget is using skia-gl, used so we can avoid
   // requesting the DT from mBufferProvider to check.
   bool mIsSkiaGL;
 
-  bool mHasPendingStableStateCallback;
-
   nsTArray<CanvasRenderingContext2DUserData*> mUserDatas;
 
   // If mCanvasElement is not provided, then a docshell is
   nsCOMPtr<nsIDocShell> mDocShell;
 
   // This is created lazily so it is necessary to call EnsureTarget before
   // accessing it. In the event of an error it will be equal to
   // sErrorTarget.