Bug 1021085 - Refactor code to ensure we use the same scrolling ancestor layer everywhere. r=Cwiiis

This commit is contained in:
Kartikaya Gupta 2014-06-23 08:41:09 -04:00
parent 6ed830eb0e
commit 5a886a99f9
3 changed files with 38 additions and 14 deletions

View File

@ -85,6 +85,32 @@ GetTransformToAncestorsParentLayer(Layer* aStart, Layer* aAncestor)
return ret;
}
void
ClientTiledThebesLayer::GetAncestorLayers(ContainerLayer** aOutScrollAncestor,
ContainerLayer** aOutDisplayPortAncestor)
{
ContainerLayer* scrollAncestor = nullptr;
ContainerLayer* displayPortAncestor = nullptr;
for (ContainerLayer* ancestor = GetParent(); ancestor; ancestor = ancestor->GetParent()) {
const FrameMetrics& metrics = ancestor->GetFrameMetrics();
if (!scrollAncestor && metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
scrollAncestor = ancestor;
}
if (!metrics.mDisplayPort.IsEmpty()) {
displayPortAncestor = ancestor;
// Any layer that has a displayport must be scrollable, so we can break
// here.
break;
}
}
if (aOutScrollAncestor) {
*aOutScrollAncestor = scrollAncestor;
}
if (aOutDisplayPortAncestor) {
*aOutDisplayPortAncestor = displayPortAncestor;
}
}
void
ClientTiledThebesLayer::BeginPaint()
{
@ -104,18 +130,7 @@ ClientTiledThebesLayer::BeginPaint()
// with a displayport.
ContainerLayer* scrollAncestor = nullptr;
ContainerLayer* displayPortAncestor = nullptr;
for (ContainerLayer* ancestor = GetParent(); ancestor; ancestor = ancestor->GetParent()) {
const FrameMetrics& metrics = ancestor->GetFrameMetrics();
if (!scrollAncestor && metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
scrollAncestor = ancestor;
}
if (!metrics.mDisplayPort.IsEmpty()) {
displayPortAncestor = ancestor;
// Any layer that has a displayport must be scrollable, so we can break
// here.
break;
}
}
GetAncestorLayers(&scrollAncestor, &displayPortAncestor);
if (!displayPortAncestor || !scrollAncestor) {
// No displayport or scroll ancestor, so we can't do progressive rendering.

View File

@ -69,6 +69,14 @@ public:
virtual void ClearCachedResources() MOZ_OVERRIDE;
/**
* Helper method to find the nearest ancestor layers which
* scroll and have a displayport. The parameters are out-params
* which hold the return values; the values passed in may be null.
*/
void GetAncestorLayers(ContainerLayer** aOutScrollAncestor,
ContainerLayer** aOutDisplayPortAncestor);
private:
ClientLayerManager* ClientManager()
{

View File

@ -1011,11 +1011,12 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval
#else
MOZ_ASSERT(mSharedFrameMetricsHelper);
ContainerLayer* parent = mThebesLayer->AsLayer()->GetParent();
ContainerLayer* scrollAncestor = nullptr;
mThebesLayer->GetAncestorLayers(&scrollAncestor, nullptr);
bool abortPaint =
mSharedFrameMetricsHelper->UpdateFromCompositorFrameMetrics(
parent,
scrollAncestor,
!staleRegion.Contains(aInvalidRegion),
drawingLowPrecision,
compositionBounds,