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-21 14:02:15 +12:00
Родитель 2cf79ec292
Коммит 2a35142b62
12 изменённых файлов: 21 добавлений и 111 удалений

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

@ -44,13 +44,6 @@ public:
// 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) {
if (mPostXScale == aXScale && mPostYScale == aYScale) {
return false;
@ -195,9 +188,6 @@ public:
// Getters.
//
const gfx::IntRect& LayerBounds() const {
return mLayerBounds;
}
float PostXScale() const {
return mPostXScale;
}
@ -265,8 +255,7 @@ public:
}
bool operator ==(const SimpleLayerAttributes& aOther) const {
return mLayerBounds == aOther.mLayerBounds &&
mTransform == aOther.mTransform &&
return mTransform == aOther.mTransform &&
mTransformIsPerspective == aOther.mTransformIsPerspective &&
mScrolledClip == aOther.mScrolledClip &&
mPostXScale == aOther.mPostXScale &&
@ -283,7 +272,6 @@ public:
}
private:
gfx::IntRect mLayerBounds;
gfx::Matrix4x4 mTransform;
bool mTransformIsPerspective;
Maybe<LayerClip> mScrolledClip;

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

@ -576,8 +576,7 @@ Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect)
return currentClip;
}
if (GetLocalVisibleRegion().IsEmpty() &&
!(AsHostLayer() && AsHostLayer()->NeedToDrawCheckerboarding())) {
if (GetLocalVisibleRegion().IsEmpty()) {
// 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.
@ -1850,9 +1849,6 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
if (GetTransformIsPerspective()) {
aStream << " [perspective]";
}
if (!GetLayerBounds().IsEmpty()) {
AppendToString(aStream, GetLayerBounds(), " [bounds=", "]");
}
if (!mVisibleRegion.IsEmpty()) {
AppendToString(aStream, mVisibleRegion.ToUnknownRegion(), " [visible=", "]");
} else {

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

@ -898,22 +898,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
* Tell this layer which region will be visible. The visible region
@ -1340,7 +1324,6 @@ public:
const Maybe<LayerClip>& GetScrolledClip() const { return mSimpleAttrs.ScrolledClip(); }
Maybe<ParentLayerIntRect> GetScrolledClipRect() const;
uint32_t GetContentFlags() { return mSimpleAttrs.ContentFlags(); }
const gfx::IntRect& GetLayerBounds() const { return mSimpleAttrs.LayerBounds(); }
const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
const ScrollMetadata& GetScrollMetadata(uint32_t aIndex) const;
const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const;

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

@ -169,7 +169,7 @@ ClientTiledPaintedLayer::BeginPaint()
ParentLayerToLayerMatrix4x4 transformDisplayPortToLayer =
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
// LayoutDevice space of this layer, but only if there is no OMT animation

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

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

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

@ -212,8 +212,7 @@ ContainerPrepare(ContainerT* aContainer,
// We don't want to skip container layers because otherwise their mPrepared
// may be null which is not allowed.
if (!layerToRender->GetLayer()->AsContainerLayer()) {
if (!layerToRender->GetLayer()->IsVisible() &&
!layerToRender->NeedToDrawCheckerboarding(nullptr)) {
if (!layerToRender->GetLayer()->IsVisible()) {
CULLING_LOG("Sublayer %p has no effective visible region\n", layerToRender->GetLayer());
continue;
}
@ -423,24 +422,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()) {
// Composer2D will compose this layer so skip GPU composition
// this time. The flag will be reset for the next composition phase

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

@ -1501,35 +1501,6 @@ 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

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

@ -589,12 +589,6 @@ public:
bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; }
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:
HostLayerManager* mCompositorManager;
@ -694,8 +688,6 @@ public:
*/
virtual nsIntRegion GetFullyRenderedRegion();
virtual bool NeedToDrawCheckerboarding(gfx::Color* aOutCheckerboardingColor = nullptr);
protected:
LayerManagerComposite* mCompositeManager;

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

@ -5313,20 +5313,29 @@ PresShell::AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
// color background behind a scrolled transparent background. Instead,
// we'll try to move the color background into the scrolled content
// by making nsDisplayCanvasBackground paint it.
bool addedScrollingBackgroundColor = false;
if (!aFrame->GetParent()) {
nsIScrollableFrame* sf =
aFrame->PresContext()->PresShell()->GetRootScrollFrameAsScrollable();
if (sf) {
nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
if (canvasFrame && canvasFrame->IsVisibleForPainting(&aBuilder)) {
if (AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor))
return;
addedScrollingBackgroundColor =
AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor);
}
}
}
aList.AppendNewToBottom(
new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor));
if (!addedScrollingBackgroundColor ||
(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)

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

@ -660,10 +660,6 @@ public:
* in mItemClip).
*/
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
* next PaintedLayerData currently in the stack, if any.
@ -3241,10 +3237,6 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
SetOuterVisibleRegionForLayer(layer, data->mVisibleRegion);
}
nsIntRect layerBounds = data->mBounds;
layerBounds.MoveBy(-GetTranslationForPaintedLayer(data->mLayer));
layer->SetLayerBounds(layerBounds);
#ifdef MOZ_DUMP_PAINTING
if (!data->mLog.IsEmpty()) {
if (PaintedLayerData* containingPld = mLayerBuilder->GetContainingPaintedLayerData()) {
@ -3441,10 +3433,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);
bool snap;
nsRect itemBounds = aItem->GetBounds(aState->mBuilder, &snap);
mBounds = mBounds.Union(aState->ScaleToOutsidePixels(itemBounds, snap));
if (aState->mBuilder->NeedToForceTransparentSurfaceForItem(aItem)) {
mForceTransparentSurface = true;
}
@ -3766,7 +3754,7 @@ ContainerState::GetDisplayPortForAnimatedGeometryRoot(AnimatedGeometryRoot* aAni
mLastDisplayPortAGR = aAnimatedGeometryRoot;
nsIScrollableFrame* sf = nsLayoutUtils::GetScrollableFrameFor(*aAnimatedGeometryRoot);
if (sf == nullptr) {
if (sf == nullptr || nsLayoutUtils::UsesAsyncScrolling(*aAnimatedGeometryRoot)) {
mLastDisplayPortRect = nsRect();
return mLastDisplayPortRect;
}

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

@ -1,6 +1,7 @@
<!DOCTYPE HTML>
<html>
<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:fixed; left: 10px; top: 10px; width: 10px; height: 10px; background-color: blue"></div>
</body>

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

@ -1,5 +1,6 @@
<!DOCTYPE HTML>
<html>
<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>
</body>