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