Commit 2fe8244b authored by wangxianzhu's avatar wangxianzhu Committed by Commit bot

Make PaintInvalidatorContext::geometryMapper and treeBuilderContext private

They are used in PaintInvalidator only, and can't be used elsewhere.
Make them private to prevent mistakes.
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2772473003
Cr-Commit-Position: refs/heads/master@{#458919}
parent 1c2910f5
......@@ -49,7 +49,7 @@ static LayoutRect slowMapToVisualRectInAncestorSpace(
// This function is templatized to avoid FloatRect<->LayoutRect conversions
// which affect performance.
template <typename Rect, typename Point>
static LayoutRect mapLocalRectToVisualRectInBacking(
LayoutRect PaintInvalidator::mapLocalRectToVisualRectInBacking(
const LayoutObject& object,
const Rect& localRect,
const PaintInvalidatorContext& context) {
......@@ -108,9 +108,9 @@ static LayoutRect mapLocalRectToVisualRectInBacking(
context.paintInvalidationContainer->paintProperties()
->contentsProperties();
if (context.treeBuilderContext.current.transform ==
if (context.m_treeBuilderContext.current.transform ==
containerContentsProperties->transform() &&
context.treeBuilderContext.current.clip ==
context.m_treeBuilderContext.current.clip ==
containerContentsProperties->clip()) {
result = LayoutRect(rect);
} else {
......@@ -119,17 +119,16 @@ static LayoutRect mapLocalRectToVisualRectInBacking(
// snapping, when transforms are applied. If there is no transform,
// enclosingIntRect is applied in the last step of paint invalidation
// (see CompositedLayerMapping::setContentsNeedDisplayInRect()).
if (!isSVGChild &&
context.treeBuilderContext.current.transform !=
containerContentsProperties->transform())
if (!isSVGChild && context.m_treeBuilderContext.current.transform !=
containerContentsProperties->transform())
rect = Rect(enclosingIntRect(rect));
PropertyTreeState currentTreeState(
context.treeBuilderContext.current.transform,
context.treeBuilderContext.current.clip, nullptr);
context.m_treeBuilderContext.current.transform,
context.m_treeBuilderContext.current.clip, nullptr);
FloatRect floatRect(rect);
context.geometryMapper.sourceToDestinationVisualRect(
context.m_geometryMapper.sourceToDestinationVisualRect(
currentTreeState, *containerContentsProperties, floatRect);
result = LayoutRect(floatRect);
}
......@@ -152,7 +151,8 @@ static LayoutRect mapLocalRectToVisualRectInBacking(
void PaintInvalidatorContext::mapLocalRectToVisualRectInBacking(
const LayoutObject& object,
LayoutRect& rect) const {
rect = blink::mapLocalRectToVisualRectInBacking<LayoutRect, LayoutPoint>(
rect = PaintInvalidator::mapLocalRectToVisualRectInBacking<LayoutRect,
LayoutPoint>(
object, rect, *this);
}
......@@ -183,10 +183,10 @@ LayoutPoint PaintInvalidator::computeLocationInBacking(
context.paintInvalidationContainer->paintProperties()
->contentsProperties()
->transform();
if (context.treeBuilderContext.current.transform != containerTransform) {
if (context.m_treeBuilderContext.current.transform != containerTransform) {
FloatRect rect = FloatRect(FloatPoint(point), FloatSize());
context.geometryMapper.sourceToDestinationRect(
context.treeBuilderContext.current.transform, containerTransform,
context.m_geometryMapper.sourceToDestinationRect(
context.m_treeBuilderContext.current.transform, containerTransform,
rect);
point = LayoutPoint(rect.location());
}
......@@ -255,10 +255,11 @@ namespace {
// apply.
class ScopedUndoFrameViewContentClipAndScroll {
public:
ScopedUndoFrameViewContentClipAndScroll(const FrameView& frameView,
PaintInvalidatorContext& context)
: m_treeBuilderContext(const_cast<PaintPropertyTreeBuilderContext&>(
context.treeBuilderContext)),
ScopedUndoFrameViewContentClipAndScroll(
const FrameView& frameView,
const PaintPropertyTreeBuilderContext& treeBuilderContext)
: m_treeBuilderContext(
const_cast<PaintPropertyTreeBuilderContext&>(treeBuilderContext)),
m_savedContext(m_treeBuilderContext.current) {
DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled());
......@@ -354,7 +355,7 @@ void PaintInvalidator::updateVisualRect(const LayoutObject& object,
if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
object.isLayoutView() && !object.isPaintInvalidationContainer()) {
undoFrameViewContentClipAndScroll.emplace(*toLayoutView(object).frameView(),
context);
context.m_treeBuilderContext);
}
// TODO(crbug.com/637313): Use GeometryMapper which now supports filter
......@@ -400,7 +401,8 @@ void PaintInvalidator::invalidatePaintIfNeeded(
context.paintingLayer = layoutView->layer();
if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
ScopedUndoFrameViewContentClipAndScroll undo(frameView, context);
ScopedUndoFrameViewContentClipAndScroll undo(frameView,
context.m_treeBuilderContext);
frameView.invalidatePaintOfScrollControlsIfNeeded(context);
}
}
......@@ -416,7 +418,7 @@ void PaintInvalidator::invalidatePaintIfNeeded(
// The paint offset should already be updated through
// PaintPropertyTreeBuilder::updatePropertiesForSelf.
DCHECK(context.treeBuilderContext.current.paintOffset ==
DCHECK(context.m_treeBuilderContext.current.paintOffset ==
object.paintOffset());
updatePaintingLayer(object, context);
......
......@@ -21,30 +21,28 @@ struct PaintInvalidatorContext {
PaintInvalidatorContext(
const PaintPropertyTreeBuilderContext& treeBuilderContext,
GeometryMapper& geometryMapper)
: treeBuilderContext(treeBuilderContext),
geometryMapper(geometryMapper),
parentContext(nullptr) {}
: parentContext(nullptr),
m_treeBuilderContext(treeBuilderContext),
m_geometryMapper(geometryMapper) {}
PaintInvalidatorContext(
const PaintPropertyTreeBuilderContext& treeBuilderContext,
const PaintInvalidatorContext& parentContext)
: treeBuilderContext(treeBuilderContext),
geometryMapper(parentContext.geometryMapper),
parentContext(&parentContext),
: parentContext(&parentContext),
forcedSubtreeInvalidationFlags(
parentContext.forcedSubtreeInvalidationFlags),
paintInvalidationContainer(parentContext.paintInvalidationContainer),
paintInvalidationContainerForStackedContents(
parentContext.paintInvalidationContainerForStackedContents),
paintingLayer(parentContext.paintingLayer) {}
paintingLayer(parentContext.paintingLayer),
m_treeBuilderContext(treeBuilderContext),
m_geometryMapper(parentContext.m_geometryMapper) {}
// This method is virtual temporarily to adapt PaintInvalidatorContext and the
// legacy PaintInvalidationState for code shared by old code and new code.
virtual void mapLocalRectToVisualRectInBacking(const LayoutObject&,
LayoutRect&) const;
const PaintPropertyTreeBuilderContext& treeBuilderContext;
GeometryMapper& geometryMapper;
const PaintInvalidatorContext* parentContext;
enum ForcedSubtreeInvalidationFlag {
......@@ -89,6 +87,11 @@ struct PaintInvalidatorContext {
// LayoutObject::adjustVisualRectForCompositedScrolling().
LayoutPoint oldLocation;
LayoutPoint newLocation;
private:
friend class PaintInvalidator;
const PaintPropertyTreeBuilderContext& m_treeBuilderContext;
GeometryMapper& m_geometryMapper;
};
class PaintInvalidator {
......@@ -101,6 +104,13 @@ class PaintInvalidator {
void processPendingDelayedPaintInvalidations();
private:
friend struct PaintInvalidatorContext;
template <typename Rect, typename Point>
static LayoutRect mapLocalRectToVisualRectInBacking(
const LayoutObject&,
const Rect&,
const PaintInvalidatorContext&);
ALWAYS_INLINE LayoutRect
computeVisualRectInBacking(const LayoutObject&,
const PaintInvalidatorContext&);
......
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