Commit 80353fce authored by pdr's avatar pdr Committed by Commit bot

Refactor PropertyTreeState as GeometryPropertyTreeState

The PropertyTreeState does not include scroll information and should
be renamed GeometryPropertyTreeState to reflect the real behavior.

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2338373004
Cr-Commit-Position: refs/heads/master@{#418736}
parent 85949830
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
namespace blink { namespace blink {
void ObjectPaintProperties::getContentsProperties(PropertyTreeState& properties) const void ObjectPaintProperties::getContentsProperties(GeometryPropertyTreeState& properties) const
{ {
properties = localBorderBoxProperties()->propertyTreeState; properties = localBorderBoxProperties()->geometryPropertyTreeState;
if (scrollTranslation()) if (scrollTranslation())
properties.transform = scrollTranslation(); properties.transform = scrollTranslation();
else if (svgLocalToBorderBoxTransform()) else if (svgLocalToBorderBoxTransform())
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "platform/geometry/LayoutPoint.h" #include "platform/geometry/LayoutPoint.h"
#include "platform/graphics/paint/ClipPaintPropertyNode.h" #include "platform/graphics/paint/ClipPaintPropertyNode.h"
#include "platform/graphics/paint/EffectPaintPropertyNode.h" #include "platform/graphics/paint/EffectPaintPropertyNode.h"
#include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/graphics/paint/PaintChunkProperties.h" #include "platform/graphics/paint/PaintChunkProperties.h"
#include "platform/graphics/paint/PropertyTreeState.h"
#include "platform/graphics/paint/ScrollPaintPropertyNode.h" #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
#include "platform/graphics/paint/TransformPaintPropertyNode.h" #include "platform/graphics/paint/TransformPaintPropertyNode.h"
#include "wtf/PassRefPtr.h" #include "wtf/PassRefPtr.h"
...@@ -81,14 +81,14 @@ public: ...@@ -81,14 +81,14 @@ public:
// at the right painting step. // at the right painting step.
struct LocalBorderBoxProperties { struct LocalBorderBoxProperties {
LayoutPoint paintOffset; LayoutPoint paintOffset;
// TODO(pdr): Rename this GeometryPropertyTreeState because it does not contain scroll. GeometryPropertyTreeState geometryPropertyTreeState;
PropertyTreeState propertyTreeState;
const ScrollPaintPropertyNode* scroll; const ScrollPaintPropertyNode* scroll;
}; };
const LocalBorderBoxProperties* localBorderBoxProperties() const { return m_localBorderBoxProperties.get(); } const LocalBorderBoxProperties* localBorderBoxProperties() const { return m_localBorderBoxProperties.get(); }
// ContentsProperties is the PropertyTreeState state that is the same as in localBorderBoxProperties, except that it is inside // ContentsProperties is the GeometryPropertyTreeState that is the same as in
// any clips and scrolls caused by this object. This PropertyTreeState is suitable as the destination for paint invalidation. // localBorderBoxProperties, except that it is inside any clips and scrolls caused by this
void getContentsProperties(PropertyTreeState&) const; // object. This GeometryPropertyTreeState is suitable as the destination for paint invalidation.
void getContentsProperties(GeometryPropertyTreeState&) const;
void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; } void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; }
void clearTransform() { m_transform = nullptr; } void clearTransform() { m_transform = nullptr; }
......
...@@ -46,8 +46,8 @@ static LayoutRect mapLocalRectToPaintInvalidationBacking(GeometryMapper& geometr ...@@ -46,8 +46,8 @@ static LayoutRect mapLocalRectToPaintInvalidationBacking(GeometryMapper& geometr
} else if (object == context.paintInvalidationContainer) { } else if (object == context.paintInvalidationContainer) {
result = LayoutRect(rect); result = LayoutRect(rect);
} else { } else {
PropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect); GeometryPropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
PropertyTreeState containerTreeState; GeometryPropertyTreeState containerTreeState;
const ObjectPaintProperties* containerPaintProperties = context.paintInvalidationContainer->objectPaintProperties(); const ObjectPaintProperties* containerPaintProperties = context.paintInvalidationContainer->objectPaintProperties();
containerPaintProperties->getContentsProperties(containerTreeState); containerPaintProperties->getContentsProperties(containerTreeState);
...@@ -92,8 +92,8 @@ LayoutPoint PaintInvalidator::computeLocationFromPaintInvalidationBacking(const ...@@ -92,8 +92,8 @@ LayoutPoint PaintInvalidator::computeLocationFromPaintInvalidationBacking(const
point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
bool success = false; bool success = false;
PropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect); GeometryPropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
PropertyTreeState containerTreeState; GeometryPropertyTreeState containerTreeState;
context.paintInvalidationContainer->objectPaintProperties()->getContentsProperties(containerTreeState); context.paintInvalidationContainer->objectPaintProperties()->getContentsProperties(containerTreeState);
point = m_geometryMapper.mapRectToDestinationSpace(FloatRect(point, FloatSize()), currentTreeState, containerTreeState, success).location(); point = m_geometryMapper.mapRectToDestinationSpace(FloatRect(point, FloatSize()), currentTreeState, containerTreeState, success).location();
DCHECK(success); DCHECK(success);
......
...@@ -333,10 +333,10 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon ...@@ -333,10 +333,10 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon
ASSERT(objectPaintProperties && objectPaintProperties->localBorderBoxProperties()); ASSERT(objectPaintProperties && objectPaintProperties->localBorderBoxProperties());
PaintChunkProperties properties(context.getPaintController().currentPaintChunkProperties()); PaintChunkProperties properties(context.getPaintController().currentPaintChunkProperties());
auto& localBorderBoxProperties = *objectPaintProperties->localBorderBoxProperties(); auto& localBorderBoxProperties = *objectPaintProperties->localBorderBoxProperties();
properties.transform = localBorderBoxProperties.propertyTreeState.transform; properties.transform = localBorderBoxProperties.geometryPropertyTreeState.transform;
properties.scroll = localBorderBoxProperties.scroll; properties.scroll = localBorderBoxProperties.scroll;
properties.clip = localBorderBoxProperties.propertyTreeState.clip; properties.clip = localBorderBoxProperties.geometryPropertyTreeState.clip;
properties.effect = localBorderBoxProperties.propertyTreeState.effect; properties.effect = localBorderBoxProperties.geometryPropertyTreeState.effect;
properties.backfaceHidden = m_paintLayer.layoutObject()->hasHiddenBackface(); properties.backfaceHidden = m_paintLayer.layoutObject()->hasHiddenBackface();
scopedPaintChunkProperties.emplace(context.getPaintController(), m_paintLayer, properties); scopedPaintChunkProperties.emplace(context.getPaintController(), m_paintLayer, properties);
} }
......
...@@ -296,15 +296,15 @@ void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o ...@@ -296,15 +296,15 @@ void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o
std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxContext = std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxContext =
wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties); wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties);
borderBoxContext->paintOffset = context.current.paintOffset; borderBoxContext->paintOffset = context.current.paintOffset;
borderBoxContext->propertyTreeState = PropertyTreeState(context.current.transform, context.current.clip, context.currentEffect); borderBoxContext->geometryPropertyTreeState = GeometryPropertyTreeState(context.current.transform, context.current.clip, context.currentEffect);
borderBoxContext->scroll = context.current.scroll; borderBoxContext->scroll = context.current.scroll;
if (!context.current.clip) { if (!context.current.clip) {
DCHECK(object.isLayoutView()); DCHECK(object.isLayoutView());
DCHECK(toLayoutView(object).frameView()->frame().isMainFrame()); DCHECK(toLayoutView(object).frameView()->frame().isMainFrame());
DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled()); DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled());
borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRect())); borderBoxContext->geometryPropertyTreeState.clip = ClipPaintPropertyNode::create(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRect()));
context.current.clip = borderBoxContext->propertyTreeState.clip.get(); context.current.clip = borderBoxContext->geometryPropertyTreeState.clip.get();
} }
object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderBoxProperties(std::move(borderBoxContext)); object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderBoxProperties(std::move(borderBoxContext));
......
...@@ -980,6 +980,7 @@ component("platform") { ...@@ -980,6 +980,7 @@ component("platform") {
"graphics/paint/ForeignLayerDisplayItem.h", "graphics/paint/ForeignLayerDisplayItem.h",
"graphics/paint/GeometryMapper.cpp", "graphics/paint/GeometryMapper.cpp",
"graphics/paint/GeometryMapper.h", "graphics/paint/GeometryMapper.h",
"graphics/paint/GeometryPropertyTreeState.h",
"graphics/paint/PaintArtifact.cpp", "graphics/paint/PaintArtifact.cpp",
"graphics/paint/PaintArtifact.h", "graphics/paint/PaintArtifact.h",
"graphics/paint/PaintArtifactToSkCanvas.cpp", "graphics/paint/PaintArtifactToSkCanvas.cpp",
...@@ -990,7 +991,6 @@ component("platform") { ...@@ -990,7 +991,6 @@ component("platform") {
"graphics/paint/PaintChunker.h", "graphics/paint/PaintChunker.h",
"graphics/paint/PaintController.cpp", "graphics/paint/PaintController.cpp",
"graphics/paint/PaintController.h", "graphics/paint/PaintController.h",
"graphics/paint/PropertyTreeState.h",
"graphics/paint/ScopedPaintChunkProperties.h", "graphics/paint/ScopedPaintChunkProperties.h",
"graphics/paint/ScrollDisplayItem.cpp", "graphics/paint/ScrollDisplayItem.cpp",
"graphics/paint/ScrollDisplayItem.h", "graphics/paint/ScrollDisplayItem.h",
...@@ -1676,11 +1676,11 @@ test("blink_platform_unittests") { ...@@ -1676,11 +1676,11 @@ test("blink_platform_unittests") {
"graphics/paint/DisplayItemListTest.cpp", "graphics/paint/DisplayItemListTest.cpp",
"graphics/paint/DisplayItemTest.cpp", "graphics/paint/DisplayItemTest.cpp",
"graphics/paint/GeometryMapperTest.cpp", "graphics/paint/GeometryMapperTest.cpp",
"graphics/paint/GeometryPropertyTreeStateTest.cpp",
"graphics/paint/PaintArtifactToSkCanvasTest.cpp", "graphics/paint/PaintArtifactToSkCanvasTest.cpp",
"graphics/paint/PaintChunkTest.cpp", "graphics/paint/PaintChunkTest.cpp",
"graphics/paint/PaintChunkerTest.cpp", "graphics/paint/PaintChunkerTest.cpp",
"graphics/paint/PaintControllerTest.cpp", "graphics/paint/PaintControllerTest.cpp",
"graphics/paint/PropertyTreeStateTest.cpp",
"image-decoders/FastSharedBufferReaderTest.cpp", "image-decoders/FastSharedBufferReaderTest.cpp",
"image-decoders/ImageDecoderTest.cpp", "image-decoders/ImageDecoderTest.cpp",
"image-decoders/ImageDecoderTestHelpers.cpp", "image-decoders/ImageDecoderTestHelpers.cpp",
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "platform/graphics/paint/DisplayItem.h" #include "platform/graphics/paint/DisplayItem.h"
#include "platform/graphics/paint/DrawingDisplayItem.h" #include "platform/graphics/paint/DrawingDisplayItem.h"
#include "platform/graphics/paint/ForeignLayerDisplayItem.h" #include "platform/graphics/paint/ForeignLayerDisplayItem.h"
#include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/graphics/paint/PaintArtifact.h" #include "platform/graphics/paint/PaintArtifact.h"
#include "platform/graphics/paint/PropertyTreeState.h"
#include "platform/graphics/paint/ScrollPaintPropertyNode.h" #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
#include "platform/graphics/paint/TransformPaintPropertyNode.h" #include "platform/graphics/paint/TransformPaintPropertyNode.h"
#include "public/platform/Platform.h" #include "public/platform/Platform.h"
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
namespace blink { namespace blink {
FloatRect GeometryMapper::mapToVisualRectInDestinationSpace(const FloatRect& rect, FloatRect GeometryMapper::mapToVisualRectInDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success) bool& success)
{ {
FloatRect result = localToVisualRectInAncestorSpace(rect, sourceState, destinationState, success); FloatRect result = localToVisualRectInAncestorSpace(rect, sourceState, destinationState, success);
...@@ -23,8 +23,8 @@ FloatRect GeometryMapper::mapToVisualRectInDestinationSpace(const FloatRect& rec ...@@ -23,8 +23,8 @@ FloatRect GeometryMapper::mapToVisualRectInDestinationSpace(const FloatRect& rec
} }
FloatRect GeometryMapper::mapRectToDestinationSpace(const FloatRect& rect, FloatRect GeometryMapper::mapRectToDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success) bool& success)
{ {
FloatRect result = localToAncestorRect(rect, sourceState, destinationState, success); FloatRect result = localToAncestorRect(rect, sourceState, destinationState, success);
...@@ -34,8 +34,8 @@ FloatRect GeometryMapper::mapRectToDestinationSpace(const FloatRect& rect, ...@@ -34,8 +34,8 @@ FloatRect GeometryMapper::mapRectToDestinationSpace(const FloatRect& rect,
} }
FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect& rect, FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success) bool& success)
{ {
const TransformPaintPropertyNode* lcaTransform = propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(sourceState.transform.get(), destinationState.transform.get()); const TransformPaintPropertyNode* lcaTransform = propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(sourceState.transform.get(), destinationState.transform.get());
...@@ -43,7 +43,7 @@ FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect& ...@@ -43,7 +43,7 @@ FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect&
// Assume that the clip of destinationState is an ancestor of the clip of sourceState // Assume that the clip of destinationState is an ancestor of the clip of sourceState
// and is under the space of lcaTransform. Otherwise localToAncestorClipRect() will fail. // and is under the space of lcaTransform. Otherwise localToAncestorClipRect() will fail.
PropertyTreeState lcaState = destinationState; GeometryPropertyTreeState lcaState = destinationState;
lcaState.transform = lcaTransform; lcaState.transform = lcaTransform;
const auto clipRect = localToAncestorClipRect(sourceState, lcaState, success); const auto clipRect = localToAncestorClipRect(sourceState, lcaState, success);
...@@ -65,13 +65,13 @@ FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect& ...@@ -65,13 +65,13 @@ FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect&
} }
FloatRect GeometryMapper::slowMapRectToDestinationSpace(const FloatRect& rect, FloatRect GeometryMapper::slowMapRectToDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success) bool& success)
{ {
const TransformPaintPropertyNode* lcaTransform = propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(sourceState.transform.get(), destinationState.transform.get()); const TransformPaintPropertyNode* lcaTransform = propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(sourceState.transform.get(), destinationState.transform.get());
DCHECK(lcaTransform); DCHECK(lcaTransform);
PropertyTreeState lcaState = sourceState; GeometryPropertyTreeState lcaState = sourceState;
lcaState.transform = lcaTransform; lcaState.transform = lcaTransform;
FloatRect result = localToAncestorRect(rect, sourceState, lcaState, success); FloatRect result = localToAncestorRect(rect, sourceState, lcaState, success);
...@@ -89,8 +89,8 @@ FloatRect GeometryMapper::slowMapRectToDestinationSpace(const FloatRect& rect, ...@@ -89,8 +89,8 @@ FloatRect GeometryMapper::slowMapRectToDestinationSpace(const FloatRect& rect,
FloatRect GeometryMapper::localToVisualRectInAncestorSpace( FloatRect GeometryMapper::localToVisualRectInAncestorSpace(
const FloatRect& rect, const FloatRect& rect,
const PropertyTreeState& localState, const GeometryPropertyTreeState& localState,
const PropertyTreeState& ancestorState, bool& success) const GeometryPropertyTreeState& ancestorState, bool& success)
{ {
const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success); const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success);
if (!success) if (!success)
...@@ -107,8 +107,8 @@ FloatRect GeometryMapper::localToVisualRectInAncestorSpace( ...@@ -107,8 +107,8 @@ FloatRect GeometryMapper::localToVisualRectInAncestorSpace(
FloatRect GeometryMapper::localToAncestorRect( FloatRect GeometryMapper::localToAncestorRect(
const FloatRect& rect, const FloatRect& rect,
const PropertyTreeState& localState, const GeometryPropertyTreeState& localState,
const PropertyTreeState& ancestorState, const GeometryPropertyTreeState& ancestorState,
bool& success) bool& success)
{ {
const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success); const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success);
...@@ -119,8 +119,8 @@ FloatRect GeometryMapper::localToAncestorRect( ...@@ -119,8 +119,8 @@ FloatRect GeometryMapper::localToAncestorRect(
FloatRect GeometryMapper::ancestorToLocalRect( FloatRect GeometryMapper::ancestorToLocalRect(
const FloatRect& rect, const FloatRect& rect,
const PropertyTreeState& localState, const GeometryPropertyTreeState& localState,
const PropertyTreeState& ancestorState, bool& success) const GeometryPropertyTreeState& ancestorState, bool& success)
{ {
const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success); const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success);
if (!success) if (!success)
...@@ -136,7 +136,7 @@ FloatRect GeometryMapper::ancestorToLocalRect( ...@@ -136,7 +136,7 @@ FloatRect GeometryMapper::ancestorToLocalRect(
return transformMatrix.inverse().mapRect(rect); return transformMatrix.inverse().mapRect(rect);
} }
PrecomputedDataForAncestor& GeometryMapper::getPrecomputedDataForAncestor(const PropertyTreeState& ancestorState) PrecomputedDataForAncestor& GeometryMapper::getPrecomputedDataForAncestor(const GeometryPropertyTreeState& ancestorState)
{ {
auto addResult = m_data.add(ancestorState.transform.get(), nullptr); auto addResult = m_data.add(ancestorState.transform.get(), nullptr);
if (addResult.isNewEntry) if (addResult.isNewEntry)
...@@ -145,8 +145,8 @@ PrecomputedDataForAncestor& GeometryMapper::getPrecomputedDataForAncestor(const ...@@ -145,8 +145,8 @@ PrecomputedDataForAncestor& GeometryMapper::getPrecomputedDataForAncestor(const
} }
FloatRect GeometryMapper::localToAncestorClipRect( FloatRect GeometryMapper::localToAncestorClipRect(
const PropertyTreeState& localState, const GeometryPropertyTreeState& localState,
const PropertyTreeState& ancestorState, const GeometryPropertyTreeState& ancestorState,
bool& success) bool& success)
{ {
PrecomputedDataForAncestor& precomputedData = getPrecomputedDataForAncestor(ancestorState); PrecomputedDataForAncestor& precomputedData = getPrecomputedDataForAncestor(ancestorState);
...@@ -196,7 +196,7 @@ FloatRect GeometryMapper::localToAncestorClipRect( ...@@ -196,7 +196,7 @@ FloatRect GeometryMapper::localToAncestorClipRect(
const TransformationMatrix& GeometryMapper::localToAncestorMatrix( const TransformationMatrix& GeometryMapper::localToAncestorMatrix(
const TransformPaintPropertyNode* localTransformNode, const TransformPaintPropertyNode* localTransformNode,
const PropertyTreeState& ancestorState, bool& success) { const GeometryPropertyTreeState& ancestorState, bool& success) {
PrecomputedDataForAncestor& precomputedData = getPrecomputedDataForAncestor(ancestorState); PrecomputedDataForAncestor& precomputedData = getPrecomputedDataForAncestor(ancestorState);
const TransformPaintPropertyNode* transformNode = localTransformNode; const TransformPaintPropertyNode* transformNode = localTransformNode;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define GeometryMapper_h #define GeometryMapper_h
#include "platform/geometry/FloatRect.h" #include "platform/geometry/FloatRect.h"
#include "platform/graphics/paint/PropertyTreeState.h" #include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/transforms/TransformationMatrix.h" #include "platform/transforms/TransformationMatrix.h"
#include "wtf/HashMap.h" #include "wtf/HashMap.h"
...@@ -29,16 +29,16 @@ struct PrecomputedDataForAncestor { ...@@ -29,16 +29,16 @@ struct PrecomputedDataForAncestor {
} }
}; };
// GeometryMapper is a helper class for fast computations of transformed and visual rects in different // GeometryMapper is a helper class for fast computations of transformed and visual rects in
// PropertyTreeStates. The design document has a number of details on use cases, algorithmic definitions, // different GeometryPropertyTreeStates. The design document has a number of details on use cases,
// and running times. // algorithmic definitions, and running times.
// //
// NOTE: a GeometryMapper object is only valid for property trees that do not change. If any mutation occurs, // NOTE: A GeometryMapper object is only valid for property trees that do not change. If any
// a new GeometryMapper object must be allocated corresponding to the new state. // mutation occurs, a new GeometryMapper object must be allocated corresponding to the new state.
// //
// Design document: http://bit.ly/28P4FDA // Design document: http://bit.ly/28P4FDA
// //
// TODO(chrishtr): take effect and scroll trees into account. // TODO(chrishtr): take effect tree into account.
class PLATFORM_EXPORT GeometryMapper { class PLATFORM_EXPORT GeometryMapper {
public: public:
GeometryMapper() {} GeometryMapper() {}
...@@ -54,14 +54,14 @@ public: ...@@ -54,14 +54,14 @@ public:
// If that inverse transform is not invertible, sets |success| to false and returns the input rect. Otherwise, sets // If that inverse transform is not invertible, sets |success| to false and returns the input rect. Otherwise, sets
// |success| to true. // |success| to true.
FloatRect mapToVisualRectInDestinationSpace(const FloatRect&, FloatRect mapToVisualRectInDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success); bool& success);
// Same as mapToVisualRectInDestinationSpace() except that *no* clip is applied. // Same as mapToVisualRectInDestinationSpace() except that *no* clip is applied.
FloatRect mapRectToDestinationSpace(const FloatRect&, FloatRect mapRectToDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success); bool& success);
// Maps from a rect in |localTransformSpace| to its visual rect in |ancestorState|. This is computed // Maps from a rect in |localTransformSpace| to its visual rect in |ancestorState|. This is computed
...@@ -75,8 +75,8 @@ public: ...@@ -75,8 +75,8 @@ public:
// to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise, // to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise,
// sets |success| to true. // sets |success| to true.
FloatRect localToVisualRectInAncestorSpace(const FloatRect&, FloatRect localToVisualRectInAncestorSpace(const FloatRect&,
const PropertyTreeState& localTransformState, const GeometryPropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState, const GeometryPropertyTreeState& ancestorState,
bool& success); bool& success);
// Maps from a rect in |localTransformSpace| to its transformed rect in |ancestorSpace|. This is computed // Maps from a rect in |localTransformSpace| to its transformed rect in |ancestorSpace|. This is computed
...@@ -91,8 +91,8 @@ public: ...@@ -91,8 +91,8 @@ public:
// to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise, // to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise,
// sets |success| to true. // sets |success| to true.
FloatRect localToAncestorRect(const FloatRect&, FloatRect localToAncestorRect(const FloatRect&,
const PropertyTreeState& localTransformState, const GeometryPropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState, const GeometryPropertyTreeState& ancestorState,
bool& success); bool& success);
// Maps from a rect in |ancestorSpace| to its transformed rect in |localTransformSpace|. This is computed // Maps from a rect in |ancestorSpace| to its transformed rect in |localTransformSpace|. This is computed
...@@ -103,39 +103,39 @@ public: ...@@ -103,39 +103,39 @@ public:
// to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise, // to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise,
// sets |success| to true. // sets |success| to true.
FloatRect ancestorToLocalRect(const FloatRect&, FloatRect ancestorToLocalRect(const FloatRect&,
const PropertyTreeState& localTransformState, const GeometryPropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState, const GeometryPropertyTreeState& ancestorState,
bool& success); bool& success);
private: private:
// Used by mapToVisualRectInDestinationSpace() after fast mapping (assuming destination is an ancestor of source) failed. // Used by mapToVisualRectInDestinationSpace() after fast mapping (assuming destination is an ancestor of source) failed.
FloatRect slowMapToVisualRectInDestinationSpace(const FloatRect&, FloatRect slowMapToVisualRectInDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success); bool& success);
// Used by mapRectToDestinationSpace() after fast mapping (assuming destination is an ancestor of source) failed. // Used by mapRectToDestinationSpace() after fast mapping (assuming destination is an ancestor of source) failed.
FloatRect slowMapRectToDestinationSpace(const FloatRect&, FloatRect slowMapRectToDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState, const GeometryPropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const GeometryPropertyTreeState& destinationState,
bool& success); bool& success);
// Returns the matrix used in |LocalToAncestorRect|. Sets |success| to failse iff |localTransformNode| is not // Returns the matrix used in |LocalToAncestorRect|. Sets |success| to failse iff |localTransformNode| is not
// equal to or a descendant of |ancestorState.transform|. // equal to or a descendant of |ancestorState.transform|.
const TransformationMatrix& localToAncestorMatrix( const TransformationMatrix& localToAncestorMatrix(
const TransformPaintPropertyNode* localTransformNode, const TransformPaintPropertyNode* localTransformNode,
const PropertyTreeState& ancestorState, const GeometryPropertyTreeState& ancestorState,
bool& success); bool& success);
// Returns the "clip visual rect" between |localTransformState| and |ancestorState|. See above for the definition // Returns the "clip visual rect" between |localTransformState| and |ancestorState|. See above for the definition
// of "clip visual rect". // of "clip visual rect".
FloatRect localToAncestorClipRect( FloatRect localToAncestorClipRect(
const PropertyTreeState& localTransformState, const GeometryPropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState, const GeometryPropertyTreeState& ancestorState,
bool& success); bool& success);
// Returns the precomputed data if already set, or adds and memoizes a new PrecomputedDataForAncestor otherwise. // Returns the precomputed data if already set, or adds and memoizes a new PrecomputedDataForAncestor otherwise.
PrecomputedDataForAncestor& getPrecomputedDataForAncestor(const PropertyTreeState&); PrecomputedDataForAncestor& getPrecomputedDataForAncestor(const GeometryPropertyTreeState&);
// Returns the least common ancestor in the transform tree. // Returns the least common ancestor in the transform tree.
PassRefPtr<TransformPaintPropertyNode> leastCommonAncestor(PassRefPtr<TransformPaintPropertyNode>, PassRefPtr<TransformPaintPropertyNode>); PassRefPtr<TransformPaintPropertyNode> leastCommonAncestor(PassRefPtr<TransformPaintPropertyNode>, PassRefPtr<TransformPaintPropertyNode>);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef PropertyTreeState_h #ifndef GeometryPropertyTreeState_h
#define PropertyTreeState_h #define GeometryPropertyTreeState_h
#include "platform/graphics/paint/ClipPaintPropertyNode.h" #include "platform/graphics/paint/ClipPaintPropertyNode.h"
#include "platform/graphics/paint/EffectPaintPropertyNode.h" #include "platform/graphics/paint/EffectPaintPropertyNode.h"
...@@ -14,14 +14,12 @@ ...@@ -14,14 +14,12 @@
namespace blink { namespace blink {
// Represents the combination of transform, clip and effect nodes for a particular coordinate space. // Represents the combination of transform, clip and effect nodes for a particular coordinate space.
// See GeometryMapper. // See GeometryMapper. Scroll nodes (ScrollPaintPropertyNode) are not needed for mapping geometry
// Scroll nodes (ScrollPaintPropertyNode) are not needed for mapping geometry and have been left off // and have been left off of this structure.
// of this structure. struct GeometryPropertyTreeState {
// TODO(pdr): Rename this GeometryPropertyTreeState. GeometryPropertyTreeState() : GeometryPropertyTreeState(nullptr, nullptr, nullptr) {}
struct PropertyTreeState {
PropertyTreeState() : PropertyTreeState(nullptr, nullptr, nullptr) {}
PropertyTreeState( GeometryPropertyTreeState(
const TransformPaintPropertyNode* transform, const TransformPaintPropertyNode* transform,
const ClipPaintPropertyNode* clip, const ClipPaintPropertyNode* clip,
const EffectPaintPropertyNode* effect) const EffectPaintPropertyNode* effect)
...@@ -72,4 +70,4 @@ const A* propertyTreeNearestCommonAncestor(const A* a, const A* b) ...@@ -72,4 +70,4 @@ const A* propertyTreeNearestCommonAncestor(const A* a, const A* b)
} // namespace blink } // namespace blink
#endif // PropertyTreeState_h #endif // GeometryPropertyTreeState_h
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "platform/graphics/paint/PropertyTreeState.h" #include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/geometry/LayoutRect.h" #include "platform/geometry/LayoutRect.h"
#include "platform/graphics/paint/ClipPaintPropertyNode.h" #include "platform/graphics/paint/ClipPaintPropertyNode.h"
...@@ -12,15 +12,15 @@ ...@@ -12,15 +12,15 @@
namespace blink { namespace blink {
class PropertyTreeStateTest : public ::testing::Test { class GeometryPropertyTreeStateTest : public ::testing::Test {
public: public:
RefPtr<TransformPaintPropertyNode> rootTransformNode; RefPtr<TransformPaintPropertyNode> rootTransformNode;
RefPtr<ClipPaintPropertyNode> rootClipNode; RefPtr<ClipPaintPropertyNode> rootClipNode;
RefPtr<EffectPaintPropertyNode> rootEffectNode; RefPtr<EffectPaintPropertyNode> rootEffectNode;
PropertyTreeState rootPropertyTreeState() GeometryPropertyTreeState rootGeometryPropertyTreeState()
{ {
PropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), rootEffectNode.get()); GeometryPropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), rootEffectNode.get());
return state; return state;
} }
...@@ -33,26 +33,26 @@ private: ...@@ -33,26 +33,26 @@ private:
} }
}; };
TEST_F(PropertyTreeStateTest, LeastCommonAncestor) TEST_F(GeometryPropertyTreeStateTest, LeastCommonAncestor)
{ {
TransformationMatrix matrix; TransformationMatrix matrix;
RefPtr<TransformPaintPropertyNode> child1 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, matrix, FloatPoint3D()); RefPtr<TransformPaintPropertyNode> child1 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> child2 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, matrix, FloatPoint3D()); RefPtr<TransformPaintPropertyNode> child2 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> childOfChild1 = TransformPaintPropertyNode::create(child1, matrix, FloatPoint3D()); RefPtr<TransformPaintPropertyNode> childOfChild1 = TransformPaintPropertyNode::create(child1, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> childOfChild2 = TransformPaintPropertyNode::create(child2, matrix, FloatPoint3D()); RefPtr<TransformPaintPropertyNode> childOfChild2 = TransformPaintPropertyNode::create(child2, matrix, FloatPoint3D());
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), childOfChild2.get())); EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), childOfChild2.get()));
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), child2.get())); EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), child2.get()));
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), rootPropertyTreeState().transform.get())); EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), rootGeometryPropertyTreeState().transform.get()));
EXPECT_EQ(child1, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), child1.get())); EXPECT_EQ(child1, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), child1.get()));
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), childOfChild1.get())); EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), childOfChild1.get()));
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), child1.get())); EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), child1.get()));
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), rootPropertyTreeState().transform.get())); EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), rootGeometryPropertyTreeState().transform.get()));
EXPECT_EQ(child2, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), child2.get())); EXPECT_EQ(child2, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), child2.get()));
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(child1.get(), child2.get())); EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(child1.get(), child2.get()));
} }
} // namespace blink } // namespace blink
...@@ -263,12 +263,12 @@ root layer to the overall layer hierarchy to be displayed to the user. ...@@ -263,12 +263,12 @@ root layer to the overall layer hierarchy to be displayed to the user.
The [`GeometryMapper`](GeometryMapper.h) is responsible for efficiently computing The [`GeometryMapper`](GeometryMapper.h) is responsible for efficiently computing
visual and transformed rects of display items in the coordinate space of ancestor visual and transformed rects of display items in the coordinate space of ancestor
[`PropertyTreeState`](PropertyTreeState.h)s. [`GeometryPropertyTreeState`](GeometryPropertyTreeState.h)s.
The transformed rect of a display item in an ancestor `PropertyTreeState` is that The transformed rect of a display item in an ancestor `GeometryPropertyTreeState`
rect, multiplied by the transforms between the display item's `PropertyTreeState` is that rect, multiplied by the transforms between the display item's
and the ancestors, then flattened into 2D. `GeometryPropertyTreeState` and the ancestors, then flattened into 2D.
The visual rect of a display item in an ancestor `PropertyTreeState` is the intersection The visual rect of a display item in an ancestor `GeometryPropertyTreeState` is
of all of the intermediate clips (transformed in to the ancestor state), with the intersection of all of the intermediate clips (transformed in to the
the display item's transformed rect. ancestor state), with the display item's transformed rect.
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