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 @@
namespace blink {
void ObjectPaintProperties::getContentsProperties(PropertyTreeState& properties) const
void ObjectPaintProperties::getContentsProperties(GeometryPropertyTreeState& properties) const
{
properties = localBorderBoxProperties()->propertyTreeState;
properties = localBorderBoxProperties()->geometryPropertyTreeState;
if (scrollTranslation())
properties.transform = scrollTranslation();
else if (svgLocalToBorderBoxTransform())
......
......@@ -9,8 +9,8 @@
#include "platform/geometry/LayoutPoint.h"
#include "platform/graphics/paint/ClipPaintPropertyNode.h"
#include "platform/graphics/paint/EffectPaintPropertyNode.h"
#include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/graphics/paint/PaintChunkProperties.h"
#include "platform/graphics/paint/PropertyTreeState.h"
#include "platform/graphics/paint/ScrollPaintPropertyNode.h"
#include "platform/graphics/paint/TransformPaintPropertyNode.h"
#include "wtf/PassRefPtr.h"
......@@ -81,14 +81,14 @@ public:
// at the right painting step.
struct LocalBorderBoxProperties {
LayoutPoint paintOffset;
// TODO(pdr): Rename this GeometryPropertyTreeState because it does not contain scroll.
PropertyTreeState propertyTreeState;
GeometryPropertyTreeState geometryPropertyTreeState;
const ScrollPaintPropertyNode* scroll;
};
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
// any clips and scrolls caused by this object. This PropertyTreeState is suitable as the destination for paint invalidation.
void getContentsProperties(PropertyTreeState&) const;
// ContentsProperties is the GeometryPropertyTreeState that is the same as in
// localBorderBoxProperties, except that it is inside any clips and scrolls caused by this
// object. This GeometryPropertyTreeState is suitable as the destination for paint invalidation.
void getContentsProperties(GeometryPropertyTreeState&) const;
void clearPaintOffsetTranslation() { m_paintOffsetTranslation = nullptr; }
void clearTransform() { m_transform = nullptr; }
......
......@@ -46,8 +46,8 @@ static LayoutRect mapLocalRectToPaintInvalidationBacking(GeometryMapper& geometr
} else if (object == context.paintInvalidationContainer) {
result = LayoutRect(rect);
} else {
PropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
PropertyTreeState containerTreeState;
GeometryPropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
GeometryPropertyTreeState containerTreeState;
const ObjectPaintProperties* containerPaintProperties = context.paintInvalidationContainer->objectPaintProperties();
containerPaintProperties->getContentsProperties(containerTreeState);
......@@ -92,8 +92,8 @@ LayoutPoint PaintInvalidator::computeLocationFromPaintInvalidationBacking(const
point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
bool success = false;
PropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
PropertyTreeState containerTreeState;
GeometryPropertyTreeState currentTreeState(context.treeBuilderContext.current.transform, context.treeBuilderContext.current.clip, context.treeBuilderContext.currentEffect);
GeometryPropertyTreeState containerTreeState;
context.paintInvalidationContainer->objectPaintProperties()->getContentsProperties(containerTreeState);
point = m_geometryMapper.mapRectToDestinationSpace(FloatRect(point, FloatSize()), currentTreeState, containerTreeState, success).location();
DCHECK(success);
......
......@@ -333,10 +333,10 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon
ASSERT(objectPaintProperties && objectPaintProperties->localBorderBoxProperties());
PaintChunkProperties properties(context.getPaintController().currentPaintChunkProperties());
auto& localBorderBoxProperties = *objectPaintProperties->localBorderBoxProperties();
properties.transform = localBorderBoxProperties.propertyTreeState.transform;
properties.transform = localBorderBoxProperties.geometryPropertyTreeState.transform;
properties.scroll = localBorderBoxProperties.scroll;
properties.clip = localBorderBoxProperties.propertyTreeState.clip;
properties.effect = localBorderBoxProperties.propertyTreeState.effect;
properties.clip = localBorderBoxProperties.geometryPropertyTreeState.clip;
properties.effect = localBorderBoxProperties.geometryPropertyTreeState.effect;
properties.backfaceHidden = m_paintLayer.layoutObject()->hasHiddenBackface();
scopedPaintChunkProperties.emplace(context.getPaintController(), m_paintLayer, properties);
}
......
......@@ -296,15 +296,15 @@ void PaintPropertyTreeBuilder::updateLocalBorderBoxContext(const LayoutObject& o
std::unique_ptr<ObjectPaintProperties::LocalBorderBoxProperties> borderBoxContext =
wrapUnique(new ObjectPaintProperties::LocalBorderBoxProperties);
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;
if (!context.current.clip) {
DCHECK(object.isLayoutView());
DCHECK(toLayoutView(object).frameView()->frame().isMainFrame());
DCHECK(RuntimeEnabledFeatures::rootLayerScrollingEnabled());
borderBoxContext->propertyTreeState.clip = ClipPaintPropertyNode::create(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRect()));
context.current.clip = borderBoxContext->propertyTreeState.clip.get();
borderBoxContext->geometryPropertyTreeState.clip = ClipPaintPropertyNode::create(nullptr, context.current.transform, FloatRoundedRect(LayoutRect::infiniteIntRect()));
context.current.clip = borderBoxContext->geometryPropertyTreeState.clip.get();
}
object.getMutableForPainting().ensureObjectPaintProperties().setLocalBorderBoxProperties(std::move(borderBoxContext));
......
......@@ -51,7 +51,7 @@ public:
const ClipPaintPropertyNode* rootClip()
{
if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
return document().view()->layoutView()->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState.clip.get();
return document().view()->layoutView()->objectPaintProperties()->localBorderBoxProperties()->geometryPropertyTreeState.clip.get();
return document().view()->rootClip();
}
......@@ -118,11 +118,11 @@ do { \
LayoutRect source((sourceLayoutObject)->localOverflowRectForPaintInvalidation()); \
source.moveBy((sourceLayoutObject)->objectPaintProperties()->localBorderBoxProperties()->paintOffset); \
bool success = false; \
PropertyTreeState contentsProperties; \
GeometryPropertyTreeState contentsProperties; \
(ancestorLayoutObject)->objectPaintProperties()->getContentsProperties(contentsProperties); \
FloatRect actual = geometryMapper.mapToVisualRectInDestinationSpace( \
FloatRect(source), \
(sourceLayoutObject)->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState, \
(sourceLayoutObject)->objectPaintProperties()->localBorderBoxProperties()->geometryPropertyTreeState, \
contentsProperties, success); \
ASSERT_TRUE(success); \
EXPECT_EQ(expected, LayoutRect(actual)) << "GeometryMapper: expected: " << expected.toString() << ", actual: " << actual.toString(); \
......@@ -876,9 +876,9 @@ TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext)
LayoutObject* child = document().getElementById("child")->layoutObject();
const ObjectPaintProperties* childProperties = child->objectPaintProperties();
EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTreeState.effect);
EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->geometryPropertyTreeState.effect);
CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller, frameView->layoutView());
CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child, frameView->layoutView());
}
......@@ -902,9 +902,9 @@ TEST_P(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext)
LayoutObject& child = *document().getElementById("child")->layoutObject();
const ObjectPaintProperties* childProperties = child.objectPaintProperties();
EXPECT_EQ(frameContentClip(), childProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxProperties()->propertyTreeState.effect);
EXPECT_EQ(frameContentClip(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.effect);
if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, document().view()->layoutView());
}
......@@ -947,7 +947,7 @@ TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation)
const ObjectPaintProperties* targetProperties = target.objectPaintProperties();
EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties()->paintOffset);
EXPECT_EQ(frameScrollTranslation(), targetProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(frameScrollTranslation(), targetProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, document().view()->layoutView());
}
......@@ -990,9 +990,9 @@ TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant)
LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties();
EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()->propertyTreeState.transform->parent());
EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->localBorderBoxProperties()->propertyTreeState.transform->matrix());
EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform->parent());
EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform->matrix());
EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintOffset);
CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
// TODO(crbug.com/599939): CSS clip of fixed-position descendants is broken in mapToVisualRectInAncestorSpace().
......@@ -1038,8 +1038,8 @@ TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant)
LayoutObject* absolute = document().getElementById("absolute")->layoutObject();
const ObjectPaintProperties* absPosProperties = absolute->objectPaintProperties();
EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties()->propertyTreeState.transform->parent());
EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform->parent());
EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties()->paintOffset);
CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(),
// TODO(crbug.com/599939): CSS clip of fixed-position descendants is broken in mapToVisualRectInAncestorSpace().
......@@ -1099,9 +1099,9 @@ TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared)
LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties();
EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()->propertyTreeState.transform->parent());
EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->localBorderBoxProperties()->propertyTreeState.transform->matrix());
EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform->parent());
EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform->matrix());
EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintOffset);
CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
// TODO(crbug.com/599939): CSS clip of fixed-position descendants is broken in geometry mapping.
......@@ -1648,18 +1648,18 @@ TEST_P(PaintPropertyTreeBuilderTest, OverflowClipContentsProperties)
LayoutObject* child = document().getElementById("child")->layoutObject();
const ObjectPaintProperties* childProperties = child->objectPaintProperties();
EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
PropertyTreeState contentsProperties;
GeometryPropertyTreeState contentsProperties;
clipProperties->getContentsProperties(contentsProperties);
EXPECT_EQ(frameScrollTranslation(), contentsProperties.transform);
EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip);
EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(clipProperties->overflowClip(), childProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
EXPECT_EQ(clipProperties->overflowClip(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTreeState.effect);
EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->geometryPropertyTreeState.effect);
CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper);
}
......@@ -1684,16 +1684,16 @@ TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsProperties)
LayoutObject* child = document().getElementById("child")->layoutObject();
const ObjectPaintProperties* childProperties = child->objectPaintProperties();
EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
PropertyTreeState contentsProperties;
GeometryPropertyTreeState contentsProperties;
clipProperties->getContentsProperties(contentsProperties);
EXPECT_EQ(clipProperties->scrollTranslation(), contentsProperties.transform);
EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip);
EXPECT_EQ(clipProperties->scrollTranslation(), childProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(clipProperties->overflowClip(), childProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(clipProperties->scrollTranslation(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
EXPECT_EQ(clipProperties->overflowClip(), childProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper);
}
......@@ -1714,11 +1714,11 @@ TEST_P(PaintPropertyTreeBuilderTest, CssClipContentsProperties)
const ObjectPaintProperties* clipProperties = clipper->objectPaintProperties();
LayoutObject* child = document().getElementById("child")->layoutObject();
EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
// CSS clip on an element causes it to clip itself, not just descendants.
EXPECT_EQ(clipProperties->cssClip(), clipProperties->localBorderBoxProperties()->propertyTreeState.clip);
EXPECT_EQ(clipProperties->cssClip(), clipProperties->localBorderBoxProperties()->geometryPropertyTreeState.clip);
PropertyTreeState contentsProperties;
GeometryPropertyTreeState contentsProperties;
clipProperties->getContentsProperties(contentsProperties);
EXPECT_EQ(frameScrollTranslation(), contentsProperties.transform);
EXPECT_EQ(clipProperties->cssClip(), contentsProperties.clip);
......@@ -1747,9 +1747,9 @@ TEST_P(PaintPropertyTreeBuilderTest, SvgLocalToBorderBoxTransformContentsPropert
LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")->layoutObject();
const ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objectPaintProperties();
EXPECT_EQ(frameScrollTranslation(), svgWithViewBoxProperties->localBorderBoxProperties()->propertyTreeState.transform);
EXPECT_EQ(frameScrollTranslation(), svgWithViewBoxProperties->localBorderBoxProperties()->geometryPropertyTreeState.transform);
PropertyTreeState contentsProperties;
GeometryPropertyTreeState contentsProperties;
svgWithViewBoxProperties->getContentsProperties(contentsProperties);
EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), contentsProperties.transform);
}
......
......@@ -980,6 +980,7 @@ component("platform") {
"graphics/paint/ForeignLayerDisplayItem.h",
"graphics/paint/GeometryMapper.cpp",
"graphics/paint/GeometryMapper.h",
"graphics/paint/GeometryPropertyTreeState.h",
"graphics/paint/PaintArtifact.cpp",
"graphics/paint/PaintArtifact.h",
"graphics/paint/PaintArtifactToSkCanvas.cpp",
......@@ -990,7 +991,6 @@ component("platform") {
"graphics/paint/PaintChunker.h",
"graphics/paint/PaintController.cpp",
"graphics/paint/PaintController.h",
"graphics/paint/PropertyTreeState.h",
"graphics/paint/ScopedPaintChunkProperties.h",
"graphics/paint/ScrollDisplayItem.cpp",
"graphics/paint/ScrollDisplayItem.h",
......@@ -1676,11 +1676,11 @@ test("blink_platform_unittests") {
"graphics/paint/DisplayItemListTest.cpp",
"graphics/paint/DisplayItemTest.cpp",
"graphics/paint/GeometryMapperTest.cpp",
"graphics/paint/GeometryPropertyTreeStateTest.cpp",
"graphics/paint/PaintArtifactToSkCanvasTest.cpp",
"graphics/paint/PaintChunkTest.cpp",
"graphics/paint/PaintChunkerTest.cpp",
"graphics/paint/PaintControllerTest.cpp",
"graphics/paint/PropertyTreeStateTest.cpp",
"image-decoders/FastSharedBufferReaderTest.cpp",
"image-decoders/ImageDecoderTest.cpp",
"image-decoders/ImageDecoderTestHelpers.cpp",
......
......@@ -22,8 +22,8 @@
#include "platform/graphics/paint/DisplayItem.h"
#include "platform/graphics/paint/DrawingDisplayItem.h"
#include "platform/graphics/paint/ForeignLayerDisplayItem.h"
#include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/graphics/paint/PaintArtifact.h"
#include "platform/graphics/paint/PropertyTreeState.h"
#include "platform/graphics/paint/ScrollPaintPropertyNode.h"
#include "platform/graphics/paint/TransformPaintPropertyNode.h"
#include "public/platform/Platform.h"
......
......@@ -12,8 +12,8 @@
namespace blink {
FloatRect GeometryMapper::mapToVisualRectInDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success)
{
FloatRect result = localToVisualRectInAncestorSpace(rect, sourceState, destinationState, success);
......@@ -23,8 +23,8 @@ FloatRect GeometryMapper::mapToVisualRectInDestinationSpace(const FloatRect& rec
}
FloatRect GeometryMapper::mapRectToDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success)
{
FloatRect result = localToAncestorRect(rect, sourceState, destinationState, success);
......@@ -34,8 +34,8 @@ FloatRect GeometryMapper::mapRectToDestinationSpace(const FloatRect& rect,
}
FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success)
{
const TransformPaintPropertyNode* lcaTransform = propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(sourceState.transform.get(), destinationState.transform.get());
......@@ -43,7 +43,7 @@ FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect&
// 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.
PropertyTreeState lcaState = destinationState;
GeometryPropertyTreeState lcaState = destinationState;
lcaState.transform = lcaTransform;
const auto clipRect = localToAncestorClipRect(sourceState, lcaState, success);
......@@ -65,13 +65,13 @@ FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace(const FloatRect&
}
FloatRect GeometryMapper::slowMapRectToDestinationSpace(const FloatRect& rect,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success)
{
const TransformPaintPropertyNode* lcaTransform = propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(sourceState.transform.get(), destinationState.transform.get());
DCHECK(lcaTransform);
PropertyTreeState lcaState = sourceState;
GeometryPropertyTreeState lcaState = sourceState;
lcaState.transform = lcaTransform;
FloatRect result = localToAncestorRect(rect, sourceState, lcaState, success);
......@@ -89,8 +89,8 @@ FloatRect GeometryMapper::slowMapRectToDestinationSpace(const FloatRect& rect,
FloatRect GeometryMapper::localToVisualRectInAncestorSpace(
const FloatRect& rect,
const PropertyTreeState& localState,
const PropertyTreeState& ancestorState, bool& success)
const GeometryPropertyTreeState& localState,
const GeometryPropertyTreeState& ancestorState, bool& success)
{
const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success);
if (!success)
......@@ -107,8 +107,8 @@ FloatRect GeometryMapper::localToVisualRectInAncestorSpace(
FloatRect GeometryMapper::localToAncestorRect(
const FloatRect& rect,
const PropertyTreeState& localState,
const PropertyTreeState& ancestorState,
const GeometryPropertyTreeState& localState,
const GeometryPropertyTreeState& ancestorState,
bool& success)
{
const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success);
......@@ -119,8 +119,8 @@ FloatRect GeometryMapper::localToAncestorRect(
FloatRect GeometryMapper::ancestorToLocalRect(
const FloatRect& rect,
const PropertyTreeState& localState,
const PropertyTreeState& ancestorState, bool& success)
const GeometryPropertyTreeState& localState,
const GeometryPropertyTreeState& ancestorState, bool& success)
{
const auto& transformMatrix = localToAncestorMatrix(localState.transform.get(), ancestorState, success);
if (!success)
......@@ -136,7 +136,7 @@ FloatRect GeometryMapper::ancestorToLocalRect(
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);
if (addResult.isNewEntry)
......@@ -145,8 +145,8 @@ PrecomputedDataForAncestor& GeometryMapper::getPrecomputedDataForAncestor(const
}
FloatRect GeometryMapper::localToAncestorClipRect(
const PropertyTreeState& localState,
const PropertyTreeState& ancestorState,
const GeometryPropertyTreeState& localState,
const GeometryPropertyTreeState& ancestorState,
bool& success)
{
PrecomputedDataForAncestor& precomputedData = getPrecomputedDataForAncestor(ancestorState);
......@@ -196,7 +196,7 @@ FloatRect GeometryMapper::localToAncestorClipRect(
const TransformationMatrix& GeometryMapper::localToAncestorMatrix(
const TransformPaintPropertyNode* localTransformNode,
const PropertyTreeState& ancestorState, bool& success) {
const GeometryPropertyTreeState& ancestorState, bool& success) {
PrecomputedDataForAncestor& precomputedData = getPrecomputedDataForAncestor(ancestorState);
const TransformPaintPropertyNode* transformNode = localTransformNode;
......
......@@ -6,7 +6,7 @@
#define GeometryMapper_h
#include "platform/geometry/FloatRect.h"
#include "platform/graphics/paint/PropertyTreeState.h"
#include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/transforms/TransformationMatrix.h"
#include "wtf/HashMap.h"
......@@ -29,16 +29,16 @@ struct PrecomputedDataForAncestor {
}
};
// GeometryMapper is a helper class for fast computations of transformed and visual rects in different
// PropertyTreeStates. The design document has a number of details on use cases, algorithmic definitions,
// and running times.
// GeometryMapper is a helper class for fast computations of transformed and visual rects in
// different GeometryPropertyTreeStates. The design document has a number of details on use cases,
// algorithmic definitions, and running times.
//
// NOTE: a GeometryMapper object is only valid for property trees that do not change. If any mutation occurs,
// a new GeometryMapper object must be allocated corresponding to the new state.
// NOTE: A GeometryMapper object is only valid for property trees that do not change. If any
// mutation occurs, a new GeometryMapper object must be allocated corresponding to the new state.
//
// 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 {
public:
GeometryMapper() {}
......@@ -54,14 +54,14 @@ public:
// If that inverse transform is not invertible, sets |success| to false and returns the input rect. Otherwise, sets
// |success| to true.
FloatRect mapToVisualRectInDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success);
// Same as mapToVisualRectInDestinationSpace() except that *no* clip is applied.
FloatRect mapRectToDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success);
// Maps from a rect in |localTransformSpace| to its visual rect in |ancestorState|. This is computed
......@@ -75,8 +75,8 @@ public:
// to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise,
// sets |success| to true.
FloatRect localToVisualRectInAncestorSpace(const FloatRect&,
const PropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState,
const GeometryPropertyTreeState& localTransformState,
const GeometryPropertyTreeState& ancestorState,
bool& success);
// Maps from a rect in |localTransformSpace| to its transformed rect in |ancestorSpace|. This is computed
......@@ -91,8 +91,8 @@ public:
// to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise,
// sets |success| to true.
FloatRect localToAncestorRect(const FloatRect&,
const PropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState,
const GeometryPropertyTreeState& localTransformState,
const GeometryPropertyTreeState& ancestorState,
bool& success);
// Maps from a rect in |ancestorSpace| to its transformed rect in |localTransformSpace|. This is computed
......@@ -103,39 +103,39 @@ public:
// to or a descendant of that in |ancestorState|, returns the passed-in rect and sets |success| to false. Otherwise,
// sets |success| to true.
FloatRect ancestorToLocalRect(const FloatRect&,
const PropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState,
const GeometryPropertyTreeState& localTransformState,
const GeometryPropertyTreeState& ancestorState,
bool& success);
private:
// Used by mapToVisualRectInDestinationSpace() after fast mapping (assuming destination is an ancestor of source) failed.
FloatRect slowMapToVisualRectInDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success);
// Used by mapRectToDestinationSpace() after fast mapping (assuming destination is an ancestor of source) failed.
FloatRect slowMapRectToDestinationSpace(const FloatRect&,
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
const GeometryPropertyTreeState& sourceState,
const GeometryPropertyTreeState& destinationState,
bool& success);
// Returns the matrix used in |LocalToAncestorRect|. Sets |success| to failse iff |localTransformNode| is not
// equal to or a descendant of |ancestorState.transform|.
const TransformationMatrix& localToAncestorMatrix(
const TransformPaintPropertyNode* localTransformNode,
const PropertyTreeState& ancestorState,
const GeometryPropertyTreeState& ancestorState,
bool& success);
// Returns the "clip visual rect" between |localTransformState| and |ancestorState|. See above for the definition
// of "clip visual rect".
FloatRect localToAncestorClipRect(
const PropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState,
const GeometryPropertyTreeState& localTransformState,
const GeometryPropertyTreeState& ancestorState,
bool& success);
// 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.
PassRefPtr<TransformPaintPropertyNode> leastCommonAncestor(PassRefPtr<TransformPaintPropertyNode>, PassRefPtr<TransformPaintPropertyNode>);
......
......@@ -21,15 +21,15 @@ public:
std::unique_ptr<GeometryMapper> geometryMapper;
PropertyTreeState rootPropertyTreeState()
GeometryPropertyTreeState rootGeometryPropertyTreeState()
{
PropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), rootEffectNode.get());
GeometryPropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), rootEffectNode.get());
return state;
}
PrecomputedDataForAncestor& getPrecomputedDataForAncestor(const PropertyTreeState& propertyTreeState)
PrecomputedDataForAncestor& getPrecomputedDataForAncestor(const GeometryPropertyTreeState& geometryPropertyTreeState)
{
return geometryMapper->getPrecomputedDataForAncestor(propertyTreeState);
return geometryMapper->getPrecomputedDataForAncestor(geometryPropertyTreeState);
}
private:
......@@ -58,58 +58,58 @@ do { \
EXPECT_TRUE(GeometryTest::ApproximatelyEqual(expected.height(), actualRect.height(), kTestEpsilon)) << "actual: " << actualRect.height() << ", expected: " << expected.height(); \
} while (false)
#define CHECK_MAPPINGS(inputRect, expectedVisualRect, expectedTransformedRect, expectedTransformToAncestor, expectedClipInAncestorSpace, localPropertyTreeState, ancestorPropertyTreeState) \
#define CHECK_MAPPINGS(inputRect, expectedVisualRect, expectedTransformedRect, expectedTransformToAncestor, expectedClipInAncestorSpace, localGeometryPropertyTreeState, ancestorGeometryPropertyTreeState) \
do { \
bool success = false; \
EXPECT_RECT_EQ(expectedVisualRect, \
geometryMapper->localToVisualRectInAncestorSpace(inputRect, localPropertyTreeState, ancestorPropertyTreeState, success)); \
geometryMapper->localToVisualRectInAncestorSpace(inputRect, localGeometryPropertyTreeState, ancestorGeometryPropertyTreeState, success)); \
EXPECT_TRUE(success); \
EXPECT_RECT_EQ(expectedVisualRect, \
geometryMapper->mapToVisualRectInDestinationSpace(inputRect, localPropertyTreeState, ancestorPropertyTreeState, success)); \
geometryMapper->mapToVisualRectInDestinationSpace(inputRect, localGeometryPropertyTreeState, ancestorGeometryPropertyTreeState, success)); \
EXPECT_TRUE(success); \
EXPECT_RECT_EQ(expectedTransformedRect, \
geometryMapper->localToAncestorRect(inputRect, localPropertyTreeState, ancestorPropertyTreeState, success)); \
geometryMapper->localToAncestorRect(inputRect, localGeometryPropertyTreeState, ancestorGeometryPropertyTreeState, success)); \
EXPECT_RECT_EQ(expectedTransformedRect, \
geometryMapper->mapRectToDestinationSpace(inputRect, localPropertyTreeState, ancestorPropertyTreeState, success)); \
geometryMapper->mapRectToDestinationSpace(inputRect, localGeometryPropertyTreeState, ancestorGeometryPropertyTreeState, success)); \
EXPECT_TRUE(success); \
EXPECT_EQ(expectedTransformToAncestor, getPrecomputedDataForAncestor(ancestorPropertyTreeState).toAncestorTransforms.get(localPropertyTreeState.transform.get())); \
EXPECT_EQ(expectedClipInAncestorSpace, getPrecomputedDataForAncestor(ancestorPropertyTreeState).toAncestorClipRects.get(localPropertyTreeState.clip.get())); \
EXPECT_EQ(expectedTransformToAncestor, getPrecomputedDataForAncestor(ancestorGeometryPropertyTreeState).toAncestorTransforms.get(localGeometryPropertyTreeState.transform.get())); \
EXPECT_EQ(expectedClipInAncestorSpace, getPrecomputedDataForAncestor(ancestorGeometryPropertyTreeState).toAncestorClipRects.get(localGeometryPropertyTreeState.clip.get())); \
} while (false)
TEST_F(GeometryMapperTest, Root)
{
FloatRect input(0, 0, 100, 100);
CHECK_MAPPINGS(input, input, input, rootTransformNode->matrix(), rootClipNode->clipRect().rect(), rootPropertyTreeState(), rootPropertyTreeState());
CHECK_MAPPINGS(input, input, input, rootTransformNode->matrix(), rootClipNode->clipRect().rect(), rootGeometryPropertyTreeState(), rootGeometryPropertyTreeState());
}
TEST_F(GeometryMapperTest, IdentityTransform)
{
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, TransformationMatrix(), FloatPoint3D());
PropertyTreeState localState = rootPropertyTreeState();
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, TransformationMatrix(), FloatPoint3D());
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.transform = transform.get();
FloatRect input(0, 0, 100, 100);
CHECK_MAPPINGS(input, input, input, transform->matrix(), rootClipNode->clipRect().rect(), localState, rootPropertyTreeState());
CHECK_MAPPINGS(input, input, input, transform->matrix(), rootClipNode->clipRect().rect(), localState, rootGeometryPropertyTreeState());
}
TEST_F(GeometryMapperTest, TranslationTransform)
{
TransformationMatrix transformMatrix;
transformMatrix.translate(20, 10);
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, transformMatrix, FloatPoint3D());
PropertyTreeState localState = rootPropertyTreeState();
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, transformMatrix, FloatPoint3D());
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.transform = transform.get();
FloatRect input(0, 0, 100, 100);
FloatRect output = transformMatrix.mapRect(input);
CHECK_MAPPINGS(input, output, output, transform->matrix(), rootClipNode->clipRect().rect(), localState, rootPropertyTreeState());
CHECK_MAPPINGS(input, output, output, transform->matrix(), rootClipNode->clipRect().rect(), localState, rootGeometryPropertyTreeState());
bool success = false;
EXPECT_RECT_EQ(input,
geometryMapper->ancestorToLocalRect(output, localState, rootPropertyTreeState(), success));
geometryMapper->ancestorToLocalRect(output, localState, rootGeometryPropertyTreeState(), success));
EXPECT_TRUE(success);
}
......@@ -118,14 +118,14 @@ TEST_F(GeometryMapperTest, RotationAndScaleTransform)
TransformationMatrix transformMatrix;
transformMatrix.rotate(45);
transformMatrix.scale(2);
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, transformMatrix, FloatPoint3D(0, 0, 0));
PropertyTreeState localState = rootPropertyTreeState();
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, transformMatrix, FloatPoint3D(0, 0, 0));
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.transform = transform.get();
FloatRect input(0, 0, 100, 100);
FloatRect output = transformMatrix.mapRect(input);
CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRect().rect(), localState, rootPropertyTreeState());
CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRect().rect(), localState, rootGeometryPropertyTreeState());
}
TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin)
......@@ -133,51 +133,51 @@ TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin)
TransformationMatrix transformMatrix;
transformMatrix.rotate(45);
transformMatrix.scale(2);
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, transformMatrix, FloatPoint3D(50, 50, 0));
PropertyTreeState localState = rootPropertyTreeState();
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, transformMatrix, FloatPoint3D(50, 50, 0));
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.transform = transform.get();
FloatRect input(0, 0, 100, 100);
transformMatrix.applyTransformOrigin(50, 50, 0);
FloatRect output = transformMatrix.mapRect(input);
CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRect().rect(), localState, rootPropertyTreeState());
CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRect().rect(), localState, rootGeometryPropertyTreeState());
}
TEST_F(GeometryMapperTest, NestedTransforms)
{
TransformationMatrix rotateTransform;
rotateTransform.rotate(45);
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform, FloatPoint3D());
TransformationMatrix scaleTransform;
scaleTransform.scale(2);
RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(transform1, scaleTransform, FloatPoint3D());
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.transform = transform2.get();
FloatRect input(0, 0, 100, 100);
TransformationMatrix final = rotateTransform * scaleTransform;
FloatRect output = final.mapRect(input);
CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), localState, rootPropertyTreeState());
CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), localState, rootGeometryPropertyTreeState());
// Check the cached matrix for the intermediate transform.
EXPECT_EQ(rotateTransform, getPrecomputedDataForAncestor(rootPropertyTreeState()).toAncestorTransforms.get(transform1.get()));
EXPECT_EQ(rotateTransform, getPrecomputedDataForAncestor(rootGeometryPropertyTreeState()).toAncestorTransforms.get(transform1.get()));
}
TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation)
{
TransformationMatrix scaleTransform;
scaleTransform.scale(2);
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, scaleTransform, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, scaleTransform, FloatPoint3D());
TransformationMatrix translateTransform;
translateTransform.translate(100, 0);
RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(transform1, translateTransform, FloatPoint3D());
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.transform = transform2.get();
FloatRect input(0, 0, 100, 100);
......@@ -185,10 +185,10 @@ TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation)
TransformationMatrix final = scaleTransform * translateTransform;
FloatRect output = final.mapRect(input);
CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), localState, rootPropertyTreeState());
CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), localState, rootGeometryPropertyTreeState());
// Check the cached matrix for the intermediate transform.
EXPECT_EQ(scaleTransform, getPrecomputedDataForAncestor(rootPropertyTreeState()).toAncestorTransforms.get(transform1.get()));
EXPECT_EQ(scaleTransform, getPrecomputedDataForAncestor(rootGeometryPropertyTreeState()).toAncestorTransforms.get(transform1.get()));
}
......@@ -196,16 +196,16 @@ TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination)
{
TransformationMatrix rotateTransform;
rotateTransform.rotate(45);
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform, FloatPoint3D());
TransformationMatrix scaleTransform;
scaleTransform.scale(2);
RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(transform1, scaleTransform, FloatPoint3D());
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.transform = transform2.get();
PropertyTreeState intermediateState = rootPropertyTreeState();
GeometryPropertyTreeState intermediateState = rootGeometryPropertyTreeState();
intermediateState.transform = transform1.get();
FloatRect input(0, 0, 100, 100);
......@@ -218,7 +218,7 @@ TEST_F(GeometryMapperTest, SimpleClip)
{
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootClipNode, rootTransformNode, FloatRoundedRect(10, 10, 50, 50));
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.clip = clip.get();
FloatRect input(0, 0, 100, 100);
......@@ -230,18 +230,18 @@ TEST_F(GeometryMapperTest, SimpleClip)
input, // Transformed rect (not clipped).
rootTransformNode->matrix(), // Transform matrix to ancestor space
clip->clipRect().rect(), // Clip rect in ancestor space
localState, rootPropertyTreeState());
localState, rootGeometryPropertyTreeState());
}
TEST_F(GeometryMapperTest, ClipBeforeTransform)
{
TransformationMatrix rotateTransform;
rotateTransform.rotate(45);
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootClipNode, transform.get(), FloatRoundedRect(10, 10, 50, 50));
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.clip = clip.get();
localState.transform = transform.get();
......@@ -256,18 +256,18 @@ TEST_F(GeometryMapperTest, ClipBeforeTransform)
rotateTransform.mapRect(input), // Transformed rect (not clipped).
rotateTransform, // Transform matrix to ancestor space
rotateTransform.mapRect(clip->clipRect().rect()), // Clip rect in ancestor space
localState, rootPropertyTreeState());
localState, rootGeometryPropertyTreeState());
}
TEST_F(GeometryMapperTest, ClipAfterTransform)
{
TransformationMatrix rotateTransform;
rotateTransform.rotate(45);
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootClipNode, rootTransformNode.get(), FloatRoundedRect(10, 10, 200, 200));
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.clip = clip.get();
localState.transform = transform.get();
......@@ -282,7 +282,7 @@ TEST_F(GeometryMapperTest, ClipAfterTransform)
rotateTransform.mapRect(input), // Transformed rect (not clipped)
rotateTransform, // Transform matrix to ancestor space
clip->clipRect().rect(), // Clip rect in ancestor space
localState, rootPropertyTreeState());
localState, rootGeometryPropertyTreeState());
}
TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween)
......@@ -291,14 +291,14 @@ TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween)
TransformationMatrix rotateTransform;
rotateTransform.rotate(45);
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform, FloatPoint3D());
RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(clip1, transform.get(), FloatRoundedRect(10, 10, 200, 200));
FloatRect input(0, 0, 100, 100);
{
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.clip = clip1.get();
localState.transform = transform.get();
......@@ -312,11 +312,11 @@ TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween)
rotateTransform.mapRect(input), // Transformed rect (not clipped)
rotateTransform, // Transform matrix to ancestor space
clip1->clipRect().rect(), // Clip rect in ancestor space
localState, rootPropertyTreeState());
localState, rootGeometryPropertyTreeState());
}
{
PropertyTreeState localState = rootPropertyTreeState();
GeometryPropertyTreeState localState = rootGeometryPropertyTreeState();
localState.clip = clip2.get();
localState.transform = transform.get();
......@@ -338,7 +338,7 @@ TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween)
rotateTransform.mapRect(input), // Transformed rect (not clipped)
rotateTransform, // Transform matrix to ancestor space
mappedClip, // Clip rect in ancestor space
localState, rootPropertyTreeState());
localState, rootGeometryPropertyTreeState());
}
}
......@@ -347,15 +347,15 @@ TEST_F(GeometryMapperTest, SiblingTransforms)
// These transforms are siblings. Thus mapping from one to the other requires going through the root.
TransformationMatrix rotateTransform1;
rotateTransform1.rotate(45);
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform1, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform1, FloatPoint3D());
TransformationMatrix rotateTransform2;
rotateTransform2.rotate(-45);
RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform2, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform2, FloatPoint3D());
PropertyTreeState transform1State = rootPropertyTreeState();
GeometryPropertyTreeState transform1State = rootGeometryPropertyTreeState();
transform1State.transform = transform1;
PropertyTreeState transform2State = rootPropertyTreeState();
GeometryPropertyTreeState transform2State = rootGeometryPropertyTreeState();
transform2State.transform = transform2;
bool success;
......@@ -395,17 +395,17 @@ TEST_F(GeometryMapperTest, SiblingTransformsWithClip)
// These transforms are siblings. Thus mapping from one to the other requires going through the root.
TransformationMatrix rotateTransform1;
rotateTransform1.rotate(45);
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform1, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform1, FloatPoint3D());
TransformationMatrix rotateTransform2;
rotateTransform2.rotate(-45);
RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, rotateTransform2, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, rotateTransform2, FloatPoint3D());
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootPropertyTreeState().clip, transform2.get(), FloatRoundedRect(10, 10, 70, 70));
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootGeometryPropertyTreeState().clip, transform2.get(), FloatRoundedRect(10, 10, 70, 70));
PropertyTreeState transform1State = rootPropertyTreeState();
GeometryPropertyTreeState transform1State = rootGeometryPropertyTreeState();
transform1State.transform = transform1;
PropertyTreeState transform2AndClipState = rootPropertyTreeState();
GeometryPropertyTreeState transform2AndClipState = rootGeometryPropertyTreeState();
transform2AndClipState.transform = transform2;
transform2AndClipState.clip = clip;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PropertyTreeState_h
#define PropertyTreeState_h
#ifndef GeometryPropertyTreeState_h
#define GeometryPropertyTreeState_h
#include "platform/graphics/paint/ClipPaintPropertyNode.h"
#include "platform/graphics/paint/EffectPaintPropertyNode.h"
......@@ -14,14 +14,12 @@
namespace blink {
// Represents the combination of transform, clip and effect nodes for a particular coordinate space.
// See GeometryMapper.
// Scroll nodes (ScrollPaintPropertyNode) are not needed for mapping geometry and have been left off
// of this structure.
// TODO(pdr): Rename this GeometryPropertyTreeState.
struct PropertyTreeState {
PropertyTreeState() : PropertyTreeState(nullptr, nullptr, nullptr) {}
// See GeometryMapper. Scroll nodes (ScrollPaintPropertyNode) are not needed for mapping geometry
// and have been left off of this structure.
struct GeometryPropertyTreeState {
GeometryPropertyTreeState() : GeometryPropertyTreeState(nullptr, nullptr, nullptr) {}
PropertyTreeState(
GeometryPropertyTreeState(
const TransformPaintPropertyNode* transform,
const ClipPaintPropertyNode* clip,
const EffectPaintPropertyNode* effect)
......@@ -72,4 +70,4 @@ const A* propertyTreeNearestCommonAncestor(const A* a, const A* b)
} // namespace blink
#endif // PropertyTreeState_h
#endif // GeometryPropertyTreeState_h
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "platform/graphics/paint/PropertyTreeState.h"
#include "platform/graphics/paint/GeometryPropertyTreeState.h"
#include "platform/geometry/LayoutRect.h"
#include "platform/graphics/paint/ClipPaintPropertyNode.h"
......@@ -12,15 +12,15 @@
namespace blink {
class PropertyTreeStateTest : public ::testing::Test {
class GeometryPropertyTreeStateTest : public ::testing::Test {
public:
RefPtr<TransformPaintPropertyNode> rootTransformNode;
RefPtr<ClipPaintPropertyNode> rootClipNode;
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;
}
......@@ -33,26 +33,26 @@ private:
}
};
TEST_F(PropertyTreeStateTest, LeastCommonAncestor)
TEST_F(GeometryPropertyTreeStateTest, LeastCommonAncestor)
{
TransformationMatrix matrix;
RefPtr<TransformPaintPropertyNode> child1 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> child2 = TransformPaintPropertyNode::create(rootPropertyTreeState().transform, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> child1 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> child2 = TransformPaintPropertyNode::create(rootGeometryPropertyTreeState().transform, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> childOfChild1 = TransformPaintPropertyNode::create(child1, matrix, FloatPoint3D());
RefPtr<TransformPaintPropertyNode> childOfChild2 = TransformPaintPropertyNode::create(child2, matrix, FloatPoint3D());
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), childOfChild2.get()));
EXPECT_EQ(rootPropertyTreeState().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(), childOfChild2.get()));
EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), child2.get()));
EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), rootGeometryPropertyTreeState().transform.get()));
EXPECT_EQ(child1, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild1.get(), child1.get()));
EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), childOfChild1.get()));
EXPECT_EQ(rootPropertyTreeState().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(), childOfChild1.get()));
EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), child1.get()));
EXPECT_EQ(rootGeometryPropertyTreeState().transform, propertyTreeNearestCommonAncestor<TransformPaintPropertyNode>(childOfChild2.get(), rootGeometryPropertyTreeState().transform.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
......@@ -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
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
rect, multiplied by the transforms between the display item's `PropertyTreeState`
and the ancestors, then flattened into 2D.
The transformed rect of a display item in an ancestor `GeometryPropertyTreeState`
is that rect, multiplied by the transforms between the display item's
`GeometryPropertyTreeState` and the ancestors, then flattened into 2D.
The visual rect of a display item in an ancestor `PropertyTreeState` is the intersection
of all of the intermediate clips (transformed in to the ancestor state), with
the display item's transformed rect.
The visual rect of a display item in an ancestor `GeometryPropertyTreeState` is
the intersection of all of the intermediate clips (transformed in to the
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