| 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/paint/ClipPaintPropertyNode.h" | 9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 FloatRect expected = rotateTransform2.inverse().mapRect(rotateTransform1.map
Rect(input)); | 383 FloatRect expected = rotateTransform2.inverse().mapRect(rotateTransform1.map
Rect(input)); |
| 384 result = geometryMapper->mapToVisualRectInDestinationSpace(input, transform1
State, transform2State, success); | 384 result = geometryMapper->mapToVisualRectInDestinationSpace(input, transform1
State, transform2State, success); |
| 385 EXPECT_TRUE(success); | 385 EXPECT_TRUE(success); |
| 386 EXPECT_RECT_EQ(expected, result); | 386 EXPECT_RECT_EQ(expected, result); |
| 387 | 387 |
| 388 result = geometryMapper->mapRectToDestinationSpace(input, transform1State, t
ransform2State, success); | 388 result = geometryMapper->mapRectToDestinationSpace(input, transform1State, t
ransform2State, success); |
| 389 EXPECT_TRUE(success); | 389 EXPECT_TRUE(success); |
| 390 EXPECT_RECT_EQ(expected, result); | 390 EXPECT_RECT_EQ(expected, result); |
| 391 } | 391 } |
| 392 | 392 |
| 393 TEST_F(GeometryMapperTest, SiblingTransformsWithClip) |
| 394 { |
| 395 // These transforms are siblings. Thus mapping from one to the other require
s going through the root. |
| 396 TransformationMatrix rotateTransform1; |
| 397 rotateTransform1.rotate(45); |
| 398 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create(rootPropertyTreeState().transform, rotateTransform1, FloatPoint3D()); |
| 399 |
| 400 TransformationMatrix rotateTransform2; |
| 401 rotateTransform2.rotate(-45); |
| 402 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create(rootPropertyTreeState().transform, rotateTransform2, FloatPoint3D()); |
| 403 |
| 404 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootPrope
rtyTreeState().clip, transform2.get(), FloatRoundedRect(10, 10, 70, 70)); |
| 405 |
| 406 PropertyTreeState transform1State = rootPropertyTreeState(); |
| 407 transform1State.transform = transform1; |
| 408 PropertyTreeState transform2AndClipState = rootPropertyTreeState(); |
| 409 transform2AndClipState.transform = transform2; |
| 410 transform2AndClipState.clip = clip; |
| 411 |
| 412 bool success; |
| 413 FloatRect input(0, 0, 100, 100); |
| 414 |
| 415 // Test map from transform1State to transform2AndClipState. |
| 416 FloatRect expected = rotateTransform2.inverse().mapRect(rotateTransform1.map
Rect(input)); |
| 417 |
| 418 // mapToVisualRectInDestinationSpace ignores clip from the common ancestor t
o destination. |
| 419 FloatRect result = geometryMapper->mapToVisualRectInDestinationSpace(input,
transform1State, transform2AndClipState, success); |
| 420 // Fails, because the clip of the destination state is not an ancestor of th
e clip of the source state. |
| 421 EXPECT_FALSE(success); |
| 422 |
| 423 // mapRectToDestinationSpace ignores clip. |
| 424 result = geometryMapper->mapRectToDestinationSpace(input, transform1State, t
ransform2AndClipState, success); |
| 425 EXPECT_TRUE(success); |
| 426 EXPECT_RECT_EQ(expected, result); |
| 427 |
| 428 // Test map from transform2AndClipState to transform1State. |
| 429 FloatRect expectedUnclipped = rotateTransform1.inverse().mapRect(rotateTrans
form2.mapRect(input)); |
| 430 FloatRect expectedClipped = rotateTransform1.inverse().mapRect(rotateTransfo
rm2.mapRect(FloatRect(10, 10, 70, 70))); |
| 431 |
| 432 // mapToVisualRectInDestinationSpace ignores clip from the common ancestor t
o destination. |
| 433 result = geometryMapper->mapToVisualRectInDestinationSpace(input, transform2
AndClipState, transform1State, success); |
| 434 EXPECT_TRUE(success); |
| 435 EXPECT_RECT_EQ(expectedClipped, result); |
| 436 |
| 437 // mapRectToDestinationSpace ignores clip. |
| 438 result = geometryMapper->mapRectToDestinationSpace(input, transform2AndClipS
tate, transform1State, success); |
| 439 EXPECT_TRUE(success); |
| 440 EXPECT_RECT_EQ(expectedUnclipped, result); |
| 441 } |
| 442 |
| 393 } // namespace blink | 443 } // namespace blink |
| OLD | NEW |