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/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/scroll_node.h" |
15 #include "cc/trees/transform_node.h" | 16 #include "cc/trees/transform_node.h" |
16 #include "platform/RuntimeEnabledFeatures.h" | 17 #include "platform/RuntimeEnabledFeatures.h" |
17 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 18 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
18 #include "platform/graphics/paint/PaintArtifact.h" | 19 #include "platform/graphics/paint/PaintArtifact.h" |
| 20 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
19 #include "platform/testing/PictureMatchers.h" | 21 #include "platform/testing/PictureMatchers.h" |
20 #include "platform/testing/TestPaintArtifact.h" | 22 #include "platform/testing/TestPaintArtifact.h" |
21 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 23 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
24 #include <memory> | 26 #include <memory> |
25 | 27 |
26 namespace blink { | 28 namespace blink { |
27 namespace { | 29 namespace { |
28 | 30 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); | 141 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
140 } | 142 } |
141 | 143 |
142 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) | 144 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) |
143 { | 145 { |
144 // A 90 degree clockwise rotation about (100, 100). | 146 // A 90 degree clockwise rotation about (100, 100). |
145 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( | 147 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( |
146 nullptr, TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); | 148 nullptr, TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); |
147 | 149 |
148 TestPaintArtifact artifact; | 150 TestPaintArtifact artifact; |
149 artifact.chunk(transform, nullptr, dummyRootEffect()) | 151 artifact.chunk(transform, nullptr, dummyRootEffect(), nullptr) |
150 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 152 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
151 artifact.chunk(nullptr, nullptr, dummyRootEffect()) | 153 artifact.chunk(nullptr, nullptr, dummyRootEffect(), nullptr) |
152 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 154 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
153 artifact.chunk(transform, nullptr, dummyRootEffect()) | 155 artifact.chunk(transform, nullptr, dummyRootEffect(), nullptr) |
154 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 156 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
155 update(artifact.build()); | 157 update(artifact.build()); |
156 | 158 |
157 ASSERT_EQ(3u, contentLayerCount()); | 159 ASSERT_EQ(3u, contentLayerCount()); |
158 { | 160 { |
159 const cc::Layer* layer = contentLayerAt(0); | 161 const cc::Layer* layer = contentLayerAt(0); |
160 EXPECT_THAT(layer->GetPicture(), | 162 EXPECT_THAT(layer->GetPicture(), |
161 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 163 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
162 gfx::RectF mappedRect(0, 0, 100, 100); | 164 gfx::RectF mappedRect(0, 0, 100, 100); |
163 layer->screen_space_transform().TransformRect(&mappedRect); | 165 layer->screen_space_transform().TransformRect(&mappedRect); |
(...skipping 17 matching lines...) Expand all Loading... |
181 | 183 |
182 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) | 184 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) |
183 { | 185 { |
184 // A translation by (5, 5) within a 2x scale about (10, 10). | 186 // A translation by (5, 5) within a 2x scale about (10, 10). |
185 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( | 187 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( |
186 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); | 188 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); |
187 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( | 189 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( |
188 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); | 190 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); |
189 | 191 |
190 TestPaintArtifact artifact; | 192 TestPaintArtifact artifact; |
191 artifact.chunk(transform1, nullptr, dummyRootEffect()) | 193 artifact.chunk(transform1, nullptr, dummyRootEffect(), nullptr) |
192 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 194 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
193 artifact.chunk(transform2, nullptr, dummyRootEffect()) | 195 artifact.chunk(transform2, nullptr, dummyRootEffect(), nullptr) |
194 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 196 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
195 update(artifact.build()); | 197 update(artifact.build()); |
196 | 198 |
197 ASSERT_EQ(2u, contentLayerCount()); | 199 ASSERT_EQ(2u, contentLayerCount()); |
198 { | 200 { |
199 const cc::Layer* layer = contentLayerAt(0); | 201 const cc::Layer* layer = contentLayerAt(0); |
200 EXPECT_THAT(layer->GetPicture(), | 202 EXPECT_THAT(layer->GetPicture(), |
201 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 203 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
202 gfx::RectF mappedRect(0, 0, 300, 200); | 204 gfx::RectF mappedRect(0, 0, 300, 200); |
203 layer->screen_space_transform().TransformRect(&mappedRect); | 205 layer->screen_space_transform().TransformRect(&mappedRect); |
(...skipping 23 matching lines...) Expand all Loading... |
227 // is flattened, while cc's notion applies in the parent's coordinate sp
ace. | 229 // is flattened, while cc's notion applies in the parent's coordinate sp
ace. |
228 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNo
de::create( | 230 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNo
de::create( |
229 nullptr, TransformationMatrix(), FloatPoint3D()); | 231 nullptr, TransformationMatrix(), FloatPoint3D()); |
230 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNo
de::create( | 232 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNo
de::create( |
231 transform1, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
)); | 233 transform1, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
)); |
232 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNo
de::create( | 234 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNo
de::create( |
233 transform2, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
), | 235 transform2, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
), |
234 transformIsFlattened); | 236 transformIsFlattened); |
235 | 237 |
236 TestPaintArtifact artifact; | 238 TestPaintArtifact artifact; |
237 artifact.chunk(transform3, nullptr, nullptr) | 239 artifact.chunk(transform3, nullptr, nullptr, nullptr) |
238 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 240 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
239 update(artifact.build()); | 241 update(artifact.build()); |
240 | 242 |
241 ASSERT_EQ(1u, contentLayerCount()); | 243 ASSERT_EQ(1u, contentLayerCount()); |
242 const cc::Layer* layer = contentLayerAt(0); | 244 const cc::Layer* layer = contentLayerAt(0); |
243 EXPECT_THAT(layer->GetPicture(), | 245 EXPECT_THAT(layer->GetPicture(), |
244 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 246 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
245 | 247 |
246 // The leaf transform node should flatten its inherited transform node | 248 // The leaf transform node should flatten its inherited transform node |
247 // if and only if the intermediate rotation transform in the Blink tree | 249 // if and only if the intermediate rotation transform in the Blink tree |
(...skipping 25 matching lines...) Expand all Loading... |
273 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( | 275 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( |
274 transform1, TransformationMatrix(), FloatPoint3D(), false, 1); | 276 transform1, TransformationMatrix(), FloatPoint3D(), false, 1); |
275 // Extends the 3D rendering context of transform2. | 277 // Extends the 3D rendering context of transform2. |
276 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNode::
create( | 278 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNode::
create( |
277 transform2, TransformationMatrix(), FloatPoint3D(), false, 1); | 279 transform2, TransformationMatrix(), FloatPoint3D(), false, 1); |
278 // Establishes a 3D rendering context distinct from transform2. | 280 // Establishes a 3D rendering context distinct from transform2. |
279 RefPtr<TransformPaintPropertyNode> transform4 = TransformPaintPropertyNode::
create( | 281 RefPtr<TransformPaintPropertyNode> transform4 = TransformPaintPropertyNode::
create( |
280 transform2, TransformationMatrix(), FloatPoint3D(), false, 2); | 282 transform2, TransformationMatrix(), FloatPoint3D(), false, 2); |
281 | 283 |
282 TestPaintArtifact artifact; | 284 TestPaintArtifact artifact; |
283 artifact.chunk(transform1, nullptr, dummyRootEffect()) | 285 artifact.chunk(transform1, nullptr, dummyRootEffect(), nullptr) |
284 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 286 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
285 artifact.chunk(transform2, nullptr, dummyRootEffect()) | 287 artifact.chunk(transform2, nullptr, dummyRootEffect(), nullptr) |
286 .rectDrawing(FloatRect(0, 0, 300, 200), Color::lightGray); | 288 .rectDrawing(FloatRect(0, 0, 300, 200), Color::lightGray); |
287 artifact.chunk(transform3, nullptr, dummyRootEffect()) | 289 artifact.chunk(transform3, nullptr, dummyRootEffect(), nullptr) |
288 .rectDrawing(FloatRect(0, 0, 300, 200), Color::darkGray); | 290 .rectDrawing(FloatRect(0, 0, 300, 200), Color::darkGray); |
289 artifact.chunk(transform4, nullptr, dummyRootEffect()) | 291 artifact.chunk(transform4, nullptr, dummyRootEffect(), nullptr) |
290 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 292 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
291 update(artifact.build()); | 293 update(artifact.build()); |
292 | 294 |
293 ASSERT_EQ(4u, contentLayerCount()); | 295 ASSERT_EQ(4u, contentLayerCount()); |
294 | 296 |
295 // The white layer is not 3D sorted. | 297 // The white layer is not 3D sorted. |
296 const cc::Layer* whiteLayer = contentLayerAt(0); | 298 const cc::Layer* whiteLayer = contentLayerAt(0); |
297 EXPECT_THAT(whiteLayer->GetPicture(), | 299 EXPECT_THAT(whiteLayer->GetPicture(), |
298 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 300 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
299 int whiteSortingContextId = transformNode(whiteLayer).sorting_context_id; | 301 int whiteSortingContextId = transformNode(whiteLayer).sorting_context_id; |
(...skipping 28 matching lines...) Expand all Loading... |
328 EXPECT_NE(0, blackSortingContextId); | 330 EXPECT_NE(0, blackSortingContextId); |
329 EXPECT_NE(lightGraySortingContextId, blackSortingContextId); | 331 EXPECT_NE(lightGraySortingContextId, blackSortingContextId); |
330 } | 332 } |
331 | 333 |
332 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) | 334 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) |
333 { | 335 { |
334 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 336 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
335 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200)); | 337 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200)); |
336 | 338 |
337 TestPaintArtifact artifact; | 339 TestPaintArtifact artifact; |
338 artifact.chunk(nullptr, clip, nullptr) | 340 artifact.chunk(nullptr, clip, nullptr, nullptr) |
339 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); | 341 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); |
340 update(artifact.build()); | 342 update(artifact.build()); |
341 | 343 |
342 ASSERT_EQ(1u, contentLayerCount()); | 344 ASSERT_EQ(1u, contentLayerCount()); |
343 const cc::Layer* layer = contentLayerAt(0); | 345 const cc::Layer* layer = contentLayerAt(0); |
344 EXPECT_THAT(layer->GetPicture(), | 346 EXPECT_THAT(layer->GetPicture(), |
345 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); | 347 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); |
346 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); | 348 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); |
347 | 349 |
348 const cc::ClipNode* clipNode = propertyTrees().clip_tree.Node(layer->clip_tr
ee_index()); | 350 const cc::ClipNode* clipNode = propertyTrees().clip_tree.Node(layer->clip_tr
ee_index()); |
349 EXPECT_TRUE(clipNode->applies_local_clip); | 351 EXPECT_TRUE(clipNode->applies_local_clip); |
350 EXPECT_TRUE(clipNode->layers_are_clipped); | 352 EXPECT_TRUE(clipNode->layers_are_clipped); |
351 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); | 353 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); |
352 } | 354 } |
353 | 355 |
354 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) | 356 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) |
355 { | 357 { |
356 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 358 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
357 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700)); | 359 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700)); |
358 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 360 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
359 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100)); | 361 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100)); |
360 | 362 |
361 TestPaintArtifact artifact; | 363 TestPaintArtifact artifact; |
362 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 364 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
363 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); | 365 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); |
364 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 366 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
365 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); | 367 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); |
366 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 368 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
367 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); | 369 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); |
368 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 370 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
369 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); | 371 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); |
370 update(artifact.build()); | 372 update(artifact.build()); |
371 | 373 |
372 ASSERT_EQ(4u, contentLayerCount()); | 374 ASSERT_EQ(4u, contentLayerCount()); |
373 | 375 |
374 const cc::Layer* whiteLayer = contentLayerAt(0); | 376 const cc::Layer* whiteLayer = contentLayerAt(0); |
375 EXPECT_THAT(whiteLayer->GetPicture(), | 377 EXPECT_THAT(whiteLayer->GetPicture(), |
376 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 378 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
377 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); | 379 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); |
378 | 380 |
(...skipping 29 matching lines...) Expand all Loading... |
408 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) | 410 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) |
409 { | 411 { |
410 Vector<RefPtr<ClipPaintPropertyNode>> clips; | 412 Vector<RefPtr<ClipPaintPropertyNode>> clips; |
411 for (unsigned i = 1; i <= 10; i++) { | 413 for (unsigned i = 1; i <= 10; i++) { |
412 clips.append(ClipPaintPropertyNode::create( | 414 clips.append(ClipPaintPropertyNode::create( |
413 clips.isEmpty() ? nullptr : clips.last(), | 415 clips.isEmpty() ? nullptr : clips.last(), |
414 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); | 416 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); |
415 } | 417 } |
416 | 418 |
417 TestPaintArtifact artifact; | 419 TestPaintArtifact artifact; |
418 artifact.chunk(nullptr, clips.last(), dummyRootEffect()) | 420 artifact.chunk(nullptr, clips.last(), dummyRootEffect(), nullptr) |
419 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); | 421 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); |
420 update(artifact.build()); | 422 update(artifact.build()); |
421 | 423 |
422 // Check the drawing layer. | 424 // Check the drawing layer. |
423 ASSERT_EQ(1u, contentLayerCount()); | 425 ASSERT_EQ(1u, contentLayerCount()); |
424 const cc::Layer* drawingLayer = contentLayerAt(0); | 426 const cc::Layer* drawingLayer = contentLayerAt(0); |
425 EXPECT_THAT(drawingLayer->GetPicture(), | 427 EXPECT_THAT(drawingLayer->GetPicture(), |
426 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); | 428 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); |
427 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); | 429 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); |
428 | 430 |
(...skipping 11 matching lines...) Expand all Loading... |
440 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) | 442 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) |
441 { | 443 { |
442 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( | 444 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( |
443 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600)); | 445 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600)); |
444 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 446 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
445 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600)); | 447 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600)); |
446 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 448 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
447 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600)); | 449 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600)); |
448 | 450 |
449 TestPaintArtifact artifact; | 451 TestPaintArtifact artifact; |
450 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 452 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
451 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); | 453 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); |
452 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 454 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
453 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); | 455 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); |
454 update(artifact.build()); | 456 update(artifact.build()); |
455 | 457 |
456 ASSERT_EQ(2u, contentLayerCount()); | 458 ASSERT_EQ(2u, contentLayerCount()); |
457 | 459 |
458 const cc::Layer* whiteLayer = contentLayerAt(0); | 460 const cc::Layer* whiteLayer = contentLayerAt(0); |
459 EXPECT_THAT(whiteLayer->GetPicture(), | 461 EXPECT_THAT(whiteLayer->GetPicture(), |
460 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); | 462 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); |
461 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); | 463 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); |
462 const cc::ClipNode* whiteClip = propertyTrees().clip_tree.Node(whiteLayer->c
lip_tree_index()); | 464 const cc::ClipNode* whiteClip = propertyTrees().clip_tree.Node(whiteLayer->c
lip_tree_index()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); | 497 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); |
496 } | 498 } |
497 | 499 |
498 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) | 500 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) |
499 { | 501 { |
500 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.5); | 502 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.5); |
501 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create(ef
fect1, 0.3); | 503 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create(ef
fect1, 0.3); |
502 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.2); | 504 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.2); |
503 | 505 |
504 TestPaintArtifact artifact; | 506 TestPaintArtifact artifact; |
505 artifact.chunk(nullptr, nullptr, effect2.get()) | 507 artifact.chunk(nullptr, nullptr, effect2.get(), nullptr) |
506 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 508 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
507 artifact.chunk(nullptr, nullptr, effect1.get()) | 509 artifact.chunk(nullptr, nullptr, effect1.get(), nullptr) |
508 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 510 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
509 artifact.chunk(nullptr, nullptr, effect3.get()) | 511 artifact.chunk(nullptr, nullptr, effect3.get(), nullptr) |
510 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 512 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
511 update(artifact.build()); | 513 update(artifact.build()); |
512 | 514 |
513 ASSERT_EQ(3u, contentLayerCount()); | 515 ASSERT_EQ(3u, contentLayerCount()); |
514 | 516 |
515 const cc::EffectTree& effectTree = propertyTrees().effect_tree; | 517 const cc::EffectTree& effectTree = propertyTrees().effect_tree; |
516 // Node #0 reserved for null; #1 for root render surface; #2 for dummyRootEf
fect, | 518 // Node #0 reserved for null; #1 for root render surface; #2 for dummyRootEf
fect, |
517 // plus 3 nodes for those created by this test. | 519 // plus 3 nodes for those created by this test. |
518 ASSERT_EQ(6u, effectTree.size()); | 520 ASSERT_EQ(6u, effectTree.size()); |
519 | 521 |
(...skipping 10 matching lines...) Expand all Loading... |
530 | 532 |
531 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5); | 533 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5); |
532 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); | 534 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); |
533 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); | 535 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); |
534 | 536 |
535 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); | 537 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); |
536 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); | 538 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); |
537 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); | 539 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); |
538 } | 540 } |
539 | 541 |
| 542 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) |
| 543 { |
| 544 RefPtr<TransformPaintPropertyNode> scrollTranslation = TransformPaintPropert
yNode::create( |
| 545 nullptr, TransformationMatrix().translate(7, 9), FloatPoint3D()); |
| 546 RefPtr<ScrollPaintPropertyNode> scroll = ScrollPaintPropertyNode::create( |
| 547 nullptr, scrollTranslation, FloatSize(), FloatSize(), true, true); |
| 548 |
| 549 TestPaintArtifact artifact; |
| 550 artifact.chunk(scrollTranslation, nullptr, nullptr, scroll) |
| 551 .rectDrawing(FloatRect(11, 13, 17, 19), Color::white); |
| 552 update(artifact.build()); |
| 553 |
| 554 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; |
| 555 // Node #0 reserved for null; #1 for root render surface. |
| 556 ASSERT_EQ(3u, scrollTree.size()); |
| 557 const cc::ScrollNode& scrollNode = *scrollTree.Node(2); |
| 558 EXPECT_EQ(1, scrollNode.parent_id); |
| 559 |
| 560 const cc::TransformTree& transformTree = propertyTrees().transform_tree; |
| 561 const cc::TransformNode& transformNode = *transformTree.Node(scrollNode.tran
sform_id); |
| 562 // TransformNode no longer contain the scroll translation as a transform but
instead as a scroll offset. |
| 563 EXPECT_TRUE(transformNode.local.IsIdentity()); |
| 564 EXPECT_EQ(gfx::ScrollOffset(7, -9), transformNode.scroll_offset); |
| 565 } |
| 566 |
540 } // namespace | 567 } // namespace |
541 } // namespace blink | 568 } // namespace blink |
OLD | NEW |