Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp

Issue 2105273004: GeometryMapper: Support computing visual rects in spaces that are not direct ancestors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
index f71ee303d62aade6e787212e123feaf7e6ab87a9..3daa15081542ccca290efc3c19ab182e093ab4c9 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
@@ -27,9 +27,9 @@ public:
return state;
}
- PrecomputedDataForAncestor& GetPrecomputedDataForAncestor(const PropertyTreeState& propertyTreeState)
+ PrecomputedDataForAncestor& getPrecomputedDataForAncestor(const PropertyTreeState& propertyTreeState)
{
- return geometryMapper->GetPrecomputedDataForAncestor(propertyTreeState);
+ return geometryMapper->getPrecomputedDataForAncestor(propertyTreeState);
}
private:
@@ -60,12 +60,15 @@ do { \
#define CHECK_MAPPINGS(inputRect, expectedVisualRect, expectedTransformedRect, expectedTransformToAncestor, expectedClipInAncestorSpace, localPropertyTreeState, ancestorPropertyTreeState) \
do { \
+ bool success = false; \
EXPECT_RECT_EQ(expectedVisualRect, \
- geometryMapper->LocalToVisualRectInAncestorSpace(inputRect, localPropertyTreeState, ancestorPropertyTreeState)); \
+ geometryMapper->localToVisualRectInAncestorSpace(inputRect, localPropertyTreeState, ancestorPropertyTreeState, success)); \
+ EXPECT_TRUE(success); \
EXPECT_RECT_EQ(expectedTransformedRect, \
- geometryMapper->LocalToAncestorRect(inputRect, localPropertyTreeState, ancestorPropertyTreeState)); \
- EXPECT_EQ(expectedTransformToAncestor, GetPrecomputedDataForAncestor(ancestorPropertyTreeState).toAncestorTransforms.get(localPropertyTreeState.transform)); \
- EXPECT_EQ(expectedClipInAncestorSpace, GetPrecomputedDataForAncestor(ancestorPropertyTreeState).toAncestorClipRects.get(localPropertyTreeState.clip)); \
+ geometryMapper->localToAncestorRect(inputRect, localPropertyTreeState, ancestorPropertyTreeState, success)); \
+ EXPECT_TRUE(success); \
+ EXPECT_EQ(expectedTransformToAncestor, getPrecomputedDataForAncestor(ancestorPropertyTreeState).toAncestorTransforms.get(localPropertyTreeState.transform.get())); \
+ EXPECT_EQ(expectedClipInAncestorSpace, getPrecomputedDataForAncestor(ancestorPropertyTreeState).toAncestorClipRects.get(localPropertyTreeState.clip.get())); \
} while (false)
TEST_F(GeometryMapperTest, Root)
@@ -101,7 +104,7 @@ TEST_F(GeometryMapperTest, TranslationTransform)
bool success = false;
EXPECT_RECT_EQ(input,
- geometryMapper->AncestorToLocalRect(output, localState, rootPropertyTreeState(), &success));
+ geometryMapper->ancestorToLocalRect(output, localState, rootPropertyTreeState(), success));
EXPECT_TRUE(success);
}
@@ -156,7 +159,7 @@ TEST_F(GeometryMapperTest, NestedTransforms)
CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), localState, rootPropertyTreeState());
// Check the cached matrix for the intermediate transform.
- EXPECT_EQ(rotateTransform, GetPrecomputedDataForAncestor(rootPropertyTreeState()).toAncestorTransforms.get(transform1.get()));
+ EXPECT_EQ(rotateTransform, getPrecomputedDataForAncestor(rootPropertyTreeState()).toAncestorTransforms.get(transform1.get()));
}
TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination)
@@ -309,4 +312,38 @@ TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween)
}
}
+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(rotateTransform1, FloatPoint3D(), rootPropertyTreeState().transform);
+
+ TransformationMatrix rotateTransform2;
+ rotateTransform2.rotate(-45);
+ RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(rotateTransform2, FloatPoint3D(), rootPropertyTreeState().transform);
+
+ PropertyTreeState transform1State = rootPropertyTreeState();
+ transform1State.transform = transform1;
+ PropertyTreeState transform2State = rootPropertyTreeState();
+ transform2State.transform = transform2;
+
+ bool success;
+ FloatRect input(0, 0, 100, 100);
+ FloatRect result = geometryMapper->localToVisualRectInAncestorSpace(input, transform1State, transform2State, success);
+ // Fails, because the transform2state is not an ancestor of transform1State.
+ EXPECT_FALSE(success);
+ EXPECT_RECT_EQ(input, result);
+
+ result = geometryMapper->localToVisualRectInAncestorSpace(input, transform2State, transform1State, success);
+ // Fails, because the transform1state is not an ancestor of transform2State.
+ EXPECT_FALSE(success);
+ EXPECT_RECT_EQ(input, result);
+
+ FloatRect expected = rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input));
+ result = geometryMapper->mapToVisualRectInDestinationSpace(input, transform1State, transform2State, success);
+ EXPECT_TRUE(success);
+ EXPECT_RECT_EQ(expected, result);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698