Move AbsoluteClipRects to the state machine

The AbsoluteClipRects are now precomputed as part of
the compositing update step as this is the only
consumer of them (more precisely overlap testing).
Added some ASSERTs to ensure we compute them at
the right time and we don't hold onto stale values.

BUG=515970

Review URL: https://codereview.chromium.org/1316173002

git-svn-id: svn://svn.chromium.org/blink/trunk@201252 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 90d21071
......@@ -2475,6 +2475,14 @@ void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases)
|| (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && lifecycle().state() == DocumentLifecycle::CompositingForSlimmingPaintV2Clean));
}
}
#ifndef NDEBUG
// TODO(jchaffraix): We will want to clear the clip rects in release too
// to reduce our long-term memory consumption. However this requires us
// to migrate all of the clip rects to the state machine and evaluate
// the performance impacts of this.
layoutView()->layer()->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects);
#endif
}
void FrameView::paintForSlimmingPaintV2()
......
......@@ -22,6 +22,7 @@ enum ClipRectsCacheSlot {
RootRelativeClipRectsIgnoringViewportClip,
// Relative to the LayoutView's layer. Used for compositing overlap testing.
// Computed during the compositing update step (see CompositingInputsUpdater::update).
AbsoluteClipRects,
// Relative to painting ancestor. Used for painting.
......
......@@ -26,6 +26,7 @@ CompositingInputsUpdater::~CompositingInputsUpdater()
void CompositingInputsUpdater::update()
{
TRACE_EVENT0("blink", "CompositingInputsUpdater::update");
m_rootLayer->clipper().precalculateAbsoluteClipRects();
updateRecursive(m_rootLayer, DoNotForceUpdate, AncestorInfo());
}
......
......@@ -365,8 +365,6 @@ void DeprecatedPaintLayer::updateTransform(const ComputedStyle* oldStyle, const
// DeprecatedPaintLayers with transforms act as clip rects roots, so clear the cached clip rects here.
m_clipper.clearClipRectsIncludingDescendants();
} else if (hasTransform) {
m_clipper.clearClipRectsIncludingDescendants(AbsoluteClipRects);
}
updateTransformationMatrix();
......
......@@ -169,7 +169,7 @@ void DeprecatedPaintLayerClipper::calculateRects(const ClipRectsContext& context
}
}
static void precalculate(const ClipRectsContext& context)
void precalculate(const ClipRectsContext& context)
{
bool isComputingPaintingRect = context.isComputingPaintingRect();
ClipRectComputationState rects;
......@@ -187,6 +187,13 @@ static void precalculate(const ClipRectsContext& context)
rootLayer->clipper().calculateClipRects(context, rects);
}
void DeprecatedPaintLayerClipper::precalculateAbsoluteClipRects()
{
ASSERT(m_layoutObject.layer()->isRootLayer());
// The absolute rectangles rely on layout sizes and position only.
ASSERT(m_layoutObject.document().lifecycle().state() >= DocumentLifecycle::LayoutClean);
precalculate(ClipRectsContext(m_layoutObject.layer(), AbsoluteClipRects));
}
// Calculates clipRect for each element in the section of the tree starting with context.rootLayer
// For painting, context.rootLayer is ignored and the entire tree is calculated.
......@@ -213,8 +220,11 @@ ClipRect DeprecatedPaintLayerClipper::backgroundClipRect(const ClipRectsContext&
// TODO(chadarmstrong): precalculation for painting should be moved to updateLifecyclePhasesInternal
// and precalculation could be done for all hit testing. This would let us avoid clearing the cache
if (!m_clips[context.cacheSlot()])
if (!m_clips[context.cacheSlot()]) {
// AbsoluteClipRects should have been updated during compositing updates so we shouldn't miss here.
ASSERT(context.cacheSlot() != AbsoluteClipRects);
precalculate(context);
}
// TODO(chadarmstrong): eliminate this if possible.
// It is necessary only because of a seemingly atypical use of rootLayer that
......
......@@ -149,6 +149,8 @@ public:
DeprecatedPaintLayer* clippingRootForPainting() const;
void precalculateAbsoluteClipRects();
private:
void setClipRect(const ClipRectsContext&, const ClipRectComputationState&) const;
void addClipsFromThisObject(const ClipRectsContext&, ClipRects&) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment