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

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

Issue 2307143002: Remove non-layer-list codepath from PaintArtifactCompositor (Closed)
Patch Set: Formatting cleanup Created 4 years, 3 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
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/test/geometry_test_utils.h" 11 #include "cc/test/geometry_test_utils.h"
12 #include "cc/trees/clip_node.h" 12 #include "cc/trees/clip_node.h"
13 #include "cc/trees/effect_node.h" 13 #include "cc/trees/effect_node.h"
14 #include "cc/trees/layer_tree_host.h" 14 #include "cc/trees/layer_tree_host.h"
15 #include "cc/trees/layer_tree_settings.h"
16 #include "cc/trees/transform_node.h" 15 #include "cc/trees/transform_node.h"
17 #include "platform/RuntimeEnabledFeatures.h" 16 #include "platform/RuntimeEnabledFeatures.h"
18 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 17 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
19 #include "platform/graphics/paint/PaintArtifact.h" 18 #include "platform/graphics/paint/PaintArtifact.h"
20 #include "platform/testing/PictureMatchers.h" 19 #include "platform/testing/PictureMatchers.h"
21 #include "platform/testing/TestPaintArtifact.h" 20 #include "platform/testing/TestPaintArtifact.h"
22 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 21 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
23 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
25 #include "wtf/PtrUtil.h"
26 #include <memory> 24 #include <memory>
27 25
28 namespace blink { 26 namespace blink {
29 namespace { 27 namespace {
30 28
31 using ::testing::Pointee; 29 using ::testing::Pointee;
32 30
33 gfx::Transform translation(SkMScalar x, SkMScalar y) 31 gfx::Transform translation(SkMScalar x, SkMScalar y)
34 { 32 {
35 gfx::Transform transform; 33 gfx::Transform transform;
36 transform.Translate(x, y); 34 transform.Translate(x, y);
37 return transform; 35 return transform;
38 } 36 }
39 37
40 EffectPaintPropertyNode* dummyRootEffect() 38 EffectPaintPropertyNode* dummyRootEffect()
41 { 39 {
42 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, EffectPaintPropertyNode::cr eate(nullptr, 1.0)); 40 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, EffectPaintPropertyNode::cr eate(nullptr, 1.0));
43 return node; 41 return node;
44 } 42 }
45 43
46 class PaintArtifactCompositorTest : public ::testing::Test {
47 protected:
48 void SetUp() override
49 {
50 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
51
52 // Delay constructing the compositor until after the feature is set.
53 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor);
54 m_paintArtifactCompositor->enableExtraDataForTesting();
55 }
56
57 void TearDown() override
58 {
59 m_featuresBackup.restore();
60 }
61
62 PaintArtifactCompositor& getPaintArtifactCompositor() { return *m_paintArtif actCompositor; }
63 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); }
64 void update(const PaintArtifact& artifact) { m_paintArtifactCompositor->upda te(artifact); }
65
66 size_t contentLayerCount()
67 {
68 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer s.size();
69 }
70
71 cc::Layer* contentLayerAt(unsigned index)
72 {
73 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer s[index].get();
74 }
75
76 private:
77 RuntimeEnabledFeatures::Backup m_featuresBackup;
78 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor;
79 };
80
81 TEST_F(PaintArtifactCompositorTest, EmptyPaintArtifact)
82 {
83 PaintArtifact emptyArtifact;
84 update(emptyArtifact);
85 EXPECT_TRUE(rootLayer()->children().empty());
86 }
87
88 TEST_F(PaintArtifactCompositorTest, OneChunkWithAnOffset)
89 {
90 TestPaintArtifact artifact;
91 artifact.chunk(PaintChunkProperties())
92 .rectDrawing(FloatRect(50, -50, 100, 100), Color::white);
93 update(artifact.build());
94
95 ASSERT_EQ(1u, rootLayer()->children().size());
96 const cc::Layer* child = rootLayer()->child_at(0);
97 EXPECT_THAT(child->GetPicture(),
98 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
99 EXPECT_EQ(translation(50, -50), child->transform());
100 EXPECT_EQ(gfx::Size(100, 100), child->bounds());
101 }
102
103 TEST_F(PaintArtifactCompositorTest, OneTransform)
104 {
105 // A 90 degree clockwise rotation about (100, 100).
106 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(
107 nullptr, TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0));
108
109 TestPaintArtifact artifact;
110 artifact.chunk(transform, nullptr, dummyRootEffect())
111 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
112 artifact.chunk(nullptr, nullptr, dummyRootEffect())
113 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray);
114 artifact.chunk(transform, nullptr, dummyRootEffect())
115 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black);
116 update(artifact.build());
117
118 ASSERT_EQ(3u, rootLayer()->children().size());
119 {
120 const cc::Layer* layer = rootLayer()->child_at(0);
121 EXPECT_THAT(layer->GetPicture(),
122 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
123 gfx::RectF mappedRect(0, 0, 100, 100);
124 layer->transform().TransformRect(&mappedRect);
125 EXPECT_EQ(gfx::RectF(100, 0, 100, 100), mappedRect);
126 }
127 {
128 const cc::Layer* layer = rootLayer()->child_at(1);
129 EXPECT_THAT(layer->GetPicture(),
130 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::gray)));
131 EXPECT_EQ(gfx::Transform(), layer->transform());
132 }
133 {
134 const cc::Layer* layer = rootLayer()->child_at(2);
135 EXPECT_THAT(layer->GetPicture(),
136 Pointee(drawsRectangle(FloatRect(0, 0, 200, 100), Color::black)));
137 gfx::RectF mappedRect(0, 0, 200, 100);
138 layer->transform().TransformRect(&mappedRect);
139 EXPECT_EQ(gfx::RectF(0, 100, 100, 200), mappedRect);
140 }
141 }
142
143 TEST_F(PaintArtifactCompositorTest, TransformCombining)
144 {
145 // A translation by (5, 5) within a 2x scale about (10, 10).
146 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode:: create(
147 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0));
148 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode:: create(
149 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D());
150
151 TestPaintArtifact artifact;
152 artifact.chunk(transform1, nullptr, dummyRootEffect())
153 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white);
154 artifact.chunk(transform2, nullptr, dummyRootEffect())
155 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black);
156 update(artifact.build());
157
158 ASSERT_EQ(2u, rootLayer()->children().size());
159 {
160 const cc::Layer* layer = rootLayer()->child_at(0);
161 EXPECT_THAT(layer->GetPicture(),
162 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white)));
163 gfx::RectF mappedRect(0, 0, 300, 200);
164 layer->transform().TransformRect(&mappedRect);
165 EXPECT_EQ(gfx::RectF(-10, -10, 600, 400), mappedRect);
166 }
167 {
168 const cc::Layer* layer = rootLayer()->child_at(1);
169 EXPECT_THAT(layer->GetPicture(),
170 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black)));
171 gfx::RectF mappedRect(0, 0, 300, 200);
172 layer->transform().TransformRect(&mappedRect);
173 EXPECT_EQ(gfx::RectF(0, 0, 600, 400), mappedRect);
174 }
175 }
176
177 TEST_F(PaintArtifactCompositorTest, LayerOriginCancellation)
178 {
179 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
180 nullptr, nullptr, FloatRoundedRect(100, 100, 100, 100));
181 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(
182 nullptr, TransformationMatrix().scale(2), FloatPoint3D());
183
184 TestPaintArtifact artifact;
185 artifact.chunk(transform, clip, nullptr)
186 .rectDrawing(FloatRect(12, 34, 56, 78), Color::white);
187 update(artifact.build());
188
189 ASSERT_EQ(1u, rootLayer()->children().size());
190 cc::Layer* clipLayer = rootLayer()->child_at(0);
191 EXPECT_EQ(gfx::Size(100, 100), clipLayer->bounds());
192 EXPECT_EQ(translation(100, 100), clipLayer->transform());
193 EXPECT_TRUE(clipLayer->masks_to_bounds());
194
195 ASSERT_EQ(1u, clipLayer->children().size());
196 cc::Layer* layer = clipLayer->child_at(0);
197 EXPECT_EQ(gfx::Size(56, 78), layer->bounds());
198 gfx::Transform expectedTransform;
199 expectedTransform.Translate(-100, -100);
200 expectedTransform.Scale(2, 2);
201 expectedTransform.Translate(12, 34);
202 EXPECT_EQ(expectedTransform, layer->transform());
203 }
204
205 TEST_F(PaintArtifactCompositorTest, OneClip)
206 {
207 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
208 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200));
209
210 TestPaintArtifact artifact;
211 artifact.chunk(nullptr, clip, nullptr)
212 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black);
213 update(artifact.build());
214
215 ASSERT_EQ(1u, rootLayer()->children().size());
216 cc::Layer* clipLayer = rootLayer()->child_at(0);
217 EXPECT_TRUE(clipLayer->masks_to_bounds());
218 EXPECT_EQ(gfx::Size(300, 200), clipLayer->bounds());
219 EXPECT_EQ(translation(100, 100), clipLayer->transform());
220
221 ASSERT_EQ(1u, clipLayer->children().size());
222 const cc::Layer* layer = clipLayer->child_at(0);
223 EXPECT_THAT(layer->GetPicture(),
224 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black)));
225 EXPECT_EQ(translation(120, -20), layer->transform());
226 }
227
228 TEST_F(PaintArtifactCompositorTest, NestedClips)
229 {
230 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
231 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700));
232 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
233 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100));
234
235 TestPaintArtifact artifact;
236 artifact.chunk(nullptr, clip1, dummyRootEffect())
237 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white);
238 artifact.chunk(nullptr, clip2, dummyRootEffect())
239 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray);
240 artifact.chunk(nullptr, clip1, dummyRootEffect())
241 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray);
242 artifact.chunk(nullptr, clip2, dummyRootEffect())
243 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black);
244 update(artifact.build());
245
246 ASSERT_EQ(1u, rootLayer()->children().size());
247 cc::Layer* clipLayer1 = rootLayer()->child_at(0);
248 EXPECT_TRUE(clipLayer1->masks_to_bounds());
249 EXPECT_EQ(gfx::Size(700, 700), clipLayer1->bounds());
250 EXPECT_EQ(translation(100, 100), clipLayer1->transform());
251
252 ASSERT_EQ(4u, clipLayer1->children().size());
253 {
254 const cc::Layer* whiteLayer = clipLayer1->child_at(0);
255 EXPECT_THAT(whiteLayer->GetPicture(),
256 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
257 EXPECT_EQ(translation(200, 250), whiteLayer->transform());
258 }
259 {
260 cc::Layer* lightGrayClip = clipLayer1->child_at(1);
261 EXPECT_TRUE(lightGrayClip->masks_to_bounds());
262 EXPECT_EQ(gfx::Size(700, 100), lightGrayClip->bounds());
263 EXPECT_EQ(translation(100, 100), lightGrayClip->transform());
264 ASSERT_EQ(1u, lightGrayClip->children().size());
265 const cc::Layer* lightGrayLayer = lightGrayClip->child_at(0);
266 EXPECT_THAT(lightGrayLayer->GetPicture(),
267 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::lightGray)) );
268 EXPECT_EQ(translation(100, 150), lightGrayLayer->transform());
269 }
270 {
271 const cc::Layer* darkGrayLayer = clipLayer1->child_at(2);
272 EXPECT_THAT(darkGrayLayer->GetPicture(),
273 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::darkGray))) ;
274 EXPECT_EQ(translation(200, 250), darkGrayLayer->transform());
275 }
276 {
277 cc::Layer* blackClip = clipLayer1->child_at(3);
278 EXPECT_TRUE(blackClip->masks_to_bounds());
279 EXPECT_EQ(gfx::Size(700, 100), blackClip->bounds());
280 EXPECT_EQ(translation(100, 100), blackClip->transform());
281 ASSERT_EQ(1u, blackClip->children().size());
282 const cc::Layer* blackLayer = blackClip->child_at(0);
283 EXPECT_THAT(blackLayer->GetPicture(),
284 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::black)));
285 EXPECT_EQ(translation(100, 150), blackLayer->transform());
286 }
287 }
288
289 TEST_F(PaintArtifactCompositorTest, DeeplyNestedClips)
290 {
291 Vector<RefPtr<ClipPaintPropertyNode>> clips;
292 for (unsigned i = 1; i <= 10; i++) {
293 clips.append(ClipPaintPropertyNode::create(
294 clips.isEmpty() ? nullptr : clips.last(),
295 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i)));
296 }
297
298 TestPaintArtifact artifact;
299 artifact.chunk(nullptr, clips.last(), nullptr)
300 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white);
301 update(artifact.build());
302
303 // Check the clip layers.
304 cc::Layer* layer = rootLayer();
305 for (const auto& clipNode : clips) {
306 ASSERT_EQ(1u, layer->children().size());
307 layer = layer->child_at(0);
308 EXPECT_EQ(clipNode->clipRect().rect().width(), layer->bounds().width());
309 EXPECT_EQ(clipNode->clipRect().rect().height(), layer->bounds().height() );
310 EXPECT_EQ(translation(5, 0), layer->transform());
311 }
312
313 // Check the drawing layer.
314 ASSERT_EQ(1u, layer->children().size());
315 cc::Layer* drawingLayer = layer->child_at(0);
316 EXPECT_THAT(drawingLayer->GetPicture(),
317 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white)));
318 EXPECT_EQ(translation(-50, 0), drawingLayer->transform());
319 }
320
321 TEST_F(PaintArtifactCompositorTest, SiblingClips)
322 {
323 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create(
324 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600));
325 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
326 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600));
327 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
328 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600));
329
330 TestPaintArtifact artifact;
331 artifact.chunk(nullptr, clip1, nullptr)
332 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white);
333 artifact.chunk(nullptr, clip2, nullptr)
334 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black);
335 update(artifact.build());
336
337 ASSERT_EQ(1u, rootLayer()->children().size());
338 cc::Layer* commonClipLayer = rootLayer()->child_at(0);
339 EXPECT_TRUE(commonClipLayer->masks_to_bounds());
340 EXPECT_EQ(gfx::Size(800, 600), commonClipLayer->bounds());
341 EXPECT_EQ(gfx::Transform(), commonClipLayer->transform());
342 ASSERT_EQ(2u, commonClipLayer->children().size());
343 {
344 cc::Layer* clipLayer1 = commonClipLayer->child_at(0);
345 EXPECT_TRUE(clipLayer1->masks_to_bounds());
346 EXPECT_EQ(gfx::Size(400, 600), clipLayer1->bounds());
347 EXPECT_EQ(gfx::Transform(), clipLayer1->transform());
348 ASSERT_EQ(1u, clipLayer1->children().size());
349 cc::Layer* whiteLayer = clipLayer1->child_at(0);
350 EXPECT_THAT(whiteLayer->GetPicture(),
351 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white)));
352 EXPECT_EQ(gfx::Transform(), whiteLayer->transform());
353 }
354 {
355 cc::Layer* clipLayer2 = commonClipLayer->child_at(1);
356 EXPECT_TRUE(clipLayer2->masks_to_bounds());
357 EXPECT_EQ(gfx::Size(400, 600), clipLayer2->bounds());
358 EXPECT_EQ(translation(400, 0), clipLayer2->transform());
359 ASSERT_EQ(1u, clipLayer2->children().size());
360 cc::Layer* blackLayer = clipLayer2->child_at(0);
361 EXPECT_THAT(blackLayer->GetPicture(),
362 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::black)));
363 EXPECT_EQ(translation(-400, 0), blackLayer->transform());
364 }
365 }
366
367 TEST_F(PaintArtifactCompositorTest, ForeignLayerPassesThrough)
368 {
369 scoped_refptr<cc::Layer> layer = cc::Layer::Create();
370
371 TestPaintArtifact artifact;
372 artifact.chunk(PaintChunkProperties())
373 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer);
374 update(artifact.build());
375
376 ASSERT_EQ(1u, rootLayer()->children().size());
377 EXPECT_EQ(layer, rootLayer()->child_at(0));
378 EXPECT_EQ(gfx::Size(400, 300), layer->bounds());
379 EXPECT_EQ(translation(50, 100), layer->transform());
380 }
381
382 // Similar to the above, but for the path where we build cc property trees
383 // directly. This will eventually supersede the above.
384
385 class WebLayerTreeViewWithOutputSurface : public WebLayerTreeViewImplForTesting { 44 class WebLayerTreeViewWithOutputSurface : public WebLayerTreeViewImplForTesting {
386 public: 45 public:
387 WebLayerTreeViewWithOutputSurface(const cc::LayerTreeSettings& settings) 46 WebLayerTreeViewWithOutputSurface(const cc::LayerTreeSettings& settings)
388 : WebLayerTreeViewImplForTesting(settings) {} 47 : WebLayerTreeViewImplForTesting(settings) {}
389 48
390 // cc::LayerTreeHostClient 49 // cc::LayerTreeHostClient
391 void RequestNewOutputSurface() override 50 void RequestNewOutputSurface() override
392 { 51 {
393 layerTreeHost()->SetOutputSurface(cc::FakeOutputSurface::CreateDelegatin g3d()); 52 layerTreeHost()->SetOutputSurface(cc::FakeOutputSurface::CreateDelegatin g3d());
394 } 53 }
395 }; 54 };
396 55
397 class PaintArtifactCompositorTestWithPropertyTrees : public PaintArtifactComposi torTest { 56 class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test {
398 protected: 57 protected:
399 PaintArtifactCompositorTestWithPropertyTrees() 58 PaintArtifactCompositorTestWithPropertyTrees()
400 : m_taskRunner(new base::TestSimpleTaskRunner) 59 : m_taskRunner(new base::TestSimpleTaskRunner)
401 , m_taskRunnerHandle(m_taskRunner) 60 , m_taskRunnerHandle(m_taskRunner)
402 { 61 {
403 } 62 }
404 63
405 void SetUp() override 64 void SetUp() override
406 { 65 {
407 PaintArtifactCompositorTest::SetUp(); 66 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
67
68 // Delay constructing the compositor until after the feature is set.
69 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor);
70 m_paintArtifactCompositor->enableExtraDataForTesting();
408 71
409 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default LayerTreeSettings(); 72 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default LayerTreeSettings();
410 settings.single_thread_proxy_scheduler = false; 73 settings.single_thread_proxy_scheduler = false;
411 settings.use_layer_lists = true; 74 settings.use_layer_lists = true;
412 m_webLayerTreeView = wrapUnique(new WebLayerTreeViewWithOutputSurface(se ttings)); 75 m_webLayerTreeView = wrapUnique(new WebLayerTreeViewWithOutputSurface(se ttings));
413 m_webLayerTreeView->setRootLayer(*getPaintArtifactCompositor().getWebLay er()); 76 m_webLayerTreeView->setRootLayer(*m_paintArtifactCompositor->getWebLayer ());
77 }
78
79 void TearDown() override
80 {
81 m_featuresBackup.restore();
414 } 82 }
415 83
416 const cc::PropertyTrees& propertyTrees() 84 const cc::PropertyTrees& propertyTrees()
417 { 85 {
418 return *m_webLayerTreeView->layerTreeHost()->GetLayerTree()->property_tr ees(); 86 return *m_webLayerTreeView->layerTreeHost()->GetLayerTree()->property_tr ees();
419 } 87 }
420 88
421 const cc::TransformNode& transformNode(const cc::Layer* layer) 89 const cc::TransformNode& transformNode(const cc::Layer* layer)
422 { 90 {
423 return *propertyTrees().transform_tree.Node(layer->transform_tree_index( )); 91 return *propertyTrees().transform_tree.Node(layer->transform_tree_index( ));
424 } 92 }
425 93
426 void update(const PaintArtifact& artifact) 94 void update(const PaintArtifact& artifact)
427 { 95 {
428 PaintArtifactCompositorTest::update(artifact); 96 m_paintArtifactCompositor->update(artifact);
429 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers(); 97 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers();
430 } 98 }
431 99
100 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); }
101
102 size_t contentLayerCount()
103 {
104 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer s.size();
105 }
106
107 cc::Layer* contentLayerAt(unsigned index)
108 {
109 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer s[index].get();
110 }
111
432 private: 112 private:
113 RuntimeEnabledFeatures::Backup m_featuresBackup;
114 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor;
433 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; 115 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner;
434 base::ThreadTaskRunnerHandle m_taskRunnerHandle; 116 base::ThreadTaskRunnerHandle m_taskRunnerHandle;
435 std::unique_ptr<WebLayerTreeViewWithOutputSurface> m_webLayerTreeView; 117 std::unique_ptr<WebLayerTreeViewWithOutputSurface> m_webLayerTreeView;
436 }; 118 };
437 119
438 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) 120 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact)
439 { 121 {
440 PaintArtifact emptyArtifact; 122 PaintArtifact emptyArtifact;
441 update(emptyArtifact); 123 update(emptyArtifact);
442 EXPECT_TRUE(rootLayer()->children().empty()); 124 EXPECT_TRUE(rootLayer()->children().empty());
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); 532 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id);
851 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); 533 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity);
852 534
853 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); 535 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index());
854 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); 536 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index());
855 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); 537 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index());
856 } 538 }
857 539
858 } // namespace 540 } // namespace
859 } // namespace blink 541 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698