From 94247181dfcb49354303fccae5371f10013c6aa8 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 7 Jul 2017 14:14:19 +1200 Subject: [PATCH] Bug 1377324 - Don't compute prepared data multiple times for ContainerLayers that are duplicated. r=miko --- .../composite/ContainerLayerComposite.cpp | 20 +++++++++++++++++++ .../composite/ContainerLayerComposite.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index eee15790fa4f..a5d4adf2a28f 100755 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -185,6 +185,12 @@ ContainerPrepare(ContainerT* aContainer, LayerManagerComposite* aManager, const RenderTargetIntRect& aClipRect) { + // We can end up calling prepare multiple times if we duplicated + // layers due to preserve-3d plane splitting. The results + // should be identical, so we only need to do it once. + if (aContainer->mPrepared) { + return; + } aContainer->mPrepared = MakeUnique(); aContainer->mPrepared->mNeedsSurfaceCopy = false; @@ -687,6 +693,10 @@ void ContainerLayerComposite::Cleanup() { mPrepared = nullptr; + + for (Layer* l = GetFirstChild(); l; l = l->GetNextSibling()) { + static_cast(l->AsHostLayer())->Cleanup(); + } } void @@ -754,6 +764,16 @@ RefLayerComposite::Prepare(const RenderTargetIntRect& aClipRect) ContainerPrepare(this, mCompositeManager, aClipRect); } +void +RefLayerComposite::Cleanup() +{ + mPrepared = nullptr; + + for (Layer* l = GetFirstChild(); l; l = l->GetNextSibling()) { + static_cast(l->AsHostLayer())->Cleanup(); + } +} + void RefLayerComposite::CleanupResources() { diff --git a/gfx/layers/composite/ContainerLayerComposite.h b/gfx/layers/composite/ContainerLayerComposite.h index 5c7c6a7a79d6..d4959cff2ace 100644 --- a/gfx/layers/composite/ContainerLayerComposite.h +++ b/gfx/layers/composite/ContainerLayerComposite.h @@ -183,6 +183,8 @@ public: DefaultComputeEffectiveTransforms(aTransformToSurface); } + virtual void Cleanup() override; + virtual void CleanupResources() override; virtual HostLayer* AsHostLayer() override { return this; }