Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 1097583002: cc: Commit property trees to the compositor thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on top of needs_rebuild patch Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/location.h" 10 #include "base/location.h"
(...skipping 3267 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 return new PushPropertiesCountingLayer(); 3278 return new PushPropertiesCountingLayer();
3279 } 3279 }
3280 3280
3281 void PushPropertiesTo(LayerImpl* layer) override { 3281 void PushPropertiesTo(LayerImpl* layer) override {
3282 Layer::PushPropertiesTo(layer); 3282 Layer::PushPropertiesTo(layer);
3283 push_properties_count_++; 3283 push_properties_count_++;
3284 if (persist_needs_push_properties_) 3284 if (persist_needs_push_properties_)
3285 needs_push_properties_ = true; 3285 needs_push_properties_ = true;
3286 } 3286 }
3287 3287
3288 // Something to make this layer push properties, but no other layer.
3289 void MakePushProperties() { SetContentsOpaque(!contents_opaque()); }
3290
3288 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override { 3291 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override {
3289 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 3292 return PushPropertiesCountingLayerImpl::Create(tree_impl, id());
3290 } 3293 }
3291 3294
3292 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); } 3295 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); }
3293 3296
3294 size_t push_properties_count() const { return push_properties_count_; } 3297 size_t push_properties_count() const { return push_properties_count_; }
3295 void reset_push_properties_count() { push_properties_count_ = 0; } 3298 void reset_push_properties_count() { push_properties_count_ = 0; }
3296 3299
3297 void set_persist_needs_push_properties(bool persist) { 3300 void set_persist_needs_push_properties(bool persist) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 child2_->AddChild(leaf_always_pushing_layer_); 3340 child2_->AddChild(leaf_always_pushing_layer_);
3338 3341
3339 other_root_ = PushPropertiesCountingLayer::Create(); 3342 other_root_ = PushPropertiesCountingLayer::Create();
3340 other_root_->CreateRenderSurface(); 3343 other_root_->CreateRenderSurface();
3341 3344
3342 // Don't set the root layer here. 3345 // Don't set the root layer here.
3343 LayerTreeHostTest::SetupTree(); 3346 LayerTreeHostTest::SetupTree();
3344 } 3347 }
3345 3348
3346 void DidCommitAndDrawFrame() override { 3349 void DidCommitAndDrawFrame() override {
3350 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count())
3351 << "num_commits: " << num_commits_;
3352 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count())
3353 << "num_commits: " << num_commits_;
3354 EXPECT_EQ(expected_push_properties_grandchild_,
3355 grandchild_->push_properties_count())
3356 << "num_commits: " << num_commits_;
3357 EXPECT_EQ(expected_push_properties_child2_,
3358 child2_->push_properties_count())
3359 << "num_commits: " << num_commits_;
3360 EXPECT_EQ(expected_push_properties_other_root_,
3361 other_root_->push_properties_count())
3362 << "num_commits: " << num_commits_;
3363 EXPECT_EQ(expected_push_properties_leaf_layer_,
3364 leaf_always_pushing_layer_->push_properties_count())
3365 << "num_commits: " << num_commits_;
3366
3347 ++num_commits_; 3367 ++num_commits_;
3348 3368
3349 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
3350 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
3351 EXPECT_EQ(expected_push_properties_grandchild_,
3352 grandchild_->push_properties_count());
3353 EXPECT_EQ(expected_push_properties_child2_,
3354 child2_->push_properties_count());
3355 EXPECT_EQ(expected_push_properties_other_root_,
3356 other_root_->push_properties_count());
3357 EXPECT_EQ(expected_push_properties_leaf_layer_,
3358 leaf_always_pushing_layer_->push_properties_count());
3359
3360 // The scrollbar layer always needs to be pushed. 3369 // The scrollbar layer always needs to be pushed.
3361 if (root_->layer_tree_host()) { 3370 if (root_->layer_tree_host()) {
3362 EXPECT_TRUE(root_->descendant_needs_push_properties()); 3371 EXPECT_TRUE(root_->descendant_needs_push_properties());
3363 EXPECT_FALSE(root_->needs_push_properties()); 3372 EXPECT_FALSE(root_->needs_push_properties());
3364 } 3373 }
3365 if (child2_->layer_tree_host()) { 3374 if (child2_->layer_tree_host()) {
3366 EXPECT_TRUE(child2_->descendant_needs_push_properties()); 3375 EXPECT_TRUE(child2_->descendant_needs_push_properties());
3367 EXPECT_FALSE(child2_->needs_push_properties()); 3376 EXPECT_FALSE(child2_->needs_push_properties());
3368 } 3377 }
3369 if (leaf_always_pushing_layer_->layer_tree_host()) { 3378 if (leaf_always_pushing_layer_->layer_tree_host()) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3438 break; 3447 break;
3439 case 10: 3448 case 10:
3440 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 3449 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
3441 // No layers need commit. 3450 // No layers need commit.
3442 break; 3451 break;
3443 case 11: 3452 case 11:
3444 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.8f, 1.1f); 3453 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.8f, 1.1f);
3445 // No layers need commit. 3454 // No layers need commit.
3446 break; 3455 break;
3447 case 12: 3456 case 12:
3448 child_->SetPosition(gfx::Point(1, 1)); 3457 child_->MakePushProperties();
enne (OOO) 2015/04/17 20:59:36 This code used to adjust the offset of children wh
ajuma 2015/04/17 22:53:11 If these extra pushes turn out to be costly, perha
3449 // The modified layer needs commit 3458 // The modified layer needs commit
3450 ++expected_push_properties_child_; 3459 ++expected_push_properties_child_;
3451 break; 3460 break;
3452 case 13: 3461 case 13:
3453 child2_->SetPosition(gfx::Point(1, 1)); 3462 child2_->MakePushProperties();
3454 // The modified layer needs commit 3463 // The modified layer needs commit
3455 ++expected_push_properties_child2_; 3464 ++expected_push_properties_child2_;
3456 break; 3465 break;
3457 case 14: 3466 case 14:
3458 child_->RemoveFromParent(); 3467 child_->RemoveFromParent();
3459 root_->AddChild(child_); 3468 root_->AddChild(child_);
3460 // Layers added to the tree get committed. 3469 // Layers added to the tree get committed.
3461 ++expected_push_properties_child_; 3470 ++expected_push_properties_child_;
3462 ++expected_push_properties_grandchild_; 3471 ++expected_push_properties_grandchild_;
3463 break; 3472 break;
3464 case 15: 3473 case 15:
3465 grandchild_->SetPosition(gfx::Point(1, 1)); 3474 grandchild_->MakePushProperties();
3466 // The modified layer needs commit 3475 // The modified layer needs commit
3467 ++expected_push_properties_grandchild_; 3476 ++expected_push_properties_grandchild_;
3468 break; 3477 break;
3469 case 16: 3478 case 16:
3470 // SetNeedsDisplay does not always set needs commit (so call it 3479 // SetNeedsDisplay does not always set needs commit (so call it
3471 // explicitly), but is a property change. 3480 // explicitly), but is a property change.
3472 child_->SetNeedsDisplay(); 3481 child_->SetNeedsDisplay();
3473 ++expected_push_properties_child_; 3482 ++expected_push_properties_child_;
3474 layer_tree_host()->SetNeedsCommit(); 3483 layer_tree_host()->SetNeedsCommit();
3475 break; 3484 break;
(...skipping 3467 matching lines...) Expand 10 before | Expand all | Expand 10 after
6943 void AfterTest() override {} 6952 void AfterTest() override {}
6944 6953
6945 scoped_refptr<FakePictureLayer> content_child_layer_; 6954 scoped_refptr<FakePictureLayer> content_child_layer_;
6946 FakeContentLayerClient client_; 6955 FakeContentLayerClient client_;
6947 }; 6956 };
6948 6957
6949 SINGLE_AND_MULTI_THREAD_TEST_F( 6958 SINGLE_AND_MULTI_THREAD_TEST_F(
6950 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); 6959 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild);
6951 6960
6952 } // namespace cc 6961 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698