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

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

Issue 2100353002: cc: DCHECK that the OutputSurface was released in ~LayerTreeHostImpl(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: released-outputsurface: rebase-on-2106273002 Created 4 years, 5 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/layer_tree_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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 settings.renderer_settings.texture_id_allocation_chunk_size = 1; 112 settings.renderer_settings.texture_id_allocation_chunk_size = 1;
113 settings.gpu_rasterization_enabled = true; 113 settings.gpu_rasterization_enabled = true;
114 settings.verify_clip_tree_calculations = true; 114 settings.verify_clip_tree_calculations = true;
115 return settings; 115 return settings;
116 } 116 }
117 117
118 void SetUp() override { 118 void SetUp() override {
119 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); 119 CreateHostImpl(DefaultSettings(), CreateOutputSurface());
120 } 120 }
121 121
122 void TearDown() override {} 122 void TearDown() override {
123 if (host_impl_)
124 host_impl_->ReleaseOutputSurface();
125 }
123 126
124 void UpdateRendererCapabilitiesOnImplThread() override {} 127 void UpdateRendererCapabilitiesOnImplThread() override {}
125 void DidLoseOutputSurfaceOnImplThread() override {} 128 void DidLoseOutputSurfaceOnImplThread() override {}
126 void CommitVSyncParameters(base::TimeTicks timebase, 129 void CommitVSyncParameters(base::TimeTicks timebase,
127 base::TimeDelta interval) override {} 130 base::TimeDelta interval) override {}
128 void SetBeginFrameSource(BeginFrameSource* source) override {} 131 void SetBeginFrameSource(BeginFrameSource* source) override {}
129 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} 132 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {}
130 void DidSwapBuffersOnImplThread() override {} 133 void DidSwapBuffersOnImplThread() override {}
131 void DidSwapBuffersCompleteOnImplThread() override {} 134 void DidSwapBuffersCompleteOnImplThread() override {}
132 void OnCanDrawStateChanged(bool can_draw) override { 135 void OnCanDrawStateChanged(bool can_draw) override {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 virtual bool CreateHostImpl(const LayerTreeSettings& settings, 187 virtual bool CreateHostImpl(const LayerTreeSettings& settings,
185 std::unique_ptr<OutputSurface> output_surface) { 188 std::unique_ptr<OutputSurface> output_surface) {
186 return CreateHostImplWithTaskRunnerProvider( 189 return CreateHostImplWithTaskRunnerProvider(
187 settings, std::move(output_surface), &task_runner_provider_); 190 settings, std::move(output_surface), &task_runner_provider_);
188 } 191 }
189 192
190 virtual bool CreateHostImplWithTaskRunnerProvider( 193 virtual bool CreateHostImplWithTaskRunnerProvider(
191 const LayerTreeSettings& settings, 194 const LayerTreeSettings& settings,
192 std::unique_ptr<OutputSurface> output_surface, 195 std::unique_ptr<OutputSurface> output_surface,
193 TaskRunnerProvider* task_runner_provider) { 196 TaskRunnerProvider* task_runner_provider) {
197 if (host_impl_)
198 host_impl_->ReleaseOutputSurface();
194 host_impl_ = LayerTreeHostImpl::Create( 199 host_impl_ = LayerTreeHostImpl::Create(
195 settings, this, task_runner_provider, &stats_instrumentation_, 200 settings, this, task_runner_provider, &stats_instrumentation_,
196 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, 201 &shared_bitmap_manager_, &gpu_memory_buffer_manager_,
197 &task_graph_runner_, 202 &task_graph_runner_,
198 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 203 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
199 output_surface_ = std::move(output_surface); 204 output_surface_ = std::move(output_surface);
200 host_impl_->SetVisible(true); 205 host_impl_->SetVisible(true);
201 bool init = host_impl_->InitializeRenderer(output_surface_.get()); 206 bool init = host_impl_->InitializeRenderer(output_surface_.get());
202 host_impl_->SetViewportSize(gfx::Size(10, 10)); 207 host_impl_->SetViewportSize(gfx::Size(10, 10));
203 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 208 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 LayerImpl* root = *host_impl_->active_tree()->begin(); 1347 LayerImpl* root = *host_impl_->active_tree()->begin();
1343 root->SetBounds(gfx::Size(50, 50)); 1348 root->SetBounds(gfx::Size(50, 50));
1344 root->test_properties()->force_render_surface = true; 1349 root->test_properties()->force_render_surface = true;
1345 1350
1346 root->test_properties()->AddChild( 1351 root->test_properties()->AddChild(
1347 LayerImpl::Create(host_impl_->active_tree(), 2)); 1352 LayerImpl::Create(host_impl_->active_tree(), 2));
1348 LayerImpl* child = root->test_properties()->children[0]; 1353 LayerImpl* child = root->test_properties()->children[0];
1349 child->SetBounds(gfx::Size(10, 10)); 1354 child->SetBounds(gfx::Size(10, 10));
1350 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1355 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1351 child->SetDrawsContent(true); 1356 child->SetDrawsContent(true);
1352 1357 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1353 host_impl_->active_tree()->SetElementIdsForTesting(); 1358 host_impl_->active_tree()->SetElementIdsForTesting();
1354 1359
1355 // Add a translate from 6,7 to 8,9. 1360 // Add a translate from 6,7 to 8,9.
1356 TransformOperations start; 1361 TransformOperations start;
1357 start.AppendTranslate(6.f, 7.f, 0.f); 1362 start.AppendTranslate(6.f, 7.f, 0.f);
1358 TransformOperations end; 1363 TransformOperations end;
1359 end.AppendTranslate(8.f, 9.f, 0.f); 1364 end.AppendTranslate(8.f, 9.f, 0.f);
1360 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, 1365 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0,
1361 start, end); 1366 start, end);
1362 1367
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 1440
1436 host_impl_->CommitComplete(); 1441 host_impl_->CommitComplete();
1437 1442
1438 // Animations on the active tree should be started and ticked, and a new frame 1443 // Animations on the active tree should be started and ticked, and a new frame
1439 // should be requested to continue ticking them. 1444 // should be requested to continue ticking them.
1440 EXPECT_TRUE(did_request_next_frame_); 1445 EXPECT_TRUE(did_request_next_frame_);
1441 EXPECT_TRUE(did_request_redraw_); 1446 EXPECT_TRUE(did_request_redraw_);
1442 EXPECT_FALSE(did_request_commit_); 1447 EXPECT_FALSE(did_request_commit_);
1443 1448
1444 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. 1449 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away.
1450 host_impl_->ReleaseOutputSurface();
1445 host_impl_ = nullptr; 1451 host_impl_ = nullptr;
1446 } 1452 }
1447 1453
1448 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { 1454 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) {
1449 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1455 host_impl_->SetViewportSize(gfx::Size(50, 50));
1450 1456
1451 host_impl_->active_tree()->SetRootLayerForTesting( 1457 host_impl_->active_tree()->SetRootLayerForTesting(
1452 LayerImpl::Create(host_impl_->active_tree(), 1)); 1458 LayerImpl::Create(host_impl_->active_tree(), 1));
1453 LayerImpl* root = *host_impl_->active_tree()->begin(); 1459 LayerImpl* root = *host_impl_->active_tree()->begin();
1454 root->SetBounds(gfx::Size(50, 50)); 1460 root->SetBounds(gfx::Size(50, 50));
1455 1461
1456 root->test_properties()->AddChild( 1462 root->test_properties()->AddChild(
1457 LayerImpl::Create(host_impl_->active_tree(), 2)); 1463 LayerImpl::Create(host_impl_->active_tree(), 2));
1458 LayerImpl* child = root->test_properties()->children[0]; 1464 LayerImpl* child = root->test_properties()->children[0];
1459 child->SetBounds(gfx::Size(10, 10)); 1465 child->SetBounds(gfx::Size(10, 10));
1460 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1466 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1461 child->SetDrawsContent(true); 1467 child->SetDrawsContent(true);
1462 1468
1469 host_impl_->active_tree()->BuildPropertyTreesForTesting();
1463 host_impl_->active_tree()->SetElementIdsForTesting(); 1470 host_impl_->active_tree()->SetElementIdsForTesting();
1464 1471
1465 // Add a translate animation. 1472 // Add a translate animation.
1466 TransformOperations start; 1473 TransformOperations start;
1467 start.AppendTranslate(6.f, 7.f, 0.f); 1474 start.AppendTranslate(6.f, 7.f, 0.f);
1468 TransformOperations end; 1475 TransformOperations end;
1469 end.AppendTranslate(8.f, 9.f, 0.f); 1476 end.AppendTranslate(8.f, 9.f, 0.f);
1470 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, 1477 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0,
1471 start, end); 1478 start, end);
1472 1479
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 fake_current_physical_time_ = fake_now; 2709 fake_current_physical_time_ = fake_now;
2703 } 2710 }
2704 2711
2705 private: 2712 private:
2706 base::TimeTicks fake_current_physical_time_; 2713 base::TimeTicks fake_current_physical_time_;
2707 }; 2714 };
2708 2715
2709 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { 2716 class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest {
2710 protected: 2717 protected:
2711 void SetupLayers(LayerTreeSettings settings) { 2718 void SetupLayers(LayerTreeSettings settings) {
2719 host_impl_->ReleaseOutputSurface();
2720 host_impl_ = nullptr;
2721
2712 gfx::Size content_size(100, 100); 2722 gfx::Size content_size(100, 100);
2713 2723
2714 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = 2724 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
2715 new LayerTreeHostImplOverridePhysicalTime( 2725 new LayerTreeHostImplOverridePhysicalTime(
2716 settings, this, &task_runner_provider_, &shared_bitmap_manager_, 2726 settings, this, &task_runner_provider_, &shared_bitmap_manager_,
2717 &task_graph_runner_, &stats_instrumentation_); 2727 &task_graph_runner_, &stats_instrumentation_);
2718 host_impl_ = base::WrapUnique(host_impl_override_time); 2728 host_impl_ = base::WrapUnique(host_impl_override_time);
2719 output_surface_ = CreateOutputSurface(); 2729 output_surface_ = CreateOutputSurface();
2720 host_impl_->SetVisible(true); 2730 host_impl_->SetVisible(true);
2721 host_impl_->InitializeRenderer(output_surface_.get()); 2731 host_impl_->InitializeRenderer(output_surface_.get());
(...skipping 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
5877 // sees the correct size of the new tree. 5887 // sees the correct size of the new tree.
5878 gfx::Size new_size(42, 24); 5888 gfx::Size new_size(42, 24);
5879 host_impl_->CreatePendingTree(); 5889 host_impl_->CreatePendingTree();
5880 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 5890 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
5881 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); 5891 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size);
5882 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 5892 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
5883 host_impl_->ActivateSyncTree(); 5893 host_impl_->ActivateSyncTree();
5884 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size()); 5894 EXPECT_EQ(gfx::SizeF(new_size), scroll_watcher.scrollable_size());
5885 5895
5886 // Tear down the LayerTreeHostImpl before the InputHandlerClient. 5896 // Tear down the LayerTreeHostImpl before the InputHandlerClient.
5887 host_impl_.reset(); 5897 host_impl_->ReleaseOutputSurface();
5898 host_impl_ = nullptr;
5888 } 5899 }
5889 5900
5890 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { 5901 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) {
5891 const gfx::Transform target_space_transform = 5902 const gfx::Transform target_space_transform =
5892 layer->draw_properties().target_space_transform; 5903 layer->draw_properties().target_space_transform;
5893 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); 5904 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation());
5894 gfx::Point translated_point; 5905 gfx::Point translated_point;
5895 target_space_transform.TransformPoint(&translated_point); 5906 target_space_transform.TransformPoint(&translated_point);
5896 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); 5907 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta);
5897 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); 5908 EXPECT_EQ(expected_point.ToString(), translated_point.ToString());
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
7051 ->root_layer_for_testing() 7062 ->root_layer_for_testing()
7052 ->SetBackgroundColor(SK_ColorBLACK); 7063 ->SetBackgroundColor(SK_ColorBLACK);
7053 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 7064 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
7054 layer_tree_host_impl->DrawLayers(&frame); 7065 layer_tree_host_impl->DrawLayers(&frame);
7055 host_impl_->DidDrawAllLayers(frame); 7066 host_impl_->DidDrawAllLayers(frame);
7056 layer_tree_host_impl->SwapBuffers(frame); 7067 layer_tree_host_impl->SwapBuffers(frame);
7057 7068
7058 expected_swap_rect = gfx::Rect(0, 0, 10, 10); 7069 expected_swap_rect = gfx::Rect(0, 0, 10, 10);
7059 EXPECT_EQ(expected_swap_rect.ToString(), 7070 EXPECT_EQ(expected_swap_rect.ToString(),
7060 fake_output_surface->last_swap_rect().ToString()); 7071 fake_output_surface->last_swap_rect().ToString());
7072
7073 layer_tree_host_impl->ReleaseOutputSurface();
7061 } 7074 }
7062 7075
7063 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 7076 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
7064 std::unique_ptr<LayerImpl> root = 7077 std::unique_ptr<LayerImpl> root =
7065 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 7078 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
7066 std::unique_ptr<LayerImpl> child = 7079 std::unique_ptr<LayerImpl> child =
7067 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 7080 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
7068 child->SetBounds(gfx::Size(10, 10)); 7081 child->SetBounds(gfx::Size(10, 10));
7069 child->SetDrawsContent(true); 7082 child->SetDrawsContent(true);
7070 root->SetBounds(gfx::Size(10, 10)); 7083 root->SetBounds(gfx::Size(10, 10));
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
7373 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7386 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7374 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7387 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7375 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7388 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7376 frame.render_passes[0]->quad_list.front()->material); 7389 frame.render_passes[0]->quad_list.front()->material);
7377 EXPECT_EQ(DrawQuad::RENDER_PASS, 7390 EXPECT_EQ(DrawQuad::RENDER_PASS,
7378 frame.render_passes[1]->quad_list.front()->material); 7391 frame.render_passes[1]->quad_list.front()->material);
7379 7392
7380 my_host_impl->DrawLayers(&frame); 7393 my_host_impl->DrawLayers(&frame);
7381 my_host_impl->DidDrawAllLayers(frame); 7394 my_host_impl->DidDrawAllLayers(frame);
7382 } 7395 }
7396 my_host_impl->ReleaseOutputSurface();
7383 } 7397 }
7384 7398
7385 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 7399 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
7386 TestSharedBitmapManager shared_bitmap_manager; 7400 TestSharedBitmapManager shared_bitmap_manager;
7387 TestTaskGraphRunner task_graph_runner; 7401 TestTaskGraphRunner task_graph_runner;
7388 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7402 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
7389 provider->BindToCurrentThread(); 7403 provider->BindToCurrentThread();
7390 provider->TestContext3d()->set_have_post_sub_buffer(true); 7404 provider->TestContext3d()->set_have_post_sub_buffer(true);
7391 std::unique_ptr<OutputSurface> output_surface( 7405 std::unique_ptr<OutputSurface> output_surface(
7392 FakeOutputSurface::Create3d(provider)); 7406 FakeOutputSurface::Create3d(provider));
(...skipping 10 matching lines...) Expand all
7403 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7417 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7404 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7418 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7405 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7419 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7406 frame.render_passes[0]->quad_list.front()->material); 7420 frame.render_passes[0]->quad_list.front()->material);
7407 EXPECT_EQ(DrawQuad::RENDER_PASS, 7421 EXPECT_EQ(DrawQuad::RENDER_PASS,
7408 frame.render_passes[1]->quad_list.front()->material); 7422 frame.render_passes[1]->quad_list.front()->material);
7409 7423
7410 my_host_impl->DrawLayers(&frame); 7424 my_host_impl->DrawLayers(&frame);
7411 my_host_impl->DidDrawAllLayers(frame); 7425 my_host_impl->DidDrawAllLayers(frame);
7412 } 7426 }
7427 my_host_impl->ReleaseOutputSurface();
7413 } 7428 }
7414 7429
7415 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { 7430 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) {
7416 std::unique_ptr<TestWebGraphicsContext3D> context = 7431 std::unique_ptr<TestWebGraphicsContext3D> context =
7417 TestWebGraphicsContext3D::Create(); 7432 TestWebGraphicsContext3D::Create();
7418 TestWebGraphicsContext3D* context3d = context.get(); 7433 TestWebGraphicsContext3D* context3d = context.get();
7419 std::unique_ptr<OutputSurface> output_surface( 7434 std::unique_ptr<OutputSurface> output_surface(
7420 FakeOutputSurface::Create3d(std::move(context))); 7435 FakeOutputSurface::Create3d(std::move(context)));
7421 CreateHostImpl(DefaultSettings(), std::move(output_surface)); 7436 CreateHostImpl(DefaultSettings(), std::move(output_surface));
7422 7437
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
7779 resourceless_software_draw); 7794 resourceless_software_draw);
7780 7795
7781 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); 7796 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size());
7782 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), 7797 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(),
7783 last_on_draw_frame_->will_draw_layers[0]); 7798 last_on_draw_frame_->will_draw_layers[0]);
7784 } 7799 }
7785 7800
7786 // Checks that we have a non-0 default allocation if we pass a context that 7801 // Checks that we have a non-0 default allocation if we pass a context that
7787 // doesn't support memory management extensions. 7802 // doesn't support memory management extensions.
7788 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { 7803 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
7804 host_impl_->ReleaseOutputSurface();
7805 host_impl_ = nullptr;
7806
7789 LayerTreeSettings settings = DefaultSettings(); 7807 LayerTreeSettings settings = DefaultSettings();
7790 host_impl_ = LayerTreeHostImpl::Create( 7808 host_impl_ = LayerTreeHostImpl::Create(
7791 settings, this, &task_runner_provider_, &stats_instrumentation_, 7809 settings, this, &task_runner_provider_, &stats_instrumentation_,
7792 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, 7810 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_,
7793 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 7811 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
7794 7812
7795 output_surface_ = 7813 output_surface_ =
7796 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 7814 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
7797 host_impl_->SetVisible(true); 7815 host_impl_->SetVisible(true);
7798 host_impl_->InitializeRenderer(output_surface_.get()); 7816 host_impl_->InitializeRenderer(output_surface_.get());
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
7962 LayerTreeHostImpl::FrameData frame; 7980 LayerTreeHostImpl::FrameData frame;
7963 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7981 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7964 host_impl_->DrawLayers(&frame); 7982 host_impl_->DrawLayers(&frame);
7965 host_impl_->DidDrawAllLayers(frame); 7983 host_impl_->DidDrawAllLayers(frame);
7966 7984
7967 // The CopyOutputResult's callback has a ref on the ContextProvider and a 7985 // The CopyOutputResult's callback has a ref on the ContextProvider and a
7968 // texture in a texture mailbox. 7986 // texture in a texture mailbox.
7969 EXPECT_FALSE(context_provider->HasOneRef()); 7987 EXPECT_FALSE(context_provider->HasOneRef());
7970 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 7988 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
7971 7989
7990 host_impl_->ReleaseOutputSurface();
7972 host_impl_ = nullptr; 7991 host_impl_ = nullptr;
7973 7992
7974 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 7993 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
7975 // released, and the texture deleted. 7994 // released, and the texture deleted.
7976 EXPECT_TRUE(context_provider->HasOneRef()); 7995 EXPECT_TRUE(context_provider->HasOneRef());
7977 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 7996 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
7978 } 7997 }
7979 7998
7980 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { 7999 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
7981 // When flinging via touch, only the child should scroll (we should not 8000 // When flinging via touch, only the child should scroll (we should not
(...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after
10927 float expected_jitter = 10946 float expected_jitter =
10928 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10947 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10929 EXPECT_EQ(jitter, expected_jitter); 10948 EXPECT_EQ(jitter, expected_jitter);
10930 } 10949 }
10931 } 10950 }
10932 10951
10933 // Checks that if we lose a GPU raster enabled OutputSurface and replace it 10952 // Checks that if we lose a GPU raster enabled OutputSurface and replace it
10934 // with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU 10953 // with a software OutputSurface, LayerTreeHostImpl correctly re-computes GPU
10935 // rasterization status. 10954 // rasterization status.
10936 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) { 10955 TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) {
10956 host_impl_->ReleaseOutputSurface();
10957 host_impl_ = nullptr;
10958
10937 LayerTreeSettings settings = DefaultSettings(); 10959 LayerTreeSettings settings = DefaultSettings();
10938 settings.gpu_rasterization_forced = true; 10960 settings.gpu_rasterization_forced = true;
10939 10961
10940 host_impl_ = LayerTreeHostImpl::Create( 10962 host_impl_ = LayerTreeHostImpl::Create(
10941 settings, this, &task_runner_provider_, &stats_instrumentation_, 10963 settings, this, &task_runner_provider_, &stats_instrumentation_,
10942 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, 10964 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_,
10943 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 10965 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
10944 host_impl_->SetVisible(true); 10966 host_impl_->SetVisible(true);
10945 10967
10946 // InitializeRenderer with a gpu-raster enabled output surface. 10968 // InitializeRenderer with a gpu-raster enabled output surface.
10947 auto gpu_raster_output_surface = 10969 auto gpu_raster_output_surface =
10948 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 10970 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
10949 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); 10971 host_impl_->InitializeRenderer(gpu_raster_output_surface.get());
10950 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10972 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10951 10973
10952 // Re-initialize with a software output surface. 10974 // Re-initialize with a software output surface.
10953 output_surface_ = FakeOutputSurface::CreateSoftware( 10975 output_surface_ = FakeOutputSurface::CreateSoftware(
10954 base::WrapUnique(new SoftwareOutputDevice)); 10976 base::WrapUnique(new SoftwareOutputDevice));
10955 host_impl_->InitializeRenderer(output_surface_.get()); 10977 host_impl_->InitializeRenderer(output_surface_.get());
10956 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10978 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10957 } 10979 }
10958 10980
10959 } // namespace 10981 } // namespace
10960 } // namespace cc 10982 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698