Backed out changeset 775fa3ede160 (bug 1294351) for failing in crashtest 647480.html. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 18 Aug 2016 12:50:56 +0200
changeset 310094 7d3e8cea2291576c15ce3aca91b2161dfa8941d3
parent 310093 72f943bf11090f85584637aa202ecfb0a45f690d
child 310095 47b7bf339876337b4b9d4ccb292b81d466c0d92d
push id30576
push userryanvm@gmail.com
push dateFri, 19 Aug 2016 13:53:39 +0000
treeherdermozilla-central@74f332c38a69 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1294351, 647480
milestone51.0a1
backs out775fa3ede1603f56bc128a21d0d1e733e70039cc
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
Backed out changeset 775fa3ede160 (bug 1294351) for failing in crashtest 647480.html. r=backout
dom/canvas/CanvasRenderingContext2D.cpp
gfx/layers/PersistentBufferProvider.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1640,37 +1640,35 @@ CanvasRenderingContext2D::EnsureTarget(c
       if (mCanvasElement) {
         mCanvasElement->InvalidateCanvas();
       }
       // Calling Redraw() tells our invalidation machinery that the entire
       // canvas is already invalid, which can speed up future drawing.
       Redraw();
     }
 
-    if (!mBufferProvider->PreservesDrawingState() || mBufferProvider != oldBufferProvider) {
-      // Restore clips and transform.
-      mTarget->SetTransform(Matrix());
-
-      if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
-        // Cairo doesn't play well with huge clips. When given a very big clip it
-        // will try to allocate big mask surface without taking the target
-        // size into account which can cause OOM. See bug 1034593.
-        // This limits the clip extents to the size of the canvas.
-        // A fix in Cairo would probably be preferable, but requires somewhat
-        // invasive changes.
-        mTarget->PushClipRect(canvasRect);
-      }
-
-      for (const auto& style : mStyleStack) {
-        for (const auto& clipOrTransform : style.clipsAndTransforms) {
-          if (clipOrTransform.IsClip()) {
-            mTarget->PushClip(clipOrTransform.clip);
-          } else {
-            mTarget->SetTransform(clipOrTransform.transform);
-          }
+    // Restore clips and transform.
+    mTarget->SetTransform(Matrix());
+
+    if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
+      // Cairo doesn't play well with huge clips. When given a very big clip it
+      // will try to allocate big mask surface without taking the target
+      // size into account which can cause OOM. See bug 1034593.
+      // This limits the clip extents to the size of the canvas.
+      // A fix in Cairo would probably be preferable, but requires somewhat
+      // invasive changes.
+      mTarget->PushClipRect(canvasRect);
+    }
+
+    for (const auto& style : mStyleStack) {
+      for (const auto& clipOrTransform : style.clipsAndTransforms) {
+        if (clipOrTransform.IsClip()) {
+          mTarget->PushClip(clipOrTransform.clip);
+        } else {
+          mTarget->SetTransform(clipOrTransform.transform);
         }
       }
     }
   } else {
     EnsureErrorTarget();
     mTarget = sErrorTarget;
     mBufferProvider = nullptr;
   }
@@ -1773,30 +1771,28 @@ CanvasRenderingContext2D::ClearTarget(bo
   }
 }
 
 void
 CanvasRenderingContext2D::ReturnTarget()
 {
   if (mTarget && mBufferProvider && mTarget != sErrorTarget) {
     CurrentState().transform = mTarget->GetTransform();
-    if (!mBufferProvider->PreservesDrawingState()) {
-      for (const auto& style : mStyleStack) {
-        for (const auto& clipOrTransform : style.clipsAndTransforms) {
-          if (clipOrTransform.IsClip()) {
-            mTarget->PopClip();
-          }
+    for (const auto& style : mStyleStack) {
+      for (const auto& clipOrTransform : style.clipsAndTransforms) {
+        if (clipOrTransform.IsClip()) {
+          mTarget->PopClip();
         }
       }
-
-      if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
-        // With the cairo backend we pushed an extra clip rect which we have to
-        // balance out here. See the comment in EnsureDrawTarget.
-        mTarget->PopClip();
-      }
+    }
+
+    if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
+      // With the cairo backend we pushed an extra clip rect which we have to
+      // balance out here. See the comment in EnsureDrawTarget.
+      mTarget->PopClip();
     }
 
     mBufferProvider->ReturnDrawTarget(mTarget.forget());
   }
 }
 
 NS_IMETHODIMP
 CanvasRenderingContext2D::InitializeWithDrawTarget(nsIDocShell* aShell,
--- a/gfx/layers/PersistentBufferProvider.h
+++ b/gfx/layers/PersistentBufferProvider.h
@@ -60,24 +60,16 @@ public:
 
   virtual void ReturnSnapshot(already_AddRefed<gfx::SourceSurface> aSnapshot) = 0;
 
   virtual TextureClient* GetTextureClient() { return nullptr; }
 
   virtual void OnShutdown() {}
 
   virtual bool SetForwarder(CompositableForwarder* aFwd) { return true; }
-
-  /**
-   * Return true if this provider preserves the drawing state (clips, transforms,
-   * etc.) across frames. In practice this means users of the provider can skip
-   * popping all of the clips at the end of the frames and pushing them back at
-   * the beginning of the following frames, which can be costly (cf. bug 1294351).
-   */
-  virtual bool PreservesDrawingState() const = 0;
 };
 
 
 class PersistentBufferProviderBasic : public PersistentBufferProvider
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PersistentBufferProviderBasic, override)
 
@@ -91,17 +83,16 @@ public:
   virtual already_AddRefed<gfx::DrawTarget> BorrowDrawTarget(const gfx::IntRect& aPersistedRect) override;
 
   virtual bool ReturnDrawTarget(already_AddRefed<gfx::DrawTarget> aDT) override;
 
   virtual already_AddRefed<gfx::SourceSurface> BorrowSnapshot() override;
 
   virtual void ReturnSnapshot(already_AddRefed<gfx::SourceSurface> aSnapshot) override;
 
-  virtual bool PreservesDrawingState() const override { return true; }
 private:
   ~PersistentBufferProviderBasic();
 
   RefPtr<gfx::DrawTarget> mDrawTarget;
   RefPtr<gfx::SourceSurface> mSnapshot;
 };
 
 
@@ -132,17 +123,16 @@ public:
   virtual TextureClient* GetTextureClient() override;
 
   virtual void NotifyInactive() override;
 
   virtual void OnShutdown() override { Destroy(); }
 
   virtual bool SetForwarder(CompositableForwarder* aFwd) override;
 
-  virtual bool PreservesDrawingState() const override { return false; }
 protected:
   PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
                                  CompositableForwarder* aFwd,
                                  RefPtr<TextureClient>& aTexture);
 
   ~PersistentBufferProviderShared();
 
   TextureClient* GetTexture(Maybe<uint32_t> aIndex);