| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 inputRect, localPropertyTreeState.transform(), \ | 135 inputRect, localPropertyTreeState.transform(), \ |
| 136 ancestorPropertyTreeState.transform())); \ | 136 ancestorPropertyTreeState.transform())); \ |
| 137 EXPECT_RECT_EQ(expectedTransformedRect, \ | 137 EXPECT_RECT_EQ(expectedTransformedRect, \ |
| 138 geometryMapper->sourceToDestinationRect( \ | 138 geometryMapper->sourceToDestinationRect( \ |
| 139 inputRect, localPropertyTreeState.transform(), \ | 139 inputRect, localPropertyTreeState.transform(), \ |
| 140 ancestorPropertyTreeState.transform())); \ | 140 ancestorPropertyTreeState.transform())); \ |
| 141 if (ancestorPropertyTreeState.transform() != \ | 141 if (ancestorPropertyTreeState.transform() != \ |
| 142 localPropertyTreeState.transform()) { \ | 142 localPropertyTreeState.transform()) { \ |
| 143 EXPECT_EQ(expectedTransformToAncestor, \ | 143 EXPECT_EQ(expectedTransformToAncestor, \ |
| 144 getTransformCache(ancestorPropertyTreeState) \ | 144 getTransformCache(ancestorPropertyTreeState) \ |
| 145 .get(localPropertyTreeState.transform())); \ | 145 .at(localPropertyTreeState.transform())); \ |
| 146 } \ | 146 } \ |
| 147 if (ancestorPropertyTreeState.clip() != localPropertyTreeState.clip()) { \ | 147 if (ancestorPropertyTreeState.clip() != localPropertyTreeState.clip()) { \ |
| 148 EXPECT_EQ(expectedClipInAncestorSpace, \ | 148 EXPECT_EQ(expectedClipInAncestorSpace, \ |
| 149 getClipCache(ancestorPropertyTreeState) \ | 149 getClipCache(ancestorPropertyTreeState) \ |
| 150 .get(localPropertyTreeState.clip())) \ | 150 .at(localPropertyTreeState.clip())) \ |
| 151 << expectedClipInAncestorSpace.rect().toString() << " " \ | 151 << expectedClipInAncestorSpace.rect().toString() << " " \ |
| 152 << getClipCache(ancestorPropertyTreeState) \ | 152 << getClipCache(ancestorPropertyTreeState) \ |
| 153 .get(localPropertyTreeState.clip()) \ | 153 .at(localPropertyTreeState.clip()) \ |
| 154 .rect() \ | 154 .rect() \ |
| 155 .toString(); \ | 155 .toString(); \ |
| 156 } \ | 156 } \ |
| 157 } while (false) | 157 } while (false) |
| 158 | 158 |
| 159 TEST_F(GeometryMapperTest, Root) { | 159 TEST_F(GeometryMapperTest, Root) { |
| 160 FloatRect input(0, 0, 100, 100); | 160 FloatRect input(0, 0, 100, 100); |
| 161 | 161 |
| 162 bool hasRadius = false; | 162 bool hasRadius = false; |
| 163 CHECK_MAPPINGS(input, input, input, | 163 CHECK_MAPPINGS(input, input, input, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 FloatRect input(0, 0, 100, 100); | 259 FloatRect input(0, 0, 100, 100); |
| 260 TransformationMatrix final = rotateTransform * scaleTransform; | 260 TransformationMatrix final = rotateTransform * scaleTransform; |
| 261 FloatRect output = final.mapRect(input); | 261 FloatRect output = final.mapRect(input); |
| 262 | 262 |
| 263 bool hasRadius = false; | 263 bool hasRadius = false; |
| 264 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState, | 264 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState, |
| 265 rootPropertyTreeState(), hasRadius); | 265 rootPropertyTreeState(), hasRadius); |
| 266 | 266 |
| 267 // Check the cached matrix for the intermediate transform. | 267 // Check the cached matrix for the intermediate transform. |
| 268 EXPECT_EQ(rotateTransform, | 268 EXPECT_EQ(rotateTransform, |
| 269 getTransformCache(rootPropertyTreeState()).get(transform1.get())); | 269 getTransformCache(rootPropertyTreeState()).at(transform1.get())); |
| 270 } | 270 } |
| 271 | 271 |
| 272 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) { | 272 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) { |
| 273 TransformationMatrix scaleTransform; | 273 TransformationMatrix scaleTransform; |
| 274 scaleTransform.scale(2); | 274 scaleTransform.scale(2); |
| 275 RefPtr<TransformPaintPropertyNode> transform1 = | 275 RefPtr<TransformPaintPropertyNode> transform1 = |
| 276 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 276 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| 277 scaleTransform, FloatPoint3D()); | 277 scaleTransform, FloatPoint3D()); |
| 278 | 278 |
| 279 TransformationMatrix translateTransform; | 279 TransformationMatrix translateTransform; |
| 280 translateTransform.translate(100, 0); | 280 translateTransform.translate(100, 0); |
| 281 RefPtr<TransformPaintPropertyNode> transform2 = | 281 RefPtr<TransformPaintPropertyNode> transform2 = |
| 282 TransformPaintPropertyNode::create(transform1, translateTransform, | 282 TransformPaintPropertyNode::create(transform1, translateTransform, |
| 283 FloatPoint3D()); | 283 FloatPoint3D()); |
| 284 | 284 |
| 285 PropertyTreeState localState = rootPropertyTreeState(); | 285 PropertyTreeState localState = rootPropertyTreeState(); |
| 286 localState.setTransform(transform2.get()); | 286 localState.setTransform(transform2.get()); |
| 287 | 287 |
| 288 FloatRect input(0, 0, 100, 100); | 288 FloatRect input(0, 0, 100, 100); |
| 289 // Note: unlike NestedTransforms, the order of these transforms matters. This | 289 // Note: unlike NestedTransforms, the order of these transforms matters. This |
| 290 // tests correct order of matrix multiplication. | 290 // tests correct order of matrix multiplication. |
| 291 TransformationMatrix final = scaleTransform * translateTransform; | 291 TransformationMatrix final = scaleTransform * translateTransform; |
| 292 FloatRect output = final.mapRect(input); | 292 FloatRect output = final.mapRect(input); |
| 293 | 293 |
| 294 bool hasRadius = false; | 294 bool hasRadius = false; |
| 295 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState, | 295 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState, |
| 296 rootPropertyTreeState(), hasRadius); | 296 rootPropertyTreeState(), hasRadius); |
| 297 | 297 |
| 298 // Check the cached matrix for the intermediate transform. | 298 // Check the cached matrix for the intermediate transform. |
| 299 EXPECT_EQ(scaleTransform, getTransformCache(rootPropertyTreeState()) | 299 EXPECT_EQ(scaleTransform, |
| 300 getTransformCache(rootPropertyTreeState()) |
| 300 | 301 |
| 301 .get(transform1.get())); | 302 .at(transform1.get())); |
| 302 } | 303 } |
| 303 | 304 |
| 304 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) { | 305 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) { |
| 305 TransformationMatrix rotateTransform; | 306 TransformationMatrix rotateTransform; |
| 306 rotateTransform.rotate(45); | 307 rotateTransform.rotate(45); |
| 307 RefPtr<TransformPaintPropertyNode> transform1 = | 308 RefPtr<TransformPaintPropertyNode> transform1 = |
| 308 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 309 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), |
| 309 rotateTransform, FloatPoint3D()); | 310 rotateTransform, FloatPoint3D()); |
| 310 | 311 |
| 311 TransformationMatrix scaleTransform; | 312 TransformationMatrix scaleTransform; |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 FloatRect input(100, 100, 50, 50); | 831 FloatRect input(100, 100, 50, 50); |
| 831 // Reflection is at (50, 100, 50, 50). | 832 // Reflection is at (50, 100, 50, 50). |
| 832 FloatRect output(50, 100, 100, 50); | 833 FloatRect output(50, 100, 100, 50); |
| 833 | 834 |
| 834 bool hasRadius = false; | 835 bool hasRadius = false; |
| 835 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(), | 836 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(), |
| 836 localState, rootPropertyTreeState(), hasRadius); | 837 localState, rootPropertyTreeState(), hasRadius); |
| 837 } | 838 } |
| 838 | 839 |
| 839 } // namespace blink | 840 } // namespace blink |
| OLD | NEW |