| 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 if (evicted_resources) { | 922 if (evicted_resources) { |
| 923 active_tree_->SetContentsTexturesPurged(); | 923 active_tree_->SetContentsTexturesPurged(); |
| 924 if (pending_tree_) | 924 if (pending_tree_) |
| 925 pending_tree_->SetContentsTexturesPurged(); | 925 pending_tree_->SetContentsTexturesPurged(); |
| 926 client_->SetNeedsCommitOnImplThread(); | 926 client_->SetNeedsCommitOnImplThread(); |
| 927 client_->OnCanDrawStateChanged(CanDraw()); | 927 client_->OnCanDrawStateChanged(CanDraw()); |
| 928 client_->RenewTreePriority(); | 928 client_->RenewTreePriority(); |
| 929 } | 929 } |
| 930 client_->SendManagedMemoryStats(); | 930 client_->SendManagedMemoryStats(); |
| 931 | 931 |
| 932 if (tile_manager_) { | 932 UpdateTileManagerMemoryPolicy(policy); |
| 933 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); | 933 } |
| 934 new_state.memory_limit_in_bytes = visible_ ? | 934 |
| 935 policy.bytes_limit_when_visible : | 935 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy( |
| 936 policy.bytes_limit_when_not_visible; | 936 const ManagedMemoryPolicy& policy) { |
| 937 // TODO(reveman): We should avoid keeping around unused resources if | 937 if (!tile_manager_) |
| 938 // possible. crbug.com/224475 | 938 return; |
| 939 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( | 939 |
| 940 (static_cast<int64>(new_state.memory_limit_in_bytes) * | 940 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); |
| 941 settings_.max_unused_resource_memory_percentage) / 100); | 941 new_state.memory_limit_in_bytes = visible_ ? |
| 942 new_state.memory_limit_policy = | 942 policy.bytes_limit_when_visible : |
| 943 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( | 943 policy.bytes_limit_when_not_visible; |
| 944 visible_ ? | 944 // TODO(reveman): We should avoid keeping around unused resources if |
| 945 policy.priority_cutoff_when_visible : | 945 // possible. crbug.com/224475 |
| 946 policy.priority_cutoff_when_not_visible); | 946 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( |
| 947 tile_manager_->SetGlobalState(new_state); | 947 (static_cast<int64>(new_state.memory_limit_in_bytes) * |
| 948 } | 948 settings_.max_unused_resource_memory_percentage) / 100); |
| 949 new_state.memory_limit_policy = |
| 950 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( |
| 951 visible_ ? |
| 952 policy.priority_cutoff_when_visible : |
| 953 policy.priority_cutoff_when_not_visible); |
| 954 tile_manager_->SetGlobalState(new_state); |
| 949 } | 955 } |
| 950 | 956 |
| 951 bool LayerTreeHostImpl::HasImplThread() const { | 957 bool LayerTreeHostImpl::HasImplThread() const { |
| 952 return proxy_->HasImplThread(); | 958 return proxy_->HasImplThread(); |
| 953 } | 959 } |
| 954 | 960 |
| 955 void LayerTreeHostImpl::ScheduleManageTiles() { | 961 void LayerTreeHostImpl::ScheduleManageTiles() { |
| 956 if (client_) | 962 if (client_) |
| 957 client_->SetNeedsManageTilesOnImplThread(); | 963 client_->SetNeedsManageTilesOnImplThread(); |
| 958 } | 964 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 return false; | 1378 return false; |
| 1373 | 1379 |
| 1374 if (settings_.impl_side_painting) { | 1380 if (settings_.impl_side_painting) { |
| 1375 tile_manager_.reset(new TileManager(this, | 1381 tile_manager_.reset(new TileManager(this, |
| 1376 resource_provider.get(), | 1382 resource_provider.get(), |
| 1377 settings_.num_raster_threads, | 1383 settings_.num_raster_threads, |
| 1378 settings_.use_cheapness_estimator, | 1384 settings_.use_cheapness_estimator, |
| 1379 settings_.use_color_estimator, | 1385 settings_.use_color_estimator, |
| 1380 settings_.prediction_benchmarking, | 1386 settings_.prediction_benchmarking, |
| 1381 rendering_stats_instrumentation_)); | 1387 rendering_stats_instrumentation_)); |
| 1388 UpdateTileManagerMemoryPolicy(managed_memory_policy_); |
| 1382 } | 1389 } |
| 1383 | 1390 |
| 1384 if (output_surface->capabilities().has_parent_compositor) { | 1391 if (output_surface->capabilities().has_parent_compositor) { |
| 1385 renderer_ = DelegatingRenderer::Create(this, output_surface.get(), | 1392 renderer_ = DelegatingRenderer::Create(this, output_surface.get(), |
| 1386 resource_provider.get()); | 1393 resource_provider.get()); |
| 1387 } else if (output_surface->context3d()) { | 1394 } else if (output_surface->context3d()) { |
| 1388 renderer_ = GLRenderer::Create(this, | 1395 renderer_ = GLRenderer::Create(this, |
| 1389 output_surface.get(), | 1396 output_surface.get(), |
| 1390 resource_provider.get(), | 1397 resource_provider.get(), |
| 1391 settings_.highp_threshold_min); | 1398 settings_.highp_threshold_min); |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 } | 2144 } |
| 2138 | 2145 |
| 2139 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2146 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
| 2140 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2147 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
| 2141 paint_time_counter_->ClearHistory(); | 2148 paint_time_counter_->ClearHistory(); |
| 2142 | 2149 |
| 2143 debug_state_ = debug_state; | 2150 debug_state_ = debug_state; |
| 2144 } | 2151 } |
| 2145 | 2152 |
| 2146 } // namespace cc | 2153 } // namespace cc |
| OLD | NEW |