| 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" |
| 11 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 11 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 12 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 12 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 14 #include "platform/testing/PaintPropertyTestHelpers.h" | 14 #include "platform/testing/PaintPropertyTestHelpers.h" |
| 15 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 15 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class GeometryMapperTest : public ::testing::Test, | 20 typedef bool SlimmingPaintV2Enabled; |
| 21 public ScopedSlimmingPaintV2ForTest { | 21 class GeometryMapperTest |
| 22 : public ::testing::Test, |
| 23 public ::testing::WithParamInterface<SlimmingPaintV2Enabled>, |
| 24 public ScopedSlimmingPaintV2ForTest { |
| 22 public: | 25 public: |
| 23 GeometryMapperTest() : ScopedSlimmingPaintV2ForTest(true) {} | 26 GeometryMapperTest() : ScopedSlimmingPaintV2ForTest(GetParam()) {} |
| 24 | 27 |
| 25 const FloatClipRect* GetClip( | 28 const FloatClipRect* GetClip( |
| 26 const ClipPaintPropertyNode* descendant_clip, | 29 const ClipPaintPropertyNode* descendant_clip, |
| 27 const PropertyTreeState& ancestor_property_tree_state) { | 30 const PropertyTreeState& ancestor_property_tree_state) { |
| 28 GeometryMapperClipCache::ClipAndTransform clip_and_transform( | 31 GeometryMapperClipCache::ClipAndTransform clip_and_transform( |
| 29 ancestor_property_tree_state.Clip(), | 32 ancestor_property_tree_state.Clip(), |
| 30 ancestor_property_tree_state.Transform()); | 33 ancestor_property_tree_state.Transform()); |
| 31 return descendant_clip->GetClipCache().GetCachedClip(clip_and_transform); | 34 return descendant_clip->GetClipCache().GetCachedClip(clip_and_transform); |
| 32 } | 35 } |
| 33 | 36 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 const TransformPaintPropertyNode* ancestor_transform_node, | 74 const TransformPaintPropertyNode* ancestor_transform_node, |
| 72 FloatRect& rect, | 75 FloatRect& rect, |
| 73 bool& success) { | 76 bool& success) { |
| 74 GeometryMapper::LocalToAncestorRectInternal( | 77 GeometryMapper::LocalToAncestorRectInternal( |
| 75 local_transform_node, ancestor_transform_node, rect, success); | 78 local_transform_node, ancestor_transform_node, rect, success); |
| 76 } | 79 } |
| 77 | 80 |
| 78 private: | 81 private: |
| 79 }; | 82 }; |
| 80 | 83 |
| 84 bool values[] = {false, true}; |
| 85 |
| 86 INSTANTIATE_TEST_CASE_P(All, GeometryMapperTest, ::testing::ValuesIn(values)); |
| 87 |
| 81 const static float kTestEpsilon = 1e-6; | 88 const static float kTestEpsilon = 1e-6; |
| 82 | 89 |
| 83 #define EXPECT_RECT_EQ(expected, actual) \ | 90 #define EXPECT_RECT_EQ(expected, actual) \ |
| 84 do { \ | 91 do { \ |
| 85 const FloatRect& actual_rect = actual; \ | 92 const FloatRect& actual_rect = actual; \ |
| 86 EXPECT_TRUE(GeometryTest::ApproximatelyEqual( \ | 93 EXPECT_TRUE(GeometryTest::ApproximatelyEqual( \ |
| 87 expected.X(), actual_rect.X(), kTestEpsilon)) \ | 94 expected.X(), actual_rect.X(), kTestEpsilon)) \ |
| 88 << "actual: " << actual_rect.X() << ", expected: " << expected.X(); \ | 95 << "actual: " << actual_rect.X() << ", expected: " << expected.X(); \ |
| 89 EXPECT_TRUE(GeometryTest::ApproximatelyEqual( \ | 96 EXPECT_TRUE(GeometryTest::ApproximatelyEqual( \ |
| 90 expected.Y(), actual_rect.Y(), kTestEpsilon)) \ | 97 expected.Y(), actual_rect.Y(), kTestEpsilon)) \ |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 DCHECK(output_clip_for_testing); \ | 157 DCHECK(output_clip_for_testing); \ |
| 151 EXPECT_EQ(expectedClipInAncestorSpace, *output_clip_for_testing) \ | 158 EXPECT_EQ(expectedClipInAncestorSpace, *output_clip_for_testing) \ |
| 152 << "expected: " << expectedClipInAncestorSpace.Rect().ToString() \ | 159 << "expected: " << expectedClipInAncestorSpace.Rect().ToString() \ |
| 153 << " (hasRadius: " << expectedClipInAncestorSpace.HasRadius() \ | 160 << " (hasRadius: " << expectedClipInAncestorSpace.HasRadius() \ |
| 154 << ") " \ | 161 << ") " \ |
| 155 << "actual: " << output_clip_for_testing->Rect().ToString() \ | 162 << "actual: " << output_clip_for_testing->Rect().ToString() \ |
| 156 << " (hasRadius: " << output_clip_for_testing->HasRadius() << ")"; \ | 163 << " (hasRadius: " << output_clip_for_testing->HasRadius() << ")"; \ |
| 157 } \ | 164 } \ |
| 158 } while (false) | 165 } while (false) |
| 159 | 166 |
| 160 TEST_F(GeometryMapperTest, Root) { | 167 TEST_P(GeometryMapperTest, Root) { |
| 161 FloatRect input(0, 0, 100, 100); | 168 FloatRect input(0, 0, 100, 100); |
| 162 | 169 |
| 163 bool has_radius = false; | 170 bool has_radius = false; |
| 164 CHECK_MAPPINGS(input, input, input, | 171 CHECK_MAPPINGS(input, input, input, |
| 165 TransformPaintPropertyNode::Root()->Matrix(), FloatClipRect(), | 172 TransformPaintPropertyNode::Root()->Matrix(), FloatClipRect(), |
| 166 PropertyTreeState::Root(), PropertyTreeState::Root()); | 173 PropertyTreeState::Root(), PropertyTreeState::Root()); |
| 167 } | 174 } |
| 168 | 175 |
| 169 TEST_F(GeometryMapperTest, IdentityTransform) { | 176 TEST_P(GeometryMapperTest, IdentityTransform) { |
| 170 RefPtr<TransformPaintPropertyNode> transform = | 177 RefPtr<TransformPaintPropertyNode> transform = |
| 171 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 178 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 172 TransformationMatrix(), | 179 TransformationMatrix(), |
| 173 FloatPoint3D()); | 180 FloatPoint3D()); |
| 174 PropertyTreeState local_state = PropertyTreeState::Root(); | 181 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 175 local_state.SetTransform(transform.Get()); | 182 local_state.SetTransform(transform.Get()); |
| 176 | 183 |
| 177 FloatRect input(0, 0, 100, 100); | 184 FloatRect input(0, 0, 100, 100); |
| 178 | 185 |
| 179 bool has_radius = false; | 186 bool has_radius = false; |
| 180 CHECK_MAPPINGS(input, input, input, transform->Matrix(), FloatClipRect(), | 187 CHECK_MAPPINGS(input, input, input, transform->Matrix(), FloatClipRect(), |
| 181 local_state, PropertyTreeState::Root()); | 188 local_state, PropertyTreeState::Root()); |
| 182 } | 189 } |
| 183 | 190 |
| 184 TEST_F(GeometryMapperTest, TranslationTransform) { | 191 TEST_P(GeometryMapperTest, TranslationTransform) { |
| 185 TransformationMatrix transform_matrix; | 192 TransformationMatrix transform_matrix; |
| 186 transform_matrix.Translate(20, 10); | 193 transform_matrix.Translate(20, 10); |
| 187 RefPtr<TransformPaintPropertyNode> transform = | 194 RefPtr<TransformPaintPropertyNode> transform = |
| 188 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 195 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 189 transform_matrix, FloatPoint3D()); | 196 transform_matrix, FloatPoint3D()); |
| 190 PropertyTreeState local_state = PropertyTreeState::Root(); | 197 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 191 local_state.SetTransform(transform.Get()); | 198 local_state.SetTransform(transform.Get()); |
| 192 | 199 |
| 193 FloatRect input(0, 0, 100, 100); | 200 FloatRect input(0, 0, 100, 100); |
| 194 FloatRect output = transform_matrix.MapRect(input); | 201 FloatRect output = transform_matrix.MapRect(input); |
| 195 | 202 |
| 196 bool has_radius = false; | 203 bool has_radius = false; |
| 197 CHECK_MAPPINGS(input, output, output, transform->Matrix(), FloatClipRect(), | 204 CHECK_MAPPINGS(input, output, output, transform->Matrix(), FloatClipRect(), |
| 198 local_state, PropertyTreeState::Root()); | 205 local_state, PropertyTreeState::Root()); |
| 199 | 206 |
| 200 GeometryMapper::AncestorToLocalRect(TransformPaintPropertyNode::Root(), | 207 GeometryMapper::AncestorToLocalRect(TransformPaintPropertyNode::Root(), |
| 201 local_state.Transform(), output); | 208 local_state.Transform(), output); |
| 202 EXPECT_RECT_EQ(input, output); | 209 EXPECT_RECT_EQ(input, output); |
| 203 } | 210 } |
| 204 | 211 |
| 205 TEST_F(GeometryMapperTest, RotationAndScaleTransform) { | 212 TEST_P(GeometryMapperTest, RotationAndScaleTransform) { |
| 206 TransformationMatrix transform_matrix; | 213 TransformationMatrix transform_matrix; |
| 207 transform_matrix.Rotate(45); | 214 transform_matrix.Rotate(45); |
| 208 transform_matrix.Scale(2); | 215 transform_matrix.Scale(2); |
| 209 RefPtr<TransformPaintPropertyNode> transform = | 216 RefPtr<TransformPaintPropertyNode> transform = |
| 210 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 217 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 211 transform_matrix, | 218 transform_matrix, |
| 212 FloatPoint3D(0, 0, 0)); | 219 FloatPoint3D(0, 0, 0)); |
| 213 PropertyTreeState local_state = PropertyTreeState::Root(); | 220 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 214 local_state.SetTransform(transform.Get()); | 221 local_state.SetTransform(transform.Get()); |
| 215 | 222 |
| 216 FloatRect input(0, 0, 100, 100); | 223 FloatRect input(0, 0, 100, 100); |
| 217 FloatRect output = transform_matrix.MapRect(input); | 224 FloatRect output = transform_matrix.MapRect(input); |
| 218 | 225 |
| 219 bool has_radius = false; | 226 bool has_radius = false; |
| 220 CHECK_MAPPINGS(input, output, output, transform_matrix, FloatClipRect(), | 227 CHECK_MAPPINGS(input, output, output, transform_matrix, FloatClipRect(), |
| 221 local_state, PropertyTreeState::Root()); | 228 local_state, PropertyTreeState::Root()); |
| 222 } | 229 } |
| 223 | 230 |
| 224 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) { | 231 TEST_P(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) { |
| 225 TransformationMatrix transform_matrix; | 232 TransformationMatrix transform_matrix; |
| 226 transform_matrix.Rotate(45); | 233 transform_matrix.Rotate(45); |
| 227 transform_matrix.Scale(2); | 234 transform_matrix.Scale(2); |
| 228 RefPtr<TransformPaintPropertyNode> transform = | 235 RefPtr<TransformPaintPropertyNode> transform = |
| 229 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 236 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 230 transform_matrix, | 237 transform_matrix, |
| 231 FloatPoint3D(50, 50, 0)); | 238 FloatPoint3D(50, 50, 0)); |
| 232 PropertyTreeState local_state = PropertyTreeState::Root(); | 239 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 233 local_state.SetTransform(transform.Get()); | 240 local_state.SetTransform(transform.Get()); |
| 234 | 241 |
| 235 FloatRect input(0, 0, 100, 100); | 242 FloatRect input(0, 0, 100, 100); |
| 236 transform_matrix.ApplyTransformOrigin(50, 50, 0); | 243 transform_matrix.ApplyTransformOrigin(50, 50, 0); |
| 237 FloatRect output = transform_matrix.MapRect(input); | 244 FloatRect output = transform_matrix.MapRect(input); |
| 238 | 245 |
| 239 bool has_radius = false; | 246 bool has_radius = false; |
| 240 CHECK_MAPPINGS(input, output, output, transform_matrix, FloatClipRect(), | 247 CHECK_MAPPINGS(input, output, output, transform_matrix, FloatClipRect(), |
| 241 local_state, PropertyTreeState::Root()); | 248 local_state, PropertyTreeState::Root()); |
| 242 } | 249 } |
| 243 | 250 |
| 244 TEST_F(GeometryMapperTest, NestedTransforms) { | 251 TEST_P(GeometryMapperTest, NestedTransforms) { |
| 245 TransformationMatrix rotate_transform; | 252 TransformationMatrix rotate_transform; |
| 246 rotate_transform.Rotate(45); | 253 rotate_transform.Rotate(45); |
| 247 RefPtr<TransformPaintPropertyNode> transform1 = | 254 RefPtr<TransformPaintPropertyNode> transform1 = |
| 248 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 255 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 249 rotate_transform, FloatPoint3D()); | 256 rotate_transform, FloatPoint3D()); |
| 250 | 257 |
| 251 TransformationMatrix scale_transform; | 258 TransformationMatrix scale_transform; |
| 252 scale_transform.Scale(2); | 259 scale_transform.Scale(2); |
| 253 RefPtr<TransformPaintPropertyNode> transform2 = | 260 RefPtr<TransformPaintPropertyNode> transform2 = |
| 254 TransformPaintPropertyNode::Create(transform1, scale_transform, | 261 TransformPaintPropertyNode::Create(transform1, scale_transform, |
| 255 FloatPoint3D()); | 262 FloatPoint3D()); |
| 256 | 263 |
| 257 PropertyTreeState local_state = PropertyTreeState::Root(); | 264 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 258 local_state.SetTransform(transform2.Get()); | 265 local_state.SetTransform(transform2.Get()); |
| 259 | 266 |
| 260 FloatRect input(0, 0, 100, 100); | 267 FloatRect input(0, 0, 100, 100); |
| 261 TransformationMatrix final = rotate_transform * scale_transform; | 268 TransformationMatrix final = rotate_transform * scale_transform; |
| 262 FloatRect output = final.MapRect(input); | 269 FloatRect output = final.MapRect(input); |
| 263 | 270 |
| 264 bool has_radius = false; | 271 bool has_radius = false; |
| 265 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), local_state, | 272 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), local_state, |
| 266 PropertyTreeState::Root()); | 273 PropertyTreeState::Root()); |
| 267 | 274 |
| 268 // Check the cached matrix for the intermediate transform. | 275 // Check the cached matrix for the intermediate transform. |
| 269 EXPECT_EQ( | 276 EXPECT_EQ( |
| 270 rotate_transform, | 277 rotate_transform, |
| 271 *GetTransform(transform1.Get(), TransformPaintPropertyNode::Root())); | 278 *GetTransform(transform1.Get(), TransformPaintPropertyNode::Root())); |
| 272 } | 279 } |
| 273 | 280 |
| 274 TEST_F(GeometryMapperTest, NestedTransformsFlattening) { | 281 TEST_P(GeometryMapperTest, NestedTransformsFlattening) { |
| 275 TransformationMatrix rotate_transform; | 282 TransformationMatrix rotate_transform; |
| 276 rotate_transform.Rotate3d(45, 0, 0); | 283 rotate_transform.Rotate3d(45, 0, 0); |
| 277 RefPtr<TransformPaintPropertyNode> transform1 = | 284 RefPtr<TransformPaintPropertyNode> transform1 = |
| 278 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 285 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 279 rotate_transform, FloatPoint3D()); | 286 rotate_transform, FloatPoint3D()); |
| 280 | 287 |
| 281 TransformationMatrix inverse_rotate_transform; | 288 TransformationMatrix inverse_rotate_transform; |
| 282 inverse_rotate_transform.Rotate3d(-45, 0, 0); | 289 inverse_rotate_transform.Rotate3d(-45, 0, 0); |
| 283 RefPtr<TransformPaintPropertyNode> transform2 = | 290 RefPtr<TransformPaintPropertyNode> transform2 = |
| 284 TransformPaintPropertyNode::Create(transform1, inverse_rotate_transform, | 291 TransformPaintPropertyNode::Create(transform1, inverse_rotate_transform, |
| 285 FloatPoint3D(), | 292 FloatPoint3D(), |
| 286 true); // Flattens | 293 true); // Flattens |
| 287 | 294 |
| 288 PropertyTreeState local_state = PropertyTreeState::Root(); | 295 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 289 local_state.SetTransform(transform2.Get()); | 296 local_state.SetTransform(transform2.Get()); |
| 290 | 297 |
| 291 FloatRect input(0, 0, 100, 100); | 298 FloatRect input(0, 0, 100, 100); |
| 292 rotate_transform.FlattenTo2d(); | 299 rotate_transform.FlattenTo2d(); |
| 293 TransformationMatrix final = rotate_transform * inverse_rotate_transform; | 300 TransformationMatrix final = rotate_transform * inverse_rotate_transform; |
| 294 FloatRect output = final.MapRect(input); | 301 FloatRect output = final.MapRect(input); |
| 295 bool has_radius = false; | 302 bool has_radius = false; |
| 296 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), local_state, | 303 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), local_state, |
| 297 PropertyTreeState::Root()); | 304 PropertyTreeState::Root()); |
| 298 } | 305 } |
| 299 | 306 |
| 300 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) { | 307 TEST_P(GeometryMapperTest, NestedTransformsScaleAndTranslation) { |
| 301 TransformationMatrix scale_transform; | 308 TransformationMatrix scale_transform; |
| 302 scale_transform.Scale(2); | 309 scale_transform.Scale(2); |
| 303 RefPtr<TransformPaintPropertyNode> transform1 = | 310 RefPtr<TransformPaintPropertyNode> transform1 = |
| 304 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 311 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 305 scale_transform, FloatPoint3D()); | 312 scale_transform, FloatPoint3D()); |
| 306 | 313 |
| 307 TransformationMatrix translate_transform; | 314 TransformationMatrix translate_transform; |
| 308 translate_transform.Translate(100, 0); | 315 translate_transform.Translate(100, 0); |
| 309 RefPtr<TransformPaintPropertyNode> transform2 = | 316 RefPtr<TransformPaintPropertyNode> transform2 = |
| 310 TransformPaintPropertyNode::Create(transform1, translate_transform, | 317 TransformPaintPropertyNode::Create(transform1, translate_transform, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 321 | 328 |
| 322 bool has_radius = false; | 329 bool has_radius = false; |
| 323 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), local_state, | 330 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), local_state, |
| 324 PropertyTreeState::Root()); | 331 PropertyTreeState::Root()); |
| 325 | 332 |
| 326 // Check the cached matrix for the intermediate transform. | 333 // Check the cached matrix for the intermediate transform. |
| 327 EXPECT_EQ(scale_transform, *GetTransform(transform1.Get(), | 334 EXPECT_EQ(scale_transform, *GetTransform(transform1.Get(), |
| 328 TransformPaintPropertyNode::Root())); | 335 TransformPaintPropertyNode::Root())); |
| 329 } | 336 } |
| 330 | 337 |
| 331 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) { | 338 TEST_P(GeometryMapperTest, NestedTransformsIntermediateDestination) { |
| 332 TransformationMatrix rotate_transform; | 339 TransformationMatrix rotate_transform; |
| 333 rotate_transform.Rotate(45); | 340 rotate_transform.Rotate(45); |
| 334 RefPtr<TransformPaintPropertyNode> transform1 = | 341 RefPtr<TransformPaintPropertyNode> transform1 = |
| 335 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 342 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 336 rotate_transform, FloatPoint3D()); | 343 rotate_transform, FloatPoint3D()); |
| 337 | 344 |
| 338 TransformationMatrix scale_transform; | 345 TransformationMatrix scale_transform; |
| 339 scale_transform.Scale(2); | 346 scale_transform.Scale(2); |
| 340 RefPtr<TransformPaintPropertyNode> transform2 = | 347 RefPtr<TransformPaintPropertyNode> transform2 = |
| 341 TransformPaintPropertyNode::Create(transform1, scale_transform, | 348 TransformPaintPropertyNode::Create(transform1, scale_transform, |
| 342 FloatPoint3D()); | 349 FloatPoint3D()); |
| 343 | 350 |
| 344 PropertyTreeState local_state = PropertyTreeState::Root(); | 351 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 345 local_state.SetTransform(transform2.Get()); | 352 local_state.SetTransform(transform2.Get()); |
| 346 | 353 |
| 347 PropertyTreeState intermediate_state = PropertyTreeState::Root(); | 354 PropertyTreeState intermediate_state = PropertyTreeState::Root(); |
| 348 intermediate_state.SetTransform(transform1.Get()); | 355 intermediate_state.SetTransform(transform1.Get()); |
| 349 | 356 |
| 350 FloatRect input(0, 0, 100, 100); | 357 FloatRect input(0, 0, 100, 100); |
| 351 FloatRect output = scale_transform.MapRect(input); | 358 FloatRect output = scale_transform.MapRect(input); |
| 352 | 359 |
| 353 bool has_radius = false; | 360 bool has_radius = false; |
| 354 CHECK_MAPPINGS(input, output, output, scale_transform, FloatClipRect(), | 361 CHECK_MAPPINGS(input, output, output, scale_transform, FloatClipRect(), |
| 355 local_state, intermediate_state); | 362 local_state, intermediate_state); |
| 356 } | 363 } |
| 357 | 364 |
| 358 TEST_F(GeometryMapperTest, SimpleClip) { | 365 TEST_P(GeometryMapperTest, SimpleClip) { |
| 359 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( | 366 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( |
| 360 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), | 367 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
| 361 FloatRoundedRect(10, 10, 50, 50)); | 368 FloatRoundedRect(10, 10, 50, 50)); |
| 362 | 369 |
| 363 PropertyTreeState local_state = PropertyTreeState::Root(); | 370 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 364 local_state.SetClip(clip.Get()); | 371 local_state.SetClip(clip.Get()); |
| 365 | 372 |
| 366 FloatRect input(0, 0, 100, 100); | 373 FloatRect input(0, 0, 100, 100); |
| 367 FloatRect output(10, 10, 50, 50); | 374 FloatRect output(10, 10, 50, 50); |
| 368 | 375 |
| 369 bool has_radius = false; | 376 bool has_radius = false; |
| 370 CHECK_MAPPINGS(input, // Input | 377 CHECK_MAPPINGS(input, // Input |
| 371 output, // Visual rect | 378 output, // Visual rect |
| 372 input, // Transformed rect (not clipped). | 379 input, // Transformed rect (not clipped). |
| 373 TransformPaintPropertyNode::Root() | 380 TransformPaintPropertyNode::Root() |
| 374 ->Matrix(), // Transform matrix to ancestor space | 381 ->Matrix(), // Transform matrix to ancestor space |
| 375 FloatClipRect(clip->ClipRect().Rect()), // Clip rect in | 382 FloatClipRect(clip->ClipRect().Rect()), // Clip rect in |
| 376 // ancestor space | 383 // ancestor space |
| 377 local_state, PropertyTreeState::Root()); | 384 local_state, PropertyTreeState::Root()); |
| 378 } | 385 } |
| 379 | 386 |
| 380 TEST_F(GeometryMapperTest, RoundedClip) { | 387 TEST_P(GeometryMapperTest, RoundedClip) { |
| 381 FloatRoundedRect rect(FloatRect(10, 10, 50, 50), | 388 FloatRoundedRect rect(FloatRect(10, 10, 50, 50), |
| 382 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), | 389 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), |
| 383 FloatSize(), FloatSize())); | 390 FloatSize(), FloatSize())); |
| 384 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( | 391 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( |
| 385 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), rect); | 392 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), rect); |
| 386 | 393 |
| 387 PropertyTreeState local_state = PropertyTreeState::Root(); | 394 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 388 local_state.SetClip(clip.Get()); | 395 local_state.SetClip(clip.Get()); |
| 389 | 396 |
| 390 FloatRect input(0, 0, 100, 100); | 397 FloatRect input(0, 0, 100, 100); |
| 391 FloatRect output(10, 10, 50, 50); | 398 FloatRect output(10, 10, 50, 50); |
| 392 | 399 |
| 393 FloatClipRect expected_clip(clip->ClipRect().Rect()); | 400 FloatClipRect expected_clip(clip->ClipRect().Rect()); |
| 394 expected_clip.SetHasRadius(); | 401 expected_clip.SetHasRadius(); |
| 395 | 402 |
| 396 bool has_radius = true; | 403 bool has_radius = true; |
| 397 CHECK_MAPPINGS(input, // Input | 404 CHECK_MAPPINGS(input, // Input |
| 398 output, // Visual rect | 405 output, // Visual rect |
| 399 input, // Transformed rect (not clipped). | 406 input, // Transformed rect (not clipped). |
| 400 TransformPaintPropertyNode::Root() | 407 TransformPaintPropertyNode::Root() |
| 401 ->Matrix(), // Transform matrix to ancestor space | 408 ->Matrix(), // Transform matrix to ancestor space |
| 402 expected_clip, // Clip rect in ancestor space | 409 expected_clip, // Clip rect in ancestor space |
| 403 local_state, PropertyTreeState::Root()); | 410 local_state, PropertyTreeState::Root()); |
| 404 } | 411 } |
| 405 | 412 |
| 406 TEST_F(GeometryMapperTest, TwoClips) { | 413 TEST_P(GeometryMapperTest, TwoClips) { |
| 407 FloatRoundedRect clip_rect1( | 414 FloatRoundedRect clip_rect1( |
| 408 FloatRect(10, 10, 30, 40), | 415 FloatRect(10, 10, 30, 40), |
| 409 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(), | 416 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(), |
| 410 FloatSize())); | 417 FloatSize())); |
| 411 | 418 |
| 412 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::Create( | 419 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::Create( |
| 413 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), | 420 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
| 414 clip_rect1); | 421 clip_rect1); |
| 415 | 422 |
| 416 RefPtr<ClipPaintPropertyNode> clip2 = | 423 RefPtr<ClipPaintPropertyNode> clip2 = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 445 has_radius = false; | 452 has_radius = false; |
| 446 CHECK_MAPPINGS(input, // Input | 453 CHECK_MAPPINGS(input, // Input |
| 447 output2, // Visual rect | 454 output2, // Visual rect |
| 448 input, // Transformed rect (not clipped). | 455 input, // Transformed rect (not clipped). |
| 449 TransformPaintPropertyNode::Root() | 456 TransformPaintPropertyNode::Root() |
| 450 ->Matrix(), // Transform matrix to ancestor space | 457 ->Matrix(), // Transform matrix to ancestor space |
| 451 clip_rect2, // Clip rect in ancestor space | 458 clip_rect2, // Clip rect in ancestor space |
| 452 local_state, ancestor_state); | 459 local_state, ancestor_state); |
| 453 } | 460 } |
| 454 | 461 |
| 455 TEST_F(GeometryMapperTest, TwoClipsTransformAbove) { | 462 TEST_P(GeometryMapperTest, TwoClipsTransformAbove) { |
| 456 RefPtr<TransformPaintPropertyNode> transform = | 463 RefPtr<TransformPaintPropertyNode> transform = |
| 457 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 464 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 458 TransformationMatrix(), | 465 TransformationMatrix(), |
| 459 FloatPoint3D()); | 466 FloatPoint3D()); |
| 460 | 467 |
| 461 FloatRoundedRect clip_rect1( | 468 FloatRoundedRect clip_rect1( |
| 462 FloatRect(10, 10, 50, 50), | 469 FloatRect(10, 10, 50, 50), |
| 463 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(), | 470 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(), |
| 464 FloatSize())); | 471 FloatSize())); |
| 465 | 472 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 493 FloatRect output2(10, 10, 50, 50); | 500 FloatRect output2(10, 10, 50, 50); |
| 494 CHECK_MAPPINGS(input, // Input | 501 CHECK_MAPPINGS(input, // Input |
| 495 output2, // Visual rect | 502 output2, // Visual rect |
| 496 input, // Transformed rect (not clipped). | 503 input, // Transformed rect (not clipped). |
| 497 TransformPaintPropertyNode::Root() | 504 TransformPaintPropertyNode::Root() |
| 498 ->Matrix(), // Transform matrix to ancestor space | 505 ->Matrix(), // Transform matrix to ancestor space |
| 499 expected_clip, // Clip rect in ancestor space | 506 expected_clip, // Clip rect in ancestor space |
| 500 local_state, ancestor_state); | 507 local_state, ancestor_state); |
| 501 } | 508 } |
| 502 | 509 |
| 503 TEST_F(GeometryMapperTest, ClipBeforeTransform) { | 510 TEST_P(GeometryMapperTest, ClipBeforeTransform) { |
| 504 TransformationMatrix rotate_transform; | 511 TransformationMatrix rotate_transform; |
| 505 rotate_transform.Rotate(45); | 512 rotate_transform.Rotate(45); |
| 506 RefPtr<TransformPaintPropertyNode> transform = | 513 RefPtr<TransformPaintPropertyNode> transform = |
| 507 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 514 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 508 rotate_transform, FloatPoint3D()); | 515 rotate_transform, FloatPoint3D()); |
| 509 | 516 |
| 510 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( | 517 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( |
| 511 ClipPaintPropertyNode::Root(), transform.Get(), | 518 ClipPaintPropertyNode::Root(), transform.Get(), |
| 512 FloatRoundedRect(10, 10, 50, 50)); | 519 FloatRoundedRect(10, 10, 50, 50)); |
| 513 | 520 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 524 CHECK_MAPPINGS( | 531 CHECK_MAPPINGS( |
| 525 input, // Input | 532 input, // Input |
| 526 output, // Visual rect | 533 output, // Visual rect |
| 527 rotate_transform.MapRect(input), // Transformed rect (not clipped). | 534 rotate_transform.MapRect(input), // Transformed rect (not clipped). |
| 528 rotate_transform, // Transform matrix to ancestor space | 535 rotate_transform, // Transform matrix to ancestor space |
| 529 FloatClipRect(rotate_transform.MapRect( | 536 FloatClipRect(rotate_transform.MapRect( |
| 530 clip->ClipRect().Rect())), // Clip rect in ancestor space | 537 clip->ClipRect().Rect())), // Clip rect in ancestor space |
| 531 local_state, PropertyTreeState::Root()); | 538 local_state, PropertyTreeState::Root()); |
| 532 } | 539 } |
| 533 | 540 |
| 534 TEST_F(GeometryMapperTest, ClipAfterTransform) { | 541 TEST_P(GeometryMapperTest, ClipAfterTransform) { |
| 535 TransformationMatrix rotate_transform; | 542 TransformationMatrix rotate_transform; |
| 536 rotate_transform.Rotate(45); | 543 rotate_transform.Rotate(45); |
| 537 RefPtr<TransformPaintPropertyNode> transform = | 544 RefPtr<TransformPaintPropertyNode> transform = |
| 538 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 545 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 539 rotate_transform, FloatPoint3D()); | 546 rotate_transform, FloatPoint3D()); |
| 540 | 547 |
| 541 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( | 548 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( |
| 542 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), | 549 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
| 543 FloatRoundedRect(10, 10, 200, 200)); | 550 FloatRoundedRect(10, 10, 200, 200)); |
| 544 | 551 |
| 545 PropertyTreeState local_state = PropertyTreeState::Root(); | 552 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 546 local_state.SetClip(clip.Get()); | 553 local_state.SetClip(clip.Get()); |
| 547 local_state.SetTransform(transform.Get()); | 554 local_state.SetTransform(transform.Get()); |
| 548 | 555 |
| 549 FloatRect input(0, 0, 100, 100); | 556 FloatRect input(0, 0, 100, 100); |
| 550 FloatRect output(input); | 557 FloatRect output(input); |
| 551 output = rotate_transform.MapRect(output); | 558 output = rotate_transform.MapRect(output); |
| 552 output.Intersect(clip->ClipRect().Rect()); | 559 output.Intersect(clip->ClipRect().Rect()); |
| 553 | 560 |
| 554 bool has_radius = false; | 561 bool has_radius = false; |
| 555 CHECK_MAPPINGS( | 562 CHECK_MAPPINGS( |
| 556 input, // Input | 563 input, // Input |
| 557 output, // Visual rect | 564 output, // Visual rect |
| 558 rotate_transform.MapRect(input), // Transformed rect (not clipped) | 565 rotate_transform.MapRect(input), // Transformed rect (not clipped) |
| 559 rotate_transform, // Transform matrix to ancestor space | 566 rotate_transform, // Transform matrix to ancestor space |
| 560 FloatClipRect(clip->ClipRect().Rect()), // Clip rect in ancestor space | 567 FloatClipRect(clip->ClipRect().Rect()), // Clip rect in ancestor space |
| 561 local_state, PropertyTreeState::Root()); | 568 local_state, PropertyTreeState::Root()); |
| 562 } | 569 } |
| 563 | 570 |
| 564 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) { | 571 TEST_P(GeometryMapperTest, TwoClipsWithTransformBetween) { |
| 565 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::Create( | 572 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::Create( |
| 566 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), | 573 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
| 567 FloatRoundedRect(10, 10, 200, 200)); | 574 FloatRoundedRect(10, 10, 200, 200)); |
| 568 | 575 |
| 569 TransformationMatrix rotate_transform; | 576 TransformationMatrix rotate_transform; |
| 570 rotate_transform.Rotate(45); | 577 rotate_transform.Rotate(45); |
| 571 RefPtr<TransformPaintPropertyNode> transform = | 578 RefPtr<TransformPaintPropertyNode> transform = |
| 572 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 579 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 573 rotate_transform, FloatPoint3D()); | 580 rotate_transform, FloatPoint3D()); |
| 574 | 581 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 CHECK_MAPPINGS( | 623 CHECK_MAPPINGS( |
| 617 input, // Input | 624 input, // Input |
| 618 output, // Visual rect | 625 output, // Visual rect |
| 619 rotate_transform.MapRect(input), // Transformed rect (not clipped) | 626 rotate_transform.MapRect(input), // Transformed rect (not clipped) |
| 620 rotate_transform, // Transform matrix to ancestor space | 627 rotate_transform, // Transform matrix to ancestor space |
| 621 FloatClipRect(mapped_clip), // Clip rect in ancestor space | 628 FloatClipRect(mapped_clip), // Clip rect in ancestor space |
| 622 local_state, PropertyTreeState::Root()); | 629 local_state, PropertyTreeState::Root()); |
| 623 } | 630 } |
| 624 } | 631 } |
| 625 | 632 |
| 626 TEST_F(GeometryMapperTest, SiblingTransforms) { | 633 TEST_P(GeometryMapperTest, SiblingTransforms) { |
| 627 // These transforms are siblings. Thus mapping from one to the other requires | 634 // These transforms are siblings. Thus mapping from one to the other requires |
| 628 // going through the root. | 635 // going through the root. |
| 629 TransformationMatrix rotate_transform1; | 636 TransformationMatrix rotate_transform1; |
| 630 rotate_transform1.Rotate(45); | 637 rotate_transform1.Rotate(45); |
| 631 RefPtr<TransformPaintPropertyNode> transform1 = | 638 RefPtr<TransformPaintPropertyNode> transform1 = |
| 632 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 639 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 633 rotate_transform1, FloatPoint3D()); | 640 rotate_transform1, FloatPoint3D()); |
| 634 | 641 |
| 635 TransformationMatrix rotate_transform2; | 642 TransformationMatrix rotate_transform2; |
| 636 rotate_transform2.Rotate(-45); | 643 rotate_transform2.Rotate(-45); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 transform1_state, transform2_state, float_clip_rect); | 688 transform1_state, transform2_state, float_clip_rect); |
| 682 result = float_clip_rect.Rect(); | 689 result = float_clip_rect.Rect(); |
| 683 EXPECT_RECT_EQ(expected, result); | 690 EXPECT_RECT_EQ(expected, result); |
| 684 | 691 |
| 685 result = input; | 692 result = input; |
| 686 GeometryMapper::SourceToDestinationRect(transform1.Get(), transform2.Get(), | 693 GeometryMapper::SourceToDestinationRect(transform1.Get(), transform2.Get(), |
| 687 result); | 694 result); |
| 688 EXPECT_RECT_EQ(expected, result); | 695 EXPECT_RECT_EQ(expected, result); |
| 689 } | 696 } |
| 690 | 697 |
| 691 TEST_F(GeometryMapperTest, SiblingTransformsWithClip) { | 698 TEST_P(GeometryMapperTest, SiblingTransformsWithClip) { |
| 692 // These transforms are siblings. Thus mapping from one to the other requires | 699 // These transforms are siblings. Thus mapping from one to the other requires |
| 693 // going through the root. | 700 // going through the root. |
| 694 TransformationMatrix rotate_transform1; | 701 TransformationMatrix rotate_transform1; |
| 695 rotate_transform1.Rotate(45); | 702 rotate_transform1.Rotate(45); |
| 696 RefPtr<TransformPaintPropertyNode> transform1 = | 703 RefPtr<TransformPaintPropertyNode> transform1 = |
| 697 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 704 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 698 rotate_transform1, FloatPoint3D()); | 705 rotate_transform1, FloatPoint3D()); |
| 699 | 706 |
| 700 TransformationMatrix rotate_transform2; | 707 TransformationMatrix rotate_transform2; |
| 701 rotate_transform2.Rotate(-45); | 708 rotate_transform2.Rotate(-45); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 result = float_clip_rect.Rect(); | 757 result = float_clip_rect.Rect(); |
| 751 EXPECT_RECT_EQ(expected_clipped, result); | 758 EXPECT_RECT_EQ(expected_clipped, result); |
| 752 | 759 |
| 753 // sourceToDestinationRect applies transforms only. | 760 // sourceToDestinationRect applies transforms only. |
| 754 result = input; | 761 result = input; |
| 755 GeometryMapper::SourceToDestinationRect(transform2.Get(), transform1.Get(), | 762 GeometryMapper::SourceToDestinationRect(transform2.Get(), transform1.Get(), |
| 756 result); | 763 result); |
| 757 EXPECT_RECT_EQ(expected_unclipped, result); | 764 EXPECT_RECT_EQ(expected_unclipped, result); |
| 758 } | 765 } |
| 759 | 766 |
| 760 TEST_F(GeometryMapperTest, LowestCommonAncestor) { | 767 TEST_P(GeometryMapperTest, LowestCommonAncestor) { |
| 761 TransformationMatrix matrix; | 768 TransformationMatrix matrix; |
| 762 RefPtr<TransformPaintPropertyNode> child1 = | 769 RefPtr<TransformPaintPropertyNode> child1 = |
| 763 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 770 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 764 matrix, FloatPoint3D()); | 771 matrix, FloatPoint3D()); |
| 765 RefPtr<TransformPaintPropertyNode> child2 = | 772 RefPtr<TransformPaintPropertyNode> child2 = |
| 766 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 773 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 767 matrix, FloatPoint3D()); | 774 matrix, FloatPoint3D()); |
| 768 | 775 |
| 769 RefPtr<TransformPaintPropertyNode> child_of_child1 = | 776 RefPtr<TransformPaintPropertyNode> child_of_child1 = |
| 770 TransformPaintPropertyNode::Create(child1, matrix, FloatPoint3D()); | 777 TransformPaintPropertyNode::Create(child1, matrix, FloatPoint3D()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 786 LowestCommonAncestor(child_of_child2.Get(), child1.Get())); | 793 LowestCommonAncestor(child_of_child2.Get(), child1.Get())); |
| 787 EXPECT_EQ(TransformPaintPropertyNode::Root(), | 794 EXPECT_EQ(TransformPaintPropertyNode::Root(), |
| 788 LowestCommonAncestor(child_of_child2.Get(), | 795 LowestCommonAncestor(child_of_child2.Get(), |
| 789 TransformPaintPropertyNode::Root())); | 796 TransformPaintPropertyNode::Root())); |
| 790 EXPECT_EQ(child2, LowestCommonAncestor(child_of_child2.Get(), child2.Get())); | 797 EXPECT_EQ(child2, LowestCommonAncestor(child_of_child2.Get(), child2.Get())); |
| 791 | 798 |
| 792 EXPECT_EQ(TransformPaintPropertyNode::Root(), | 799 EXPECT_EQ(TransformPaintPropertyNode::Root(), |
| 793 LowestCommonAncestor(child1.Get(), child2.Get())); | 800 LowestCommonAncestor(child1.Get(), child2.Get())); |
| 794 } | 801 } |
| 795 | 802 |
| 796 TEST_F(GeometryMapperTest, FilterWithClipsAndTransforms) { | 803 TEST_P(GeometryMapperTest, FilterWithClipsAndTransforms) { |
| 797 RefPtr<TransformPaintPropertyNode> transform_above_effect = | 804 RefPtr<TransformPaintPropertyNode> transform_above_effect = |
| 798 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), | 805 TransformPaintPropertyNode::Create(TransformPaintPropertyNode::Root(), |
| 799 TransformationMatrix().Scale(3), | 806 TransformationMatrix().Scale(3), |
| 800 FloatPoint3D()); | 807 FloatPoint3D()); |
| 801 RefPtr<TransformPaintPropertyNode> transform_below_effect = | 808 RefPtr<TransformPaintPropertyNode> transform_below_effect = |
| 802 TransformPaintPropertyNode::Create(transform_above_effect, | 809 TransformPaintPropertyNode::Create(transform_above_effect, |
| 803 TransformationMatrix().Scale(2), | 810 TransformationMatrix().Scale(2), |
| 804 FloatPoint3D()); | 811 FloatPoint3D()); |
| 805 | 812 |
| 806 // This clip is between transformAboveEffect and the effect. | 813 // This clip is between transformAboveEffect and the effect. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 EXPECT_EQ(FloatRect(-150, -150, 450, 450), output); | 846 EXPECT_EQ(FloatRect(-150, -150, 450, 450), output); |
| 840 | 847 |
| 841 bool has_radius = false; | 848 bool has_radius = false; |
| 842 TransformationMatrix combined_transform = | 849 TransformationMatrix combined_transform = |
| 843 transform_above_effect->Matrix() * transform_below_effect->Matrix(); | 850 transform_above_effect->Matrix() * transform_below_effect->Matrix(); |
| 844 CHECK_MAPPINGS(input, output, FloatRect(0, 0, 300, 300), combined_transform, | 851 CHECK_MAPPINGS(input, output, FloatRect(0, 0, 300, 300), combined_transform, |
| 845 FloatClipRect(FloatRect(30, 30, 270, 270)), local_state, | 852 FloatClipRect(FloatRect(30, 30, 270, 270)), local_state, |
| 846 PropertyTreeState::Root()); | 853 PropertyTreeState::Root()); |
| 847 } | 854 } |
| 848 | 855 |
| 849 TEST_F(GeometryMapperTest, ReflectionWithPaintOffset) { | 856 TEST_P(GeometryMapperTest, ReflectionWithPaintOffset) { |
| 850 CompositorFilterOperations filters; | 857 CompositorFilterOperations filters; |
| 851 filters.AppendReferenceFilter(SkiaImageFilterBuilder::BuildBoxReflectFilter( | 858 filters.AppendReferenceFilter(SkiaImageFilterBuilder::BuildBoxReflectFilter( |
| 852 BoxReflection(BoxReflection::kHorizontalReflection, 0), nullptr)); | 859 BoxReflection(BoxReflection::kHorizontalReflection, 0), nullptr)); |
| 853 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::Create( | 860 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::Create( |
| 854 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), | 861 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
| 855 ClipPaintPropertyNode::Root(), kColorFilterNone, filters, 1.0, | 862 ClipPaintPropertyNode::Root(), kColorFilterNone, filters, 1.0, |
| 856 SkBlendMode::kSrcOver, kCompositingReasonNone, CompositorElementId(), | 863 SkBlendMode::kSrcOver, kCompositingReasonNone, CompositorElementId(), |
| 857 FloatPoint(100, 100)); | 864 FloatPoint(100, 100)); |
| 858 | 865 |
| 859 PropertyTreeState local_state = PropertyTreeState::Root(); | 866 PropertyTreeState local_state = PropertyTreeState::Root(); |
| 860 local_state.SetEffect(effect); | 867 local_state.SetEffect(effect); |
| 861 | 868 |
| 862 FloatRect input(100, 100, 50, 50); | 869 FloatRect input(100, 100, 50, 50); |
| 863 // Reflection is at (50, 100, 50, 50). | 870 // Reflection is at (50, 100, 50, 50). |
| 864 FloatRect output(50, 100, 100, 50); | 871 FloatRect output(50, 100, 100, 50); |
| 865 | 872 |
| 866 bool has_radius = false; | 873 bool has_radius = false; |
| 867 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(), | 874 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(), |
| 868 local_state, PropertyTreeState::Root()); | 875 local_state, PropertyTreeState::Root()); |
| 869 } | 876 } |
| 870 | 877 |
| 878 TEST_P(GeometryMapperTest, InvertedClip) { |
| 879 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 880 return; |
| 881 |
| 882 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::Create( |
| 883 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
| 884 FloatRoundedRect(10, 10, 50, 50)); |
| 885 |
| 886 PropertyTreeState dest(TransformPaintPropertyNode::Root(), clip.Get(), |
| 887 EffectPaintPropertyNode::Root()); |
| 888 |
| 889 FloatClipRect floatClipRect(FloatRect(0, 0, 10, 200)); |
| 890 GeometryMapper::LocalToAncestorVisualRect(PropertyTreeState::Root(), dest, |
| 891 floatClipRect); |
| 892 |
| 893 // The "ancestor" clip is below the source clip in this case, so |
| 894 // LocalToAncestorVisualRect must fall back to the original rect, mapped |
| 895 // into the root space. |
| 896 EXPECT_EQ(FloatRect(0, 0, 10, 200), floatClipRect.Rect()); |
| 897 } |
| 898 |
| 871 } // namespace blink | 899 } // namespace blink |
| OLD | NEW |