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