Bug 1349418 - Remove checkerboarding code and just use an opaque background color behind root scroll frames. r=kats

This commit is contained in:
Markus Stange
2017-04-10 17:01:53 +12:00
parent 85f31a7ad5
commit f510a8a0ad
12 changed files with 21 additions and 111 deletions

View File

@@ -44,13 +44,6 @@ public:
// All set methods return true if values changed, false otherwise. // All set methods return true if values changed, false otherwise.
// //
bool SetLayerBounds(const gfx::IntRect& aLayerBounds) {
if (mLayerBounds.IsEqualEdges(aLayerBounds)) {
return false;
}
mLayerBounds = aLayerBounds;
return true;
}
bool SetPostScale(float aXScale, float aYScale) { bool SetPostScale(float aXScale, float aYScale) {
if (mPostXScale == aXScale && mPostYScale == aYScale) { if (mPostXScale == aXScale && mPostYScale == aYScale) {
return false; return false;
@@ -174,9 +167,6 @@ public:
// Getters. // Getters.
// //
const gfx::IntRect& LayerBounds() const {
return mLayerBounds;
}
float PostXScale() const { float PostXScale() const {
return mPostXScale; return mPostXScale;
} }
@@ -244,8 +234,7 @@ public:
} }
bool operator ==(const SimpleLayerAttributes& aOther) const { bool operator ==(const SimpleLayerAttributes& aOther) const {
return mLayerBounds == aOther.mLayerBounds && return mTransform == aOther.mTransform &&
mTransform == aOther.mTransform &&
mTransformIsPerspective == aOther.mTransformIsPerspective && mTransformIsPerspective == aOther.mTransformIsPerspective &&
mScrolledClip == aOther.mScrolledClip && mScrolledClip == aOther.mScrolledClip &&
mPostXScale == aOther.mPostXScale && mPostXScale == aOther.mPostXScale &&
@@ -262,7 +251,6 @@ public:
} }
private: private:
gfx::IntRect mLayerBounds;
gfx::Matrix4x4 mTransform; gfx::Matrix4x4 mTransform;
bool mTransformIsPerspective; bool mTransformIsPerspective;
Maybe<LayerClip> mScrolledClip; Maybe<LayerClip> mScrolledClip;

View File

@@ -576,8 +576,7 @@ Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect)
return currentClip; return currentClip;
} }
if (GetLocalVisibleRegion().IsEmpty() && if (GetLocalVisibleRegion().IsEmpty()) {
!(AsHostLayer() && AsHostLayer()->NeedToDrawCheckerboarding())) {
// When our visible region is empty, our parent may not have created the // When our visible region is empty, our parent may not have created the
// intermediate surface that we would require for correct clipping; however, // intermediate surface that we would require for correct clipping; however,
// this does not matter since we are invisible. // this does not matter since we are invisible.
@@ -1855,9 +1854,6 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
if (GetTransformIsPerspective()) { if (GetTransformIsPerspective()) {
aStream << " [perspective]"; aStream << " [perspective]";
} }
if (!GetLayerBounds().IsEmpty()) {
AppendToString(aStream, GetLayerBounds(), " [bounds=", "]");
}
if (!mVisibleRegion.IsEmpty()) { if (!mVisibleRegion.IsEmpty()) {
AppendToString(aStream, mVisibleRegion.ToUnknownRegion(), " [visible=", "]"); AppendToString(aStream, mVisibleRegion.ToUnknownRegion(), " [visible=", "]");
} else { } else {

View File

@@ -897,22 +897,6 @@ public:
} }
} }
/**
* CONSTRUCTION PHASE ONLY
* The union of the bounds of all the display item that got flattened
* into this layer. This is intended to be an approximation to the
* size of the layer if the nearest scrollable ancestor had an infinitely
* large displayport. Computing this more exactly is too expensive,
* but this approximation is sufficient for what we need to use it for.
*/
virtual void SetLayerBounds(const gfx::IntRect& aLayerBounds)
{
if (mSimpleAttrs.SetLayerBounds(aLayerBounds)) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) LayerBounds", this));
MutatedSimple();
}
}
/** /**
* CONSTRUCTION PHASE ONLY * CONSTRUCTION PHASE ONLY
* Tell this layer which region will be visible. The visible region * Tell this layer which region will be visible. The visible region
@@ -1339,7 +1323,6 @@ public:
const Maybe<LayerClip>& GetScrolledClip() const { return mSimpleAttrs.ScrolledClip(); } const Maybe<LayerClip>& GetScrolledClip() const { return mSimpleAttrs.ScrolledClip(); }
Maybe<ParentLayerIntRect> GetScrolledClipRect() const; Maybe<ParentLayerIntRect> GetScrolledClipRect() const;
uint32_t GetContentFlags() { return mSimpleAttrs.ContentFlags(); } uint32_t GetContentFlags() { return mSimpleAttrs.ContentFlags(); }
const gfx::IntRect& GetLayerBounds() const { return mSimpleAttrs.LayerBounds(); }
const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; } const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
const ScrollMetadata& GetScrollMetadata(uint32_t aIndex) const; const ScrollMetadata& GetScrollMetadata(uint32_t aIndex) const;
const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const; const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const;

View File

@@ -169,7 +169,7 @@ ClientTiledPaintedLayer::BeginPaint()
ParentLayerToLayerMatrix4x4 transformDisplayPortToLayer = ParentLayerToLayerMatrix4x4 transformDisplayPortToLayer =
GetTransformToAncestorsParentLayer(this, displayPortAncestor).Inverse(); GetTransformToAncestorsParentLayer(this, displayPortAncestor).Inverse();
LayerRect layerBounds = ViewAs<LayerPixel>(Rect(GetLayerBounds())); LayerRect layerBounds(GetVisibleRegion().GetBounds());
// Compute the critical display port that applies to this layer in the // Compute the critical display port that applies to this layer in the
// LayoutDevice space of this layer, but only if there is no OMT animation // LayoutDevice space of this layer, but only if there is no OMT animation

View File

@@ -1218,7 +1218,7 @@ ClientMultiTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& a
GetCompositorSideCompositionBounds(scrollAncestor, GetCompositorSideCompositionBounds(scrollAncestor,
aPaintData->mTransformToCompBounds, aPaintData->mTransformToCompBounds,
viewTransform, viewTransform,
ViewAs<LayerPixel>(Rect(mPaintedLayer.GetLayerBounds()))); LayerRect(mPaintedLayer.GetVisibleRegion().GetBounds()));
if (!transformedCompositionBounds) { if (!transformedCompositionBounds) {
aPaintData->mPaintFinished = true; aPaintData->mPaintFinished = true;

View File

@@ -209,8 +209,7 @@ ContainerPrepare(ContainerT* aContainer,
// We don't want to skip container layers because otherwise their mPrepared // We don't want to skip container layers because otherwise their mPrepared
// may be null which is not allowed. // may be null which is not allowed.
if (!layerToRender->GetLayer()->AsContainerLayer()) { if (!layerToRender->GetLayer()->AsContainerLayer()) {
if (!layerToRender->GetLayer()->IsVisible() && if (!layerToRender->GetLayer()->IsVisible()) {
!layerToRender->NeedToDrawCheckerboarding(nullptr)) {
CULLING_LOG("Sublayer %p has no effective visible region\n", layerToRender->GetLayer()); CULLING_LOG("Sublayer %p has no effective visible region\n", layerToRender->GetLayer());
continue; continue;
} }
@@ -419,24 +418,6 @@ RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager,
} }
} }
Color color;
if (layerToRender->NeedToDrawCheckerboarding(&color)) {
if (gfxPrefs::APZHighlightCheckerboardedAreas()) {
color = Color(255 / 255.f, 188 / 255.f, 217 / 255.f, 1.f); // "Cotton Candy"
}
// Ideally we would want to intersect the checkerboard region from the APZ with the layer bounds
// and only fill in that area. However the layer bounds takes into account the base translation
// for the painted layer whereas the checkerboard region does not. One does not simply
// intersect areas in different coordinate spaces. So we do this a little more permissively
// and only fill in the background when we know there is checkerboard, which in theory
// should only occur transiently.
EffectChain effectChain(layer);
effectChain.mPrimaryEffect = new EffectSolidColor(color);
aManager->GetCompositor()->DrawGeometry(gfx::Rect(layer->GetLayerBounds()), clipRect,
effectChain, layer->GetEffectiveOpacity(),
layer->GetEffectiveTransform(), Nothing());
}
if (layerToRender->HasLayerBeenComposited()) { if (layerToRender->HasLayerBeenComposited()) {
// Composer2D will compose this layer so skip GPU composition // Composer2D will compose this layer so skip GPU composition
// this time. The flag will be reset for the next composition phase // this time. The flag will be reset for the next composition phase

View File

@@ -1450,35 +1450,6 @@ LayerComposite::HasStaleCompositor() const
return mCompositeManager->GetCompositor() != mCompositor; 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 #ifndef MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
/*static*/ bool /*static*/ bool

View File

@@ -565,12 +565,6 @@ public:
bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; } bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; }
bool GetShadowOpacitySetByAnimation() { return mShadowOpacitySetByAnimation; } bool GetShadowOpacitySetByAnimation() { return mShadowOpacitySetByAnimation; }
/**
* Return true if a checkerboarding background color needs to be drawn
* for this layer.
*/
virtual bool NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor = nullptr) { return false; }
protected: protected:
HostLayerManager* mCompositorManager; HostLayerManager* mCompositorManager;
@@ -670,8 +664,6 @@ public:
*/ */
virtual nsIntRegion GetFullyRenderedRegion(); virtual nsIntRegion GetFullyRenderedRegion();
virtual bool NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor = nullptr);
protected: protected:
LayerManagerComposite* mCompositeManager; LayerManagerComposite* mCompositeManager;

View File

@@ -5352,20 +5352,29 @@ PresShell::AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
// color background behind a scrolled transparent background. Instead, // color background behind a scrolled transparent background. Instead,
// we'll try to move the color background into the scrolled content // we'll try to move the color background into the scrolled content
// by making nsDisplayCanvasBackground paint it. // by making nsDisplayCanvasBackground paint it.
bool addedScrollingBackgroundColor = false;
if (!aFrame->GetParent()) { if (!aFrame->GetParent()) {
nsIScrollableFrame* sf = nsIScrollableFrame* sf =
aFrame->PresContext()->PresShell()->GetRootScrollFrameAsScrollable(); aFrame->PresContext()->PresShell()->GetRootScrollFrameAsScrollable();
if (sf) { if (sf) {
nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame()); nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
if (canvasFrame && canvasFrame->IsVisibleForPainting(&aBuilder)) { if (canvasFrame && canvasFrame->IsVisibleForPainting(&aBuilder)) {
if (AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor)) addedScrollingBackgroundColor =
return; AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor);
} }
} }
} }
aList.AppendNewToBottom( if (!addedScrollingBackgroundColor ||
new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor)); (nsLayoutUtils::UsesAsyncScrolling(aFrame) && NS_GET_A(bgcolor) == 255)) {
// With async scrolling, we'd like to have two instances of the background
// color: one that scrolls with the content (for the reasons stated above),
// and one underneath which does not scroll with the content, but which can
// be shown during checkerboarding and overscroll.
// We can only do that if the color is opaque.
aList.AppendNewToBottom(
new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor));
}
} }
static bool IsTransparentContainerElement(nsPresContext* aPresContext) static bool IsTransparentContainerElement(nsPresContext* aPresContext)

View File

@@ -651,10 +651,6 @@ public:
* in mItemClip). * in mItemClip).
*/ */
void UpdateCommonClipCount(const DisplayItemClip& aCurrentClip); void UpdateCommonClipCount(const DisplayItemClip& aCurrentClip);
/**
* The union of all the bounds of the display items in this layer.
*/
nsIntRect mBounds;
/** /**
* The region of visible content above the layer and below the * The region of visible content above the layer and below the
* next PaintedLayerData currently in the stack, if any. * next PaintedLayerData currently in the stack, if any.
@@ -3275,10 +3271,6 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
SetOuterVisibleRegionForLayer(layer, data->mVisibleRegion); SetOuterVisibleRegionForLayer(layer, data->mVisibleRegion);
} }
nsIntRect layerBounds = data->mBounds;
layerBounds.MoveBy(-GetTranslationForPaintedLayer(data->mLayer));
layer->SetLayerBounds(layerBounds);
#ifdef MOZ_DUMP_PAINTING #ifdef MOZ_DUMP_PAINTING
if (!data->mLog.IsEmpty()) { if (!data->mLog.IsEmpty()) {
if (PaintedLayerData* containingPld = mLayerBuilder->GetContainingPaintedLayerData()) { if (PaintedLayerData* containingPld = mLayerBuilder->GetContainingPaintedLayerData()) {
@@ -3475,10 +3467,6 @@ PaintedLayerData::Accumulate(ContainerState* aState,
{ {
FLB_LOG_PAINTED_LAYER_DECISION(this, "Accumulating dp=%s(%p), f=%p against pld=%p\n", aItem->Name(), aItem, aItem->Frame(), this); FLB_LOG_PAINTED_LAYER_DECISION(this, "Accumulating dp=%s(%p), f=%p against pld=%p\n", aItem->Name(), aItem, aItem->Frame(), this);
bool snap;
nsRect itemBounds = aItem->GetBounds(aState->mBuilder, &snap);
mBounds = mBounds.Union(aState->ScaleToOutsidePixels(itemBounds, snap));
if (aState->mBuilder->NeedToForceTransparentSurfaceForItem(aItem)) { if (aState->mBuilder->NeedToForceTransparentSurfaceForItem(aItem)) {
mForceTransparentSurface = true; mForceTransparentSurface = true;
} }
@@ -3798,7 +3786,7 @@ ContainerState::GetDisplayPortForAnimatedGeometryRoot(AnimatedGeometryRoot* aAni
} }
nsIScrollableFrame* sf = nsLayoutUtils::GetScrollableFrameFor(*aAnimatedGeometryRoot); nsIScrollableFrame* sf = nsLayoutUtils::GetScrollableFrameFor(*aAnimatedGeometryRoot);
if (sf == nullptr) { if (sf == nullptr || nsLayoutUtils::UsesAsyncScrolling(*aAnimatedGeometryRoot)) {
return nsRect(); return nsRect();
} }

View File

@@ -1,6 +1,7 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<body style="background-color: green; overflow:hidden"> <body style="background-color: green; overflow:hidden">
<div style="position:fixed; left: 0px; top: 0px; width: 100px; height: 500px; background-color: purple; z-index: -1"></div>
<div style="position:absolute; left: 0px; top: 0px; background-color: yellow; width: 100px; height: 200px"></div> <div style="position:absolute; left: 0px; top: 0px; background-color: yellow; width: 100px; height: 200px"></div>
<div style="position:fixed; left: 10px; top: 10px; width: 10px; height: 10px; background-color: blue"></div> <div style="position:fixed; left: 10px; top: 10px; width: 10px; height: 10px; background-color: blue"></div>
</body> </body>

View File

@@ -1,5 +1,6 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<body style="background-color: green; overflow:hidden"> <body style="background-color: green; overflow:hidden">
<div style="position:fixed; left: 0px; top: 0px; width: 100px; height: 500px; background-color: purple; z-index: -1"></div>
<div style="position:fixed; left: 10px; top: 10px; width: 10px; height: 10px; background-color: blue"></div> <div style="position:fixed; left: 10px; top: 10px; width: 10px; height: 10px; background-color: blue"></div>
</body> </body>