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