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

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

Issue 2258833002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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_impl.cc ('k') | cc/trees/remote_channel_impl.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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 4342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4353 compositor_context_provider = first_context_provider_; 4353 compositor_context_provider = first_context_provider_;
4354 } else { 4354 } else {
4355 EXPECT_FALSE(second_context_provider_); 4355 EXPECT_FALSE(second_context_provider_);
4356 second_context_provider_ = TestContextProvider::Create(); 4356 second_context_provider_ = TestContextProvider::Create();
4357 compositor_context_provider = second_context_provider_; 4357 compositor_context_provider = second_context_provider_;
4358 } 4358 }
4359 4359
4360 auto output_surface = 4360 auto output_surface =
4361 FakeOutputSurface::Create3d(std::move(compositor_context_provider)); 4361 FakeOutputSurface::Create3d(std::move(compositor_context_provider));
4362 output_surface->SetMemoryPolicyToSetAtBind( 4362 output_surface->SetMemoryPolicyToSetAtBind(
4363 base::WrapUnique(new ManagedMemoryPolicy( 4363 base::MakeUnique<ManagedMemoryPolicy>(
4364 second_context_provider_.get() ? second_output_surface_memory_limit_ 4364 second_context_provider_.get() ? second_output_surface_memory_limit_
4365 : first_output_surface_memory_limit_, 4365 : first_output_surface_memory_limit_,
4366 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 4366 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
4367 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); 4367 ManagedMemoryPolicy::kDefaultNumResourcesLimit));
4368 return std::move(output_surface); 4368 return std::move(output_surface);
4369 } 4369 }
4370 4370
4371 void SetupTree() override { 4371 void SetupTree() override {
4372 root_ = FakePictureLayer::Create(&client_); 4372 root_ = FakePictureLayer::Create(&client_);
4373 root_->SetBounds(gfx::Size(20, 20)); 4373 root_->SetBounds(gfx::Size(20, 20));
4374 layer_tree()->SetRootLayer(root_); 4374 layer_tree()->SetRootLayer(root_);
4375 LayerTreeHostTest::SetupTree(); 4375 LayerTreeHostTest::SetupTree();
4376 client_.set_bounds(root_->bounds()); 4376 client_.set_bounds(root_->bounds());
4377 } 4377 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
4479 class PinnedLayerTreeSwapPromise : public LayerTreeHostTest { 4479 class PinnedLayerTreeSwapPromise : public LayerTreeHostTest {
4480 protected: 4480 protected:
4481 void BeginTest() override { 4481 void BeginTest() override {
4482 PostSetNextCommitForcesRedrawToMainThread(); 4482 PostSetNextCommitForcesRedrawToMainThread();
4483 PostSetNeedsCommitToMainThread(); 4483 PostSetNeedsCommitToMainThread();
4484 } 4484 }
4485 4485
4486 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 4486 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4487 int frame = host_impl->active_tree()->source_frame_number(); 4487 int frame = host_impl->active_tree()->source_frame_number();
4488 if (frame == -1) { 4488 if (frame == -1) {
4489 host_impl->active_tree()->QueuePinnedSwapPromise(base::WrapUnique( 4489 host_impl->active_tree()->QueuePinnedSwapPromise(
4490 new TestSwapPromise(&pinned_active_swap_promise_result_))); 4490 base::MakeUnique<TestSwapPromise>(
4491 &pinned_active_swap_promise_result_));
4491 host_impl->pending_tree()->QueueSwapPromise( 4492 host_impl->pending_tree()->QueueSwapPromise(
4492 base::WrapUnique(new TestSwapPromise(&pending_swap_promise_result_))); 4493 base::MakeUnique<TestSwapPromise>(&pending_swap_promise_result_));
4493 host_impl->active_tree()->QueueSwapPromise( 4494 host_impl->active_tree()->QueueSwapPromise(
4494 base::WrapUnique(new TestSwapPromise(&active_swap_promise_result_))); 4495 base::MakeUnique<TestSwapPromise>(&active_swap_promise_result_));
4495 } 4496 }
4496 } 4497 }
4497 4498
4498 void DisplayDidDrawAndSwapOnThread() override { EndTest(); } 4499 void DisplayDidDrawAndSwapOnThread() override { EndTest(); }
4499 4500
4500 void AfterTest() override { 4501 void AfterTest() override {
4501 // The pending swap promise should activate and swap. 4502 // The pending swap promise should activate and swap.
4502 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called); 4503 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called);
4503 EXPECT_TRUE(pending_swap_promise_result_.did_swap_called); 4504 EXPECT_TRUE(pending_swap_promise_result_.did_swap_called);
4504 4505
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4635 MainThreadTaskRunner()->PostTask( 4636 MainThreadTaskRunner()->PostTask(
4636 FROM_HERE, base::Bind(&LayerTreeHostTestKeepSwapPromise::ChangeFrame, 4637 FROM_HERE, base::Bind(&LayerTreeHostTestKeepSwapPromise::ChangeFrame,
4637 base::Unretained(this))); 4638 base::Unretained(this)));
4638 } 4639 }
4639 4640
4640 void ChangeFrame() { 4641 void ChangeFrame() {
4641 switch (layer_tree_host()->source_frame_number()) { 4642 switch (layer_tree_host()->source_frame_number()) {
4642 case 1: 4643 case 1:
4643 layer_->SetBounds(gfx::Size(10, 11)); 4644 layer_->SetBounds(gfx::Size(10, 11));
4644 layer_tree_host()->QueueSwapPromise( 4645 layer_tree_host()->QueueSwapPromise(
4645 base::WrapUnique(new TestSwapPromise(&swap_promise_result_))); 4646 base::MakeUnique<TestSwapPromise>(&swap_promise_result_));
4646 break; 4647 break;
4647 case 2: 4648 case 2:
4648 break; 4649 break;
4649 default: 4650 default:
4650 NOTREACHED(); 4651 NOTREACHED();
4651 break; 4652 break;
4652 } 4653 }
4653 } 4654 }
4654 4655
4655 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 4656 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4750 EXPECT_FALSE(swap_promise_result_.did_swap_called); 4751 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4751 host_impl->BlockNotifyReadyToActivateForTesting(false); 4752 host_impl->BlockNotifyReadyToActivateForTesting(false);
4752 } 4753 }
4753 4754
4754 void ChangeFrame() { 4755 void ChangeFrame() {
4755 switch (layer_tree_host()->source_frame_number()) { 4756 switch (layer_tree_host()->source_frame_number()) {
4756 case 1: 4757 case 1:
4757 // Make no changes so that we abort the next commit caused by queuing 4758 // Make no changes so that we abort the next commit caused by queuing
4758 // the swap promise. 4759 // the swap promise.
4759 layer_tree_host()->QueueSwapPromise( 4760 layer_tree_host()->QueueSwapPromise(
4760 base::WrapUnique(new TestSwapPromise(&swap_promise_result_))); 4761 base::MakeUnique<TestSwapPromise>(&swap_promise_result_));
4761 layer_tree_host()->SetNeedsUpdateLayers(); 4762 layer_tree_host()->SetNeedsUpdateLayers();
4762 break; 4763 break;
4763 case 2: 4764 case 2:
4764 break; 4765 break;
4765 default: 4766 default:
4766 NOTREACHED(); 4767 NOTREACHED();
4767 break; 4768 break;
4768 } 4769 }
4769 } 4770 }
4770 4771
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after
7025 private: 7026 private:
7026 FakeContentLayerClient client_; 7027 FakeContentLayerClient client_;
7027 const gfx::Size viewport_size_; 7028 const gfx::Size viewport_size_;
7028 const gfx::Size large_image_size_; 7029 const gfx::Size large_image_size_;
7029 }; 7030 };
7030 7031
7031 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); 7032 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage);
7032 7033
7033 } // namespace 7034 } // namespace
7034 } // namespace cc 7035 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/remote_channel_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698