OLD | NEW |
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 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 if (evicted_resources) { | 918 if (evicted_resources) { |
919 active_tree_->SetContentsTexturesPurged(); | 919 active_tree_->SetContentsTexturesPurged(); |
920 if (pending_tree_) | 920 if (pending_tree_) |
921 pending_tree_->SetContentsTexturesPurged(); | 921 pending_tree_->SetContentsTexturesPurged(); |
922 client_->SetNeedsCommitOnImplThread(); | 922 client_->SetNeedsCommitOnImplThread(); |
923 client_->OnCanDrawStateChanged(CanDraw()); | 923 client_->OnCanDrawStateChanged(CanDraw()); |
924 client_->RenewTreePriority(); | 924 client_->RenewTreePriority(); |
925 } | 925 } |
926 client_->SendManagedMemoryStats(); | 926 client_->SendManagedMemoryStats(); |
927 | 927 |
928 if (tile_manager_) { | 928 UpdateTileManagerMemoryPolicy(policy); |
929 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); | 929 } |
930 new_state.memory_limit_in_bytes = visible_ ? | 930 |
931 policy.bytes_limit_when_visible : | 931 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy( |
932 policy.bytes_limit_when_not_visible; | 932 const ManagedMemoryPolicy& policy) { |
933 // TODO(reveman): We should avoid keeping around unused resources if | 933 if (!tile_manager_) |
934 // possible. crbug.com/224475 | 934 return; |
935 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( | 935 |
936 (static_cast<int64>(new_state.memory_limit_in_bytes) * | 936 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); |
937 settings_.max_unused_resource_memory_percentage) / 100); | 937 new_state.memory_limit_in_bytes = visible_ ? |
938 new_state.memory_limit_policy = | 938 policy.bytes_limit_when_visible : |
939 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( | 939 policy.bytes_limit_when_not_visible; |
940 visible_ ? | 940 // TODO(reveman): We should avoid keeping around unused resources if |
941 policy.priority_cutoff_when_visible : | 941 // possible. crbug.com/224475 |
942 policy.priority_cutoff_when_not_visible); | 942 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( |
943 tile_manager_->SetGlobalState(new_state); | 943 (static_cast<int64>(new_state.memory_limit_in_bytes) * |
944 } | 944 settings_.max_unused_resource_memory_percentage) / 100); |
| 945 new_state.memory_limit_policy = |
| 946 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( |
| 947 visible_ ? |
| 948 policy.priority_cutoff_when_visible : |
| 949 policy.priority_cutoff_when_not_visible); |
| 950 tile_manager_->SetGlobalState(new_state); |
945 } | 951 } |
946 | 952 |
947 bool LayerTreeHostImpl::HasImplThread() const { | 953 bool LayerTreeHostImpl::HasImplThread() const { |
948 return proxy_->HasImplThread(); | 954 return proxy_->HasImplThread(); |
949 } | 955 } |
950 | 956 |
951 void LayerTreeHostImpl::ScheduleManageTiles() { | 957 void LayerTreeHostImpl::ScheduleManageTiles() { |
952 if (client_) | 958 if (client_) |
953 client_->SetNeedsManageTilesOnImplThread(); | 959 client_->SetNeedsManageTilesOnImplThread(); |
954 } | 960 } |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 if (!resource_provider) | 1375 if (!resource_provider) |
1370 return false; | 1376 return false; |
1371 | 1377 |
1372 if (settings_.impl_side_painting) { | 1378 if (settings_.impl_side_painting) { |
1373 tile_manager_.reset(new TileManager(this, | 1379 tile_manager_.reset(new TileManager(this, |
1374 resource_provider.get(), | 1380 resource_provider.get(), |
1375 settings_.num_raster_threads, | 1381 settings_.num_raster_threads, |
1376 settings_.use_color_estimator, | 1382 settings_.use_color_estimator, |
1377 settings_.prediction_benchmarking, | 1383 settings_.prediction_benchmarking, |
1378 rendering_stats_instrumentation_)); | 1384 rendering_stats_instrumentation_)); |
| 1385 UpdateTileManagerMemoryPolicy(managed_memory_policy_); |
1379 } | 1386 } |
1380 | 1387 |
1381 if (output_surface->capabilities().has_parent_compositor) { | 1388 if (output_surface->capabilities().has_parent_compositor) { |
1382 renderer_ = DelegatingRenderer::Create(this, output_surface.get(), | 1389 renderer_ = DelegatingRenderer::Create(this, output_surface.get(), |
1383 resource_provider.get()); | 1390 resource_provider.get()); |
1384 } else if (output_surface->context3d()) { | 1391 } else if (output_surface->context3d()) { |
1385 renderer_ = GLRenderer::Create(this, | 1392 renderer_ = GLRenderer::Create(this, |
1386 output_surface.get(), | 1393 output_surface.get(), |
1387 resource_provider.get(), | 1394 resource_provider.get(), |
1388 settings_.highp_threshold_min); | 1395 settings_.highp_threshold_min); |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 } | 2158 } |
2152 | 2159 |
2153 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2160 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2154 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2161 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2155 paint_time_counter_->ClearHistory(); | 2162 paint_time_counter_->ClearHistory(); |
2156 | 2163 |
2157 debug_state_ = debug_state; | 2164 debug_state_ = debug_state; |
2158 } | 2165 } |
2159 | 2166 |
2160 } // namespace cc | 2167 } // namespace cc |
OLD | NEW |