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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 2986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2997 if (persist_needs_push_properties_) | 2997 if (persist_needs_push_properties_) |
2998 needs_push_properties_ = true; | 2998 needs_push_properties_ = true; |
2999 } | 2999 } |
3000 | 3000 |
3001 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 3001 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
3002 OVERRIDE { | 3002 OVERRIDE { |
3003 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()). | 3003 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()). |
3004 PassAs<LayerImpl>(); | 3004 PassAs<LayerImpl>(); |
3005 } | 3005 } |
3006 | 3006 |
| 3007 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); } |
| 3008 |
3007 size_t push_properties_count() const { return push_properties_count_; } | 3009 size_t push_properties_count() const { return push_properties_count_; } |
3008 void reset_push_properties_count() { push_properties_count_ = 0; } | 3010 void reset_push_properties_count() { push_properties_count_ = 0; } |
3009 | 3011 |
3010 void set_persist_needs_push_properties(bool persist) { | 3012 void set_persist_needs_push_properties(bool persist) { |
3011 persist_needs_push_properties_ = persist; | 3013 persist_needs_push_properties_ = persist; |
3012 } | 3014 } |
3013 | 3015 |
3014 private: | 3016 private: |
3015 PushPropertiesCountingLayer() | 3017 PushPropertiesCountingLayer() |
3016 : push_properties_count_(0), persist_needs_push_properties_(false) { | 3018 : push_properties_count_(0), persist_needs_push_properties_(false) { |
3017 SetBounds(gfx::Size(1, 1)); | 3019 SetBounds(gfx::Size(1, 1)); |
3018 SetIsDrawable(true); | |
3019 } | 3020 } |
3020 virtual ~PushPropertiesCountingLayer() {} | 3021 virtual ~PushPropertiesCountingLayer() {} |
3021 | 3022 |
3022 size_t push_properties_count_; | 3023 size_t push_properties_count_; |
3023 bool persist_needs_push_properties_; | 3024 bool persist_needs_push_properties_; |
3024 }; | 3025 }; |
3025 | 3026 |
3026 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { | 3027 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { |
3027 protected: | 3028 protected: |
3028 virtual void BeginTest() OVERRIDE { | 3029 virtual void BeginTest() OVERRIDE { |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3465 } | 3466 } |
3466 | 3467 |
3467 virtual void AfterTest() OVERRIDE {} | 3468 virtual void AfterTest() OVERRIDE {} |
3468 | 3469 |
3469 scoped_refptr<Layer> root_; | 3470 scoped_refptr<Layer> root_; |
3470 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; | 3471 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; |
3471 }; | 3472 }; |
3472 | 3473 |
3473 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); | 3474 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); |
3474 | 3475 |
| 3476 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { |
| 3477 protected: |
| 3478 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 3479 |
| 3480 virtual void SetupTree() OVERRIDE { |
| 3481 root_ = PushPropertiesCountingLayer::Create(); |
| 3482 child_ = PushPropertiesCountingLayer::Create(); |
| 3483 root_->AddChild(child_); |
| 3484 |
| 3485 layer_tree_host()->SetRootLayer(root_); |
| 3486 LayerTreeHostTest::SetupTree(); |
| 3487 } |
| 3488 |
| 3489 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 3490 switch (layer_tree_host()->source_frame_number()) { |
| 3491 case 0: |
| 3492 break; |
| 3493 case 1: { |
| 3494 // During update, the ignore_set_needs_commit_ bit is set to true to |
| 3495 // avoid causing a second commit to be scheduled. If a property change |
| 3496 // is made during this, however, it needs to be pushed in the upcoming |
| 3497 // commit. |
| 3498 EXPECT_FALSE(root_->needs_push_properties()); |
| 3499 EXPECT_FALSE(child_->needs_push_properties()); |
| 3500 EXPECT_EQ(0, root_->NumDescendantsThatDrawContent()); |
| 3501 root_->reset_push_properties_count(); |
| 3502 child_->reset_push_properties_count(); |
| 3503 child_->SetDrawsContent(true); |
| 3504 EXPECT_EQ(1, root_->NumDescendantsThatDrawContent()); |
| 3505 EXPECT_EQ(0u, root_->push_properties_count()); |
| 3506 EXPECT_EQ(0u, child_->push_properties_count()); |
| 3507 EXPECT_TRUE(root_->needs_push_properties()); |
| 3508 EXPECT_TRUE(child_->needs_push_properties()); |
| 3509 break; |
| 3510 } |
| 3511 case 2: |
| 3512 EXPECT_EQ(1u, root_->push_properties_count()); |
| 3513 EXPECT_EQ(1u, child_->push_properties_count()); |
| 3514 EXPECT_FALSE(root_->needs_push_properties()); |
| 3515 EXPECT_FALSE(child_->needs_push_properties()); |
| 3516 EndTest(); |
| 3517 break; |
| 3518 } |
| 3519 } |
| 3520 |
| 3521 virtual void AfterTest() OVERRIDE {} |
| 3522 |
| 3523 scoped_refptr<PushPropertiesCountingLayer> root_; |
| 3524 scoped_refptr<PushPropertiesCountingLayer> child_; |
| 3525 }; |
| 3526 |
| 3527 MULTI_THREAD_TEST_F(LayerTreeHostTestSetDrawableCausesCommit); |
| 3528 |
3475 class LayerTreeHostTestCasePushPropertiesThreeGrandChildren | 3529 class LayerTreeHostTestCasePushPropertiesThreeGrandChildren |
3476 : public LayerTreeHostTest { | 3530 : public LayerTreeHostTest { |
3477 protected: | 3531 protected: |
3478 virtual void BeginTest() OVERRIDE { | 3532 virtual void BeginTest() OVERRIDE { |
3479 expected_push_properties_root_ = 0; | 3533 expected_push_properties_root_ = 0; |
3480 expected_push_properties_child_ = 0; | 3534 expected_push_properties_child_ = 0; |
3481 expected_push_properties_grandchild1_ = 0; | 3535 expected_push_properties_grandchild1_ = 0; |
3482 expected_push_properties_grandchild2_ = 0; | 3536 expected_push_properties_grandchild2_ = 0; |
3483 expected_push_properties_grandchild3_ = 0; | 3537 expected_push_properties_grandchild3_ = 0; |
3484 PostSetNeedsCommitToMainThread(); | 3538 PostSetNeedsCommitToMainThread(); |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4967 const gfx::Size bounds_; | 5021 const gfx::Size bounds_; |
4968 FakeContentLayerClient client_; | 5022 FakeContentLayerClient client_; |
4969 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5023 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
4970 scoped_refptr<FakePictureLayer> picture_layer_; | 5024 scoped_refptr<FakePictureLayer> picture_layer_; |
4971 Layer* child_layer_; | 5025 Layer* child_layer_; |
4972 }; | 5026 }; |
4973 | 5027 |
4974 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5028 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
4975 | 5029 |
4976 } // namespace cc | 5030 } // namespace cc |
OLD | NEW |