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
This commit is contained in:
Matt Woodrow ext:(%2C%20Botond%20Ballo%20%3Cbotond%40mozilla.com%3E) 2016-06-09 16:36:12 +12:00
Родитель e5645e5c78
Коммит 8fdf6e51d8
4 изменённых файлов: 42 добавлений и 36 удалений

Просмотреть файл

@ -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));
}

Просмотреть файл

@ -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()
{

Просмотреть файл

@ -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

Просмотреть файл

@ -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;