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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 ASSERT_EQ(1u, contentLayerCount()); | 412 ASSERT_EQ(1u, contentLayerCount()); |
413 const cc::Layer* layer = contentLayerAt(0); | 413 const cc::Layer* layer = contentLayerAt(0); |
414 EXPECT_THAT(layer->GetPicture(), | 414 EXPECT_THAT(layer->GetPicture(), |
415 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); | 415 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); |
416 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); | 416 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); |
417 | 417 |
418 const cc::ClipNode* clipNode = | 418 const cc::ClipNode* clipNode = |
419 propertyTrees().clip_tree.Node(layer->clip_tree_index()); | 419 propertyTrees().clip_tree.Node(layer->clip_tree_index()); |
420 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); | 420 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); |
421 EXPECT_TRUE(clipNode->layers_are_clipped); | |
422 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); | 421 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); |
423 } | 422 } |
424 | 423 |
425 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) { | 424 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) { |
426 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 425 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
427 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 426 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
428 FloatRoundedRect(100, 100, 700, 700), | 427 FloatRoundedRect(100, 100, 700, 700), |
429 CompositingReasonOverflowScrollingTouch); | 428 CompositingReasonOverflowScrollingTouch); |
430 RefPtr<ClipPaintPropertyNode> clip2 = | 429 RefPtr<ClipPaintPropertyNode> clip2 = |
431 ClipPaintPropertyNode::create(clip1, TransformPaintPropertyNode::root(), | 430 ClipPaintPropertyNode::create(clip1, TransformPaintPropertyNode::root(), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 471 |
473 const cc::Layer* blackLayer = contentLayerAt(3); | 472 const cc::Layer* blackLayer = contentLayerAt(3); |
474 EXPECT_THAT(blackLayer->GetPicture(), | 473 EXPECT_THAT(blackLayer->GetPicture(), |
475 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::black))); | 474 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::black))); |
476 EXPECT_EQ(translation(300, 350), blackLayer->screen_space_transform()); | 475 EXPECT_EQ(translation(300, 350), blackLayer->screen_space_transform()); |
477 | 476 |
478 EXPECT_EQ(whiteLayer->clip_tree_index(), darkGrayLayer->clip_tree_index()); | 477 EXPECT_EQ(whiteLayer->clip_tree_index(), darkGrayLayer->clip_tree_index()); |
479 const cc::ClipNode* outerClip = | 478 const cc::ClipNode* outerClip = |
480 propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index()); | 479 propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index()); |
481 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, outerClip->clip_type); | 480 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, outerClip->clip_type); |
482 EXPECT_TRUE(outerClip->layers_are_clipped); | |
483 EXPECT_EQ(gfx::RectF(100, 100, 700, 700), outerClip->clip); | 481 EXPECT_EQ(gfx::RectF(100, 100, 700, 700), outerClip->clip); |
484 | 482 |
485 EXPECT_EQ(lightGrayLayer->clip_tree_index(), blackLayer->clip_tree_index()); | 483 EXPECT_EQ(lightGrayLayer->clip_tree_index(), blackLayer->clip_tree_index()); |
486 const cc::ClipNode* innerClip = | 484 const cc::ClipNode* innerClip = |
487 propertyTrees().clip_tree.Node(blackLayer->clip_tree_index()); | 485 propertyTrees().clip_tree.Node(blackLayer->clip_tree_index()); |
488 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, innerClip->clip_type); | 486 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, innerClip->clip_type); |
489 EXPECT_TRUE(innerClip->layers_are_clipped); | |
490 EXPECT_EQ(gfx::RectF(200, 200, 700, 700), innerClip->clip); | 487 EXPECT_EQ(gfx::RectF(200, 200, 700, 700), innerClip->clip); |
491 EXPECT_EQ(outerClip->id, innerClip->parent_id); | 488 EXPECT_EQ(outerClip->id, innerClip->parent_id); |
492 } | 489 } |
493 | 490 |
494 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) { | 491 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) { |
495 Vector<RefPtr<ClipPaintPropertyNode>> clips; | 492 Vector<RefPtr<ClipPaintPropertyNode>> clips; |
496 for (unsigned i = 1; i <= 10; i++) { | 493 for (unsigned i = 1; i <= 10; i++) { |
497 clips.push_back(ClipPaintPropertyNode::create( | 494 clips.push_back(ClipPaintPropertyNode::create( |
498 clips.isEmpty() ? ClipPaintPropertyNode::root() : clips.back(), | 495 clips.isEmpty() ? ClipPaintPropertyNode::root() : clips.back(), |
499 TransformPaintPropertyNode::root(), | 496 TransformPaintPropertyNode::root(), |
(...skipping 13 matching lines...) Expand all Loading... |
513 EXPECT_THAT(drawingLayer->GetPicture(), | 510 EXPECT_THAT(drawingLayer->GetPicture(), |
514 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); | 511 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); |
515 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); | 512 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); |
516 | 513 |
517 // Check the clip nodes. | 514 // Check the clip nodes. |
518 const cc::ClipNode* clipNode = | 515 const cc::ClipNode* clipNode = |
519 propertyTrees().clip_tree.Node(drawingLayer->clip_tree_index()); | 516 propertyTrees().clip_tree.Node(drawingLayer->clip_tree_index()); |
520 for (auto it = clips.rbegin(); it != clips.rend(); ++it) { | 517 for (auto it = clips.rbegin(); it != clips.rend(); ++it) { |
521 const ClipPaintPropertyNode* paintClipNode = it->get(); | 518 const ClipPaintPropertyNode* paintClipNode = it->get(); |
522 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); | 519 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); |
523 EXPECT_TRUE(clipNode->layers_are_clipped); | |
524 EXPECT_EQ(paintClipNode->clipRect().rect(), clipNode->clip); | 520 EXPECT_EQ(paintClipNode->clipRect().rect(), clipNode->clip); |
525 clipNode = propertyTrees().clip_tree.Node(clipNode->parent_id); | 521 clipNode = propertyTrees().clip_tree.Node(clipNode->parent_id); |
526 } | 522 } |
527 } | 523 } |
528 | 524 |
529 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) { | 525 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) { |
530 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( | 526 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( |
531 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 527 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
532 FloatRoundedRect(0, 0, 800, 600)); | 528 FloatRoundedRect(0, 0, 800, 600)); |
533 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 529 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
(...skipping 16 matching lines...) Expand all Loading... |
550 | 546 |
551 ASSERT_EQ(2u, contentLayerCount()); | 547 ASSERT_EQ(2u, contentLayerCount()); |
552 | 548 |
553 const cc::Layer* whiteLayer = contentLayerAt(0); | 549 const cc::Layer* whiteLayer = contentLayerAt(0); |
554 EXPECT_THAT(whiteLayer->GetPicture(), | 550 EXPECT_THAT(whiteLayer->GetPicture(), |
555 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); | 551 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); |
556 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); | 552 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); |
557 const cc::ClipNode* whiteClip = | 553 const cc::ClipNode* whiteClip = |
558 propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index()); | 554 propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index()); |
559 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, whiteClip->clip_type); | 555 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, whiteClip->clip_type); |
560 EXPECT_TRUE(whiteClip->layers_are_clipped); | |
561 ASSERT_EQ(gfx::RectF(0, 0, 400, 600), whiteClip->clip); | 556 ASSERT_EQ(gfx::RectF(0, 0, 400, 600), whiteClip->clip); |
562 | 557 |
563 const cc::Layer* blackLayer = contentLayerAt(1); | 558 const cc::Layer* blackLayer = contentLayerAt(1); |
564 EXPECT_THAT(blackLayer->GetPicture(), | 559 EXPECT_THAT(blackLayer->GetPicture(), |
565 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::black))); | 560 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::black))); |
566 EXPECT_EQ(gfx::Transform(), blackLayer->screen_space_transform()); | 561 EXPECT_EQ(gfx::Transform(), blackLayer->screen_space_transform()); |
567 const cc::ClipNode* blackClip = | 562 const cc::ClipNode* blackClip = |
568 propertyTrees().clip_tree.Node(blackLayer->clip_tree_index()); | 563 propertyTrees().clip_tree.Node(blackLayer->clip_tree_index()); |
569 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, blackClip->clip_type); | 564 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, blackClip->clip_type); |
570 EXPECT_TRUE(blackClip->layers_are_clipped); | |
571 ASSERT_EQ(gfx::RectF(400, 0, 400, 600), blackClip->clip); | 565 ASSERT_EQ(gfx::RectF(400, 0, 400, 600), blackClip->clip); |
572 | 566 |
573 EXPECT_EQ(whiteClip->parent_id, blackClip->parent_id); | 567 EXPECT_EQ(whiteClip->parent_id, blackClip->parent_id); |
574 const cc::ClipNode* commonClipNode = | 568 const cc::ClipNode* commonClipNode = |
575 propertyTrees().clip_tree.Node(whiteClip->parent_id); | 569 propertyTrees().clip_tree.Node(whiteClip->parent_id); |
576 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, | 570 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, |
577 commonClipNode->clip_type); | 571 commonClipNode->clip_type); |
578 EXPECT_TRUE(commonClipNode->layers_are_clipped); | |
579 ASSERT_EQ(gfx::RectF(0, 0, 800, 600), commonClipNode->clip); | 572 ASSERT_EQ(gfx::RectF(0, 0, 800, 600), commonClipNode->clip); |
580 } | 573 } |
581 | 574 |
582 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, | 575 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, |
583 ForeignLayerPassesThrough) { | 576 ForeignLayerPassesThrough) { |
584 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); | 577 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); |
585 | 578 |
586 TestPaintArtifact testArtifact; | 579 TestPaintArtifact testArtifact; |
587 testArtifact | 580 testArtifact |
588 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 581 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 | 1803 |
1811 EXPECT_EQ(5u, rootLayer()->children().size()); | 1804 EXPECT_EQ(5u, rootLayer()->children().size()); |
1812 sequenceNumber++; | 1805 sequenceNumber++; |
1813 EXPECT_EQ(sequenceNumber, propertyTrees().sequence_number); | 1806 EXPECT_EQ(sequenceNumber, propertyTrees().sequence_number); |
1814 for (auto layer : rootLayer()->children()) { | 1807 for (auto layer : rootLayer()->children()) { |
1815 EXPECT_EQ(sequenceNumber, layer->property_tree_sequence_number()); | 1808 EXPECT_EQ(sequenceNumber, layer->property_tree_sequence_number()); |
1816 } | 1809 } |
1817 } | 1810 } |
1818 | 1811 |
1819 } // namespace blink | 1812 } // namespace blink |
OLD | NEW |