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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 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
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>
11 11
12 #include "base/auto_reset.h" 12 #include "base/auto_reset.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/memory/ptr_util.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
17 #include "cc/animation/timing_function.h" 18 #include "cc/animation/timing_function.h"
18 #include "cc/debug/frame_rate_counter.h" 19 #include "cc/debug/frame_rate_counter.h"
19 #include "cc/input/scroll_elasticity_helper.h" 20 #include "cc/input/scroll_elasticity_helper.h"
20 #include "cc/layers/content_layer_client.h" 21 #include "cc/layers/content_layer_client.h"
21 #include "cc/layers/io_surface_layer.h" 22 #include "cc/layers/io_surface_layer.h"
22 #include "cc/layers/layer_impl.h" 23 #include "cc/layers/layer_impl.h"
23 #include "cc/layers/painted_scrollbar_layer.h" 24 #include "cc/layers/painted_scrollbar_layer.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 bool did_notify_ready_to_draw_; 424 bool did_notify_ready_to_draw_;
424 bool did_draw_; 425 bool did_draw_;
425 }; 426 };
426 427
427 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in 428 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in
428 // single threaded mode. 429 // single threaded mode.
429 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility); 430 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility);
430 431
431 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { 432 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
432 public: 433 public:
433 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 434 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
434 auto output_surface = make_scoped_ptr(new testing::StrictMock< 435 auto output_surface = base::WrapUnique(
435 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( 436 new testing::StrictMock<
436 delegating_renderer())); 437 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>(
438 delegating_renderer()));
437 439
438 // At init, we expect one call to set visibility to true. 440 // At init, we expect one call to set visibility to true.
439 testing::Expectation visibility_true = 441 testing::Expectation visibility_true =
440 EXPECT_CALL(*output_surface, 442 EXPECT_CALL(*output_surface,
441 SetWorkerContextShouldAggressivelyFreeResources(false)) 443 SetWorkerContextShouldAggressivelyFreeResources(false))
442 .Times(1); 444 .Times(1);
443 445
444 // After running, we should get exactly one call to 446 // After running, we should get exactly one call to
445 // FreeWorkerContextGpuResources. 447 // FreeWorkerContextGpuResources.
446 EXPECT_CALL(*output_surface, 448 EXPECT_CALL(*output_surface,
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 1382
1381 // Tests that if a layer is not drawn because of some reason in the parent then 1383 // Tests that if a layer is not drawn because of some reason in the parent then
1382 // its damage is preserved until the next time it is drawn. 1384 // its damage is preserved until the next time it is drawn.
1383 class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest { 1385 class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest {
1384 public: 1386 public:
1385 LayerTreeHostTestDamageWithScale() {} 1387 LayerTreeHostTestDamageWithScale() {}
1386 1388
1387 void SetupTree() override { 1389 void SetupTree() override {
1388 client_.set_fill_with_nonsolid_color(true); 1390 client_.set_fill_with_nonsolid_color(true);
1389 1391
1390 scoped_ptr<FakeRecordingSource> recording(new FakeRecordingSource); 1392 std::unique_ptr<FakeRecordingSource> recording(new FakeRecordingSource);
1391 root_layer_ = FakePictureLayer::CreateWithRecordingSource( 1393 root_layer_ = FakePictureLayer::CreateWithRecordingSource(
1392 &client_, std::move(recording)); 1394 &client_, std::move(recording));
1393 root_layer_->SetBounds(gfx::Size(50, 50)); 1395 root_layer_->SetBounds(gfx::Size(50, 50));
1394 1396
1395 recording.reset(new FakeRecordingSource); 1397 recording.reset(new FakeRecordingSource);
1396 child_layer_ = FakePictureLayer::CreateWithRecordingSource( 1398 child_layer_ = FakePictureLayer::CreateWithRecordingSource(
1397 &client_, std::move(recording)); 1399 &client_, std::move(recording));
1398 child_layer_->SetBounds(gfx::Size(25, 25)); 1400 child_layer_->SetBounds(gfx::Size(25, 25));
1399 child_layer_->SetIsDrawable(true); 1401 child_layer_->SetIsDrawable(true);
1400 child_layer_->SetContentsOpaque(true); 1402 child_layer_->SetContentsOpaque(true);
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 GLsizei count, 2303 GLsizei count,
2302 GLenum type, 2304 GLenum type,
2303 GLintptr offset)); 2305 GLintptr offset));
2304 MOCK_METHOD1(deleteTexture, void(GLenum texture)); 2306 MOCK_METHOD1(deleteTexture, void(GLenum texture));
2305 MOCK_METHOD3(produceTextureDirectCHROMIUM, 2307 MOCK_METHOD3(produceTextureDirectCHROMIUM,
2306 void(GLuint texture, GLenum target, const GLbyte* mailbox)); 2308 void(GLuint texture, GLenum target, const GLbyte* mailbox));
2307 }; 2309 };
2308 2310
2309 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { 2311 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest {
2310 protected: 2312 protected:
2311 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 2313 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
2312 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( 2314 std::unique_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned(
2313 new MockIOSurfaceWebGraphicsContext3D); 2315 new MockIOSurfaceWebGraphicsContext3D);
2314 mock_context_ = mock_context_owned.get(); 2316 mock_context_ = mock_context_owned.get();
2315 2317
2316 if (delegating_renderer()) 2318 if (delegating_renderer())
2317 return FakeOutputSurface::CreateDelegating3d( 2319 return FakeOutputSurface::CreateDelegating3d(
2318 std::move(mock_context_owned)); 2320 std::move(mock_context_owned));
2319 else 2321 else
2320 return FakeOutputSurface::Create3d(std::move(mock_context_owned)); 2322 return FakeOutputSurface::Create3d(std::move(mock_context_owned));
2321 } 2323 }
2322 2324
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 child_layer_->SetBounds(gfx::Size(50, 50)); 2490 child_layer_->SetBounds(gfx::Size(50, 50));
2489 2491
2490 root_layer_->AddChild(parent_layer_); 2492 root_layer_->AddChild(parent_layer_);
2491 parent_layer_->AddChild(child_layer_); 2493 parent_layer_->AddChild(child_layer_);
2492 layer_tree_host()->SetRootLayer(root_layer_); 2494 layer_tree_host()->SetRootLayer(root_layer_);
2493 2495
2494 LayerTreeHostTest::SetupTree(); 2496 LayerTreeHostTest::SetupTree();
2495 client_.set_bounds(root_layer_->bounds()); 2497 client_.set_bounds(root_layer_->bounds());
2496 } 2498 }
2497 2499
2498 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 2500 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
2499 if (delegating_renderer()) { 2501 if (delegating_renderer()) {
2500 return FakeOutputSurface::CreateDelegatingSoftware( 2502 return FakeOutputSurface::CreateDelegatingSoftware(
2501 make_scoped_ptr(new SoftwareOutputDevice)); 2503 base::WrapUnique(new SoftwareOutputDevice));
2502 } else { 2504 } else {
2503 return FakeOutputSurface::CreateSoftware( 2505 return FakeOutputSurface::CreateSoftware(
2504 make_scoped_ptr(new SoftwareOutputDevice)); 2506 base::WrapUnique(new SoftwareOutputDevice));
2505 } 2507 }
2506 } 2508 }
2507 2509
2508 void BeginTest() override { 2510 void BeginTest() override {
2509 PostSetNeedsCommitToMainThread(); 2511 PostSetNeedsCommitToMainThread();
2510 swap_count_ = 0; 2512 swap_count_ = 0;
2511 } 2513 }
2512 2514
2513 void ScheduledActionInvalidateOutputSurface() override { 2515 void ScheduledActionInvalidateOutputSurface() override {
2514 if (TestEnded()) 2516 if (TestEnded())
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 void ClearResources() { 2655 void ClearResources() {
2654 for (int i = 0; i < num_ui_resources_; i++) 2656 for (int i = 0; i < num_ui_resources_; i++)
2655 ui_resources_[i] = nullptr; 2657 ui_resources_[i] = nullptr;
2656 } 2658 }
2657 2659
2658 void CreateResource() { 2660 void CreateResource() {
2659 ui_resources_[num_ui_resources_++] = 2661 ui_resources_[num_ui_resources_++] =
2660 FakeScopedUIResource::Create(layer_tree_host()); 2662 FakeScopedUIResource::Create(layer_tree_host());
2661 } 2663 }
2662 2664
2663 scoped_ptr<FakeScopedUIResource> ui_resources_[5]; 2665 std::unique_ptr<FakeScopedUIResource> ui_resources_[5];
2664 int num_ui_resources_; 2666 int num_ui_resources_;
2665 }; 2667 };
2666 2668
2667 MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource); 2669 MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource);
2668 2670
2669 class PushPropertiesCountingLayerImpl : public LayerImpl { 2671 class PushPropertiesCountingLayerImpl : public LayerImpl {
2670 public: 2672 public:
2671 static scoped_ptr<PushPropertiesCountingLayerImpl> Create( 2673 static std::unique_ptr<PushPropertiesCountingLayerImpl> Create(
2672 LayerTreeImpl* tree_impl, int id) { 2674 LayerTreeImpl* tree_impl,
2673 return make_scoped_ptr(new PushPropertiesCountingLayerImpl(tree_impl, id)); 2675 int id) {
2676 return base::WrapUnique(new PushPropertiesCountingLayerImpl(tree_impl, id));
2674 } 2677 }
2675 2678
2676 ~PushPropertiesCountingLayerImpl() override {} 2679 ~PushPropertiesCountingLayerImpl() override {}
2677 2680
2678 void PushPropertiesTo(LayerImpl* layer) override { 2681 void PushPropertiesTo(LayerImpl* layer) override {
2679 LayerImpl::PushPropertiesTo(layer); 2682 LayerImpl::PushPropertiesTo(layer);
2680 push_properties_count_++; 2683 push_properties_count_++;
2681 // Push state to the active tree because we can only access it from there. 2684 // Push state to the active tree because we can only access it from there.
2682 static_cast<PushPropertiesCountingLayerImpl*>( 2685 static_cast<PushPropertiesCountingLayerImpl*>(
2683 layer)->push_properties_count_ = push_properties_count_; 2686 layer)->push_properties_count_ = push_properties_count_;
2684 } 2687 }
2685 2688
2686 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override { 2689 std::unique_ptr<LayerImpl> CreateLayerImpl(
2690 LayerTreeImpl* tree_impl) override {
2687 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 2691 return PushPropertiesCountingLayerImpl::Create(tree_impl, id());
2688 } 2692 }
2689 2693
2690 size_t push_properties_count() const { return push_properties_count_; } 2694 size_t push_properties_count() const { return push_properties_count_; }
2691 void reset_push_properties_count() { push_properties_count_ = 0; } 2695 void reset_push_properties_count() { push_properties_count_ = 0; }
2692 2696
2693 private: 2697 private:
2694 size_t push_properties_count_; 2698 size_t push_properties_count_;
2695 2699
2696 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id) 2700 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id)
(...skipping 13 matching lines...) Expand all
2710 Layer::PushPropertiesTo(layer); 2714 Layer::PushPropertiesTo(layer);
2711 push_properties_count_++; 2715 push_properties_count_++;
2712 if (persist_needs_push_properties_) { 2716 if (persist_needs_push_properties_) {
2713 layer_tree_host()->AddLayerShouldPushProperties(this); 2717 layer_tree_host()->AddLayerShouldPushProperties(this);
2714 } 2718 }
2715 } 2719 }
2716 2720
2717 // Something to make this layer push properties, but no other layer. 2721 // Something to make this layer push properties, but no other layer.
2718 void MakePushProperties() { SetContentsOpaque(!contents_opaque()); } 2722 void MakePushProperties() { SetContentsOpaque(!contents_opaque()); }
2719 2723
2720 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override { 2724 std::unique_ptr<LayerImpl> CreateLayerImpl(
2725 LayerTreeImpl* tree_impl) override {
2721 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 2726 return PushPropertiesCountingLayerImpl::Create(tree_impl, id());
2722 } 2727 }
2723 2728
2724 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); } 2729 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); }
2725 2730
2726 size_t push_properties_count() const { return push_properties_count_; } 2731 size_t push_properties_count() const { return push_properties_count_; }
2727 void reset_push_properties_count() { push_properties_count_ = 0; } 2732 void reset_push_properties_count() { push_properties_count_ = 0; }
2728 2733
2729 void set_persist_needs_push_properties(bool persist) { 2734 void set_persist_needs_push_properties(bool persist) {
2730 persist_needs_push_properties_ = persist; 2735 persist_needs_push_properties_ = persist;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 3173
3169 void DidCommitAndDrawFrame() override { 3174 void DidCommitAndDrawFrame() override {
3170 switch (layer_tree_host()->source_frame_number()) { 3175 switch (layer_tree_host()->source_frame_number()) {
3171 case 0: 3176 case 0:
3172 break; 3177 break;
3173 case 1: { 3178 case 1: {
3174 // During update, the ignore_set_needs_commit_ bit is set to true to 3179 // During update, the ignore_set_needs_commit_ bit is set to true to
3175 // avoid causing a second commit to be scheduled. If a property change 3180 // avoid causing a second commit to be scheduled. If a property change
3176 // is made during this, however, it needs to be pushed in the upcoming 3181 // is made during this, however, it needs to be pushed in the upcoming
3177 // commit. 3182 // commit.
3178 scoped_ptr<base::AutoReset<bool>> ignore = 3183 std::unique_ptr<base::AutoReset<bool>> ignore =
3179 scrollbar_layer_->IgnoreSetNeedsCommit(); 3184 scrollbar_layer_->IgnoreSetNeedsCommit();
3180 3185
3181 scrollbar_layer_->SetBounds(gfx::Size(30, 30)); 3186 scrollbar_layer_->SetBounds(gfx::Size(30, 30));
3182 3187
3183 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( 3188 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
3184 scrollbar_layer_.get())); 3189 scrollbar_layer_.get()));
3185 layer_tree_host()->SetNeedsCommit(); 3190 layer_tree_host()->SetNeedsCommit();
3186 3191
3187 scrollbar_layer_->reset_push_properties_count(); 3192 scrollbar_layer_->reset_push_properties_count();
3188 EXPECT_EQ(0u, scrollbar_layer_->push_properties_count()); 3193 EXPECT_EQ(0u, scrollbar_layer_->push_properties_count());
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
4000 4005
4001 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); 4006 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll);
4002 4007
4003 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface 4008 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface
4004 : public LayerTreeHostTest { 4009 : public LayerTreeHostTest {
4005 protected: 4010 protected:
4006 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() 4011 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface()
4007 : first_output_surface_memory_limit_(4321234), 4012 : first_output_surface_memory_limit_(4321234),
4008 second_output_surface_memory_limit_(1234321) {} 4013 second_output_surface_memory_limit_(1234321) {}
4009 4014
4010 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 4015 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
4011 if (!first_context_provider_.get()) { 4016 if (!first_context_provider_.get()) {
4012 first_context_provider_ = TestContextProvider::Create(); 4017 first_context_provider_ = TestContextProvider::Create();
4013 } else { 4018 } else {
4014 EXPECT_FALSE(second_context_provider_.get()); 4019 EXPECT_FALSE(second_context_provider_.get());
4015 second_context_provider_ = TestContextProvider::Create(); 4020 second_context_provider_ = TestContextProvider::Create();
4016 } 4021 }
4017 4022
4018 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() 4023 scoped_refptr<TestContextProvider> provider(second_context_provider_.get()
4019 ? second_context_provider_ 4024 ? second_context_provider_
4020 : first_context_provider_); 4025 : first_context_provider_);
4021 scoped_ptr<FakeOutputSurface> output_surface; 4026 std::unique_ptr<FakeOutputSurface> output_surface;
4022 if (delegating_renderer()) 4027 if (delegating_renderer())
4023 output_surface = FakeOutputSurface::CreateDelegating3d(provider); 4028 output_surface = FakeOutputSurface::CreateDelegating3d(provider);
4024 else 4029 else
4025 output_surface = FakeOutputSurface::Create3d(provider); 4030 output_surface = FakeOutputSurface::Create3d(provider);
4026 output_surface->SetMemoryPolicyToSetAtBind( 4031 output_surface->SetMemoryPolicyToSetAtBind(
4027 make_scoped_ptr(new ManagedMemoryPolicy( 4032 base::WrapUnique(new ManagedMemoryPolicy(
4028 second_context_provider_.get() ? second_output_surface_memory_limit_ 4033 second_context_provider_.get() ? second_output_surface_memory_limit_
4029 : first_output_surface_memory_limit_, 4034 : first_output_surface_memory_limit_,
4030 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 4035 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
4031 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); 4036 ManagedMemoryPolicy::kDefaultNumResourcesLimit)));
4032 return output_surface; 4037 return output_surface;
4033 } 4038 }
4034 4039
4035 void SetupTree() override { 4040 void SetupTree() override {
4036 root_ = FakePictureLayer::Create(&client_); 4041 root_ = FakePictureLayer::Create(&client_);
4037 root_->SetBounds(gfx::Size(20, 20)); 4042 root_->SetBounds(gfx::Size(20, 20));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 class PinnedLayerTreeSwapPromise : public LayerTreeHostTest { 4147 class PinnedLayerTreeSwapPromise : public LayerTreeHostTest {
4143 protected: 4148 protected:
4144 void BeginTest() override { 4149 void BeginTest() override {
4145 PostSetNextCommitForcesRedrawToMainThread(); 4150 PostSetNextCommitForcesRedrawToMainThread();
4146 PostSetNeedsCommitToMainThread(); 4151 PostSetNeedsCommitToMainThread();
4147 } 4152 }
4148 4153
4149 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 4154 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4150 int frame = host_impl->active_tree()->source_frame_number(); 4155 int frame = host_impl->active_tree()->source_frame_number();
4151 if (frame == -1) { 4156 if (frame == -1) {
4152 host_impl->active_tree()->QueuePinnedSwapPromise(make_scoped_ptr( 4157 host_impl->active_tree()->QueuePinnedSwapPromise(base::WrapUnique(
4153 new TestSwapPromise(&pinned_active_swap_promise_result_))); 4158 new TestSwapPromise(&pinned_active_swap_promise_result_)));
4154 host_impl->pending_tree()->QueueSwapPromise( 4159 host_impl->pending_tree()->QueueSwapPromise(
4155 make_scoped_ptr(new TestSwapPromise(&pending_swap_promise_result_))); 4160 base::WrapUnique(new TestSwapPromise(&pending_swap_promise_result_)));
4156 host_impl->active_tree()->QueueSwapPromise( 4161 host_impl->active_tree()->QueueSwapPromise(
4157 make_scoped_ptr(new TestSwapPromise(&active_swap_promise_result_))); 4162 base::WrapUnique(new TestSwapPromise(&active_swap_promise_result_)));
4158 } 4163 }
4159 } 4164 }
4160 4165
4161 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { 4166 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
4162 EndTest(); 4167 EndTest();
4163 } 4168 }
4164 4169
4165 void AfterTest() override { 4170 void AfterTest() override {
4166 // The pending swap promise should activate and swap. 4171 // The pending swap promise should activate and swap.
4167 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called); 4172 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called);
(...skipping 18 matching lines...) Expand all
4186 4191
4187 MULTI_THREAD_TEST_F(PinnedLayerTreeSwapPromise); 4192 MULTI_THREAD_TEST_F(PinnedLayerTreeSwapPromise);
4188 4193
4189 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { 4194 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest {
4190 protected: 4195 protected:
4191 LayerTreeHostTestBreakSwapPromise() 4196 LayerTreeHostTestBreakSwapPromise()
4192 : commit_count_(0), commit_complete_count_(0) {} 4197 : commit_count_(0), commit_complete_count_(0) {}
4193 4198
4194 void WillBeginMainFrame() override { 4199 void WillBeginMainFrame() override {
4195 ASSERT_LE(commit_count_, 2); 4200 ASSERT_LE(commit_count_, 2);
4196 scoped_ptr<SwapPromise> swap_promise( 4201 std::unique_ptr<SwapPromise> swap_promise(
4197 new TestSwapPromise(&swap_promise_result_[commit_count_])); 4202 new TestSwapPromise(&swap_promise_result_[commit_count_]));
4198 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); 4203 layer_tree_host()->QueueSwapPromise(std::move(swap_promise));
4199 } 4204 }
4200 4205
4201 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 4206 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4202 4207
4203 void DidCommit() override { 4208 void DidCommit() override {
4204 commit_count_++; 4209 commit_count_++;
4205 if (commit_count_ == 2) { 4210 if (commit_count_ == 2) {
4206 // This commit will finish. 4211 // This commit will finish.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 MainThreadTaskRunner()->PostTask( 4305 MainThreadTaskRunner()->PostTask(
4301 FROM_HERE, base::Bind(&LayerTreeHostTestKeepSwapPromise::ChangeFrame, 4306 FROM_HERE, base::Bind(&LayerTreeHostTestKeepSwapPromise::ChangeFrame,
4302 base::Unretained(this))); 4307 base::Unretained(this)));
4303 } 4308 }
4304 4309
4305 void ChangeFrame() { 4310 void ChangeFrame() {
4306 switch (layer_tree_host()->source_frame_number()) { 4311 switch (layer_tree_host()->source_frame_number()) {
4307 case 1: 4312 case 1:
4308 layer_->SetBounds(gfx::Size(10, 11)); 4313 layer_->SetBounds(gfx::Size(10, 11));
4309 layer_tree_host()->QueueSwapPromise( 4314 layer_tree_host()->QueueSwapPromise(
4310 make_scoped_ptr(new TestSwapPromise(&swap_promise_result_))); 4315 base::WrapUnique(new TestSwapPromise(&swap_promise_result_)));
4311 break; 4316 break;
4312 case 2: 4317 case 2:
4313 break; 4318 break;
4314 default: 4319 default:
4315 NOTREACHED(); 4320 NOTREACHED();
4316 break; 4321 break;
4317 } 4322 }
4318 } 4323 }
4319 4324
4320 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 4325 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4373 4378
4374 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestKeepSwapPromise); 4379 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestKeepSwapPromise);
4375 4380
4376 class LayerTreeHostTestBreakSwapPromiseForVisibility 4381 class LayerTreeHostTestBreakSwapPromiseForVisibility
4377 : public LayerTreeHostTest { 4382 : public LayerTreeHostTest {
4378 protected: 4383 protected:
4379 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 4384 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4380 4385
4381 void SetVisibleFalseAndQueueSwapPromise() { 4386 void SetVisibleFalseAndQueueSwapPromise() {
4382 layer_tree_host()->SetVisible(false); 4387 layer_tree_host()->SetVisible(false);
4383 scoped_ptr<SwapPromise> swap_promise( 4388 std::unique_ptr<SwapPromise> swap_promise(
4384 new TestSwapPromise(&swap_promise_result_)); 4389 new TestSwapPromise(&swap_promise_result_));
4385 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); 4390 layer_tree_host()->QueueSwapPromise(std::move(swap_promise));
4386 } 4391 }
4387 4392
4388 void ScheduledActionWillSendBeginMainFrame() override { 4393 void ScheduledActionWillSendBeginMainFrame() override {
4389 MainThreadTaskRunner()->PostTask( 4394 MainThreadTaskRunner()->PostTask(
4390 FROM_HERE, 4395 FROM_HERE,
4391 base::Bind(&LayerTreeHostTestBreakSwapPromiseForVisibility 4396 base::Bind(&LayerTreeHostTestBreakSwapPromiseForVisibility
4392 ::SetVisibleFalseAndQueueSwapPromise, 4397 ::SetVisibleFalseAndQueueSwapPromise,
4393 base::Unretained(this))); 4398 base::Unretained(this)));
(...skipping 23 matching lines...) Expand all
4417 class LayerTreeHostTestBreakSwapPromiseForContext : public LayerTreeHostTest { 4422 class LayerTreeHostTestBreakSwapPromiseForContext : public LayerTreeHostTest {
4418 protected: 4423 protected:
4419 LayerTreeHostTestBreakSwapPromiseForContext() 4424 LayerTreeHostTestBreakSwapPromiseForContext()
4420 : output_surface_lost_triggered_(false) { 4425 : output_surface_lost_triggered_(false) {
4421 } 4426 }
4422 4427
4423 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 4428 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4424 4429
4425 void LoseOutputSurfaceAndQueueSwapPromise() { 4430 void LoseOutputSurfaceAndQueueSwapPromise() {
4426 layer_tree_host()->DidLoseOutputSurface(); 4431 layer_tree_host()->DidLoseOutputSurface();
4427 scoped_ptr<SwapPromise> swap_promise( 4432 std::unique_ptr<SwapPromise> swap_promise(
4428 new TestSwapPromise(&swap_promise_result_)); 4433 new TestSwapPromise(&swap_promise_result_));
4429 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); 4434 layer_tree_host()->QueueSwapPromise(std::move(swap_promise));
4430 } 4435 }
4431 4436
4432 void ScheduledActionWillSendBeginMainFrame() override { 4437 void ScheduledActionWillSendBeginMainFrame() override {
4433 if (output_surface_lost_triggered_) 4438 if (output_surface_lost_triggered_)
4434 return; 4439 return;
4435 output_surface_lost_triggered_ = true; 4440 output_surface_lost_triggered_ = true;
4436 4441
4437 MainThreadTaskRunner()->PostTask( 4442 MainThreadTaskRunner()->PostTask(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4496 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 4501 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4497 4502
4498 void WillBeginMainFrame() override { 4503 void WillBeginMainFrame() override {
4499 if (TestEnded()) 4504 if (TestEnded())
4500 return; 4505 return;
4501 4506
4502 int set_needs_commit_count = 0; 4507 int set_needs_commit_count = 0;
4503 int set_needs_redraw_count = 0; 4508 int set_needs_redraw_count = 0;
4504 4509
4505 { 4510 {
4506 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( 4511 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
4507 new SimpleSwapPromiseMonitor(layer_tree_host(), 4512 new SimpleSwapPromiseMonitor(layer_tree_host(), NULL,
4508 NULL,
4509 &set_needs_commit_count, 4513 &set_needs_commit_count,
4510 &set_needs_redraw_count)); 4514 &set_needs_redraw_count));
4511 layer_tree_host()->SetNeedsCommit(); 4515 layer_tree_host()->SetNeedsCommit();
4512 EXPECT_EQ(1, set_needs_commit_count); 4516 EXPECT_EQ(1, set_needs_commit_count);
4513 EXPECT_EQ(0, set_needs_redraw_count); 4517 EXPECT_EQ(0, set_needs_redraw_count);
4514 } 4518 }
4515 4519
4516 // Now the monitor is destroyed, SetNeedsCommit() is no longer being 4520 // Now the monitor is destroyed, SetNeedsCommit() is no longer being
4517 // monitored. 4521 // monitored.
4518 layer_tree_host()->SetNeedsCommit(); 4522 layer_tree_host()->SetNeedsCommit();
4519 EXPECT_EQ(1, set_needs_commit_count); 4523 EXPECT_EQ(1, set_needs_commit_count);
4520 EXPECT_EQ(0, set_needs_redraw_count); 4524 EXPECT_EQ(0, set_needs_redraw_count);
4521 4525
4522 { 4526 {
4523 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( 4527 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
4524 new SimpleSwapPromiseMonitor(layer_tree_host(), 4528 new SimpleSwapPromiseMonitor(layer_tree_host(), NULL,
4525 NULL,
4526 &set_needs_commit_count, 4529 &set_needs_commit_count,
4527 &set_needs_redraw_count)); 4530 &set_needs_redraw_count));
4528 layer_tree_host()->SetNeedsUpdateLayers(); 4531 layer_tree_host()->SetNeedsUpdateLayers();
4529 EXPECT_EQ(2, set_needs_commit_count); 4532 EXPECT_EQ(2, set_needs_commit_count);
4530 EXPECT_EQ(0, set_needs_redraw_count); 4533 EXPECT_EQ(0, set_needs_redraw_count);
4531 } 4534 }
4532 4535
4533 { 4536 {
4534 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( 4537 std::unique_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
4535 new SimpleSwapPromiseMonitor(layer_tree_host(), 4538 new SimpleSwapPromiseMonitor(layer_tree_host(), NULL,
4536 NULL,
4537 &set_needs_commit_count, 4539 &set_needs_commit_count,
4538 &set_needs_redraw_count)); 4540 &set_needs_redraw_count));
4539 layer_tree_host()->SetNeedsAnimate(); 4541 layer_tree_host()->SetNeedsAnimate();
4540 EXPECT_EQ(3, set_needs_commit_count); 4542 EXPECT_EQ(3, set_needs_commit_count);
4541 EXPECT_EQ(0, set_needs_redraw_count); 4543 EXPECT_EQ(0, set_needs_redraw_count);
4542 } 4544 }
4543 4545
4544 EndTest(); 4546 EndTest();
4545 } 4547 }
4546 4548
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4578 case 2: 4580 case 2:
4579 ui_resource_ = nullptr; 4581 ui_resource_ = nullptr;
4580 EndTest(); 4582 EndTest();
4581 break; 4583 break;
4582 } 4584 }
4583 } 4585 }
4584 4586
4585 void AfterTest() override {} 4587 void AfterTest() override {}
4586 4588
4587 FakeContentLayerClient client_; 4589 FakeContentLayerClient client_;
4588 scoped_ptr<FakeScopedUIResource> ui_resource_; 4590 std::unique_ptr<FakeScopedUIResource> ui_resource_;
4589 }; 4591 };
4590 4592
4591 // This test is flaky, see http://crbug.com/386199 4593 // This test is flaky, see http://crbug.com/386199
4592 // MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources) 4594 // MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources)
4593 4595
4594 class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest { 4596 class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest {
4595 protected: 4597 protected:
4596 void InitializeSettings(LayerTreeSettings* settings) override { 4598 void InitializeSettings(LayerTreeSettings* settings) override {
4597 EXPECT_FALSE(settings->gpu_rasterization_enabled); 4599 EXPECT_FALSE(settings->gpu_rasterization_enabled);
4598 EXPECT_FALSE(settings->gpu_rasterization_forced); 4600 EXPECT_FALSE(settings->gpu_rasterization_forced);
4599 } 4601 }
4600 4602
4601 void SetupTree() override { 4603 void SetupTree() override {
4602 LayerTreeHostTest::SetupTree(); 4604 LayerTreeHostTest::SetupTree();
4603 4605
4604 scoped_ptr<FakeRecordingSource> recording_source(new FakeRecordingSource); 4606 std::unique_ptr<FakeRecordingSource> recording_source(
4607 new FakeRecordingSource);
4605 recording_source_ = recording_source.get(); 4608 recording_source_ = recording_source.get();
4606 4609
4607 scoped_refptr<FakePictureLayer> layer = 4610 scoped_refptr<FakePictureLayer> layer =
4608 FakePictureLayer::CreateWithRecordingSource( 4611 FakePictureLayer::CreateWithRecordingSource(
4609 &layer_client_, std::move(recording_source)); 4612 &layer_client_, std::move(recording_source));
4610 layer_ = layer.get(); 4613 layer_ = layer.get();
4611 layer->SetBounds(gfx::Size(10, 10)); 4614 layer->SetBounds(gfx::Size(10, 10));
4612 layer->SetIsDrawable(true); 4615 layer->SetIsDrawable(true);
4613 layer_tree_host()->root_layer()->AddChild(layer); 4616 layer_tree_host()->root_layer()->AddChild(layer);
4614 layer_client_.set_bounds(layer_->bounds()); 4617 layer_client_.set_bounds(layer_->bounds());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4649 FakeRecordingSource* recording_source_; 4652 FakeRecordingSource* recording_source_;
4650 }; 4653 };
4651 4654
4652 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationDefault); 4655 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationDefault);
4653 4656
4654 class LayerTreeHostTestEmptyLayerGpuRasterization : public LayerTreeHostTest { 4657 class LayerTreeHostTestEmptyLayerGpuRasterization : public LayerTreeHostTest {
4655 protected: 4658 protected:
4656 void SetupTree() override { 4659 void SetupTree() override {
4657 LayerTreeHostTest::SetupTree(); 4660 LayerTreeHostTest::SetupTree();
4658 4661
4659 scoped_ptr<FakeRecordingSource> recording_source(new FakeRecordingSource); 4662 std::unique_ptr<FakeRecordingSource> recording_source(
4663 new FakeRecordingSource);
4660 recording_source_ = recording_source.get(); 4664 recording_source_ = recording_source.get();
4661 4665
4662 scoped_refptr<FakePictureLayer> layer = 4666 scoped_refptr<FakePictureLayer> layer =
4663 FakePictureLayer::CreateWithRecordingSource( 4667 FakePictureLayer::CreateWithRecordingSource(
4664 &layer_client_, std::move(recording_source)); 4668 &layer_client_, std::move(recording_source));
4665 layer_ = layer.get(); 4669 layer_ = layer.get();
4666 layer->SetBounds(gfx::Size()); 4670 layer->SetBounds(gfx::Size());
4667 layer->SetIsDrawable(true); 4671 layer->SetIsDrawable(true);
4668 layer_tree_host()->root_layer()->AddChild(layer); 4672 layer_tree_host()->root_layer()->AddChild(layer);
4669 layer_client_.set_bounds(layer->bounds()); 4673 layer_client_.set_bounds(layer->bounds());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4706 class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { 4710 class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest {
4707 protected: 4711 protected:
4708 void InitializeSettings(LayerTreeSettings* settings) override { 4712 void InitializeSettings(LayerTreeSettings* settings) override {
4709 EXPECT_FALSE(settings->gpu_rasterization_enabled); 4713 EXPECT_FALSE(settings->gpu_rasterization_enabled);
4710 settings->gpu_rasterization_enabled = true; 4714 settings->gpu_rasterization_enabled = true;
4711 } 4715 }
4712 4716
4713 void SetupTree() override { 4717 void SetupTree() override {
4714 LayerTreeHostTest::SetupTree(); 4718 LayerTreeHostTest::SetupTree();
4715 4719
4716 scoped_ptr<FakeRecordingSource> recording_source(new FakeRecordingSource); 4720 std::unique_ptr<FakeRecordingSource> recording_source(
4721 new FakeRecordingSource);
4717 recording_source_ = recording_source.get(); 4722 recording_source_ = recording_source.get();
4718 4723
4719 scoped_refptr<FakePictureLayer> layer = 4724 scoped_refptr<FakePictureLayer> layer =
4720 FakePictureLayer::CreateWithRecordingSource( 4725 FakePictureLayer::CreateWithRecordingSource(
4721 &layer_client_, std::move(recording_source)); 4726 &layer_client_, std::move(recording_source));
4722 layer_ = layer.get(); 4727 layer_ = layer.get();
4723 layer->SetBounds(gfx::Size(10, 10)); 4728 layer->SetBounds(gfx::Size(10, 10));
4724 layer->SetIsDrawable(true); 4729 layer->SetIsDrawable(true);
4725 layer_tree_host()->root_layer()->AddChild(layer); 4730 layer_tree_host()->root_layer()->AddChild(layer);
4726 layer_client_.set_bounds(layer_->bounds()); 4731 layer_client_.set_bounds(layer_->bounds());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { 4780 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest {
4776 protected: 4781 protected:
4777 void InitializeSettings(LayerTreeSettings* settings) override { 4782 void InitializeSettings(LayerTreeSettings* settings) override {
4778 EXPECT_FALSE(settings->gpu_rasterization_forced); 4783 EXPECT_FALSE(settings->gpu_rasterization_forced);
4779 settings->gpu_rasterization_forced = true; 4784 settings->gpu_rasterization_forced = true;
4780 } 4785 }
4781 4786
4782 void SetupTree() override { 4787 void SetupTree() override {
4783 LayerTreeHostTest::SetupTree(); 4788 LayerTreeHostTest::SetupTree();
4784 4789
4785 scoped_ptr<FakeRecordingSource> recording_source(new FakeRecordingSource); 4790 std::unique_ptr<FakeRecordingSource> recording_source(
4791 new FakeRecordingSource);
4786 recording_source_ = recording_source.get(); 4792 recording_source_ = recording_source.get();
4787 4793
4788 scoped_refptr<FakePictureLayer> layer = 4794 scoped_refptr<FakePictureLayer> layer =
4789 FakePictureLayer::CreateWithRecordingSource( 4795 FakePictureLayer::CreateWithRecordingSource(
4790 &layer_client_, std::move(recording_source)); 4796 &layer_client_, std::move(recording_source));
4791 layer_ = layer.get(); 4797 layer_ = layer.get();
4792 4798
4793 layer->SetBounds(gfx::Size(10, 10)); 4799 layer->SetBounds(gfx::Size(10, 10));
4794 layer->SetIsDrawable(true); 4800 layer->SetIsDrawable(true);
4795 layer_tree_host()->root_layer()->AddChild(layer); 4801 layer_tree_host()->root_layer()->AddChild(layer);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
5090 public: 5096 public:
5091 LayerTreeHostTestSynchronousCompositeSwapPromise() : commit_count_(0) {} 5097 LayerTreeHostTestSynchronousCompositeSwapPromise() : commit_count_(0) {}
5092 5098
5093 void InitializeSettings(LayerTreeSettings* settings) override { 5099 void InitializeSettings(LayerTreeSettings* settings) override {
5094 settings->single_thread_proxy_scheduler = false; 5100 settings->single_thread_proxy_scheduler = false;
5095 settings->use_zero_copy = true; 5101 settings->use_zero_copy = true;
5096 } 5102 }
5097 5103
5098 void BeginTest() override { 5104 void BeginTest() override {
5099 // Successful composite. 5105 // Successful composite.
5100 scoped_ptr<SwapPromise> swap_promise0( 5106 std::unique_ptr<SwapPromise> swap_promise0(
5101 new TestSwapPromise(&swap_promise_result_[0])); 5107 new TestSwapPromise(&swap_promise_result_[0]));
5102 layer_tree_host()->QueueSwapPromise(std::move(swap_promise0)); 5108 layer_tree_host()->QueueSwapPromise(std::move(swap_promise0));
5103 layer_tree_host()->Composite(base::TimeTicks::Now()); 5109 layer_tree_host()->Composite(base::TimeTicks::Now());
5104 5110
5105 // Fail to swap (no damage). 5111 // Fail to swap (no damage).
5106 scoped_ptr<SwapPromise> swap_promise1( 5112 std::unique_ptr<SwapPromise> swap_promise1(
5107 new TestSwapPromise(&swap_promise_result_[1])); 5113 new TestSwapPromise(&swap_promise_result_[1]));
5108 layer_tree_host()->QueueSwapPromise(std::move(swap_promise1)); 5114 layer_tree_host()->QueueSwapPromise(std::move(swap_promise1));
5109 layer_tree_host()->SetNeedsCommit(); 5115 layer_tree_host()->SetNeedsCommit();
5110 layer_tree_host()->Composite(base::TimeTicks::Now()); 5116 layer_tree_host()->Composite(base::TimeTicks::Now());
5111 5117
5112 // Fail to draw (not visible). 5118 // Fail to draw (not visible).
5113 scoped_ptr<SwapPromise> swap_promise2( 5119 std::unique_ptr<SwapPromise> swap_promise2(
5114 new TestSwapPromise(&swap_promise_result_[2])); 5120 new TestSwapPromise(&swap_promise_result_[2]));
5115 layer_tree_host()->QueueSwapPromise(std::move(swap_promise2)); 5121 layer_tree_host()->QueueSwapPromise(std::move(swap_promise2));
5116 layer_tree_host()->SetNeedsDisplayOnAllLayers(); 5122 layer_tree_host()->SetNeedsDisplayOnAllLayers();
5117 layer_tree_host()->SetVisible(false); 5123 layer_tree_host()->SetVisible(false);
5118 layer_tree_host()->Composite(base::TimeTicks::Now()); 5124 layer_tree_host()->Composite(base::TimeTicks::Now());
5119 5125
5120 EndTest(); 5126 EndTest();
5121 } 5127 }
5122 5128
5123 void DidCommit() override { 5129 void DidCommit() override {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
5221 scoped_refptr<Layer> page_scale_layer = Layer::Create(); 5227 scoped_refptr<Layer> page_scale_layer = Layer::Create();
5222 page_scale_layer->SetBounds(gfx::Size(500, 500)); 5228 page_scale_layer->SetBounds(gfx::Size(500, 500));
5223 5229
5224 scoped_refptr<Layer> pinch = Layer::Create(); 5230 scoped_refptr<Layer> pinch = Layer::Create();
5225 pinch->SetBounds(gfx::Size(500, 500)); 5231 pinch->SetBounds(gfx::Size(500, 500));
5226 pinch->SetScrollClipLayerId(root_clip->id()); 5232 pinch->SetScrollClipLayerId(root_clip->id());
5227 pinch->SetIsContainerForFixedPositionLayers(true); 5233 pinch->SetIsContainerForFixedPositionLayers(true);
5228 page_scale_layer->AddChild(pinch); 5234 page_scale_layer->AddChild(pinch);
5229 root_clip->AddChild(page_scale_layer); 5235 root_clip->AddChild(page_scale_layer);
5230 5236
5231 scoped_ptr<FakeRecordingSource> recording(new FakeRecordingSource); 5237 std::unique_ptr<FakeRecordingSource> recording(new FakeRecordingSource);
5232 recording->SetPlaybackAllowedEvent(&playback_allowed_event_); 5238 recording->SetPlaybackAllowedEvent(&playback_allowed_event_);
5233 scoped_refptr<FakePictureLayer> layer = 5239 scoped_refptr<FakePictureLayer> layer =
5234 FakePictureLayer::CreateWithRecordingSource(&client_, 5240 FakePictureLayer::CreateWithRecordingSource(&client_,
5235 std::move(recording)); 5241 std::move(recording));
5236 layer->SetBounds(gfx::Size(500, 500)); 5242 layer->SetBounds(gfx::Size(500, 500));
5237 layer->SetContentsOpaque(true); 5243 layer->SetContentsOpaque(true);
5238 // Avoid LCD text on the layer so we don't cause extra commits when we 5244 // Avoid LCD text on the layer so we don't cause extra commits when we
5239 // pinch. 5245 // pinch.
5240 pinch->AddChild(layer); 5246 pinch->AddChild(layer);
5241 5247
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
5391 base::WaitableEvent playback_allowed_event_; 5397 base::WaitableEvent playback_allowed_event_;
5392 }; 5398 };
5393 5399
5394 // This test does pinching on the impl side which is not supported in single 5400 // This test does pinching on the impl side which is not supported in single
5395 // thread. 5401 // thread.
5396 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); 5402 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds);
5397 5403
5398 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy 5404 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy
5399 : public LayerTreeHostTestCrispUpAfterPinchEnds { 5405 : public LayerTreeHostTestCrispUpAfterPinchEnds {
5400 protected: 5406 protected:
5401 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { 5407 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
5402 scoped_ptr<TestWebGraphicsContext3D> context3d = 5408 std::unique_ptr<TestWebGraphicsContext3D> context3d =
5403 TestWebGraphicsContext3D::Create(); 5409 TestWebGraphicsContext3D::Create();
5404 context3d->set_support_image(true); 5410 context3d->set_support_image(true);
5405 context3d->set_support_sync_query(true); 5411 context3d->set_support_sync_query(true);
5406 #if defined(OS_MACOSX) 5412 #if defined(OS_MACOSX)
5407 context3d->set_support_texture_rectangle(true); 5413 context3d->set_support_texture_rectangle(true);
5408 #endif 5414 #endif
5409 5415
5410 if (delegating_renderer()) 5416 if (delegating_renderer())
5411 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); 5417 return FakeOutputSurface::CreateDelegating3d(std::move(context3d));
5412 else 5418 else
(...skipping 13 matching lines...) Expand all
5426 settings->gpu_rasterization_forced = true; 5432 settings->gpu_rasterization_forced = true;
5427 } 5433 }
5428 5434
5429 void SetupTree() override { 5435 void SetupTree() override {
5430 client_.set_fill_with_nonsolid_color(true); 5436 client_.set_fill_with_nonsolid_color(true);
5431 5437
5432 scoped_refptr<Layer> root = Layer::Create(); 5438 scoped_refptr<Layer> root = Layer::Create();
5433 root->SetBounds(gfx::Size(500, 500)); 5439 root->SetBounds(gfx::Size(500, 500));
5434 client_.set_bounds(root->bounds()); 5440 client_.set_bounds(root->bounds());
5435 5441
5436 scoped_ptr<FakeRecordingSource> recording(new FakeRecordingSource); 5442 std::unique_ptr<FakeRecordingSource> recording(new FakeRecordingSource);
5437 scoped_refptr<FakePictureLayer> layer = 5443 scoped_refptr<FakePictureLayer> layer =
5438 FakePictureLayer::CreateWithRecordingSource(&client_, 5444 FakePictureLayer::CreateWithRecordingSource(&client_,
5439 std::move(recording)); 5445 std::move(recording));
5440 layer->SetBounds(gfx::Size(500, 500)); 5446 layer->SetBounds(gfx::Size(500, 500));
5441 layer->SetContentsOpaque(true); 5447 layer->SetContentsOpaque(true);
5442 root->AddChild(layer); 5448 root->AddChild(layer);
5443 5449
5444 layer_tree_host()->SetRootLayer(root); 5450 layer_tree_host()->SetRootLayer(root);
5445 LayerTreeHostTest::SetupTree(); 5451 LayerTreeHostTest::SetupTree();
5446 client_.set_bounds(root->bounds()); 5452 client_.set_bounds(root->bounds());
(...skipping 20 matching lines...) Expand all
5467 GpuRasterizationRasterizesBorderTiles() : viewport_size_(1024, 2048) {} 5473 GpuRasterizationRasterizesBorderTiles() : viewport_size_(1024, 2048) {}
5468 5474
5469 void InitializeSettings(LayerTreeSettings* settings) override { 5475 void InitializeSettings(LayerTreeSettings* settings) override {
5470 settings->gpu_rasterization_enabled = true; 5476 settings->gpu_rasterization_enabled = true;
5471 settings->gpu_rasterization_forced = true; 5477 settings->gpu_rasterization_forced = true;
5472 } 5478 }
5473 5479
5474 void SetupTree() override { 5480 void SetupTree() override {
5475 client_.set_fill_with_nonsolid_color(true); 5481 client_.set_fill_with_nonsolid_color(true);
5476 5482
5477 scoped_ptr<FakeRecordingSource> recording(new FakeRecordingSource); 5483 std::unique_ptr<FakeRecordingSource> recording(new FakeRecordingSource);
5478 scoped_refptr<FakePictureLayer> root = 5484 scoped_refptr<FakePictureLayer> root =
5479 FakePictureLayer::CreateWithRecordingSource(&client_, 5485 FakePictureLayer::CreateWithRecordingSource(&client_,
5480 std::move(recording)); 5486 std::move(recording));
5481 root->SetBounds(gfx::Size(10000, 10000)); 5487 root->SetBounds(gfx::Size(10000, 10000));
5482 client_.set_bounds(root->bounds()); 5488 client_.set_bounds(root->bounds());
5483 root->SetContentsOpaque(true); 5489 root->SetContentsOpaque(true);
5484 5490
5485 layer_tree_host()->SetRootLayer(root); 5491 layer_tree_host()->SetRootLayer(root);
5486 LayerTreeHostTest::SetupTree(); 5492 LayerTreeHostTest::SetupTree();
5487 layer_tree_host()->SetViewportSize(viewport_size_); 5493 layer_tree_host()->SetViewportSize(viewport_size_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5523 scoped_refptr<Layer> page_scale_layer = Layer::Create(); 5529 scoped_refptr<Layer> page_scale_layer = Layer::Create();
5524 page_scale_layer->SetBounds(gfx::Size(500, 500)); 5530 page_scale_layer->SetBounds(gfx::Size(500, 500));
5525 5531
5526 scoped_refptr<Layer> pinch = Layer::Create(); 5532 scoped_refptr<Layer> pinch = Layer::Create();
5527 pinch->SetBounds(gfx::Size(500, 500)); 5533 pinch->SetBounds(gfx::Size(500, 500));
5528 pinch->SetScrollClipLayerId(root_clip->id()); 5534 pinch->SetScrollClipLayerId(root_clip->id());
5529 pinch->SetIsContainerForFixedPositionLayers(true); 5535 pinch->SetIsContainerForFixedPositionLayers(true);
5530 page_scale_layer->AddChild(pinch); 5536 page_scale_layer->AddChild(pinch);
5531 root_clip->AddChild(page_scale_layer); 5537 root_clip->AddChild(page_scale_layer);
5532 5538
5533 scoped_ptr<FakeRecordingSource> recording(new FakeRecordingSource); 5539 std::unique_ptr<FakeRecordingSource> recording(new FakeRecordingSource);
5534 recording->SetPlaybackAllowedEvent(&playback_allowed_event_); 5540 recording->SetPlaybackAllowedEvent(&playback_allowed_event_);
5535 scoped_refptr<FakePictureLayer> layer = 5541 scoped_refptr<FakePictureLayer> layer =
5536 FakePictureLayer::CreateWithRecordingSource(&client_, 5542 FakePictureLayer::CreateWithRecordingSource(&client_,
5537 std::move(recording)); 5543 std::move(recording));
5538 layer->SetBounds(gfx::Size(500, 500)); 5544 layer->SetBounds(gfx::Size(500, 500));
5539 layer->SetContentsOpaque(true); 5545 layer->SetContentsOpaque(true);
5540 // Avoid LCD text on the layer so we don't cause extra commits when we 5546 // Avoid LCD text on the layer so we don't cause extra commits when we
5541 // pinch. 5547 // pinch.
5542 pinch->AddChild(layer); 5548 pinch->AddChild(layer);
5543 5549
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
5778 5784
5779 // Since in reality, the events will be read by LayerTreeHost during commit, 5785 // Since in reality, the events will be read by LayerTreeHost during commit,
5780 // we check the requests here to ensure that they are correct at the next 5786 // we check the requests here to ensure that they are correct at the next
5781 // commit time (as opposed to checking in DrawLayers for instance). 5787 // commit time (as opposed to checking in DrawLayers for instance).
5782 // TODO(vmpstr): Change this to read things from the main thread when this 5788 // TODO(vmpstr): Change this to read things from the main thread when this
5783 // information is propagated to the main thread (not yet implemented). 5789 // information is propagated to the main thread (not yet implemented).
5784 FrameTimingTracker* tracker = host_impl->frame_timing_tracker(); 5790 FrameTimingTracker* tracker = host_impl->frame_timing_tracker();
5785 5791
5786 // Check composite events. 5792 // Check composite events.
5787 { 5793 {
5788 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timing_set = 5794 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> timing_set =
5789 tracker->GroupCompositeCountsByRectId(); 5795 tracker->GroupCompositeCountsByRectId();
5790 EXPECT_EQ(1u, timing_set->size()); 5796 EXPECT_EQ(1u, timing_set->size());
5791 auto rect_1_it = timing_set->find(1); 5797 auto rect_1_it = timing_set->find(1);
5792 EXPECT_TRUE(rect_1_it != timing_set->end()); 5798 EXPECT_TRUE(rect_1_it != timing_set->end());
5793 const auto& timing_events = rect_1_it->second; 5799 const auto& timing_events = rect_1_it->second;
5794 EXPECT_EQ(1u, timing_events.size()); 5800 EXPECT_EQ(1u, timing_events.size());
5795 EXPECT_EQ(host_impl->active_tree()->source_frame_number(), 5801 EXPECT_EQ(host_impl->active_tree()->source_frame_number(),
5796 timing_events[0].frame_id); 5802 timing_events[0].frame_id);
5797 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks()); 5803 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks());
5798 } 5804 }
5799 5805
5800 // Check main frame events. 5806 // Check main frame events.
5801 { 5807 {
5802 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> timing_set = 5808 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> timing_set =
5803 tracker->GroupMainFrameCountsByRectId(); 5809 tracker->GroupMainFrameCountsByRectId();
5804 EXPECT_EQ(2u, timing_set->size()); 5810 EXPECT_EQ(2u, timing_set->size());
5805 auto rect_1_it = timing_set->find(1); 5811 auto rect_1_it = timing_set->find(1);
5806 EXPECT_TRUE(rect_1_it != timing_set->end()); 5812 EXPECT_TRUE(rect_1_it != timing_set->end());
5807 const auto& timing_events = rect_1_it->second; 5813 const auto& timing_events = rect_1_it->second;
5808 EXPECT_EQ(1u, timing_events.size()); 5814 EXPECT_EQ(1u, timing_events.size());
5809 EXPECT_EQ(host_impl->active_tree()->source_frame_number(), 5815 EXPECT_EQ(host_impl->active_tree()->source_frame_number(),
5810 timing_events[0].frame_id); 5816 timing_events[0].frame_id);
5811 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks()); 5817 EXPECT_GT(timing_events[0].timestamp, base::TimeTicks());
5812 EXPECT_GT(timing_events[0].end_time, timing_events[0].timestamp); 5818 EXPECT_GT(timing_events[0].end_time, timing_events[0].timestamp);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
5917 class LayerTreeHostTestUpdateCopyRequests : public LayerTreeHostTest { 5923 class LayerTreeHostTestUpdateCopyRequests : public LayerTreeHostTest {
5918 protected: 5924 protected:
5919 void SetupTree() override { 5925 void SetupTree() override {
5920 root = Layer::Create(); 5926 root = Layer::Create();
5921 child = Layer::Create(); 5927 child = Layer::Create();
5922 root->AddChild(child); 5928 root->AddChild(child);
5923 layer_tree_host()->SetRootLayer(root); 5929 layer_tree_host()->SetRootLayer(root);
5924 LayerTreeHostTest::SetupTree(); 5930 LayerTreeHostTest::SetupTree();
5925 } 5931 }
5926 5932
5927 static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} 5933 static void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
5928 5934
5929 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 5935 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
5930 5936
5931 void WillCommit() override { 5937 void WillCommit() override {
5932 switch (layer_tree_host()->source_frame_number()) { 5938 switch (layer_tree_host()->source_frame_number()) {
5933 case 1: 5939 case 1:
5934 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); 5940 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0);
5935 break; 5941 break;
5936 } 5942 }
5937 } 5943 }
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
6618 EndTest(); 6624 EndTest();
6619 } 6625 }
6620 6626
6621 void AfterTest() override {} 6627 void AfterTest() override {}
6622 }; 6628 };
6623 6629
6624 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); 6630 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor);
6625 6631
6626 } // namespace 6632 } // namespace
6627 } // namespace cc 6633 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_pixeltest_tiles.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698