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

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

Issue 1014993002: [exp] cc: Introduce cc::CompositorMutator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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_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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void DidCompletePageScaleAnimationOnImplThread() override { 160 void DidCompletePageScaleAnimationOnImplThread() override {
161 did_complete_page_scale_animation_ = true; 161 did_complete_page_scale_animation_ = true;
162 } 162 }
163 163
164 void set_reduce_memory_result(bool reduce_memory_result) { 164 void set_reduce_memory_result(bool reduce_memory_result) {
165 reduce_memory_result_ = reduce_memory_result; 165 reduce_memory_result_ = reduce_memory_result;
166 } 166 }
167 167
168 virtual bool CreateHostImpl(const LayerTreeSettings& settings, 168 virtual bool CreateHostImpl(const LayerTreeSettings& settings,
169 scoped_ptr<OutputSurface> output_surface) { 169 scoped_ptr<OutputSurface> output_surface) {
170 host_impl_ = LayerTreeHostImpl::Create(settings, 170 host_impl_ = LayerTreeHostImpl::Create(
171 this, 171 settings, this, &proxy_, &stats_instrumentation_,
172 &proxy_, 172 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), nullptr,
173 &stats_instrumentation_, 173 0);
174 shared_bitmap_manager_.get(),
175 gpu_memory_buffer_manager_.get(),
176 0);
177 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); 174 bool init = host_impl_->InitializeRenderer(output_surface.Pass());
178 host_impl_->SetViewportSize(gfx::Size(10, 10)); 175 host_impl_->SetViewportSize(gfx::Size(10, 10));
179 return init; 176 return init;
180 } 177 }
181 178
182 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { 179 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
183 root->SetPosition(gfx::PointF()); 180 root->SetPosition(gfx::PointF());
184 root->SetBounds(gfx::Size(10, 10)); 181 root->SetBounds(gfx::Size(10, 10));
185 root->SetContentBounds(gfx::Size(10, 10)); 182 root->SetContentBounds(gfx::Size(10, 10));
186 root->SetDrawsContent(true); 183 root->SetDrawsContent(true);
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 LayerTreeHostImplClient* client, 1538 LayerTreeHostImplClient* client,
1542 Proxy* proxy, 1539 Proxy* proxy,
1543 SharedBitmapManager* manager, 1540 SharedBitmapManager* manager,
1544 RenderingStatsInstrumentation* rendering_stats_instrumentation) 1541 RenderingStatsInstrumentation* rendering_stats_instrumentation)
1545 : LayerTreeHostImpl(settings, 1542 : LayerTreeHostImpl(settings,
1546 client, 1543 client,
1547 proxy, 1544 proxy,
1548 rendering_stats_instrumentation, 1545 rendering_stats_instrumentation,
1549 manager, 1546 manager,
1550 NULL, 1547 NULL,
1548 NULL,
1551 0) {} 1549 0) {}
1552 1550
1553 BeginFrameArgs CurrentBeginFrameArgs() const override { 1551 BeginFrameArgs CurrentBeginFrameArgs() const override {
1554 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 1552 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE,
1555 fake_current_physical_time_); 1553 fake_current_physical_time_);
1556 } 1554 }
1557 1555
1558 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { 1556 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) {
1559 fake_current_physical_time_ = fake_now; 1557 fake_current_physical_time_ = fake_now;
1560 } 1558 }
(...skipping 3482 matching lines...) Expand 10 before | Expand all | Expand 10 after
5043 FakeOutputSurface::Create3d(context_provider)); 5041 FakeOutputSurface::Create3d(context_provider));
5044 FakeOutputSurface* fake_output_surface = output_surface.get(); 5042 FakeOutputSurface* fake_output_surface = output_surface.get();
5045 5043
5046 // This test creates its own LayerTreeHostImpl, so 5044 // This test creates its own LayerTreeHostImpl, so
5047 // that we can force partial swap enabled. 5045 // that we can force partial swap enabled.
5048 LayerTreeSettings settings; 5046 LayerTreeSettings settings;
5049 settings.renderer_settings.partial_swap_enabled = true; 5047 settings.renderer_settings.partial_swap_enabled = true;
5050 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 5048 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
5051 new TestSharedBitmapManager()); 5049 new TestSharedBitmapManager());
5052 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = 5050 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl =
5053 LayerTreeHostImpl::Create(settings, 5051 LayerTreeHostImpl::Create(settings, this, &proxy_,
5054 this,
5055 &proxy_,
5056 &stats_instrumentation_, 5052 &stats_instrumentation_,
5057 shared_bitmap_manager.get(), 5053 shared_bitmap_manager.get(), nullptr, NULL, 0);
5058 NULL,
5059 0);
5060 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); 5054 layer_tree_host_impl->InitializeRenderer(output_surface.Pass());
5061 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); 5055 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
5062 5056
5063 scoped_ptr<LayerImpl> root = 5057 scoped_ptr<LayerImpl> root =
5064 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 5058 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
5065 root->SetHasRenderSurface(true); 5059 root->SetHasRenderSurface(true);
5066 scoped_ptr<LayerImpl> child = 5060 scoped_ptr<LayerImpl> child =
5067 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 5061 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
5068 child->SetPosition(gfx::PointF(12.f, 13.f)); 5062 child->SetPosition(gfx::PointF(12.f, 13.f));
5069 child->SetBounds(gfx::Size(14, 15)); 5063 child->SetBounds(gfx::Size(14, 15));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
5337 RenderingStatsInstrumentation* stats_instrumentation) { 5331 RenderingStatsInstrumentation* stats_instrumentation) {
5338 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 5332 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
5339 scoped_ptr<OutputSurface> output_surface( 5333 scoped_ptr<OutputSurface> output_surface(
5340 FakeOutputSurface::Create3d(provider)); 5334 FakeOutputSurface::Create3d(provider));
5341 provider->BindToCurrentThread(); 5335 provider->BindToCurrentThread();
5342 provider->TestContext3d()->set_have_post_sub_buffer(true); 5336 provider->TestContext3d()->set_have_post_sub_buffer(true);
5343 5337
5344 LayerTreeSettings settings; 5338 LayerTreeSettings settings;
5345 settings.renderer_settings.partial_swap_enabled = partial_swap; 5339 settings.renderer_settings.partial_swap_enabled = partial_swap;
5346 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( 5340 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create(
5347 settings, client, proxy, stats_instrumentation, manager, NULL, 0); 5341 settings, client, proxy, stats_instrumentation, manager, NULL, NULL, 0);
5348 my_host_impl->InitializeRenderer(output_surface.Pass()); 5342 my_host_impl->InitializeRenderer(output_surface.Pass());
5349 my_host_impl->SetViewportSize(gfx::Size(100, 100)); 5343 my_host_impl->SetViewportSize(gfx::Size(100, 100));
5350 5344
5351 /* 5345 /*
5352 Layers are created as follows: 5346 Layers are created as follows:
5353 5347
5354 +--------------------+ 5348 +--------------------+
5355 | 1 | 5349 | 1 |
5356 | +-----------+ | 5350 | +-----------+ |
5357 | | 2 | | 5351 | | 2 | |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
6663 EXPECT_FALSE(did_update_renderer_capabilities_); 6657 EXPECT_FALSE(did_update_renderer_capabilities_);
6664 6658
6665 // Software draw again. 6659 // Software draw again.
6666 DrawFrame(); 6660 DrawFrame();
6667 } 6661 }
6668 6662
6669 // Checks that we have a non-0 default allocation if we pass a context that 6663 // Checks that we have a non-0 default allocation if we pass a context that
6670 // doesn't support memory management extensions. 6664 // doesn't support memory management extensions.
6671 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { 6665 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
6672 LayerTreeSettings settings; 6666 LayerTreeSettings settings;
6673 host_impl_ = LayerTreeHostImpl::Create(settings, 6667 host_impl_ = LayerTreeHostImpl::Create(
6674 this, 6668 settings, this, &proxy_, &stats_instrumentation_,
6675 &proxy_, 6669 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), nullptr,
6676 &stats_instrumentation_, 6670 0);
6677 shared_bitmap_manager_.get(),
6678 gpu_memory_buffer_manager_.get(),
6679 0);
6680 6671
6681 scoped_ptr<OutputSurface> output_surface( 6672 scoped_ptr<OutputSurface> output_surface(
6682 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); 6673 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()));
6683 host_impl_->InitializeRenderer(output_surface.Pass()); 6674 host_impl_->InitializeRenderer(output_surface.Pass());
6684 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); 6675 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes());
6685 } 6676 }
6686 6677
6687 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { 6678 TEST_F(LayerTreeHostImplTest, MemoryPolicy) {
6688 ManagedMemoryPolicy policy1( 6679 ManagedMemoryPolicy policy1(
6689 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000); 6680 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000);
(...skipping 20 matching lines...) Expand all
6710 6701
6711 host_impl_->SetVisible(true); 6702 host_impl_->SetVisible(true);
6712 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); 6703 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
6713 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_); 6704 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_);
6714 6705
6715 // Now enable GPU rasterization and test if we get nice to have cutoff, 6706 // Now enable GPU rasterization and test if we get nice to have cutoff,
6716 // when visible. 6707 // when visible.
6717 LayerTreeSettings settings; 6708 LayerTreeSettings settings;
6718 settings.gpu_rasterization_enabled = true; 6709 settings.gpu_rasterization_enabled = true;
6719 host_impl_ = LayerTreeHostImpl::Create( 6710 host_impl_ = LayerTreeHostImpl::Create(
6720 settings, this, &proxy_, &stats_instrumentation_, NULL, NULL, 0); 6711 settings, this, &proxy_, &stats_instrumentation_, NULL, NULL, NULL, 0);
6721 host_impl_->SetUseGpuRasterization(true); 6712 host_impl_->SetUseGpuRasterization(true);
6722 host_impl_->SetVisible(true); 6713 host_impl_->SetVisible(true);
6723 host_impl_->SetMemoryPolicy(policy1); 6714 host_impl_->SetMemoryPolicy(policy1);
6724 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); 6715 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
6725 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); 6716 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_);
6726 6717
6727 host_impl_->SetVisible(false); 6718 host_impl_->SetVisible(false);
6728 EXPECT_EQ(0u, current_limit_bytes_); 6719 EXPECT_EQ(0u, current_limit_bytes_);
6729 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); 6720 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_);
6730 } 6721 }
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
8499 // surface. 8490 // surface.
8500 EXPECT_EQ(0, num_lost_surfaces_); 8491 EXPECT_EQ(0, num_lost_surfaces_);
8501 host_impl_->DidLoseOutputSurface(); 8492 host_impl_->DidLoseOutputSurface();
8502 EXPECT_EQ(1, num_lost_surfaces_); 8493 EXPECT_EQ(1, num_lost_surfaces_);
8503 host_impl_->DidLoseOutputSurface(); 8494 host_impl_->DidLoseOutputSurface();
8504 EXPECT_LE(1, num_lost_surfaces_); 8495 EXPECT_LE(1, num_lost_surfaces_);
8505 } 8496 }
8506 8497
8507 } // namespace 8498 } // namespace
8508 } // namespace cc 8499 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698