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

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

Issue 2321883002: cc: Remove SetMemoryPolicy from OutputSurface and Display. (Closed)
Patch Set: nits Created 4 years, 3 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 7812 matching lines...) Expand 10 before | Expand all | Expand 10 after
7823 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7823 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7824 7824
7825 host_impl_->OnDraw(external_transform, external_viewport, 7825 host_impl_->OnDraw(external_transform, external_viewport,
7826 resourceless_software_draw); 7826 resourceless_software_draw);
7827 7827
7828 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); 7828 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size());
7829 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), 7829 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(),
7830 last_on_draw_frame_->will_draw_layers[0]); 7830 last_on_draw_frame_->will_draw_layers[0]);
7831 } 7831 }
7832 7832
7833 // Checks that we have a non-0 default allocation if we pass a context that 7833 // Checks that we use the memory limits provided.
7834 // doesn't support memory management extensions. 7834 TEST_F(LayerTreeHostImplTest, MemoryLimits) {
7835 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
7836 host_impl_->ReleaseOutputSurface(); 7835 host_impl_->ReleaseOutputSurface();
7837 host_impl_ = nullptr; 7836 host_impl_ = nullptr;
7838 7837
7838 const size_t kGpuByteLimit = 1234321;
7839 const size_t kSoftwareByteLimit = 4321234;
7840 const size_t kGpuResourceLimit = 2345432;
7841 const size_t kSoftwareResourceLimit = 5432345;
7842 const gpu::MemoryAllocation::PriorityCutoff kGpuCutoff =
7843 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING;
7844 const gpu::MemoryAllocation::PriorityCutoff kSoftwareCutoff =
7845 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
7846
7847 const TileMemoryLimitPolicy kGpuTileCutoff =
7848 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(kGpuCutoff);
7849 const TileMemoryLimitPolicy kSoftwareTileCutoff =
7850 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
7851 kSoftwareCutoff);
7852 const TileMemoryLimitPolicy kNothingTileCutoff =
7853 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
7854 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
7855 EXPECT_NE(kGpuTileCutoff, kNothingTileCutoff);
7856 EXPECT_NE(kSoftwareTileCutoff, kNothingTileCutoff);
7857
7839 LayerTreeSettings settings = DefaultSettings(); 7858 LayerTreeSettings settings = DefaultSettings();
7859 settings.gpu_memory_policy =
7860 ManagedMemoryPolicy(kGpuByteLimit, kGpuCutoff, kGpuResourceLimit);
7861 settings.software_memory_policy = ManagedMemoryPolicy(
7862 kSoftwareByteLimit, kSoftwareCutoff, kSoftwareResourceLimit);
7840 host_impl_ = LayerTreeHostImpl::Create( 7863 host_impl_ = LayerTreeHostImpl::Create(
7841 settings, this, &task_runner_provider_, &stats_instrumentation_, 7864 settings, this, &task_runner_provider_, &stats_instrumentation_,
7842 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, 7865 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_,
7843 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); 7866 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
7844 7867
7868 // Gpu compositing.
7845 output_surface_ = 7869 output_surface_ =
7846 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create()); 7870 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create());
7847 host_impl_->SetVisible(true); 7871 host_impl_->SetVisible(true);
7848 host_impl_->InitializeRenderer(output_surface_.get()); 7872 host_impl_->InitializeRenderer(output_surface_.get());
7849 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); 7873 {
7874 const auto& state = host_impl_->global_tile_state();
7875 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes);
7876 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit);
7877 EXPECT_EQ(kGpuTileCutoff, state.memory_limit_policy);
7878 }
7879
7880 // Not visible, drops to 0.
7881 host_impl_->SetVisible(false);
7882 {
7883 const auto& state = host_impl_->global_tile_state();
7884 EXPECT_EQ(0u, state.hard_memory_limit_in_bytes);
7885 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit);
7886 EXPECT_EQ(kNothingTileCutoff, state.memory_limit_policy);
7887 }
7888
7889 // Visible, is the gpu limit again.
7890 host_impl_->SetVisible(true);
7891 {
7892 const auto& state = host_impl_->global_tile_state();
7893 EXPECT_EQ(kGpuByteLimit, state.hard_memory_limit_in_bytes);
7894 EXPECT_EQ(kGpuResourceLimit, state.num_resources_limit);
7895 }
7896
7897 // Software compositing.
7898 host_impl_->ReleaseOutputSurface();
7899 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware();
7900 host_impl_->InitializeRenderer(output_surface_.get());
7901 {
7902 const auto& state = host_impl_->global_tile_state();
7903 EXPECT_EQ(kSoftwareByteLimit, state.hard_memory_limit_in_bytes);
7904 EXPECT_EQ(kSoftwareResourceLimit, state.num_resources_limit);
7905 EXPECT_EQ(kSoftwareTileCutoff, state.memory_limit_policy);
7906 }
7907
7908 // Not visible, drops to 0.
7909 host_impl_->SetVisible(false);
7910 {
7911 const auto& state = host_impl_->global_tile_state();
7912 EXPECT_EQ(0u, state.hard_memory_limit_in_bytes);
7913 EXPECT_EQ(kSoftwareResourceLimit, state.num_resources_limit);
7914 EXPECT_EQ(kNothingTileCutoff, state.memory_limit_policy);
7915 }
7916
7917 // Visible, is the software limit again.
7918 host_impl_->SetVisible(true);
7919 {
7920 const auto& state = host_impl_->global_tile_state();
7921 EXPECT_EQ(kSoftwareByteLimit, state.hard_memory_limit_in_bytes);
7922 EXPECT_EQ(kSoftwareResourceLimit, state.num_resources_limit);
7923 EXPECT_EQ(kSoftwareTileCutoff, state.memory_limit_policy);
7924 }
7850 } 7925 }
7851 7926
7852 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { 7927 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) {
7853 ASSERT_TRUE(host_impl_->active_tree()); 7928 ASSERT_TRUE(host_impl_->active_tree());
7854 7929
7855 // RequiresHighResToDraw is set when new output surface is used. 7930 // RequiresHighResToDraw is set when new output surface is used.
7856 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); 7931 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
7857 7932
7858 host_impl_->ResetRequiresHighResToDraw(); 7933 host_impl_->ResetRequiresHighResToDraw();
7859 7934
(...skipping 3312 matching lines...) Expand 10 before | Expand all | Expand 10 after
11172 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11247 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11173 11248
11174 // Re-initialize with a software output surface. 11249 // Re-initialize with a software output surface.
11175 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); 11250 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware();
11176 host_impl_->InitializeRenderer(output_surface_.get()); 11251 host_impl_->InitializeRenderer(output_surface_.get());
11177 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11252 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11178 } 11253 }
11179 11254
11180 } // namespace 11255 } // namespace
11181 } // namespace cc 11256 } // 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