Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

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

Powered by Google App Engine
This is Rietveld 408576698