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/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
6 | 6 |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
11 #include "cc/trees/clip_node.h" | 11 #include "cc/trees/clip_node.h" |
12 #include "cc/trees/effect_node.h" | |
13 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
14 #include "cc/trees/layer_tree_settings.h" | 13 #include "cc/trees/layer_tree_settings.h" |
15 #include "platform/RuntimeEnabledFeatures.h" | 14 #include "platform/RuntimeEnabledFeatures.h" |
16 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | |
17 #include "platform/graphics/paint/PaintArtifact.h" | 15 #include "platform/graphics/paint/PaintArtifact.h" |
18 #include "platform/testing/PictureMatchers.h" | 16 #include "platform/testing/PictureMatchers.h" |
19 #include "platform/testing/TestPaintArtifact.h" | 17 #include "platform/testing/TestPaintArtifact.h" |
20 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 18 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "wtf/PtrUtil.h" | 21 #include "wtf/PtrUtil.h" |
24 #include <memory> | 22 #include <memory> |
25 | 23 |
26 namespace blink { | 24 namespace blink { |
27 namespace { | 25 namespace { |
28 | 26 |
29 using ::testing::Pointee; | 27 using ::testing::Pointee; |
30 | 28 |
31 gfx::Transform translation(SkMScalar x, SkMScalar y) | 29 gfx::Transform translation(SkMScalar x, SkMScalar y) |
32 { | 30 { |
33 gfx::Transform transform; | 31 gfx::Transform transform; |
34 transform.Translate(x, y); | 32 transform.Translate(x, y); |
35 return transform; | 33 return transform; |
36 } | 34 } |
37 | 35 |
38 EffectPaintPropertyNode* dummyRootEffect() | |
39 { | |
40 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, EffectPaintPropertyNode::cr
eate(1.0)); | |
41 return node; | |
42 } | |
43 | |
44 class PaintArtifactCompositorTest : public ::testing::Test { | 36 class PaintArtifactCompositorTest : public ::testing::Test { |
45 protected: | 37 protected: |
46 void SetUp() override | 38 void SetUp() override |
47 { | 39 { |
48 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 40 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
49 | 41 |
50 // Delay constructing the compositor until after the feature is set. | 42 // Delay constructing the compositor until after the feature is set. |
51 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor); | 43 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor); |
52 m_paintArtifactCompositor->enableExtraDataForTesting(); | 44 m_paintArtifactCompositor->enableExtraDataForTesting(); |
53 } | 45 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); | 90 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
99 } | 91 } |
100 | 92 |
101 TEST_F(PaintArtifactCompositorTest, OneTransform) | 93 TEST_F(PaintArtifactCompositorTest, OneTransform) |
102 { | 94 { |
103 // A 90 degree clockwise rotation about (100, 100). | 95 // A 90 degree clockwise rotation about (100, 100). |
104 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( | 96 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( |
105 TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); | 97 TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); |
106 | 98 |
107 TestPaintArtifact artifact; | 99 TestPaintArtifact artifact; |
108 artifact.chunk(transform, nullptr, dummyRootEffect()) | 100 artifact.chunk(transform, nullptr, nullptr) |
109 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 101 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
110 artifact.chunk(nullptr, nullptr, dummyRootEffect()) | 102 artifact.chunk(nullptr, nullptr, nullptr) |
111 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 103 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
112 artifact.chunk(transform, nullptr, dummyRootEffect()) | 104 artifact.chunk(transform, nullptr, nullptr) |
113 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 105 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
114 update(artifact.build()); | 106 update(artifact.build()); |
115 | 107 |
116 ASSERT_EQ(3u, rootLayer()->children().size()); | 108 ASSERT_EQ(3u, rootLayer()->children().size()); |
117 { | 109 { |
118 const cc::Layer* layer = rootLayer()->child_at(0); | 110 const cc::Layer* layer = rootLayer()->child_at(0); |
119 EXPECT_THAT(layer->GetPicture(), | 111 EXPECT_THAT(layer->GetPicture(), |
120 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 112 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
121 gfx::RectF mappedRect(0, 0, 100, 100); | 113 gfx::RectF mappedRect(0, 0, 100, 100); |
122 layer->transform().TransformRect(&mappedRect); | 114 layer->transform().TransformRect(&mappedRect); |
(...skipping 17 matching lines...) Expand all Loading... |
140 | 132 |
141 TEST_F(PaintArtifactCompositorTest, TransformCombining) | 133 TEST_F(PaintArtifactCompositorTest, TransformCombining) |
142 { | 134 { |
143 // A translation by (5, 5) within a 2x scale about (10, 10). | 135 // A translation by (5, 5) within a 2x scale about (10, 10). |
144 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( | 136 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( |
145 TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); | 137 TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); |
146 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( | 138 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( |
147 TransformationMatrix().translate(5, 5), FloatPoint3D(), transform1); | 139 TransformationMatrix().translate(5, 5), FloatPoint3D(), transform1); |
148 | 140 |
149 TestPaintArtifact artifact; | 141 TestPaintArtifact artifact; |
150 artifact.chunk(transform1, nullptr, dummyRootEffect()) | 142 artifact.chunk(transform1, nullptr, nullptr) |
151 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 143 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
152 artifact.chunk(transform2, nullptr, dummyRootEffect()) | 144 artifact.chunk(transform2, nullptr, nullptr) |
153 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 145 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
154 update(artifact.build()); | 146 update(artifact.build()); |
155 | 147 |
156 ASSERT_EQ(2u, rootLayer()->children().size()); | 148 ASSERT_EQ(2u, rootLayer()->children().size()); |
157 { | 149 { |
158 const cc::Layer* layer = rootLayer()->child_at(0); | 150 const cc::Layer* layer = rootLayer()->child_at(0); |
159 EXPECT_THAT(layer->GetPicture(), | 151 EXPECT_THAT(layer->GetPicture(), |
160 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 152 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
161 gfx::RectF mappedRect(0, 0, 300, 200); | 153 gfx::RectF mappedRect(0, 0, 300, 200); |
162 layer->transform().TransformRect(&mappedRect); | 154 layer->transform().TransformRect(&mappedRect); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 216 } |
225 | 217 |
226 TEST_F(PaintArtifactCompositorTest, NestedClips) | 218 TEST_F(PaintArtifactCompositorTest, NestedClips) |
227 { | 219 { |
228 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 220 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
229 nullptr, FloatRoundedRect(100, 100, 700, 700)); | 221 nullptr, FloatRoundedRect(100, 100, 700, 700)); |
230 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 222 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
231 nullptr, FloatRoundedRect(200, 200, 700, 100), clip1); | 223 nullptr, FloatRoundedRect(200, 200, 700, 100), clip1); |
232 | 224 |
233 TestPaintArtifact artifact; | 225 TestPaintArtifact artifact; |
234 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 226 artifact.chunk(nullptr, clip1, nullptr) |
235 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); | 227 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); |
236 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 228 artifact.chunk(nullptr, clip2, nullptr) |
237 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); | 229 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); |
238 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 230 artifact.chunk(nullptr, clip1, nullptr) |
239 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); | 231 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); |
240 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 232 artifact.chunk(nullptr, clip2, nullptr) |
241 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); | 233 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); |
242 update(artifact.build()); | 234 update(artifact.build()); |
243 | 235 |
244 ASSERT_EQ(1u, rootLayer()->children().size()); | 236 ASSERT_EQ(1u, rootLayer()->children().size()); |
245 cc::Layer* clipLayer1 = rootLayer()->child_at(0); | 237 cc::Layer* clipLayer1 = rootLayer()->child_at(0); |
246 EXPECT_TRUE(clipLayer1->masks_to_bounds()); | 238 EXPECT_TRUE(clipLayer1->masks_to_bounds()); |
247 EXPECT_EQ(gfx::Size(700, 700), clipLayer1->bounds()); | 239 EXPECT_EQ(gfx::Size(700, 700), clipLayer1->bounds()); |
248 EXPECT_EQ(translation(100, 100), clipLayer1->transform()); | 240 EXPECT_EQ(translation(100, 100), clipLayer1->transform()); |
249 | 241 |
250 ASSERT_EQ(4u, clipLayer1->children().size()); | 242 ASSERT_EQ(4u, clipLayer1->children().size()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); | 442 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
451 } | 443 } |
452 | 444 |
453 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) | 445 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) |
454 { | 446 { |
455 // A 90 degree clockwise rotation about (100, 100). | 447 // A 90 degree clockwise rotation about (100, 100). |
456 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( | 448 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( |
457 TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); | 449 TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); |
458 | 450 |
459 TestPaintArtifact artifact; | 451 TestPaintArtifact artifact; |
460 artifact.chunk(transform, nullptr, dummyRootEffect()) | 452 artifact.chunk(transform, nullptr, nullptr) |
461 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 453 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
462 artifact.chunk(nullptr, nullptr, dummyRootEffect()) | 454 artifact.chunk(nullptr, nullptr, nullptr) |
463 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 455 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
464 artifact.chunk(transform, nullptr, dummyRootEffect()) | 456 artifact.chunk(transform, nullptr, nullptr) |
465 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 457 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
466 update(artifact.build()); | 458 update(artifact.build()); |
467 | 459 |
468 ASSERT_EQ(3u, contentLayerCount()); | 460 ASSERT_EQ(3u, contentLayerCount()); |
469 { | 461 { |
470 const cc::Layer* layer = contentLayerAt(0); | 462 const cc::Layer* layer = contentLayerAt(0); |
471 EXPECT_THAT(layer->GetPicture(), | 463 EXPECT_THAT(layer->GetPicture(), |
472 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 464 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
473 gfx::RectF mappedRect(0, 0, 100, 100); | 465 gfx::RectF mappedRect(0, 0, 100, 100); |
474 layer->screen_space_transform().TransformRect(&mappedRect); | 466 layer->screen_space_transform().TransformRect(&mappedRect); |
(...skipping 17 matching lines...) Expand all Loading... |
492 | 484 |
493 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) | 485 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) |
494 { | 486 { |
495 // A translation by (5, 5) within a 2x scale about (10, 10). | 487 // A translation by (5, 5) within a 2x scale about (10, 10). |
496 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( | 488 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( |
497 TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); | 489 TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); |
498 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( | 490 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( |
499 TransformationMatrix().translate(5, 5), FloatPoint3D(), transform1); | 491 TransformationMatrix().translate(5, 5), FloatPoint3D(), transform1); |
500 | 492 |
501 TestPaintArtifact artifact; | 493 TestPaintArtifact artifact; |
502 artifact.chunk(transform1, nullptr, dummyRootEffect()) | 494 artifact.chunk(transform1, nullptr, nullptr) |
503 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 495 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
504 artifact.chunk(transform2, nullptr, dummyRootEffect()) | 496 artifact.chunk(transform2, nullptr, nullptr) |
505 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 497 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
506 update(artifact.build()); | 498 update(artifact.build()); |
507 | 499 |
508 ASSERT_EQ(2u, contentLayerCount()); | 500 ASSERT_EQ(2u, contentLayerCount()); |
509 { | 501 { |
510 const cc::Layer* layer = contentLayerAt(0); | 502 const cc::Layer* layer = contentLayerAt(0); |
511 EXPECT_THAT(layer->GetPicture(), | 503 EXPECT_THAT(layer->GetPicture(), |
512 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 504 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
513 gfx::RectF mappedRect(0, 0, 300, 200); | 505 gfx::RectF mappedRect(0, 0, 300, 200); |
514 layer->screen_space_transform().TransformRect(&mappedRect); | 506 layer->screen_space_transform().TransformRect(&mappedRect); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 } | 542 } |
551 | 543 |
552 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) | 544 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) |
553 { | 545 { |
554 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 546 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
555 nullptr, FloatRoundedRect(100, 100, 700, 700)); | 547 nullptr, FloatRoundedRect(100, 100, 700, 700)); |
556 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 548 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
557 nullptr, FloatRoundedRect(200, 200, 700, 100), clip1); | 549 nullptr, FloatRoundedRect(200, 200, 700, 100), clip1); |
558 | 550 |
559 TestPaintArtifact artifact; | 551 TestPaintArtifact artifact; |
560 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 552 artifact.chunk(nullptr, clip1, nullptr) |
561 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); | 553 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); |
562 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 554 artifact.chunk(nullptr, clip2, nullptr) |
563 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); | 555 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); |
564 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 556 artifact.chunk(nullptr, clip1, nullptr) |
565 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); | 557 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); |
566 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 558 artifact.chunk(nullptr, clip2, nullptr) |
567 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); | 559 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); |
568 update(artifact.build()); | 560 update(artifact.build()); |
569 | 561 |
570 ASSERT_EQ(4u, contentLayerCount()); | 562 ASSERT_EQ(4u, contentLayerCount()); |
571 | 563 |
572 const cc::Layer* whiteLayer = contentLayerAt(0); | 564 const cc::Layer* whiteLayer = contentLayerAt(0); |
573 EXPECT_THAT(whiteLayer->GetPicture(), | 565 EXPECT_THAT(whiteLayer->GetPicture(), |
574 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 566 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
575 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); | 567 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); |
576 | 568 |
(...skipping 29 matching lines...) Expand all Loading... |
606 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) | 598 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) |
607 { | 599 { |
608 Vector<RefPtr<ClipPaintPropertyNode>> clips; | 600 Vector<RefPtr<ClipPaintPropertyNode>> clips; |
609 for (unsigned i = 1; i <= 10; i++) { | 601 for (unsigned i = 1; i <= 10; i++) { |
610 clips.append(ClipPaintPropertyNode::create( | 602 clips.append(ClipPaintPropertyNode::create( |
611 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i), | 603 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i), |
612 clips.isEmpty() ? nullptr : clips.last())); | 604 clips.isEmpty() ? nullptr : clips.last())); |
613 } | 605 } |
614 | 606 |
615 TestPaintArtifact artifact; | 607 TestPaintArtifact artifact; |
616 artifact.chunk(nullptr, clips.last(), dummyRootEffect()) | 608 artifact.chunk(nullptr, clips.last(), nullptr) |
617 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); | 609 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); |
618 update(artifact.build()); | 610 update(artifact.build()); |
619 | 611 |
620 // Check the drawing layer. | 612 // Check the drawing layer. |
621 ASSERT_EQ(1u, contentLayerCount()); | 613 ASSERT_EQ(1u, contentLayerCount()); |
622 const cc::Layer* drawingLayer = contentLayerAt(0); | 614 const cc::Layer* drawingLayer = contentLayerAt(0); |
623 EXPECT_THAT(drawingLayer->GetPicture(), | 615 EXPECT_THAT(drawingLayer->GetPicture(), |
624 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); | 616 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); |
625 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); | 617 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); |
626 | 618 |
(...skipping 11 matching lines...) Expand all Loading... |
638 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) | 630 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) |
639 { | 631 { |
640 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( | 632 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( |
641 nullptr, FloatRoundedRect(0, 0, 800, 600)); | 633 nullptr, FloatRoundedRect(0, 0, 800, 600)); |
642 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 634 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
643 nullptr, FloatRoundedRect(0, 0, 400, 600), commonClip); | 635 nullptr, FloatRoundedRect(0, 0, 400, 600), commonClip); |
644 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 636 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
645 nullptr, FloatRoundedRect(400, 0, 400, 600), commonClip); | 637 nullptr, FloatRoundedRect(400, 0, 400, 600), commonClip); |
646 | 638 |
647 TestPaintArtifact artifact; | 639 TestPaintArtifact artifact; |
648 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 640 artifact.chunk(nullptr, clip1, nullptr) |
649 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); | 641 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); |
650 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 642 artifact.chunk(nullptr, clip2, nullptr) |
651 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); | 643 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); |
652 update(artifact.build()); | 644 update(artifact.build()); |
653 | 645 |
654 ASSERT_EQ(2u, contentLayerCount()); | 646 ASSERT_EQ(2u, contentLayerCount()); |
655 | 647 |
656 const cc::Layer* whiteLayer = contentLayerAt(0); | 648 const cc::Layer* whiteLayer = contentLayerAt(0); |
657 EXPECT_THAT(whiteLayer->GetPicture(), | 649 EXPECT_THAT(whiteLayer->GetPicture(), |
658 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); | 650 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); |
659 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); | 651 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); |
660 const cc::ClipNode* whiteClip = propertyTrees().clip_tree.Node(whiteLayer->c
lip_tree_index()); | 652 const cc::ClipNode* whiteClip = propertyTrees().clip_tree.Node(whiteLayer->c
lip_tree_index()); |
(...skipping 25 matching lines...) Expand all Loading... |
686 artifact.chunk(PaintChunkProperties()) | 678 artifact.chunk(PaintChunkProperties()) |
687 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); | 679 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); |
688 update(artifact.build()); | 680 update(artifact.build()); |
689 | 681 |
690 ASSERT_EQ(1u, contentLayerCount()); | 682 ASSERT_EQ(1u, contentLayerCount()); |
691 EXPECT_EQ(layer, contentLayerAt(0)); | 683 EXPECT_EQ(layer, contentLayerAt(0)); |
692 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); | 684 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); |
693 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); | 685 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); |
694 } | 686 } |
695 | 687 |
696 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) | |
697 { | |
698 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create(0.
5, dummyRootEffect()); | |
699 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create(0.
3, effect1.get()); | |
700 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create(0.
2, dummyRootEffect()); | |
701 | |
702 TestPaintArtifact artifact; | |
703 artifact.chunk(nullptr, nullptr, effect2.get()) | |
704 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | |
705 artifact.chunk(nullptr, nullptr, effect1.get()) | |
706 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | |
707 artifact.chunk(nullptr, nullptr, effect3.get()) | |
708 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | |
709 update(artifact.build()); | |
710 | |
711 ASSERT_EQ(3u, contentLayerCount()); | |
712 | |
713 const cc::EffectTree& effectTree = propertyTrees().effect_tree; | |
714 // Node #0 reserved for null; #1 for root render surface; #2 for dummyRootEf
fect, | |
715 // plus 3 nodes for those created by this test. | |
716 ASSERT_EQ(6u, effectTree.size()); | |
717 | |
718 const cc::EffectNode& convertedDummyRootEffect = *effectTree.Node(2); | |
719 EXPECT_EQ(1, convertedDummyRootEffect.parent_id); | |
720 | |
721 const cc::EffectNode& convertedEffect1 = *effectTree.Node(3); | |
722 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect1.parent_id); | |
723 EXPECT_FLOAT_EQ(0.5, convertedEffect1.opacity); | |
724 | |
725 const cc::EffectNode& convertedEffect2 = *effectTree.Node(4); | |
726 EXPECT_EQ(convertedEffect1.id, convertedEffect2.parent_id); | |
727 EXPECT_FLOAT_EQ(0.3, convertedEffect2.opacity); | |
728 | |
729 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5); | |
730 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); | |
731 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); | |
732 | |
733 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); | |
734 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); | |
735 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); | |
736 } | |
737 | |
738 } // namespace | 688 } // namespace |
739 } // namespace blink | 689 } // namespace blink |
OLD | NEW |