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

Rename, simplify and change parameter type of some GeometryMapper methods

Rename
mapRectToDestinationSpace to sourceToDestinationRect
mapToVisualRectInDestinationSpace to sourceToDestinationVisualRect
localToVisualRectInAncestorSpace to localToAncestorVisualRect
so that all mapping methods are in the form
  (local|source|ancestor)To(local|source|ancestor)(Rect|VisualRect|Matrix|ClipRect)

Changed parameters to localToAncestorMatrix and getPrecomputedDataForAncestor()
from const PropertyTreeState& to const TransformPaintPropertyNode*
because some later changes will require the new form (
TransformationPaintPropertyNode without a state).

Simplified localToAncestorMatrix and localToAncestorClipRect because
we have early returns when the local node is the same as the ancestor
node and we no longer need to handle that condition in the loop.

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2623823002
Cr-Commit-Position: refs/heads/master@{#443436}
parent e7225c31
...@@ -110,7 +110,7 @@ static LayoutRect mapLocalRectToPaintInvalidationBacking( ...@@ -110,7 +110,7 @@ static LayoutRect mapLocalRectToPaintInvalidationBacking(
containerPaintProperties->contentsProperties(); containerPaintProperties->contentsProperties();
bool success = false; bool success = false;
result = LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( result = LayoutRect(geometryMapper.sourceToDestinationVisualRect(
rect, currentTreeState, containerContentsProperties, success)); rect, currentTreeState, containerContentsProperties, success));
DCHECK(success); DCHECK(success);
...@@ -166,11 +166,6 @@ LayoutPoint PaintInvalidator::computeLocationInBacking( ...@@ -166,11 +166,6 @@ LayoutPoint PaintInvalidator::computeLocationInBacking(
if (object != context.paintInvalidationContainer) { if (object != context.paintInvalidationContainer) {
point.moveBy(FloatPoint(object.paintOffset())); point.moveBy(FloatPoint(object.paintOffset()));
PropertyTreeState currentTreeState(
context.treeBuilderContext.current.transform,
context.treeBuilderContext.current.clip,
context.treeBuilderContext.currentEffect,
context.treeBuilderContext.current.scroll);
const auto* containerPaintProperties = const auto* containerPaintProperties =
context.paintInvalidationContainer->paintProperties(); context.paintInvalidationContainer->paintProperties();
auto containerContentsProperties = auto containerContentsProperties =
...@@ -178,9 +173,10 @@ LayoutPoint PaintInvalidator::computeLocationInBacking( ...@@ -178,9 +173,10 @@ LayoutPoint PaintInvalidator::computeLocationInBacking(
bool success = false; bool success = false;
point = m_geometryMapper point = m_geometryMapper
.mapRectToDestinationSpace(FloatRect(point, FloatSize()), .sourceToDestinationRect(
currentTreeState, FloatRect(point, FloatSize()),
containerContentsProperties, success) context.treeBuilderContext.current.transform,
containerContentsProperties.transform(), success)
.location(); .location();
DCHECK(success); DCHECK(success);
......
...@@ -216,15 +216,18 @@ LayoutRect PaintLayerClipper::localClipRect( ...@@ -216,15 +216,18 @@ LayoutRect PaintLayerClipper::localClipRect(
// The rect now needs to be transformed to the local space of this // The rect now needs to be transformed to the local space of this
// PaintLayer. // PaintLayer.
bool success = false; bool success = false;
FloatRect clippedRectInLocalSpace = const auto* clipRootLayerTransform = clippingRootLayer->layoutObject()
m_geometryMapper->mapRectToDestinationSpace(
FloatRect(clipRect.rect()), *clippingRootLayer->layoutObject()
->paintProperties() ->paintProperties()
->localBorderBoxProperties(), ->localBorderBoxProperties()
*m_layer.layoutObject() ->transform();
->paintProperties() const auto* layerTransform = m_layer.layoutObject()
->localBorderBoxProperties(), ->paintProperties()
success); ->localBorderBoxProperties()
->transform();
FloatRect clippedRectInLocalSpace =
m_geometryMapper->sourceToDestinationRect(FloatRect(clipRect.rect()),
clipRootLayerTransform,
layerTransform, success);
DCHECK(success); DCHECK(success);
return LayoutRect(clippedRectInLocalSpace); return LayoutRect(clippedRectInLocalSpace);
...@@ -259,16 +262,19 @@ void PaintLayerClipper::mapLocalToRootWithGeometryMapper( ...@@ -259,16 +262,19 @@ void PaintLayerClipper::mapLocalToRootWithGeometryMapper(
DCHECK(m_geometryMapper); DCHECK(m_geometryMapper);
bool success; bool success;
const auto* layerBorderBoxProperties = const auto* layerTransform = m_layer.layoutObject()
m_layer.layoutObject()->paintProperties()->localBorderBoxProperties(); ->paintProperties()
->localBorderBoxProperties()
->transform();
const auto* rootTransform = context.rootLayer->layoutObject()
->paintProperties()
->localBorderBoxProperties()
->transform();
FloatRect localRect(layoutRect); FloatRect localRect(layoutRect);
localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset())); localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset()));
layoutRect = LayoutRect(m_geometryMapper->sourceToDestinationRect(
layoutRect = LayoutRect(m_geometryMapper->mapRectToDestinationSpace( localRect, layerTransform, rootTransform, success));
localRect, *layerBorderBoxProperties, *context.rootLayer->layoutObject()
->paintProperties()
->localBorderBoxProperties(),
success));
DCHECK(success); DCHECK(success);
} }
...@@ -452,7 +458,7 @@ ClipRect PaintLayerClipper::clipRectWithGeometryMapper( ...@@ -452,7 +458,7 @@ ClipRect PaintLayerClipper::clipRectWithGeometryMapper(
destinationPropertyTreeState.setClip(ancestorProperties->overflowClip()); destinationPropertyTreeState.setClip(ancestorProperties->overflowClip());
} }
FloatRect clippedRectInRootLayerSpace = FloatRect clippedRectInRootLayerSpace =
m_geometryMapper->mapToVisualRectInDestinationSpace( m_geometryMapper->sourceToDestinationVisualRect(
FloatRect(source), propertyTreeState, destinationPropertyTreeState, FloatRect(source), propertyTreeState, destinationPropertyTreeState,
success); success);
DCHECK(success); DCHECK(success);
......
...@@ -80,7 +80,7 @@ void PaintPropertyTreeBuilderTest::TearDown() { ...@@ -80,7 +80,7 @@ void PaintPropertyTreeBuilderTest::TearDown() {
auto contentsProperties = \ auto contentsProperties = \
(ancestorLayoutObject)->paintProperties()->contentsProperties(); \ (ancestorLayoutObject)->paintProperties()->contentsProperties(); \
LayoutRect actual = \ LayoutRect actual = \
LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( \ LayoutRect(geometryMapper.sourceToDestinationVisualRect( \
FloatRect(source), *(sourceLayoutObject) \ FloatRect(source), *(sourceLayoutObject) \
->paintProperties() \ ->paintProperties() \
->localBorderBoxProperties(), \ ->localBorderBoxProperties(), \
......
...@@ -286,8 +286,8 @@ static void applyClipsBetweenStates(const PropertyTreeState& localState, ...@@ -286,8 +286,8 @@ static void applyClipsBetweenStates(const PropertyTreeState& localState,
if (transformNode != ancestorState.transform()) { if (transformNode != ancestorState.transform()) {
bool success = false; bool success = false;
const TransformationMatrix& localToAncestorMatrix = const TransformationMatrix& localToAncestorMatrix =
geometryMapper.localToAncestorMatrix(transformNode, ancestorState, geometryMapper.localToAncestorMatrix(
success); transformNode, ancestorState.transform(), success);
DCHECK(success); DCHECK(success);
// Clips are only in descendant spaces that are transformed by one // Clips are only in descendant spaces that are transformed by one
// or more scrolls. // or more scrolls.
...@@ -373,8 +373,8 @@ static void recordPairedBeginDisplayItems( ...@@ -373,8 +373,8 @@ static void recordPairedBeginDisplayItems(
const TransformPaintPropertyNode* transformNode = const TransformPaintPropertyNode* transformNode =
pairedState->effect()->localTransformSpace(); pairedState->effect()->localTransformSpace();
const TransformationMatrix& localToAncestorMatrix = const TransformationMatrix& localToAncestorMatrix =
geometryMapper.localToAncestorMatrix(transformNode, *pairedState, geometryMapper.localToAncestorMatrix(
success); transformNode, pairedState->transform(), success);
DCHECK(success); DCHECK(success);
// Effects are only in descendant spaces that are transformed by one // Effects are only in descendant spaces that are transformed by one
// or more scrolls. // or more scrolls.
...@@ -1084,14 +1084,14 @@ bool PaintArtifactCompositor::mightOverlap( ...@@ -1084,14 +1084,14 @@ bool PaintArtifactCompositor::mightOverlap(
bool success = false; bool success = false;
FloatRect paintChunkScreenVisualRect = FloatRect paintChunkScreenVisualRect =
geometryMapper.localToVisualRectInAncestorSpace( geometryMapper.localToAncestorVisualRect(
paintChunk.bounds, paintChunk.properties.propertyTreeState, paintChunk.bounds, paintChunk.properties.propertyTreeState,
rootPropertyTreeState, success); rootPropertyTreeState, success);
DCHECK(success); DCHECK(success);
success = false; success = false;
FloatRect pendingLayerScreenVisualRect = FloatRect pendingLayerScreenVisualRect =
geometryMapper.localToVisualRectInAncestorSpace( geometryMapper.localToAncestorVisualRect(
candidatePendingLayer.bounds, candidatePendingLayer.propertyTreeState, candidatePendingLayer.bounds, candidatePendingLayer.propertyTreeState,
rootPropertyTreeState, success); rootPropertyTreeState, success);
DCHECK(success); DCHECK(success);
...@@ -1117,8 +1117,8 @@ void PaintArtifactCompositor::PendingLayer::add( ...@@ -1117,8 +1117,8 @@ void PaintArtifactCompositor::PendingLayer::add(
if (geometryMapper) { if (geometryMapper) {
bool success = false; bool success = false;
mappedBounds = geometryMapper->localToAncestorRect( mappedBounds = geometryMapper->localToAncestorRect(
mappedBounds, paintChunk.properties.propertyTreeState, mappedBounds, paintChunk.properties.propertyTreeState.transform(),
propertyTreeState, success); propertyTreeState.transform(), success);
DCHECK(success); DCHECK(success);
} }
bounds.unite(mappedBounds); bounds.unite(mappedBounds);
......
...@@ -45,14 +45,14 @@ struct PrecomputedDataForAncestor { ...@@ -45,14 +45,14 @@ struct PrecomputedDataForAncestor {
class PLATFORM_EXPORT GeometryMapper { class PLATFORM_EXPORT GeometryMapper {
public: public:
GeometryMapper() {} GeometryMapper() {}
// The runtime of m calls among localToVisualRectInAncestorSpace, // The runtime of m calls among localToAncestorVisualRect, localToAncestorRect
// localToAncestorRect or ancestorToLocalRect with the same |ancestorState| // or ancestorToLocalRect with the same |ancestorState| parameter is
// parameter is guaranteed to be O(n + m), where n is the number of transform // guaranteed to be O(n + m), where n is the number of transform and clip
// and clip nodes in their respective property trees. // nodes in their respective property trees.
// If the clips and transforms of |sourceState| are equal to or descendants of // If the clips and transforms of |sourceState| are equal to or descendants of
// those of |destinationState|, returns the same value as // those of |destinationState|, returns the same value as
// localToVisualRectInAncestorSpace. Otherwise, maps the input rect to the // localToAncestorVisualRect. Otherwise, maps the input rect to the
// transform state which is the least common ancestor of // transform state which is the least common ancestor of
// |sourceState.transform| and |destinationState.transform|, then multiplies // |sourceState.transform| and |destinationState.transform|, then multiplies
// it by the the inverse transform mapping from the least common ancestor to // it by the the inverse transform mapping from the least common ancestor to
...@@ -60,18 +60,19 @@ class PLATFORM_EXPORT GeometryMapper { ...@@ -60,18 +60,19 @@ class PLATFORM_EXPORT GeometryMapper {
// //
// Sets |success| to whether that inverse transform is invertible. If it is // Sets |success| to whether that inverse transform is invertible. If it is
// not, returns the input rect. // not, returns the input rect.
FloatRect mapToVisualRectInDestinationSpace( FloatRect sourceToDestinationVisualRect(
const FloatRect&, const FloatRect&,
const PropertyTreeState& sourceState, const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const PropertyTreeState& destinationState,
bool& success); bool& success);
// Same as mapToVisualRectInDestinationSpace() except that *no* clip is // Same as sourceToDestinationVisualRect() except that only transforms are
// applied. // applied.
FloatRect mapRectToDestinationSpace(const FloatRect&, FloatRect sourceToDestinationRect(
const PropertyTreeState& sourceState, const FloatRect&,
const PropertyTreeState& destinationState, const TransformPaintPropertyNode* sourceTransformNode,
bool& success); const TransformPaintPropertyNode* destinationTransformNode,
bool& success);
// Maps from a rect in |localTransformSpace| to its visual rect in // Maps from a rect in |localTransformSpace| to its visual rect in
// |ancestorState|. This is computed by multiplying the rect by its combined // |ancestorState|. This is computed by multiplying the rect by its combined
...@@ -85,44 +86,46 @@ class PLATFORM_EXPORT GeometryMapper { ...@@ -85,44 +86,46 @@ class PLATFORM_EXPORT GeometryMapper {
// If any of the paint property tree nodes in |localTransformState| are not // If any of the paint property tree nodes in |localTransformState| are not
// equal to or a descendant of that in |ancestorState|, returns the passed-in // equal to or a descendant of that in |ancestorState|, returns the passed-in
// rect and sets |success| to false. Otherwise, sets |success| to true. // rect and sets |success| to false. Otherwise, sets |success| to true.
FloatRect localToVisualRectInAncestorSpace( FloatRect localToAncestorVisualRect(
const FloatRect&, const FloatRect&,
const PropertyTreeState& localTransformState, const PropertyTreeState& localTransformState,
const PropertyTreeState& ancestorState, const PropertyTreeState& ancestorState,
bool& success); bool& success);
// Maps from a rect in |localTransformSpace| to its transformed rect in // Maps from a rect in |localTransformNode| space to its transformed rect in
// |ancestorSpace|. This is computed by multiplying the rect by the combined // |ancestorTransformNode| space. This is computed by multiplying the rect by
// transform between |localTransformState| and |ancestorState|, then // the combined transform between |localTransformNode| and
// flattening into 2D space. // |ancestorTransformNode|, then flattening into 2D space.
// //
// If any of the paint property tree nodes in |localTransformState| are not // If |localTransformNode| is not equal to or a descendant of
// equal to or a descendant of that in |ancestorState|, returns the passed-in // |ancestorTransformNode|, returns the passed-in rec and sets |success| to
// rec and sets |success| to false. Otherwise, sets |success| to true. // false. Otherwise, sets |success| to true.
FloatRect localToAncestorRect(const FloatRect&, FloatRect localToAncestorRect(
const PropertyTreeState& localTransformState, const FloatRect&,
const PropertyTreeState& ancestorState, const TransformPaintPropertyNode* localTransformNode,
bool& success); const TransformPaintPropertyNode* ancestorTransformNode,
bool& success);
// Maps from a rect in |ancestorSpace| to its transformed rect in
// |localTransformSpace|. This is computed by multiplying the rect by the // Maps from a rect in |ancestorTransformNode| space to its transformed rect
// inverse combined transform between |localTransformState| and // in |localTransformNode| space. This is computed by multiplying the rect by
// |ancestorState|, if the transform is invertible. // the inverse combined transform between |localTransformNode| and
// |ancestorTransformNode|, if the transform is invertible.
// //
// If any of the paint property tree nodes in |localTransformState| are not // If the combined transform is not invertible, or |localTransformNode| is not
// equal to or a descendant of that in |ancestorState|, returns the passed-in // equal to or a descendant of |ancestorTransformNode|, returns the passed-in
// rect and sets |success| to false. Otherwise, sets |success| to true. // rect and sets |success| to false. Otherwise, sets |success| to true.
FloatRect ancestorToLocalRect(const FloatRect&, FloatRect ancestorToLocalRect(
const PropertyTreeState& localTransformState, const FloatRect&,
const PropertyTreeState& ancestorState, const TransformPaintPropertyNode* ancestorTransformNode,
bool& success); const TransformPaintPropertyNode* localTransformNode,
bool& success);
// Returns the matrix used in |LocalToAncestorRect|. Sets |success| to false // Returns the matrix used in |LocalToAncestorRect|. Sets |success| to false
// iff |localTransformNode| is not equal to or a descendant of // iff |localTransformNode| is not equal to or a descendant of
// |ancestorState.transform|. // |ancestorTransformNode|.
const TransformationMatrix& localToAncestorMatrix( const TransformationMatrix& localToAncestorMatrix(
const TransformPaintPropertyNode* localTransformNode, const TransformPaintPropertyNode* localTransformNode,
const PropertyTreeState& ancestorState, const TransformPaintPropertyNode* ancestorTransformNode,
bool& success); bool& success);
// Returns the "clip visual rect" between |localTransformState| and // Returns the "clip visual rect" between |localTransformState| and
...@@ -133,26 +136,26 @@ class PLATFORM_EXPORT GeometryMapper { ...@@ -133,26 +136,26 @@ class PLATFORM_EXPORT GeometryMapper {
bool& success); bool& success);
private: private:
// Used by mapToVisualRectInDestinationSpace() after fast mapping (assuming // Used by sourceToDestinationVisualRect() after fast mapping (assuming
// destination is an ancestor of source) failed. // destination is an ancestor of source) failed.
FloatRect slowMapToVisualRectInDestinationSpace( FloatRect slowSourceToDestinationVisualRect(
const FloatRect&, const FloatRect&,
const PropertyTreeState& sourceState, const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState, const PropertyTreeState& destinationState,
bool& success); bool& success);
// Used by mapRectToDestinationSpace() after fast mapping (assuming // Used by sourceToDestinationRect() after fast mapping (assuming destination
// destination is an ancestor of source) failed. // is an ancestor of source) failed.
FloatRect slowMapRectToDestinationSpace( FloatRect slowSourceToDestinationRect(
const FloatRect&, const FloatRect&,
const PropertyTreeState& sourceState, const TransformPaintPropertyNode* sourceTransformNode,
const PropertyTreeState& destinationState, const TransformPaintPropertyNode* destinationTransformNode,
bool& success); bool& success);
// Returns the precomputed data if already set, or adds and memoizes a new // Returns the precomputed data if already set, or adds and memoizes a new
// PrecomputedDataForAncestor otherwise. // PrecomputedDataForAncestor otherwise.
PrecomputedDataForAncestor& getPrecomputedDataForAncestor( PrecomputedDataForAncestor& getPrecomputedDataForAncestor(
const PropertyTreeState&); const TransformPaintPropertyNode*);
// Returns the least common ancestor in the transform tree. // Returns the least common ancestor in the transform tree.
static const TransformPaintPropertyNode* leastCommonAncestor( static const TransformPaintPropertyNode* leastCommonAncestor(
......
...@@ -11,12 +11,16 @@ ...@@ -11,12 +11,16 @@
#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 "platform/testing/PaintPropertyTestHelpers.h" #include "platform/testing/PaintPropertyTestHelpers.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace blink { namespace blink {
class GeometryMapperTest : public ::testing::Test { class GeometryMapperTest : public ::testing::Test,
public ScopedSlimmingPaintV2ForTest {
public: public:
GeometryMapperTest() : ScopedSlimmingPaintV2ForTest(true) {}
std::unique_ptr<GeometryMapper> geometryMapper; std::unique_ptr<GeometryMapper> geometryMapper;
PropertyTreeState rootPropertyTreeState() { PropertyTreeState rootPropertyTreeState() {
...@@ -28,7 +32,8 @@ class GeometryMapperTest : public ::testing::Test { ...@@ -28,7 +32,8 @@ class GeometryMapperTest : public ::testing::Test {
PrecomputedDataForAncestor& getPrecomputedDataForAncestor( PrecomputedDataForAncestor& getPrecomputedDataForAncestor(
const PropertyTreeState& propertyTreeState) { const PropertyTreeState& propertyTreeState) {
return geometryMapper->getPrecomputedDataForAncestor(propertyTreeState); return geometryMapper->getPrecomputedDataForAncestor(
propertyTreeState.transform());
} }
const TransformPaintPropertyNode* leastCommonAncestor( const TransformPaintPropertyNode* leastCommonAncestor(
...@@ -73,7 +78,7 @@ const static float kTestEpsilon = 1e-6; ...@@ -73,7 +78,7 @@ const static float kTestEpsilon = 1e-6;
do { \ do { \
bool success = false; \ bool success = false; \
EXPECT_RECT_EQ(expectedVisualRect, \ EXPECT_RECT_EQ(expectedVisualRect, \
geometryMapper->localToVisualRectInAncestorSpace( \ geometryMapper->localToAncestorVisualRect( \
inputRect, localPropertyTreeState, \ inputRect, localPropertyTreeState, \
ancestorPropertyTreeState, success)); \ ancestorPropertyTreeState, success)); \
EXPECT_TRUE(success); \ EXPECT_TRUE(success); \
...@@ -82,18 +87,18 @@ const static float kTestEpsilon = 1e-6; ...@@ -82,18 +87,18 @@ const static float kTestEpsilon = 1e-6;
EXPECT_TRUE(success); \ EXPECT_TRUE(success); \
EXPECT_RECT_EQ(expectedClipInAncestorSpace, mappedClip); \ EXPECT_RECT_EQ(expectedClipInAncestorSpace, mappedClip); \
EXPECT_RECT_EQ(expectedVisualRect, \ EXPECT_RECT_EQ(expectedVisualRect, \
geometryMapper->mapToVisualRectInDestinationSpace( \ geometryMapper->sourceToDestinationVisualRect( \
inputRect, localPropertyTreeState, \ inputRect, localPropertyTreeState, \
ancestorPropertyTreeState, success)); \ ancestorPropertyTreeState, success)); \
EXPECT_TRUE(success); \ EXPECT_TRUE(success); \
EXPECT_RECT_EQ(expectedTransformedRect, \ EXPECT_RECT_EQ(expectedTransformedRect, \
geometryMapper->localToAncestorRect( \ geometryMapper->localToAncestorRect( \
inputRect, localPropertyTreeState, \ inputRect, localPropertyTreeState.transform(), \
ancestorPropertyTreeState, success)); \ ancestorPropertyTreeState.transform(), success)); \
EXPECT_RECT_EQ(expectedTransformedRect, \ EXPECT_RECT_EQ(expectedTransformedRect, \
geometryMapper->mapRectToDestinationSpace( \ geometryMapper->sourceToDestinationRect( \
inputRect, localPropertyTreeState, \ inputRect, localPropertyTreeState.transform(), \
ancestorPropertyTreeState, success)); \ ancestorPropertyTreeState.transform(), success)); \
EXPECT_TRUE(success); \ EXPECT_TRUE(success); \
if (ancestorPropertyTreeState.transform() != \ if (ancestorPropertyTreeState.transform() != \
localPropertyTreeState.transform()) { \ localPropertyTreeState.transform()) { \
...@@ -150,9 +155,9 @@ TEST_F(GeometryMapperTest, TranslationTransform) { ...@@ -150,9 +155,9 @@ TEST_F(GeometryMapperTest, TranslationTransform) {
rootPropertyTreeState()); rootPropertyTreeState());
bool success = false; bool success = false;
EXPECT_RECT_EQ(input, EXPECT_RECT_EQ(input, geometryMapper->ancestorToLocalRect(
geometryMapper->ancestorToLocalRect( output, rootPropertyTreeState().transform(),
output, localState, rootPropertyTreeState(), success)); localState.transform(), success));
EXPECT_TRUE(success); EXPECT_TRUE(success);
} }
...@@ -448,39 +453,39 @@ TEST_F(GeometryMapperTest, SiblingTransforms) { ...@@ -448,39 +453,39 @@ TEST_F(GeometryMapperTest, SiblingTransforms) {
bool success; bool success;
FloatRect input(0, 0, 100, 100); FloatRect input(0, 0, 100, 100);
FloatRect result = geometryMapper->localToVisualRectInAncestorSpace( FloatRect result = geometryMapper->localToAncestorVisualRect(
input, transform1State, transform2State, success); input, transform1State, transform2State, success);
// Fails, because the transform2state is not an ancestor of transform1State. // Fails, because the transform2state is not an ancestor of transform1State.
EXPECT_FALSE(success); EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result); EXPECT_RECT_EQ(input, result);
result = geometryMapper->localToAncestorRect(input, transform1State, result = geometryMapper->localToAncestorRect(input, transform1.get(),
transform2State, success); transform2.get(), success);
// Fails, because the transform2state is not an ancestor of transform1State. // Fails, because the transform2state is not an ancestor of transform1State.
EXPECT_FALSE(success); EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result); EXPECT_RECT_EQ(input, result);
result = geometryMapper->localToVisualRectInAncestorSpace( result = geometryMapper->localToAncestorVisualRect(input, transform2State,
input, transform2State, transform1State, success); transform1State, success);
// Fails, because the transform1state is not an ancestor of transform2State. // Fails, because the transform1state is not an ancestor of transform2State.
EXPECT_FALSE(success); EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result); EXPECT_RECT_EQ(input, result);
result = geometryMapper->localToAncestorRect(input, transform2State, result = geometryMapper->localToAncestorRect(input, transform2.get(),
transform1State, success); transform1.get(), success);
// Fails, because the transform1state is not an ancestor of transform2State. // Fails, because the transform1state is not an ancestor of transform2State.
EXPECT_FALSE(success); EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result); EXPECT_RECT_EQ(input, result);
FloatRect expected = FloatRect expected =
rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input)); rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input));
result = geometryMapper->mapToVisualRectInDestinationSpace( result = geometryMapper->sourceToDestinationVisualRect(
input, transform1State, transform2State, success); input, transform1State, transform2State, success);
EXPECT_TRUE(success); EXPECT_TRUE(success);
EXPECT_RECT_EQ(expected, result); EXPECT_RECT_EQ(expected, result);
result = geometryMapper->mapRectToDestinationSpace(input, transform1State, result = geometryMapper->sourceToDestinationRect(input, transform1.get(),
transform2State, success); transform2.get(), success);
EXPECT_TRUE(success); EXPECT_TRUE(success);
EXPECT_RECT_EQ(expected, result); EXPECT_RECT_EQ(expected, result);
} }
...@@ -517,17 +522,17 @@ TEST_F(GeometryMapperTest, SiblingTransformsWithClip) { ...@@ -517,17 +522,17 @@ TEST_F(GeometryMapperTest, SiblingTransformsWithClip) {
FloatRect expected = FloatRect expected =
rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input)); rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input));
// mapToVisualRectInDestinationSpace ignores clip from the common ancestor to // sourceToDestinationVisualRect ignores clip from the common ancestor to
// destination. // destination.
FloatRect result = geometryMapper->mapToVisualRectInDestinationSpace( FloatRect result = geometryMapper->sourceToDestinationVisualRect(
input, transform1State, transform2AndClipState, success); input, transform1State, transform2AndClipState, success);
// Fails, because the clip of the destination state is not an ancestor of the // Fails, because the clip of the destination state is not an ancestor of the
// clip of the source state. // clip of the source state.
EXPECT_FALSE(success); EXPECT_FALSE(success);
// mapRectToDestinationSpace ignores clip. // sourceToDestinationRect applies transforms only.
result = geometryMapper->mapRectToDestinationSpace( result = geometryMapper->sourceToDestinationRect(input, transform1.get(),
input, transform1State, transform2AndClipState, success); transform2.get(), success);
EXPECT_TRUE(success); EXPECT_TRUE(success);
EXPECT_RECT_EQ(expected, result); EXPECT_RECT_EQ(expected, result);
...@@ -537,16 +542,16 @@ TEST_F(GeometryMapperTest, SiblingTransformsWithClip) { ...@@ -537,16 +542,16 @@ TEST_F(GeometryMapperTest, SiblingTransformsWithClip) {
FloatRect expectedClipped = rotateTransform1.inverse().mapRect( FloatRect expectedClipped = rotateTransform1.inverse().mapRect(
rotateTransform2.mapRect(FloatRect(10, 10, 70, 70))); rotateTransform2.mapRect(FloatRect(10, 10, 70, 70)));
// mapToVisualRectInDestinationSpace ignores clip from the common ancestor to // sourceToDestinationVisualRect ignores clip from the common ancestor to
// destination. // destination.
result = geometryMapper->mapToVisualRectInDestinationSpace( result = geometryMapper->sourceToDestinationVisualRect(
input, transform2AndClipState, transform1State, success); input, transform2AndClipState, transform1State, success);
EXPECT_TRUE(success); EXPECT_TRUE(success);
EXPECT_RECT_EQ(expectedClipped, result); EXPECT_RECT_EQ(expectedClipped, result);
// mapRectToDestinationSpace ignores clip. // sourceToDestinationRect applies transforms only.
result = geometryMapper->mapRectToDestinationSpace( result = geometryMapper->sourceToDestinationRect(input, transform2.get(),
input, transform2AndClipState, transform1State, success); transform1.get(), success);
EXPECT_TRUE(success); EXPECT_TRUE(success);
EXPECT_RECT_EQ(expectedUnclipped, result); EXPECT_RECT_EQ(expectedUnclipped, result);
} }
......
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