Bug 1359993 - Reduce invalidation of video r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Mon, 05 Jun 2017 20:55:14 +0900
changeset 412802 80abb5ca3b7364930ab3cf177dca8ffb4512dca6
parent 412795 0b104ac29e71e240d6f31dbb128dd500ecdfdede
child 412803 ed5d32c4c0acaf9312d073ff1d0035a8a9764d1f
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1359993
milestone55.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 1359993 - Reduce invalidation of video r=nical
gfx/layers/Layers.h
gfx/layers/client/ClientImageLayer.cpp
gfx/layers/wr/WebRenderImageLayer.cpp
gfx/layers/wr/WebRenderImageLayer.h
layout/generic/nsFrame.cpp
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -1808,16 +1808,18 @@ public:
   // attempting to get an APZC for a non-scrollable metrics will return null.
   // The aIndex for these functions must be less than GetScrollMetadataCount().
   void SetAsyncPanZoomController(uint32_t aIndex, AsyncPanZoomController *controller);
   AsyncPanZoomController* GetAsyncPanZoomController(uint32_t aIndex) const;
   // The ScrollMetadataChanged function is used internally to ensure the APZC array length
   // matches the frame metrics array length.
 
   virtual void ClearCachedResources() {}
+
+  virtual bool SupportsAsyncUpdate() { return false; }
 private:
   void ScrollMetadataChanged();
 public:
 
   void ApplyPendingUpdatesForThisTransaction();
 
 #ifdef DEBUG
   void SetDebugColorIndex(uint32_t aIndex) { mDebugColorIndex = aIndex; }
--- a/gfx/layers/client/ClientImageLayer.cpp
+++ b/gfx/layers/client/ClientImageLayer.cpp
@@ -54,16 +54,24 @@ protected:
 
   virtual void RenderLayer() override;
   
   virtual void ClearCachedResources() override
   {
     DestroyBackBuffer();
   }
 
+  virtual bool SupportsAsyncUpdate() override
+  {
+    if (GetImageClientType() == CompositableType::IMAGE_BRIDGE) {
+      return true;
+    }
+    return false;
+  }
+
   virtual void HandleMemoryPressure() override
   {
     if (mImageClient) {
       mImageClient->HandleMemoryPressure();
     }
   }
 
   virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override
--- a/gfx/layers/wr/WebRenderImageLayer.cpp
+++ b/gfx/layers/wr/WebRenderImageLayer.cpp
@@ -85,16 +85,26 @@ WebRenderImageLayer::GetAsSourceSurface(
 void
 WebRenderImageLayer::ClearCachedResources()
 {
   if (mImageClient) {
     mImageClient->ClearCachedResources();
   }
 }
 
+bool
+WebRenderImageLayer::SupportsAsyncUpdate()
+{
+  if (GetImageClientType() == CompositableType::IMAGE_BRIDGE &&
+      mPipelineId.isSome()) {
+    return true;
+  }
+  return false;
+}
+
 void
 WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
                                  const StackingContextHelper& aSc)
 {
   if (!mContainer) {
      return;
   }
 
--- a/gfx/layers/wr/WebRenderImageLayer.h
+++ b/gfx/layers/wr/WebRenderImageLayer.h
@@ -19,16 +19,18 @@ class WebRenderImageLayer : public WebRe
                             public ImageLayer {
 public:
   explicit WebRenderImageLayer(WebRenderLayerManager* aLayerManager);
 
   virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
 
   virtual void ClearCachedResources() override;
 
+  virtual bool SupportsAsyncUpdate() override;
+
 protected:
   virtual ~WebRenderImageLayer();
 
 public:
   Layer* GetLayer() override { return this; }
   void RenderLayer(wr::DisplayListBuilder& aBuilder,
                    const StackingContextHelper& aSc) override;
   Maybe<WrImageMask> RenderMaskLayer(const gfx::Matrix4x4& aTransform) override;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -6676,18 +6676,17 @@ nsIFrame::InvalidateLayer(uint32_t aDisp
   NS_ASSERTION(aDisplayItemKey > 0, "Need a key");
 
   Layer* layer = FrameLayerBuilder::GetDedicatedLayer(this, aDisplayItemKey);
 
   InvalidateRenderingObservers(this);
 
   // If the layer is being updated asynchronously, and it's being forwarded
   // to a compositor, then we don't need to invalidate.
-  if ((aFlags & UPDATE_IS_ASYNC) && layer &&
-      layer->Manager()->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
+  if ((aFlags & UPDATE_IS_ASYNC) && layer && layer->SupportsAsyncUpdate()) {
     return layer;
   }
 
   if (!layer) {
     if (aFrameDamageRect && aFrameDamageRect->IsEmpty()) {
       return nullptr;
     }