| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/paint/GeometryMapper.h" | 5 #include "platform/graphics/paint/GeometryMapper.h" |
| 6 | 6 |
| 7 #include "platform/geometry/GeometryTestHelpers.h" | 7 #include "platform/geometry/GeometryTestHelpers.h" |
| 8 #include "platform/geometry/LayoutRect.h" | 8 #include "platform/geometry/LayoutRect.h" |
| 9 #include "platform/graphics/BoxReflection.h" | 9 #include "platform/graphics/BoxReflection.h" |
| 10 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 10 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return descendantTransform->getTransformCache().getCachedTransform( | 46 return descendantTransform->getTransformCache().getCachedTransform( |
| 47 ancestorTransform); | 47 ancestorTransform); |
| 48 } | 48 } |
| 49 | 49 |
| 50 const TransformPaintPropertyNode* lowestCommonAncestor( | 50 const TransformPaintPropertyNode* lowestCommonAncestor( |
| 51 const TransformPaintPropertyNode* a, | 51 const TransformPaintPropertyNode* a, |
| 52 const TransformPaintPropertyNode* b) { | 52 const TransformPaintPropertyNode* b) { |
| 53 return GeometryMapper::lowestCommonAncestor(a, b); | 53 return GeometryMapper::lowestCommonAncestor(a, b); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void sourceToDestinationVisualRectInternal( | 56 FloatRect sourceToDestinationVisualRectInternal( |
| 57 const FloatRect& rect, |
| 57 const PropertyTreeState& sourceState, | 58 const PropertyTreeState& sourceState, |
| 58 const PropertyTreeState& destinationState, | 59 const PropertyTreeState& destinationState, |
| 59 FloatRect& mappingRect, | |
| 60 bool& success) { | 60 bool& success) { |
| 61 geometryMapper->localToAncestorVisualRectInternal( | 61 return geometryMapper |
| 62 sourceState, destinationState, mappingRect, success); | 62 ->localToAncestorVisualRectInternal(rect, sourceState, destinationState, |
| 63 success) |
| 64 .rect(); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void localToAncestorVisualRectInternal(const PropertyTreeState& localState, | 67 FloatRect localToAncestorVisualRectInternal( |
| 66 const PropertyTreeState& ancestorState, | 68 const FloatRect& rect, |
| 67 FloatRect& mappingRect, | 69 const PropertyTreeState& localState, |
| 68 bool& success) { | 70 const PropertyTreeState& ancestorState, |
| 69 geometryMapper->localToAncestorVisualRectInternal(localState, ancestorState, | 71 bool& success) { |
| 70 mappingRect, success); | 72 return geometryMapper |
| 73 ->localToAncestorVisualRectInternal(rect, localState, ancestorState, |
| 74 success) |
| 75 .rect(); |
| 71 } | 76 } |
| 72 | 77 |
| 73 void localToAncestorRectInternal( | 78 FloatRect localToAncestorRectInternal( |
| 79 const FloatRect& rect, |
| 74 const TransformPaintPropertyNode* localTransformNode, | 80 const TransformPaintPropertyNode* localTransformNode, |
| 75 const TransformPaintPropertyNode* ancestorTransformNode, | 81 const TransformPaintPropertyNode* ancestorTransformNode, |
| 76 FloatRect& rect, | |
| 77 bool& success) { | 82 bool& success) { |
| 78 geometryMapper->localToAncestorRectInternal( | 83 return geometryMapper->localToAncestorRectInternal( |
| 79 localTransformNode, ancestorTransformNode, rect, success); | 84 rect, localTransformNode, ancestorTransformNode, success); |
| 80 } | 85 } |
| 81 | 86 |
| 82 private: | 87 private: |
| 83 void SetUp() override { geometryMapper = GeometryMapper::create(); } | 88 void SetUp() override { geometryMapper = GeometryMapper::create(); } |
| 84 | 89 |
| 85 void TearDown() override { geometryMapper.reset(); } | 90 void TearDown() override { geometryMapper.reset(); } |
| 86 }; | 91 }; |
| 87 | 92 |
| 88 const static float kTestEpsilon = 1e-6; | 93 const static float kTestEpsilon = 1e-6; |
| 89 | 94 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 111 EXPECT_EQ(expected.isInfinite(), actual.isInfinite()); \ | 116 EXPECT_EQ(expected.isInfinite(), actual.isInfinite()); \ |
| 112 if (!expected.isInfinite()) \ | 117 if (!expected.isInfinite()) \ |
| 113 EXPECT_RECT_EQ(expected.rect(), actual.rect()); \ | 118 EXPECT_RECT_EQ(expected.rect(), actual.rect()); \ |
| 114 } while (false) | 119 } while (false) |
| 115 | 120 |
| 116 #define CHECK_MAPPINGS(inputRect, expectedVisualRect, expectedTransformedRect, \ | 121 #define CHECK_MAPPINGS(inputRect, expectedVisualRect, expectedTransformedRect, \ |
| 117 expectedTransformToAncestor, \ | 122 expectedTransformToAncestor, \ |
| 118 expectedClipInAncestorSpace, localPropertyTreeState, \ | 123 expectedClipInAncestorSpace, localPropertyTreeState, \ |
| 119 ancestorPropertyTreeState, hasRadius) \ | 124 ancestorPropertyTreeState, hasRadius) \ |
| 120 do { \ | 125 do { \ |
| 121 FloatRect floatRect = inputRect; \ | 126 FloatClipRect clipRect = geometryMapper->localToAncestorVisualRect( \ |
| 122 geometryMapper->localToAncestorVisualRect( \ | 127 inputRect, localPropertyTreeState, ancestorPropertyTreeState); \ |
| 123 localPropertyTreeState, ancestorPropertyTreeState, floatRect); \ | 128 EXPECT_EQ(hasRadius, clipRect.hasRadius()); \ |
| 124 EXPECT_RECT_EQ(expectedVisualRect, floatRect); \ | 129 EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \ |
| 125 FloatClipRect floatClipRect; \ | 130 clipRect = geometryMapper->localToAncestorClipRect( \ |
| 126 floatClipRect = geometryMapper->localToAncestorClipRect( \ | |
| 127 localPropertyTreeState, ancestorPropertyTreeState); \ | 131 localPropertyTreeState, ancestorPropertyTreeState); \ |
| 128 EXPECT_EQ(hasRadius, floatClipRect.hasRadius()); \ | 132 EXPECT_EQ(hasRadius, clipRect.hasRadius()); \ |
| 129 EXPECT_CLIP_RECT_EQ(expectedClipInAncestorSpace, floatClipRect); \ | 133 EXPECT_CLIP_RECT_EQ(expectedClipInAncestorSpace, clipRect); \ |
| 130 floatRect = inputRect; \ | 134 clipRect = geometryMapper->sourceToDestinationVisualRect( \ |
| 131 geometryMapper->sourceToDestinationVisualRect( \ | 135 inputRect, localPropertyTreeState, ancestorPropertyTreeState); \ |
| 132 localPropertyTreeState, ancestorPropertyTreeState, floatRect); \ | 136 EXPECT_EQ(hasRadius, clipRect.hasRadius()); \ |
| 133 EXPECT_RECT_EQ(expectedVisualRect, floatRect); \ | 137 EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \ |
| 134 FloatRect testMappedRect = inputRect; \ | 138 EXPECT_RECT_EQ(expectedTransformedRect, \ |
| 135 geometryMapper->localToAncestorRect(localPropertyTreeState.transform(), \ | 139 geometryMapper->localToAncestorRect( \ |
| 136 ancestorPropertyTreeState.transform(), \ | 140 inputRect, localPropertyTreeState.transform(), \ |
| 137 testMappedRect); \ | 141 ancestorPropertyTreeState.transform())); \ |
| 138 EXPECT_RECT_EQ(expectedTransformedRect, testMappedRect); \ | 142 EXPECT_RECT_EQ(expectedTransformedRect, \ |
| 139 testMappedRect = inputRect; \ | 143 geometryMapper->sourceToDestinationRect( \ |
| 140 geometryMapper->sourceToDestinationRect( \ | 144 inputRect, localPropertyTreeState.transform(), \ |
| 141 localPropertyTreeState.transform(), \ | 145 ancestorPropertyTreeState.transform())); \ |
| 142 ancestorPropertyTreeState.transform(), testMappedRect); \ | |
| 143 EXPECT_RECT_EQ(expectedTransformedRect, testMappedRect); \ | |
| 144 if (ancestorPropertyTreeState.transform() != \ | 146 if (ancestorPropertyTreeState.transform() != \ |
| 145 localPropertyTreeState.transform()) { \ | 147 localPropertyTreeState.transform()) { \ |
| 146 const TransformationMatrix* transformForTesting = \ | 148 const TransformationMatrix* transformForTesting = \ |
| 147 getTransform(localPropertyTreeState.transform(), \ | 149 getTransform(localPropertyTreeState.transform(), \ |
| 148 ancestorPropertyTreeState.transform()); \ | 150 ancestorPropertyTreeState.transform()); \ |
| 149 CHECK(transformForTesting); \ | 151 CHECK(transformForTesting); \ |
| 150 EXPECT_EQ(expectedTransformToAncestor, *transformForTesting); \ | 152 EXPECT_EQ(expectedTransformToAncestor, *transformForTesting); \ |
| 151 } \ | 153 } \ |
| 152 if (ancestorPropertyTreeState.clip() != localPropertyTreeState.clip()) { \ | 154 if (ancestorPropertyTreeState.clip() != localPropertyTreeState.clip()) { \ |
| 153 const FloatClipRect* outputClipForTesting = \ | 155 const FloatClipRect* outputClipForTesting = \ |
| 154 getClip(localPropertyTreeState.clip(), ancestorPropertyTreeState); \ | 156 getClip(localPropertyTreeState.clip(), ancestorPropertyTreeState); \ |
| 155 DCHECK(outputClipForTesting); \ | 157 DCHECK(outputClipForTesting); \ |
| 156 EXPECT_EQ(expectedClipInAncestorSpace, *outputClipForTesting) \ | 158 EXPECT_EQ(expectedClipInAncestorSpace, *outputClipForTesting) \ |
| 157 << "expected: " << expectedClipInAncestorSpace.rect().toString() \ | 159 << expectedClipInAncestorSpace.rect().toString() << " " \ |
| 158 << " (hasRadius: " << expectedClipInAncestorSpace.hasRadius() \ | 160 << outputClipForTesting->rect().toString(); \ |
| 159 << ") " \ | |
| 160 << "actual: " << outputClipForTesting->rect().toString() \ | |
| 161 << " (hasRadius: " << outputClipForTesting->hasRadius() << ")"; \ | |
| 162 } \ | 161 } \ |
| 163 } while (false) | 162 } while (false) |
| 164 | 163 |
| 165 TEST_F(GeometryMapperTest, Root) { | 164 TEST_F(GeometryMapperTest, Root) { |
| 166 FloatRect input(0, 0, 100, 100); | 165 FloatRect input(0, 0, 100, 100); |
| 167 | 166 |
| 168 bool hasRadius = false; | 167 bool hasRadius = false; |
| 169 CHECK_MAPPINGS(input, input, input, | 168 CHECK_MAPPINGS(input, input, input, |
| 170 TransformPaintPropertyNode::root()->matrix(), FloatClipRect(), | 169 TransformPaintPropertyNode::root()->matrix(), FloatClipRect(), |
| 171 rootPropertyTreeState(), rootPropertyTreeState(), hasRadius); | 170 rootPropertyTreeState(), rootPropertyTreeState(), hasRadius); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 195 PropertyTreeState localState = rootPropertyTreeState(); | 194 PropertyTreeState localState = rootPropertyTreeState(); |
| 196 localState.setTransform(transform.get()); | 195 localState.setTransform(transform.get()); |
| 197 | 196 |
| 198 FloatRect input(0, 0, 100, 100); | 197 FloatRect input(0, 0, 100, 100); |
| 199 FloatRect output = transformMatrix.mapRect(input); | 198 FloatRect output = transformMatrix.mapRect(input); |
| 200 | 199 |
| 201 bool hasRadius = false; | 200 bool hasRadius = false; |
| 202 CHECK_MAPPINGS(input, output, output, transform->matrix(), FloatClipRect(), | 201 CHECK_MAPPINGS(input, output, output, transform->matrix(), FloatClipRect(), |
| 203 localState, rootPropertyTreeState(), hasRadius); | 202 localState, rootPropertyTreeState(), hasRadius); |
| 204 | 203 |
| 205 geometryMapper->ancestorToLocalRect(rootPropertyTreeState().transform(), | 204 EXPECT_RECT_EQ(input, geometryMapper->ancestorToLocalRect( |
| 206 localState.transform(), output); | 205 output, rootPropertyTreeState().transform(), |
| 207 EXPECT_RECT_EQ(input, output); | 206 localState.transform())); |
| 208 } | 207 } |
| 209 | 208 |
| 210 TEST_F(GeometryMapperTest, RotationAndScaleTransform) { | 209 TEST_F(GeometryMapperTest, RotationAndScaleTransform) { |
| 211 TransformationMatrix transformMatrix; | 210 TransformationMatrix transformMatrix; |
| 212 transformMatrix.rotate(45); | 211 transformMatrix.rotate(45); |
| 213 transformMatrix.scale(2); | 212 transformMatrix.scale(2); |
| 214 RefPtr<TransformPaintPropertyNode> transform = | 213 RefPtr<TransformPaintPropertyNode> transform = |
| 215 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 214 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| 216 transformMatrix, | 215 transformMatrix, |
| 217 FloatPoint3D(0, 0, 0)); | 216 FloatPoint3D(0, 0, 0)); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 input, // Transformed rect (not clipped). | 413 input, // Transformed rect (not clipped). |
| 415 TransformPaintPropertyNode::root() | 414 TransformPaintPropertyNode::root() |
| 416 ->matrix(), // Transform matrix to ancestor space | 415 ->matrix(), // Transform matrix to ancestor space |
| 417 clipRect, // Clip rect in ancestor space | 416 clipRect, // Clip rect in ancestor space |
| 418 localState, | 417 localState, |
| 419 ancestorState, hasRadius); | 418 ancestorState, hasRadius); |
| 420 | 419 |
| 421 ancestorState.setClip(clip1.get()); | 420 ancestorState.setClip(clip1.get()); |
| 422 FloatRect output2(10, 10, 50, 50); | 421 FloatRect output2(10, 10, 50, 50); |
| 423 | 422 |
| 424 FloatClipRect clipRect2; | 423 clipRect.setRect(clip2->clipRect().rect()); |
| 425 clipRect2.setRect(clip2->clipRect().rect()); | |
| 426 | 424 |
| 427 hasRadius = false; | 425 hasRadius = false; |
| 428 CHECK_MAPPINGS(input, // Input | 426 CHECK_MAPPINGS(input, // Input |
| 429 output2, // Visual rect | 427 output2, // Visual rect |
| 430 input, // Transformed rect (not clipped). | 428 input, // Transformed rect (not clipped). |
| 431 TransformPaintPropertyNode::root() | 429 TransformPaintPropertyNode::root() |
| 432 ->matrix(), // Transform matrix to ancestor space | 430 ->matrix(), // Transform matrix to ancestor space |
| 433 clipRect2, // Clip rect in ancestor space | 431 clipRect, // Clip rect in ancestor space |
| 434 localState, ancestorState, hasRadius); | 432 localState, |
| 433 ancestorState, hasRadius); |
| 435 } | 434 } |
| 436 | 435 |
| 437 TEST_F(GeometryMapperTest, TwoClipsTransformAbove) { | 436 TEST_F(GeometryMapperTest, TwoClipsTransformAbove) { |
| 438 RefPtr<TransformPaintPropertyNode> transform = | 437 RefPtr<TransformPaintPropertyNode> transform = |
| 439 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 438 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| 440 TransformationMatrix(), | 439 TransformationMatrix(), |
| 441 FloatPoint3D()); | 440 FloatPoint3D()); |
| 442 | 441 |
| 443 FloatRoundedRect clipRect1( | 442 FloatRoundedRect clipRect1( |
| 444 FloatRect(10, 10, 50, 50), | 443 FloatRect(10, 10, 50, 50), |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 622 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| 624 rotateTransform2, FloatPoint3D()); | 623 rotateTransform2, FloatPoint3D()); |
| 625 | 624 |
| 626 PropertyTreeState transform1State = rootPropertyTreeState(); | 625 PropertyTreeState transform1State = rootPropertyTreeState(); |
| 627 transform1State.setTransform(transform1.get()); | 626 transform1State.setTransform(transform1.get()); |
| 628 PropertyTreeState transform2State = rootPropertyTreeState(); | 627 PropertyTreeState transform2State = rootPropertyTreeState(); |
| 629 transform2State.setTransform(transform2.get()); | 628 transform2State.setTransform(transform2.get()); |
| 630 | 629 |
| 631 bool success; | 630 bool success; |
| 632 FloatRect input(0, 0, 100, 100); | 631 FloatRect input(0, 0, 100, 100); |
| 633 FloatRect result = input; | 632 FloatRect result = localToAncestorVisualRectInternal( |
| 634 localToAncestorVisualRectInternal(transform1State, transform2State, result, | 633 input, transform1State, transform2State, success); |
| 635 success); | |
| 636 // Fails, because the transform2state is not an ancestor of transform1State. | 634 // Fails, because the transform2state is not an ancestor of transform1State. |
| 637 EXPECT_FALSE(success); | 635 EXPECT_FALSE(success); |
| 638 EXPECT_RECT_EQ(input, result); | 636 EXPECT_RECT_EQ(input, result); |
| 639 | 637 |
| 640 result = input; | 638 result = localToAncestorRectInternal(input, transform1.get(), |
| 641 localToAncestorRectInternal(transform1.get(), transform2.get(), result, | 639 transform2.get(), success); |
| 642 success); | |
| 643 // Fails, because the transform2state is not an ancestor of transform1State. | 640 // Fails, because the transform2state is not an ancestor of transform1State. |
| 644 EXPECT_FALSE(success); | 641 EXPECT_FALSE(success); |
| 645 EXPECT_RECT_EQ(input, result); | 642 EXPECT_RECT_EQ(input, result); |
| 646 | 643 |
| 647 result = input; | 644 result = localToAncestorVisualRectInternal(input, transform2State, |
| 648 localToAncestorVisualRectInternal(transform2State, transform1State, result, | 645 transform1State, success); |
| 649 success); | |
| 650 // Fails, because the transform1state is not an ancestor of transform2State. | 646 // Fails, because the transform1state is not an ancestor of transform2State. |
| 651 EXPECT_FALSE(success); | 647 EXPECT_FALSE(success); |
| 652 EXPECT_RECT_EQ(input, result); | 648 EXPECT_RECT_EQ(input, result); |
| 653 | 649 |
| 654 result = input; | 650 result = localToAncestorRectInternal(input, transform2.get(), |
| 655 localToAncestorRectInternal(transform2.get(), transform1.get(), result, | 651 transform1.get(), success); |
| 656 success); | |
| 657 // Fails, because the transform1state is not an ancestor of transform2State. | 652 // Fails, because the transform1state is not an ancestor of transform2State. |
| 658 EXPECT_FALSE(success); | 653 EXPECT_FALSE(success); |
| 659 EXPECT_RECT_EQ(input, result); | 654 EXPECT_RECT_EQ(input, result); |
| 660 | 655 |
| 661 FloatRect expected = | 656 FloatRect expected = |
| 662 rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input)); | 657 rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input)); |
| 663 result = input; | 658 result = geometryMapper |
| 664 geometryMapper->sourceToDestinationVisualRect(transform1State, | 659 ->sourceToDestinationVisualRect(input, transform1State, |
| 665 transform2State, result); | 660 transform2State) |
| 661 .rect(); |
| 666 EXPECT_RECT_EQ(expected, result); | 662 EXPECT_RECT_EQ(expected, result); |
| 667 | 663 |
| 668 result = input; | 664 result = geometryMapper->sourceToDestinationRect(input, transform1.get(), |
| 669 geometryMapper->sourceToDestinationRect(transform1.get(), transform2.get(), | 665 transform2.get()); |
| 670 result); | |
| 671 EXPECT_RECT_EQ(expected, result); | 666 EXPECT_RECT_EQ(expected, result); |
| 672 } | 667 } |
| 673 | 668 |
| 674 TEST_F(GeometryMapperTest, SiblingTransformsWithClip) { | 669 TEST_F(GeometryMapperTest, SiblingTransformsWithClip) { |
| 675 // These transforms are siblings. Thus mapping from one to the other requires | 670 // These transforms are siblings. Thus mapping from one to the other requires |
| 676 // going through the root. | 671 // going through the root. |
| 677 TransformationMatrix rotateTransform1; | 672 TransformationMatrix rotateTransform1; |
| 678 rotateTransform1.rotate(45); | 673 rotateTransform1.rotate(45); |
| 679 RefPtr<TransformPaintPropertyNode> transform1 = | 674 RefPtr<TransformPaintPropertyNode> transform1 = |
| 680 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 675 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 698 | 693 |
| 699 bool success; | 694 bool success; |
| 700 FloatRect input(0, 0, 100, 100); | 695 FloatRect input(0, 0, 100, 100); |
| 701 | 696 |
| 702 // Test map from transform1State to transform2AndClipState. | 697 // Test map from transform1State to transform2AndClipState. |
| 703 FloatRect expected = | 698 FloatRect expected = |
| 704 rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input)); | 699 rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input)); |
| 705 | 700 |
| 706 // sourceToDestinationVisualRect ignores clip from the common ancestor to | 701 // sourceToDestinationVisualRect ignores clip from the common ancestor to |
| 707 // destination. | 702 // destination. |
| 708 FloatRect result = input; | 703 FloatRect result = sourceToDestinationVisualRectInternal( |
| 709 sourceToDestinationVisualRectInternal(transform1State, transform2AndClipState, | 704 input, transform1State, transform2AndClipState, success); |
| 710 result, success); | |
| 711 // Fails, because the clip of the destination state is not an ancestor of the | 705 // Fails, because the clip of the destination state is not an ancestor of the |
| 712 // clip of the source state. | 706 // clip of the source state. |
| 713 EXPECT_FALSE(success); | 707 EXPECT_FALSE(success); |
| 714 | 708 |
| 715 // sourceToDestinationRect applies transforms only. | 709 // sourceToDestinationRect applies transforms only. |
| 716 result = input; | 710 result = geometryMapper->sourceToDestinationRect(input, transform1.get(), |
| 717 geometryMapper->sourceToDestinationRect(transform1.get(), transform2.get(), | 711 transform2.get()); |
| 718 result); | |
| 719 EXPECT_RECT_EQ(expected, result); | 712 EXPECT_RECT_EQ(expected, result); |
| 720 | 713 |
| 721 // Test map from transform2AndClipState to transform1State. | 714 // Test map from transform2AndClipState to transform1State. |
| 722 FloatRect expectedUnclipped = | 715 FloatRect expectedUnclipped = |
| 723 rotateTransform1.inverse().mapRect(rotateTransform2.mapRect(input)); | 716 rotateTransform1.inverse().mapRect(rotateTransform2.mapRect(input)); |
| 724 FloatRect expectedClipped = rotateTransform1.inverse().mapRect( | 717 FloatRect expectedClipped = rotateTransform1.inverse().mapRect( |
| 725 rotateTransform2.mapRect(FloatRect(10, 10, 70, 70))); | 718 rotateTransform2.mapRect(FloatRect(10, 10, 70, 70))); |
| 726 | 719 |
| 727 // sourceToDestinationVisualRect ignores clip from the common ancestor to | 720 // sourceToDestinationVisualRect ignores clip from the common ancestor to |
| 728 // destination. | 721 // destination. |
| 729 result = input; | 722 result = geometryMapper |
| 730 geometryMapper->sourceToDestinationVisualRect(transform2AndClipState, | 723 ->sourceToDestinationVisualRect(input, transform2AndClipState, |
| 731 transform1State, result); | 724 transform1State) |
| 725 .rect(); |
| 732 EXPECT_RECT_EQ(expectedClipped, result); | 726 EXPECT_RECT_EQ(expectedClipped, result); |
| 733 | 727 |
| 734 // sourceToDestinationRect applies transforms only. | 728 // sourceToDestinationRect applies transforms only. |
| 735 result = input; | 729 result = geometryMapper->sourceToDestinationRect(input, transform2.get(), |
| 736 geometryMapper->sourceToDestinationRect(transform2.get(), transform1.get(), | 730 transform1.get()); |
| 737 result); | |
| 738 EXPECT_RECT_EQ(expectedUnclipped, result); | 731 EXPECT_RECT_EQ(expectedUnclipped, result); |
| 739 } | 732 } |
| 740 | 733 |
| 741 TEST_F(GeometryMapperTest, LowestCommonAncestor) { | 734 TEST_F(GeometryMapperTest, LowestCommonAncestor) { |
| 742 TransformationMatrix matrix; | 735 TransformationMatrix matrix; |
| 743 RefPtr<TransformPaintPropertyNode> child1 = | 736 RefPtr<TransformPaintPropertyNode> child1 = |
| 744 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 737 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| 745 matrix, FloatPoint3D()); | 738 matrix, FloatPoint3D()); |
| 746 RefPtr<TransformPaintPropertyNode> child2 = | 739 RefPtr<TransformPaintPropertyNode> child2 = |
| 747 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 740 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 FloatRect input(100, 100, 50, 50); | 835 FloatRect input(100, 100, 50, 50); |
| 843 // Reflection is at (50, 100, 50, 50). | 836 // Reflection is at (50, 100, 50, 50). |
| 844 FloatRect output(50, 100, 100, 50); | 837 FloatRect output(50, 100, 100, 50); |
| 845 | 838 |
| 846 bool hasRadius = false; | 839 bool hasRadius = false; |
| 847 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(), | 840 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(), |
| 848 localState, rootPropertyTreeState(), hasRadius); | 841 localState, rootPropertyTreeState(), hasRadius); |
| 849 } | 842 } |
| 850 | 843 |
| 851 } // namespace blink | 844 } // namespace blink |
| OLD | NEW |