| 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 c1375c5bf31c7296d1a499fee25528e506d0153d..7c44f7b1c2c3b125fd45a24665f38b68954e5cba 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
|
| @@ -53,35 +53,30 @@
|
| return GeometryMapper::lowestCommonAncestor(a, b);
|
| }
|
|
|
| - FloatRect sourceToDestinationVisualRectInternal(
|
| - const FloatRect& rect,
|
| + void sourceToDestinationVisualRectInternal(
|
| const PropertyTreeState& sourceState,
|
| const PropertyTreeState& destinationState,
|
| + FloatRect& mappingRect,
|
| bool& success) {
|
| - return geometryMapper
|
| - ->localToAncestorVisualRectInternal(rect, sourceState, destinationState,
|
| - success)
|
| - .rect();
|
| + geometryMapper->localToAncestorVisualRectInternal(
|
| + sourceState, destinationState, mappingRect, success);
|
| }
|
|
|
| - FloatRect localToAncestorVisualRectInternal(
|
| - const FloatRect& rect,
|
| - const PropertyTreeState& localState,
|
| - const PropertyTreeState& ancestorState,
|
| - bool& success) {
|
| - return geometryMapper
|
| - ->localToAncestorVisualRectInternal(rect, localState, ancestorState,
|
| - success)
|
| - .rect();
|
| + void localToAncestorVisualRectInternal(const PropertyTreeState& localState,
|
| + const PropertyTreeState& ancestorState,
|
| + FloatRect& mappingRect,
|
| + bool& success) {
|
| + geometryMapper->localToAncestorVisualRectInternal(localState, ancestorState,
|
| + mappingRect, success);
|
| }
|
|
|
| - FloatRect localToAncestorRectInternal(
|
| - const FloatRect& rect,
|
| + void localToAncestorRectInternal(
|
| const TransformPaintPropertyNode* localTransformNode,
|
| const TransformPaintPropertyNode* ancestorTransformNode,
|
| + FloatRect& rect,
|
| bool& success) {
|
| - return geometryMapper->localToAncestorRectInternal(
|
| - rect, localTransformNode, ancestorTransformNode, success);
|
| + geometryMapper->localToAncestorRectInternal(
|
| + localTransformNode, ancestorTransformNode, rect, success);
|
| }
|
|
|
| private:
|
| @@ -123,26 +118,29 @@
|
| expectedClipInAncestorSpace, localPropertyTreeState, \
|
| ancestorPropertyTreeState, hasRadius) \
|
| do { \
|
| - FloatClipRect clipRect = geometryMapper->localToAncestorVisualRect( \
|
| - inputRect, localPropertyTreeState, ancestorPropertyTreeState); \
|
| - EXPECT_EQ(hasRadius, clipRect.hasRadius()); \
|
| - EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \
|
| - clipRect = geometryMapper->localToAncestorClipRect( \
|
| + FloatRect floatRect = inputRect; \
|
| + geometryMapper->localToAncestorVisualRect( \
|
| + localPropertyTreeState, ancestorPropertyTreeState, floatRect); \
|
| + EXPECT_RECT_EQ(expectedVisualRect, floatRect); \
|
| + FloatClipRect floatClipRect; \
|
| + floatClipRect = geometryMapper->localToAncestorClipRect( \
|
| localPropertyTreeState, ancestorPropertyTreeState); \
|
| - EXPECT_EQ(hasRadius, clipRect.hasRadius()); \
|
| - EXPECT_CLIP_RECT_EQ(expectedClipInAncestorSpace, clipRect); \
|
| - clipRect = geometryMapper->sourceToDestinationVisualRect( \
|
| - inputRect, localPropertyTreeState, ancestorPropertyTreeState); \
|
| - EXPECT_EQ(hasRadius, clipRect.hasRadius()); \
|
| - EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \
|
| - EXPECT_RECT_EQ(expectedTransformedRect, \
|
| - geometryMapper->localToAncestorRect( \
|
| - inputRect, localPropertyTreeState.transform(), \
|
| - ancestorPropertyTreeState.transform())); \
|
| - EXPECT_RECT_EQ(expectedTransformedRect, \
|
| - geometryMapper->sourceToDestinationRect( \
|
| - inputRect, localPropertyTreeState.transform(), \
|
| - ancestorPropertyTreeState.transform())); \
|
| + EXPECT_EQ(hasRadius, floatClipRect.hasRadius()); \
|
| + EXPECT_CLIP_RECT_EQ(expectedClipInAncestorSpace, floatClipRect); \
|
| + floatRect = inputRect; \
|
| + geometryMapper->sourceToDestinationVisualRect( \
|
| + localPropertyTreeState, ancestorPropertyTreeState, floatRect); \
|
| + EXPECT_RECT_EQ(expectedVisualRect, floatRect); \
|
| + FloatRect testMappedRect = inputRect; \
|
| + geometryMapper->localToAncestorRect(localPropertyTreeState.transform(), \
|
| + ancestorPropertyTreeState.transform(), \
|
| + testMappedRect); \
|
| + EXPECT_RECT_EQ(expectedTransformedRect, testMappedRect); \
|
| + testMappedRect = inputRect; \
|
| + geometryMapper->sourceToDestinationRect( \
|
| + localPropertyTreeState.transform(), \
|
| + ancestorPropertyTreeState.transform(), testMappedRect); \
|
| + EXPECT_RECT_EQ(expectedTransformedRect, testMappedRect); \
|
| if (ancestorPropertyTreeState.transform() != \
|
| localPropertyTreeState.transform()) { \
|
| const TransformationMatrix* transformForTesting = \
|
| @@ -156,8 +154,11 @@
|
| getClip(localPropertyTreeState.clip(), ancestorPropertyTreeState); \
|
| DCHECK(outputClipForTesting); \
|
| EXPECT_EQ(expectedClipInAncestorSpace, *outputClipForTesting) \
|
| - << expectedClipInAncestorSpace.rect().toString() << " " \
|
| - << outputClipForTesting->rect().toString(); \
|
| + << "expected: " << expectedClipInAncestorSpace.rect().toString() \
|
| + << " (hasRadius: " << expectedClipInAncestorSpace.hasRadius() \
|
| + << ") " \
|
| + << "actual: " << outputClipForTesting->rect().toString() \
|
| + << " (hasRadius: " << outputClipForTesting->hasRadius() << ")"; \
|
| } \
|
| } while (false)
|
|
|
| @@ -201,9 +202,9 @@
|
| CHECK_MAPPINGS(input, output, output, transform->matrix(), FloatClipRect(),
|
| localState, rootPropertyTreeState(), hasRadius);
|
|
|
| - EXPECT_RECT_EQ(input, geometryMapper->ancestorToLocalRect(
|
| - output, rootPropertyTreeState().transform(),
|
| - localState.transform()));
|
| + geometryMapper->ancestorToLocalRect(rootPropertyTreeState().transform(),
|
| + localState.transform(), output);
|
| + EXPECT_RECT_EQ(input, output);
|
| }
|
|
|
| TEST_F(GeometryMapperTest, RotationAndScaleTransform) {
|
| @@ -420,7 +421,8 @@
|
| ancestorState.setClip(clip1.get());
|
| FloatRect output2(10, 10, 50, 50);
|
|
|
| - clipRect.setRect(clip2->clipRect().rect());
|
| + FloatClipRect clipRect2;
|
| + clipRect2.setRect(clip2->clipRect().rect());
|
|
|
| hasRadius = false;
|
| CHECK_MAPPINGS(input, // Input
|
| @@ -428,9 +430,8 @@
|
| input, // Transformed rect (not clipped).
|
| TransformPaintPropertyNode::root()
|
| ->matrix(), // Transform matrix to ancestor space
|
| - clipRect, // Clip rect in ancestor space
|
| - localState,
|
| - ancestorState, hasRadius);
|
| + clipRect2, // Clip rect in ancestor space
|
| + localState, ancestorState, hasRadius);
|
| }
|
|
|
| TEST_F(GeometryMapperTest, TwoClipsTransformAbove) {
|
| @@ -629,40 +630,44 @@
|
|
|
| bool success;
|
| FloatRect input(0, 0, 100, 100);
|
| - FloatRect result = localToAncestorVisualRectInternal(
|
| - input, transform1State, transform2State, success);
|
| + FloatRect result = input;
|
| + localToAncestorVisualRectInternal(transform1State, transform2State, result,
|
| + success);
|
| // Fails, because the transform2state is not an ancestor of transform1State.
|
| EXPECT_FALSE(success);
|
| EXPECT_RECT_EQ(input, result);
|
|
|
| - result = localToAncestorRectInternal(input, transform1.get(),
|
| - transform2.get(), success);
|
| + result = input;
|
| + localToAncestorRectInternal(transform1.get(), transform2.get(), result,
|
| + success);
|
| // Fails, because the transform2state is not an ancestor of transform1State.
|
| EXPECT_FALSE(success);
|
| EXPECT_RECT_EQ(input, result);
|
|
|
| - result = localToAncestorVisualRectInternal(input, transform2State,
|
| - transform1State, success);
|
| + result = input;
|
| + localToAncestorVisualRectInternal(transform2State, transform1State, result,
|
| + success);
|
| // Fails, because the transform1state is not an ancestor of transform2State.
|
| EXPECT_FALSE(success);
|
| EXPECT_RECT_EQ(input, result);
|
|
|
| - result = localToAncestorRectInternal(input, transform2.get(),
|
| - transform1.get(), success);
|
| + result = input;
|
| + localToAncestorRectInternal(transform2.get(), transform1.get(), result,
|
| + 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
|
| - ->sourceToDestinationVisualRect(input, transform1State,
|
| - transform2State)
|
| - .rect();
|
| + result = input;
|
| + geometryMapper->sourceToDestinationVisualRect(transform1State,
|
| + transform2State, result);
|
| EXPECT_RECT_EQ(expected, result);
|
|
|
| - result = geometryMapper->sourceToDestinationRect(input, transform1.get(),
|
| - transform2.get());
|
| + result = input;
|
| + geometryMapper->sourceToDestinationRect(transform1.get(), transform2.get(),
|
| + result);
|
| EXPECT_RECT_EQ(expected, result);
|
| }
|
|
|
| @@ -700,15 +705,17 @@
|
|
|
| // sourceToDestinationVisualRect ignores clip from the common ancestor to
|
| // destination.
|
| - FloatRect result = sourceToDestinationVisualRectInternal(
|
| - input, transform1State, transform2AndClipState, success);
|
| + FloatRect result = input;
|
| + sourceToDestinationVisualRectInternal(transform1State, transform2AndClipState,
|
| + result, success);
|
| // Fails, because the clip of the destination state is not an ancestor of the
|
| // clip of the source state.
|
| EXPECT_FALSE(success);
|
|
|
| // sourceToDestinationRect applies transforms only.
|
| - result = geometryMapper->sourceToDestinationRect(input, transform1.get(),
|
| - transform2.get());
|
| + result = input;
|
| + geometryMapper->sourceToDestinationRect(transform1.get(), transform2.get(),
|
| + result);
|
| EXPECT_RECT_EQ(expected, result);
|
|
|
| // Test map from transform2AndClipState to transform1State.
|
| @@ -719,15 +726,15 @@
|
|
|
| // sourceToDestinationVisualRect ignores clip from the common ancestor to
|
| // destination.
|
| - result = geometryMapper
|
| - ->sourceToDestinationVisualRect(input, transform2AndClipState,
|
| - transform1State)
|
| - .rect();
|
| + result = input;
|
| + geometryMapper->sourceToDestinationVisualRect(transform2AndClipState,
|
| + transform1State, result);
|
| EXPECT_RECT_EQ(expectedClipped, result);
|
|
|
| // sourceToDestinationRect applies transforms only.
|
| - result = geometryMapper->sourceToDestinationRect(input, transform2.get(),
|
| - transform1.get());
|
| + result = input;
|
| + geometryMapper->sourceToDestinationRect(transform2.get(), transform1.get(),
|
| + result);
|
| EXPECT_RECT_EQ(expectedUnclipped, result);
|
| }
|
|
|
|
|