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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/blimp/layer_tree_host_remote.h" 5 #include "cc/blimp/layer_tree_host_remote.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 base::MakeUnique<UpdateTrackingRemoteCompositorBridge>( 157 base::MakeUnique<UpdateTrackingRemoteCompositorBridge>(
158 main_task_runner); 158 main_task_runner);
159 remote_compositor_bridge_ = remote_compositor_bridge.get(); 159 remote_compositor_bridge_ = remote_compositor_bridge.get();
160 params.remote_compositor_bridge = std::move(remote_compositor_bridge); 160 params.remote_compositor_bridge = std::move(remote_compositor_bridge);
161 params.engine_picture_cache = 161 params.engine_picture_cache =
162 image_serialization_processor_.CreateEnginePictureCache(); 162 image_serialization_processor_.CreateEnginePictureCache();
163 LayerTreeSettings settings; 163 LayerTreeSettings settings;
164 params.settings = &settings; 164 params.settings = &settings;
165 165
166 layer_tree_host_ = base::MakeUnique<LayerTreeHostRemoteForTesting>(&params); 166 layer_tree_host_ = base::MakeUnique<LayerTreeHostRemoteForTesting>(&params);
167
168 // Make sure the root layer always updates.
167 root_layer_ = make_scoped_refptr(new MockLayer(false)); 169 root_layer_ = make_scoped_refptr(new MockLayer(false));
170 root_layer_->SetIsDrawable(true);
171 root_layer_->SetBounds(gfx::Size(5, 10));
168 layer_tree_host_->GetLayerTree()->SetRootLayer(root_layer_); 172 layer_tree_host_->GetLayerTree()->SetRootLayer(root_layer_);
169 } 173 }
170 174
171 void TearDown() override { 175 void TearDown() override {
172 Mock::VerifyAndClearExpectations(&mock_layer_tree_host_client_); 176 Mock::VerifyAndClearExpectations(&mock_layer_tree_host_client_);
173 layer_tree_host_ = nullptr; 177 layer_tree_host_ = nullptr;
174 root_layer_ = nullptr; 178 root_layer_ = nullptr;
175 remote_compositor_bridge_ = nullptr; 179 remote_compositor_bridge_ = nullptr;
176 } 180 }
177 181
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 layer_tree_host_->SetNeedsAnimate(); 345 layer_tree_host_->SetNeedsAnimate();
342 346
343 base::RunLoop().RunUntilIdle(); 347 base::RunLoop().RunUntilIdle();
344 EXPECT_TRUE(root_layer_->did_update()); 348 EXPECT_TRUE(root_layer_->did_update());
345 EXPECT_EQ(1, remote_compositor_bridge_->num_updates_received()); 349 EXPECT_EQ(1, remote_compositor_bridge_->num_updates_received());
346 } 350 }
347 351
348 TEST_F(LayerTreeHostRemoteTest, RequestCommitDuringLayerUpdates) { 352 TEST_F(LayerTreeHostRemoteTest, RequestCommitDuringLayerUpdates) {
349 // A layer update during a main frame should result in a commit. 353 // A layer update during a main frame should result in a commit.
350 scoped_refptr<Layer> child_layer = make_scoped_refptr(new MockLayer(true)); 354 scoped_refptr<Layer> child_layer = make_scoped_refptr(new MockLayer(true));
355 child_layer->SetIsDrawable(true);
356 child_layer->SetBounds(gfx::Size(5, 10));
351 root_layer_->AddChild(child_layer); 357 root_layer_->AddChild(child_layer);
352 EXPECT_BEGIN_MAIN_FRAME_AND_COMMIT(mock_layer_tree_host_client_, 1); 358 EXPECT_BEGIN_MAIN_FRAME_AND_COMMIT(mock_layer_tree_host_client_, 1);
353 359
354 layer_tree_host_->SetNeedsUpdateLayers(); 360 layer_tree_host_->SetNeedsUpdateLayers();
355 361
356 base::RunLoop().RunUntilIdle(); 362 base::RunLoop().RunUntilIdle();
357 EXPECT_TRUE(root_layer_->did_update()); 363 EXPECT_TRUE(root_layer_->did_update());
358 EXPECT_EQ(1, remote_compositor_bridge_->num_updates_received()); 364 EXPECT_EQ(1, remote_compositor_bridge_->num_updates_received());
359 } 365 }
360 366
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // Destroy a layer and send a scroll update for it. We should be informed that 412 // Destroy a layer and send a scroll update for it. We should be informed that
407 // the update could not be applied successfully. 413 // the update could not be applied successfully.
408 child_layer1->RemoveAllChildren(); 414 child_layer1->RemoveAllChildren();
409 scroll_updates.clear(); 415 scroll_updates.clear();
410 scroll_updates[child_layer2->id()] = gfx::ScrollOffset(3, 2); 416 scroll_updates[child_layer2->id()] = gfx::ScrollOffset(3, 2);
411 updates_applied = 417 updates_applied =
412 remote_compositor_bridge_->SendUpdates(scroll_updates, new_scale_factor); 418 remote_compositor_bridge_->SendUpdates(scroll_updates, new_scale_factor);
413 EXPECT_FALSE(updates_applied); 419 EXPECT_FALSE(updates_applied);
414 } 420 }
415 421
422 TEST_F(LayerTreeHostRemoteTest, IdentifiedLayersToSkipUpdates) {
423 EXPECT_BEGIN_MAIN_FRAME_AND_COMMIT(mock_layer_tree_host_client_, 1);
424
425 scoped_refptr<MockLayer> non_drawable_layer = new MockLayer(true);
426 non_drawable_layer->SetIsDrawable(false);
427 non_drawable_layer->SetBounds(gfx::Size(5, 5));
428
429 scoped_refptr<MockLayer> empty_bound_layer = new MockLayer(true);
430 empty_bound_layer->SetIsDrawable(true);
431 empty_bound_layer->SetBounds(gfx::Size());
432
433 scoped_refptr<MockLayer> transparent_layer = new MockLayer(true);
434 transparent_layer->SetIsDrawable(true);
435 transparent_layer->SetBounds(gfx::Size(5, 5));
436 transparent_layer->SetOpacity(0.f);
437
438 scoped_refptr<MockLayer> updated_layer = new MockLayer(true);
439 updated_layer->SetIsDrawable(true);
440 updated_layer->SetBounds(gfx::Size(5, 5));
441
442 root_layer_->AddChild(non_drawable_layer);
443 root_layer_->AddChild(empty_bound_layer);
444 empty_bound_layer->SetMaskLayer(transparent_layer.get());
445 empty_bound_layer->AddChild(updated_layer);
446 DCHECK(updated_layer->GetLayerTreeHostForTesting());
447
448 // Commit and serialize.
449 layer_tree_host_->SetNeedsCommit();
450 base::RunLoop().RunUntilIdle();
451
452 // Only the updated_layer should have been updated.
453 EXPECT_FALSE(non_drawable_layer->did_update());
454 EXPECT_FALSE(empty_bound_layer->did_update());
455 EXPECT_FALSE(transparent_layer->did_update());
456 EXPECT_TRUE(updated_layer->did_update());
457 }
458
416 } // namespace 459 } // namespace
417 } // namespace cc 460 } // namespace cc
OLDNEW
« 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