OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include "cc/animation/keyframed_animation_curve.h" | 7 #include "cc/animation/keyframed_animation_curve.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
10 #include "cc/resources/layer_painter.h" | 10 #include "cc/resources/layer_painter.h" |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to | 529 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to |
530 // SetNeedsDisplay. | 530 // SetNeedsDisplay. |
531 | 531 |
532 scoped_refptr<Layer> test_layer = Layer::Create(); | 532 scoped_refptr<Layer> test_layer = Layer::Create(); |
533 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 533 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
534 1, layer_tree_host_->SetRootLayer(test_layer)); | 534 1, layer_tree_host_->SetRootLayer(test_layer)); |
535 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 535 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
536 | 536 |
537 gfx::Size test_bounds = gfx::Size(501, 508); | 537 gfx::Size test_bounds = gfx::Size(501, 508); |
538 | 538 |
539 gfx::RectF dirty1 = gfx::RectF(10.f, 15.f, 1.f, 2.f); | 539 gfx::Rect dirty1 = gfx::Rect(10, 15, 1, 2); |
540 gfx::RectF dirty2 = gfx::RectF(20.f, 25.f, 3.f, 4.f); | 540 gfx::Rect dirty2 = gfx::Rect(20, 25, 3, 4); |
541 gfx::RectF empty_dirty_rect = gfx::RectF(40.f, 45.f, 0.f, 0.f); | 541 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); |
542 gfx::RectF out_of_bounds_dirty_rect = gfx::RectF(400.f, 405.f, 500.f, 502.f); | |
543 | 542 |
544 // Before anything, test_layer should not be dirty. | 543 // Before anything, test_layer should not be dirty. |
545 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 544 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
546 | 545 |
547 // This is just initialization, but SetNeedsCommit behavior is verified anyway | 546 // This is just initialization, but SetNeedsCommit behavior is verified anyway |
548 // to avoid warnings. | 547 // to avoid warnings. |
549 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBounds(test_bounds)); | 548 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBounds(test_bounds)); |
550 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 549 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
551 | 550 |
552 // The real test begins here. | 551 // The real test begins here. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 } | 641 } |
643 | 642 |
644 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { | 643 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { |
645 scoped_refptr<Layer> test_layer = Layer::Create(); | 644 scoped_refptr<Layer> test_layer = Layer::Create(); |
646 scoped_ptr<LayerImpl> impl_layer = | 645 scoped_ptr<LayerImpl> impl_layer = |
647 LayerImpl::Create(host_impl_.active_tree(), 1); | 646 LayerImpl::Create(host_impl_.active_tree(), 1); |
648 | 647 |
649 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 648 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
650 layer_tree_host_->SetRootLayer(test_layer)); | 649 layer_tree_host_->SetRootLayer(test_layer)); |
651 | 650 |
652 test_layer->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); | 651 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); |
653 test_layer->PushPropertiesTo(impl_layer.get()); | 652 test_layer->PushPropertiesTo(impl_layer.get()); |
654 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), | 653 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), |
655 impl_layer->update_rect()); | 654 impl_layer->update_rect()); |
656 | 655 |
657 // The LayerImpl's update_rect() should be accumulated here, since we did not | 656 // The LayerImpl's update_rect() should be accumulated here, since we did not |
658 // do anything to clear it. | 657 // do anything to clear it. |
659 test_layer->SetNeedsDisplayRect(gfx::RectF(10.f, 10.f, 5.f, 5.f)); | 658 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); |
660 test_layer->PushPropertiesTo(impl_layer.get()); | 659 test_layer->PushPropertiesTo(impl_layer.get()); |
661 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 15.f, 15.f), | 660 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 15.f, 15.f), |
662 impl_layer->update_rect()); | 661 impl_layer->update_rect()); |
663 | 662 |
664 // If we do clear the LayerImpl side, then the next update_rect() should be | 663 // If we do clear the LayerImpl side, then the next update_rect() should be |
665 // fresh without accumulation. | 664 // fresh without accumulation. |
666 impl_layer->ResetAllChangeTrackingForSubtree(); | 665 impl_layer->ResetAllChangeTrackingForSubtree(); |
667 test_layer->SetNeedsDisplayRect(gfx::RectF(10.f, 10.f, 5.f, 5.f)); | 666 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); |
668 test_layer->PushPropertiesTo(impl_layer.get()); | 667 test_layer->PushPropertiesTo(impl_layer.get()); |
669 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), | 668 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), |
670 impl_layer->update_rect()); | 669 impl_layer->update_rect()); |
671 } | 670 } |
672 | 671 |
673 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { | 672 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { |
674 scoped_refptr<Layer> test_layer = Layer::Create(); | 673 scoped_refptr<Layer> test_layer = Layer::Create(); |
675 scoped_ptr<LayerImpl> impl_layer = | 674 scoped_ptr<LayerImpl> impl_layer = |
676 LayerImpl::Create(host_impl_.active_tree(), 1); | 675 LayerImpl::Create(host_impl_.active_tree(), 1); |
677 | 676 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 root_layer->AddChild(becomes_not_draws_content); | 1244 root_layer->AddChild(becomes_not_draws_content); |
1246 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1245 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
1247 | 1246 |
1248 becomes_draws_content->SetIsDrawable(true); | 1247 becomes_draws_content->SetIsDrawable(true); |
1249 root_layer->AddChild(becomes_draws_content); | 1248 root_layer->AddChild(becomes_draws_content); |
1250 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1249 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
1251 } | 1250 } |
1252 | 1251 |
1253 } // namespace | 1252 } // namespace |
1254 } // namespace cc | 1253 } // namespace cc |
OLD | NEW |