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 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2969 if (persist_needs_push_properties_) | 2969 if (persist_needs_push_properties_) |
2970 needs_push_properties_ = true; | 2970 needs_push_properties_ = true; |
2971 } | 2971 } |
2972 | 2972 |
2973 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 2973 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
2974 OVERRIDE { | 2974 OVERRIDE { |
2975 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()). | 2975 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()). |
2976 PassAs<LayerImpl>(); | 2976 PassAs<LayerImpl>(); |
2977 } | 2977 } |
2978 | 2978 |
| 2979 void SetDrawsContent(bool draws_content) { |
| 2980 UpdateDrawsContent(draws_content); |
| 2981 } |
| 2982 |
2979 size_t push_properties_count() const { return push_properties_count_; } | 2983 size_t push_properties_count() const { return push_properties_count_; } |
2980 void reset_push_properties_count() { push_properties_count_ = 0; } | 2984 void reset_push_properties_count() { push_properties_count_ = 0; } |
2981 | 2985 |
2982 void set_persist_needs_push_properties(bool persist) { | 2986 void set_persist_needs_push_properties(bool persist) { |
2983 persist_needs_push_properties_ = persist; | 2987 persist_needs_push_properties_ = persist; |
2984 } | 2988 } |
2985 | 2989 |
2986 private: | 2990 private: |
2987 PushPropertiesCountingLayer() | 2991 PushPropertiesCountingLayer() |
2988 : push_properties_count_(0), persist_needs_push_properties_(false) { | 2992 : push_properties_count_(0), persist_needs_push_properties_(false) { |
2989 SetBounds(gfx::Size(1, 1)); | 2993 SetBounds(gfx::Size(1, 1)); |
2990 SetIsDrawable(true); | |
2991 } | 2994 } |
2992 virtual ~PushPropertiesCountingLayer() {} | 2995 virtual ~PushPropertiesCountingLayer() {} |
2993 | 2996 |
2994 size_t push_properties_count_; | 2997 size_t push_properties_count_; |
2995 bool persist_needs_push_properties_; | 2998 bool persist_needs_push_properties_; |
2996 }; | 2999 }; |
2997 | 3000 |
2998 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { | 3001 class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { |
2999 protected: | 3002 protected: |
3000 virtual void BeginTest() OVERRIDE { | 3003 virtual void BeginTest() OVERRIDE { |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3437 } | 3440 } |
3438 | 3441 |
3439 virtual void AfterTest() OVERRIDE {} | 3442 virtual void AfterTest() OVERRIDE {} |
3440 | 3443 |
3441 scoped_refptr<Layer> root_; | 3444 scoped_refptr<Layer> root_; |
3442 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; | 3445 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer_; |
3443 }; | 3446 }; |
3444 | 3447 |
3445 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); | 3448 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); |
3446 | 3449 |
| 3450 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { |
| 3451 protected: |
| 3452 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 3453 |
| 3454 virtual void SetupTree() OVERRIDE { |
| 3455 root_ = PushPropertiesCountingLayer::Create(); |
| 3456 child_ = PushPropertiesCountingLayer::Create(); |
| 3457 root_->AddChild(child_); |
| 3458 |
| 3459 layer_tree_host()->SetRootLayer(root_); |
| 3460 LayerTreeHostTest::SetupTree(); |
| 3461 } |
| 3462 |
| 3463 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 3464 switch (layer_tree_host()->source_frame_number()) { |
| 3465 case 0: |
| 3466 break; |
| 3467 case 1: { |
| 3468 // During update, the ignore_set_needs_commit_ bit is set to true to |
| 3469 // avoid causing a second commit to be scheduled. If a property change |
| 3470 // is made during this, however, it needs to be pushed in the upcoming |
| 3471 // commit. |
| 3472 EXPECT_FALSE(root_->needs_push_properties()); |
| 3473 EXPECT_FALSE(child_->needs_push_properties()); |
| 3474 EXPECT_EQ(0, root_->NumDescendantsThatDrawContent()); |
| 3475 root_->reset_push_properties_count(); |
| 3476 child_->reset_push_properties_count(); |
| 3477 child_->SetDrawsContent(true); |
| 3478 EXPECT_EQ(1, root_->NumDescendantsThatDrawContent()); |
| 3479 EXPECT_EQ(0u, root_->push_properties_count()); |
| 3480 EXPECT_EQ(0u, child_->push_properties_count()); |
| 3481 EXPECT_TRUE(root_->needs_push_properties()); |
| 3482 EXPECT_TRUE(child_->needs_push_properties()); |
| 3483 break; |
| 3484 } |
| 3485 case 2: |
| 3486 EXPECT_EQ(1u, root_->push_properties_count()); |
| 3487 EXPECT_EQ(1u, child_->push_properties_count()); |
| 3488 EXPECT_FALSE(root_->needs_push_properties()); |
| 3489 EXPECT_FALSE(child_->needs_push_properties()); |
| 3490 EndTest(); |
| 3491 break; |
| 3492 } |
| 3493 } |
| 3494 |
| 3495 virtual void AfterTest() OVERRIDE {} |
| 3496 |
| 3497 scoped_refptr<PushPropertiesCountingLayer> root_; |
| 3498 scoped_refptr<PushPropertiesCountingLayer> child_; |
| 3499 }; |
| 3500 |
| 3501 MULTI_THREAD_TEST_F(LayerTreeHostTestSetDrawableCausesCommit); |
| 3502 |
3447 class LayerTreeHostTestCasePushPropertiesThreeGrandChildren | 3503 class LayerTreeHostTestCasePushPropertiesThreeGrandChildren |
3448 : public LayerTreeHostTest { | 3504 : public LayerTreeHostTest { |
3449 protected: | 3505 protected: |
3450 virtual void BeginTest() OVERRIDE { | 3506 virtual void BeginTest() OVERRIDE { |
3451 expected_push_properties_root_ = 0; | 3507 expected_push_properties_root_ = 0; |
3452 expected_push_properties_child_ = 0; | 3508 expected_push_properties_child_ = 0; |
3453 expected_push_properties_grandchild1_ = 0; | 3509 expected_push_properties_grandchild1_ = 0; |
3454 expected_push_properties_grandchild2_ = 0; | 3510 expected_push_properties_grandchild2_ = 0; |
3455 expected_push_properties_grandchild3_ = 0; | 3511 expected_push_properties_grandchild3_ = 0; |
3456 PostSetNeedsCommitToMainThread(); | 3512 PostSetNeedsCommitToMainThread(); |
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4899 const gfx::Size bounds_; | 4955 const gfx::Size bounds_; |
4900 FakeContentLayerClient client_; | 4956 FakeContentLayerClient client_; |
4901 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4957 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
4902 scoped_refptr<FakePictureLayer> picture_layer_; | 4958 scoped_refptr<FakePictureLayer> picture_layer_; |
4903 Layer* child_layer_; | 4959 Layer* child_layer_; |
4904 }; | 4960 }; |
4905 | 4961 |
4906 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4962 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
4907 | 4963 |
4908 } // namespace cc | 4964 } // namespace cc |
OLD | NEW |