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

Unified Diff: cc/blimp/layer_tree_host_remote_unittest.cc

Issue 2467043002: cc/blimp: Eliminate Layer updates for common cases. (Closed)
Patch Set: test update Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/blimp/layer_tree_host_remote.cc ('k') | cc/layers/layer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/blimp/layer_tree_host_remote_unittest.cc
diff --git a/cc/blimp/layer_tree_host_remote_unittest.cc b/cc/blimp/layer_tree_host_remote_unittest.cc
index 8cd6d6d439db2426ab6048250d5deecd98a415aa..efb2ed9d583e2ecea8eb35f7e410be3912c14b82 100644
--- a/cc/blimp/layer_tree_host_remote_unittest.cc
+++ b/cc/blimp/layer_tree_host_remote_unittest.cc
@@ -164,7 +164,11 @@ class LayerTreeHostRemoteTest : public testing::Test {
params.settings = &settings;
layer_tree_host_ = base::MakeUnique<LayerTreeHostRemoteForTesting>(&params);
+
+ // Make sure the root layer always updates.
root_layer_ = make_scoped_refptr(new MockLayer(false));
+ root_layer_->SetIsDrawable(true);
+ root_layer_->SetBounds(gfx::Size(5, 10));
layer_tree_host_->GetLayerTree()->SetRootLayer(root_layer_);
}
@@ -348,6 +352,8 @@ TEST_F(LayerTreeHostRemoteTest, RequestCommitDuringMainFrame) {
TEST_F(LayerTreeHostRemoteTest, RequestCommitDuringLayerUpdates) {
// A layer update during a main frame should result in a commit.
scoped_refptr<Layer> child_layer = make_scoped_refptr(new MockLayer(true));
+ child_layer->SetIsDrawable(true);
+ child_layer->SetBounds(gfx::Size(5, 10));
root_layer_->AddChild(child_layer);
EXPECT_BEGIN_MAIN_FRAME_AND_COMMIT(mock_layer_tree_host_client_, 1);
@@ -413,5 +419,42 @@ TEST_F(LayerTreeHostRemoteTest, ScrollAndScaleSync) {
EXPECT_FALSE(updates_applied);
}
+TEST_F(LayerTreeHostRemoteTest, IdentifiedLayersToSkipUpdates) {
+ EXPECT_BEGIN_MAIN_FRAME_AND_COMMIT(mock_layer_tree_host_client_, 1);
+
+ scoped_refptr<MockLayer> non_drawable_layer = new MockLayer(true);
+ non_drawable_layer->SetIsDrawable(false);
+ non_drawable_layer->SetBounds(gfx::Size(5, 5));
+
+ scoped_refptr<MockLayer> empty_bound_layer = new MockLayer(true);
+ empty_bound_layer->SetIsDrawable(true);
+ empty_bound_layer->SetBounds(gfx::Size());
+
+ scoped_refptr<MockLayer> transparent_layer = new MockLayer(true);
+ transparent_layer->SetIsDrawable(true);
+ transparent_layer->SetBounds(gfx::Size(5, 5));
+ transparent_layer->SetOpacity(0.f);
+
+ scoped_refptr<MockLayer> updated_layer = new MockLayer(true);
+ updated_layer->SetIsDrawable(true);
+ updated_layer->SetBounds(gfx::Size(5, 5));
+
+ root_layer_->AddChild(non_drawable_layer);
+ root_layer_->AddChild(empty_bound_layer);
+ empty_bound_layer->SetMaskLayer(transparent_layer.get());
+ empty_bound_layer->AddChild(updated_layer);
+ DCHECK(updated_layer->GetLayerTreeHostForTesting());
+
+ // Commit and serialize.
+ layer_tree_host_->SetNeedsCommit();
+ base::RunLoop().RunUntilIdle();
+
+ // Only the updated_layer should have been updated.
+ EXPECT_FALSE(non_drawable_layer->did_update());
+ EXPECT_FALSE(empty_bound_layer->did_update());
+ EXPECT_FALSE(transparent_layer->did_update());
+ EXPECT_TRUE(updated_layer->did_update());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/blimp/layer_tree_host_remote.cc ('k') | cc/layers/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698