From 8fdf6e51d87acb8a87531ab7cc8a9b37beff036e Mon Sep 17 00:00:00 2001 From: "Matt Woodrow ext:(%2C%20Botond%20Ballo%20%3Cbotond%40mozilla.com%3E)" Date: Thu, 9 Jun 2016 16:36:12 +1200 Subject: [PATCH] Bug 1275694 - Use the local visible region to decide when to cull a layer in CalculateScissorRect(). r=kats We still take care not to cull a layer if we need to draw a checkerboarding background for it. MozReview-Commit-ID: 3EuXEFB2wF9 --HG-- extra : rebase_source : 88e20d9c56be0e09056b7fc3d3e72addee1b1af4 extra : source : 1b8e6e22a983754ef967fe81c1d184a4a966d828 --- gfx/layers/Layers.cpp | 10 +++--- .../composite/ContainerLayerComposite.cpp | 32 ++----------------- .../composite/LayerManagerComposite.cpp | 30 +++++++++++++++++ gfx/layers/composite/LayerManagerComposite.h | 6 ++++ 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 962f48a46fad..f941ca9e263c 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -799,15 +799,13 @@ Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect) return currentClip; } - if (GetVisibleRegion().IsEmpty()) { + if (GetLocalVisibleRegion().IsEmpty() && + !(AsLayerComposite() && AsLayerComposite()->NeedToDrawCheckerboarding())) { // When our visible region is empty, our parent may not have created the // intermediate surface that we would require for correct clipping; however, // this does not matter since we are invisible. - // Note that we do not use GetLocalVisibleRegion(), because that can be - // empty for a layer whose rendered contents have been async-scrolled - // completely offscreen, but for which we still need to draw a - // checkerboarding backround color, and calculating an empty scissor rect - // for such a layer would prevent that (see bug 1247452 comment 10). + // Make sure we still compute a clip rect if we want to draw checkboarding + // for this layer, since we want to do this even if the layer is invisible. return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0)); } diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 2dc3123e2b5e..9e891ab693af 100755 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -53,24 +53,6 @@ namespace layers { using namespace gfx; -static bool -LayerHasCheckerboardingAPZC(Layer* aLayer, Color* aOutColor) -{ - for (LayerMetricsWrapper i(aLayer, LayerMetricsWrapper::StartAt::BOTTOM); i; i = i.GetParent()) { - if (!i.Metrics().IsScrollable()) { - continue; - } - if (i.GetApzc() && i.GetApzc()->IsCurrentlyCheckerboarding()) { - if (aOutColor) { - *aOutColor = i.Metadata().GetBackgroundColor(); - } - return true; - } - break; - } - return false; -} - static void DrawLayerInfo(const RenderTargetIntRect& aClipRect, LayerManagerComposite* aManager, Layer* aLayer) @@ -357,15 +339,6 @@ ContainerRenderVR(ContainerT* aContainer, DUMP("<<< ContainerRenderVR [%p]\n", aContainer); } -static bool -NeedToDrawCheckerboardingForLayer(Layer* aLayer, Color* aOutCheckerboardingColor) -{ - return (aLayer->Manager()->AsyncPanZoomEnabled() && - aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) && - aLayer->IsOpaqueForVisibility() && - LayerHasCheckerboardingAPZC(aLayer, aOutCheckerboardingColor); -} - /* all of the prepared data that we need in RenderLayer() */ struct PreparedData { @@ -412,7 +385,7 @@ ContainerPrepare(ContainerT* aContainer, // may be null which is not allowed. if (!layerToRender->GetLayer()->AsContainerLayer()) { if (!layerToRender->GetLayer()->IsVisible() && - !NeedToDrawCheckerboardingForLayer(layerToRender->GetLayer(), nullptr)) { + !layerToRender->NeedToDrawCheckerboarding(nullptr)) { CULLING_LOG("Sublayer %p has no effective visible region\n", layerToRender->GetLayer()); continue; } @@ -635,7 +608,7 @@ RenderLayers(ContainerT* aContainer, } Color color; - if (NeedToDrawCheckerboardingForLayer(layer, &color)) { + if (layerToRender->NeedToDrawCheckerboarding(&color)) { if (gfxPrefs::APZHighlightCheckerboardedAreas()) { color = Color(255 / 255.f, 188 / 255.f, 217 / 255.f, 1.f); // "Cotton Candy" } @@ -967,7 +940,6 @@ RefLayerComposite::Prepare(const RenderTargetIntRect& aClipRect) ContainerPrepare(this, mCompositeManager, aClipRect); } - void RefLayerComposite::CleanupResources() { diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index d9e08bf1a21c..d3f35696ad87 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -22,6 +22,7 @@ #include "TiledContentHost.h" #include "Units.h" // for ScreenIntRect #include "UnitTransforms.h" // for ViewAs +#include "apz/src/AsyncPanZoomController.h" // for AsyncPanZoomController #include "gfxPrefs.h" // for gfxPrefs #ifdef XP_MACOSX #include "gfxPlatformMac.h" @@ -1603,6 +1604,35 @@ LayerComposite::HasStaleCompositor() const return mCompositeManager->GetCompositor() != mCompositor; } +static bool +LayerHasCheckerboardingAPZC(Layer* aLayer, Color* aOutColor) +{ + bool answer = false; + for (LayerMetricsWrapper i(aLayer, LayerMetricsWrapper::StartAt::BOTTOM); i; i = i.GetParent()) { + if (!i.Metrics().IsScrollable()) { + continue; + } + if (i.GetApzc() && i.GetApzc()->IsCurrentlyCheckerboarding()) { + if (aOutColor) { + *aOutColor = i.Metadata().GetBackgroundColor(); + } + answer = true; + break; + } + break; + } + return answer; +} + +bool +LayerComposite::NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor) +{ + return GetLayer()->Manager()->AsyncPanZoomEnabled() && + (GetLayer()->GetContentFlags() & Layer::CONTENT_OPAQUE) && + GetLayer()->IsOpaqueForVisibility() && + LayerHasCheckerboardingAPZC(GetLayer(), aOutCheckerboardingColor); +} + #ifndef MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS /*static*/ bool diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index c324446d07da..7e68e398fa40 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -560,6 +560,12 @@ public: */ virtual nsIntRegion GetFullyRenderedRegion(); + /** + * Return true if a checkerboarding background color needs to be drawn + * for this layer. + */ + bool NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor = nullptr); + protected: gfx::Matrix4x4 mShadowTransform; LayerIntRegion mShadowVisibleRegion;