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

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

Issue 1385043002: cc: Remove SetLayerTreeHostClientReady() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@startcomp
Patch Set: sky's offline comment Created 5 years, 2 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_host_unittest.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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 reduce_memory_result_ = reduce_memory_result; 163 reduce_memory_result_ = reduce_memory_result;
164 } 164 }
165 165
166 virtual bool CreateHostImpl(const LayerTreeSettings& settings, 166 virtual bool CreateHostImpl(const LayerTreeSettings& settings,
167 scoped_ptr<OutputSurface> output_surface) { 167 scoped_ptr<OutputSurface> output_surface) {
168 host_impl_ = LayerTreeHostImpl::Create( 168 host_impl_ = LayerTreeHostImpl::Create(
169 settings, this, &proxy_, &stats_instrumentation_, 169 settings, this, &proxy_, &stats_instrumentation_,
170 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, 170 &shared_bitmap_manager_, &gpu_memory_buffer_manager_,
171 &task_graph_runner_, 0); 171 &task_graph_runner_, 0);
172 output_surface_ = output_surface.Pass(); 172 output_surface_ = output_surface.Pass();
173 host_impl_->SetVisible(true);
173 bool init = host_impl_->InitializeRenderer(output_surface_.get()); 174 bool init = host_impl_->InitializeRenderer(output_surface_.get());
174 host_impl_->SetViewportSize(gfx::Size(10, 10)); 175 host_impl_->SetViewportSize(gfx::Size(10, 10));
175 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 176 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
176 // Set the BeginFrameArgs so that methods which use it are able to. 177 // Set the BeginFrameArgs so that methods which use it are able to.
177 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( 178 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting(
178 BEGINFRAME_FROM_HERE, 179 BEGINFRAME_FROM_HERE,
179 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); 180 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1)));
180 host_impl_->DidFinishImplFrame(); 181 host_impl_->DidFinishImplFrame();
181 return init; 182 return init;
182 } 183 }
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 protected: 2139 protected:
2139 void SetupLayers(LayerTreeSettings settings) { 2140 void SetupLayers(LayerTreeSettings settings) {
2140 gfx::Size content_size(100, 100); 2141 gfx::Size content_size(100, 100);
2141 2142
2142 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = 2143 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
2143 new LayerTreeHostImplOverridePhysicalTime( 2144 new LayerTreeHostImplOverridePhysicalTime(
2144 settings, this, &proxy_, &shared_bitmap_manager_, 2145 settings, this, &proxy_, &shared_bitmap_manager_,
2145 &task_graph_runner_, &stats_instrumentation_); 2146 &task_graph_runner_, &stats_instrumentation_);
2146 host_impl_ = make_scoped_ptr(host_impl_override_time); 2147 host_impl_ = make_scoped_ptr(host_impl_override_time);
2147 output_surface_ = CreateOutputSurface(); 2148 output_surface_ = CreateOutputSurface();
2149 host_impl_->SetVisible(true);
2148 host_impl_->InitializeRenderer(output_surface_.get()); 2150 host_impl_->InitializeRenderer(output_surface_.get());
2149 2151
2150 SetupScrollAndContentsLayers(content_size); 2152 SetupScrollAndContentsLayers(content_size);
2151 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); 2153 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f);
2152 host_impl_->SetViewportSize( 2154 host_impl_->SetViewportSize(
2153 gfx::Size(content_size.width() / 2, content_size.height() / 2)); 2155 gfx::Size(content_size.width() / 2, content_size.height() / 2));
2154 2156
2155 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2157 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2156 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, 2158 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400,
2157 VERTICAL, 10, 0, false, true); 2159 VERTICAL, 10, 0, false, true);
(...skipping 3529 matching lines...) Expand 10 before | Expand all | Expand 10 after
5687 FakeOutputSurface* fake_output_surface = output_surface.get(); 5689 FakeOutputSurface* fake_output_surface = output_surface.get();
5688 5690
5689 // This test creates its own LayerTreeHostImpl, so 5691 // This test creates its own LayerTreeHostImpl, so
5690 // that we can force partial swap enabled. 5692 // that we can force partial swap enabled.
5691 LayerTreeSettings settings; 5693 LayerTreeSettings settings;
5692 settings.renderer_settings.partial_swap_enabled = true; 5694 settings.renderer_settings.partial_swap_enabled = true;
5693 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = 5695 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl =
5694 LayerTreeHostImpl::Create( 5696 LayerTreeHostImpl::Create(
5695 settings, this, &proxy_, &stats_instrumentation_, 5697 settings, this, &proxy_, &stats_instrumentation_,
5696 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); 5698 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0);
5699 layer_tree_host_impl->SetVisible(true);
5697 layer_tree_host_impl->InitializeRenderer(output_surface.get()); 5700 layer_tree_host_impl->InitializeRenderer(output_surface.get());
5698 layer_tree_host_impl->WillBeginImplFrame( 5701 layer_tree_host_impl->WillBeginImplFrame(
5699 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); 5702 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
5700 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); 5703 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
5701 5704
5702 scoped_ptr<LayerImpl> root = 5705 scoped_ptr<LayerImpl> root =
5703 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 5706 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
5704 root->SetHasRenderSurface(true); 5707 root->SetHasRenderSurface(true);
5705 scoped_ptr<LayerImpl> child = 5708 scoped_ptr<LayerImpl> child =
5706 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 5709 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
5970 Proxy* proxy, 5973 Proxy* proxy,
5971 SharedBitmapManager* manager, 5974 SharedBitmapManager* manager,
5972 TaskGraphRunner* task_graph_runner, 5975 TaskGraphRunner* task_graph_runner,
5973 RenderingStatsInstrumentation* stats_instrumentation, 5976 RenderingStatsInstrumentation* stats_instrumentation,
5974 OutputSurface* output_surface) { 5977 OutputSurface* output_surface) {
5975 LayerTreeSettings settings; 5978 LayerTreeSettings settings;
5976 settings.renderer_settings.partial_swap_enabled = partial_swap; 5979 settings.renderer_settings.partial_swap_enabled = partial_swap;
5977 scoped_ptr<LayerTreeHostImpl> my_host_impl = 5980 scoped_ptr<LayerTreeHostImpl> my_host_impl =
5978 LayerTreeHostImpl::Create(settings, client, proxy, stats_instrumentation, 5981 LayerTreeHostImpl::Create(settings, client, proxy, stats_instrumentation,
5979 manager, nullptr, task_graph_runner, 0); 5982 manager, nullptr, task_graph_runner, 0);
5983 my_host_impl->SetVisible(true);
5980 my_host_impl->InitializeRenderer(output_surface); 5984 my_host_impl->InitializeRenderer(output_surface);
5981 my_host_impl->WillBeginImplFrame( 5985 my_host_impl->WillBeginImplFrame(
5982 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); 5986 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
5983 my_host_impl->SetViewportSize(gfx::Size(100, 100)); 5987 my_host_impl->SetViewportSize(gfx::Size(100, 100));
5984 5988
5985 /* 5989 /*
5986 Layers are created as follows: 5990 Layers are created as follows:
5987 5991
5988 +--------------------+ 5992 +--------------------+
5989 | 1 | 5993 | 1 |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
6490 // Checks that we have a non-0 default allocation if we pass a context that 6494 // Checks that we have a non-0 default allocation if we pass a context that
6491 // doesn't support memory management extensions. 6495 // doesn't support memory management extensions.
6492 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { 6496 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
6493 LayerTreeSettings settings; 6497 LayerTreeSettings settings;
6494 host_impl_ = LayerTreeHostImpl::Create( 6498 host_impl_ = LayerTreeHostImpl::Create(
6495 settings, this, &proxy_, &stats_instrumentation_, &shared_bitmap_manager_, 6499 settings, this, &proxy_, &stats_instrumentation_, &shared_bitmap_manager_,
6496 &gpu_memory_buffer_manager_, &task_graph_runner_, 0); 6500 &gpu_memory_buffer_manager_, &task_graph_runner_, 0);
6497 6501
6498 output_surface_ = 6502 output_surface_ =
6499 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 6503 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
6504 host_impl_->SetVisible(true);
6500 host_impl_->InitializeRenderer(output_surface_.get()); 6505 host_impl_->InitializeRenderer(output_surface_.get());
6501 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); 6506 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes());
6502 } 6507 }
6503 6508
6504 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { 6509 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) {
6505 ASSERT_TRUE(host_impl_->active_tree()); 6510 ASSERT_TRUE(host_impl_->active_tree());
6506 6511
6507 // RequiresHighResToDraw is set when new output surface is used. 6512 // RequiresHighResToDraw is set when new output surface is used.
6508 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); 6513 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6509 6514
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
6552 } 6557 }
6553 6558
6554 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { 6559 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest {
6555 public: 6560 public:
6556 void SetUp() override { 6561 void SetUp() override {
6557 fake_host_impl_ = 6562 fake_host_impl_ =
6558 new FakeLayerTreeHostImpl(LayerTreeSettings(), &proxy_, 6563 new FakeLayerTreeHostImpl(LayerTreeSettings(), &proxy_,
6559 &shared_bitmap_manager_, &task_graph_runner_); 6564 &shared_bitmap_manager_, &task_graph_runner_);
6560 host_impl_.reset(fake_host_impl_); 6565 host_impl_.reset(fake_host_impl_);
6561 output_surface_ = CreateOutputSurface(); 6566 output_surface_ = CreateOutputSurface();
6567 host_impl_->SetVisible(true);
6562 host_impl_->InitializeRenderer(output_surface_.get()); 6568 host_impl_->InitializeRenderer(output_surface_.get());
6563 host_impl_->SetViewportSize(gfx::Size(10, 10)); 6569 host_impl_->SetViewportSize(gfx::Size(10, 10));
6564 } 6570 }
6565 6571
6566 FakeLayerTreeHostImpl* fake_host_impl_; 6572 FakeLayerTreeHostImpl* fake_host_impl_;
6567 }; 6573 };
6568 6574
6569 TEST_F(LayerTreeHostImplTestPrepareTiles, PrepareTilesWhenInvisible) { 6575 TEST_F(LayerTreeHostImplTestPrepareTiles, PrepareTilesWhenInvisible) {
6570 fake_host_impl_->DidModifyTilePriorities();
6571 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); 6576 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed());
6572 fake_host_impl_->SetVisible(false); 6577 host_impl_->SetVisible(false);
6573 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); 6578 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed());
6579 host_impl_->SetVisible(true);
6580 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed());
6574 } 6581 }
6575 6582
6576 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { 6583 TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
6577 scoped_ptr<TestWebGraphicsContext3D> context = 6584 scoped_ptr<TestWebGraphicsContext3D> context =
6578 TestWebGraphicsContext3D::Create(); 6585 TestWebGraphicsContext3D::Create();
6579 TestWebGraphicsContext3D* context3d = context.get(); 6586 TestWebGraphicsContext3D* context3d = context.get();
6580 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); 6587 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d();
6581 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 6588 CreateHostImpl(DefaultSettings(), output_surface.Pass());
6582 6589
6583 EXPECT_EQ(0u, context3d->NumTextures()); 6590 EXPECT_EQ(0u, context3d->NumTextures());
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
8572 // Hold an unowned pointer to the output surface to use for mock expectations. 8579 // Hold an unowned pointer to the output surface to use for mock expectations.
8573 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); 8580 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get();
8574 8581
8575 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 8582 CreateHostImpl(DefaultSettings(), output_surface.Pass());
8576 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); 8583 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1);
8577 host_impl_->BeginCommit(); 8584 host_impl_->BeginCommit();
8578 } 8585 }
8579 8586
8580 } // namespace 8587 } // namespace
8581 } // namespace cc 8588 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698