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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 const LayerTreeSettings& settings, | 156 const LayerTreeSettings& settings, |
157 LayerTreeHostImplClient* client, | 157 LayerTreeHostImplClient* client, |
158 Proxy* proxy, | 158 Proxy* proxy, |
159 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 159 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
160 : client_(client), | 160 : client_(client), |
161 proxy_(proxy), | 161 proxy_(proxy), |
162 input_handler_client_(NULL), | 162 input_handler_client_(NULL), |
163 did_lock_scrolling_layer_(false), | 163 did_lock_scrolling_layer_(false), |
164 should_bubble_scrolls_(false), | 164 should_bubble_scrolls_(false), |
165 wheel_scrolling_(false), | 165 wheel_scrolling_(false), |
| 166 manage_tiles_needed_(false), |
166 root_layer_scroll_offset_delegate_(NULL), | 167 root_layer_scroll_offset_delegate_(NULL), |
167 settings_(settings), | 168 settings_(settings), |
168 visible_(true), | 169 visible_(true), |
169 managed_memory_policy_( | 170 managed_memory_policy_( |
170 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 171 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
171 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, | 172 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, |
172 0, | 173 0, |
173 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING), | 174 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING), |
174 pinch_gesture_active_(false), | 175 pinch_gesture_active_(false), |
175 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), | 176 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 232 |
232 void LayerTreeHostImpl::CommitComplete() { | 233 void LayerTreeHostImpl::CommitComplete() { |
233 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 234 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
234 | 235 |
235 // Impl-side painting needs an update immediately post-commit to have the | 236 // Impl-side painting needs an update immediately post-commit to have the |
236 // opportunity to create tilings. Other paths can call UpdateDrawProperties | 237 // opportunity to create tilings. Other paths can call UpdateDrawProperties |
237 // more lazily when needed prior to drawing. | 238 // more lazily when needed prior to drawing. |
238 if (settings_.impl_side_painting) { | 239 if (settings_.impl_side_painting) { |
239 pending_tree_->set_needs_update_draw_properties(); | 240 pending_tree_->set_needs_update_draw_properties(); |
240 pending_tree_->UpdateDrawProperties(); | 241 pending_tree_->UpdateDrawProperties(); |
| 242 // Start working on newly created tiles immediately if needed. |
| 243 ManageTiles(); |
241 } else { | 244 } else { |
242 active_tree_->set_needs_update_draw_properties(); | 245 active_tree_->set_needs_update_draw_properties(); |
243 } | 246 } |
244 | 247 |
245 client_->SendManagedMemoryStats(); | 248 client_->SendManagedMemoryStats(); |
246 } | 249 } |
247 | 250 |
248 bool LayerTreeHostImpl::CanDraw() { | 251 bool LayerTreeHostImpl::CanDraw() { |
249 // Note: If you are changing this function or any other function that might | 252 // Note: If you are changing this function or any other function that might |
250 // affect the result of CanDraw, make sure to call | 253 // affect the result of CanDraw, make sure to call |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 base::Time wall_clock_time) { | 288 base::Time wall_clock_time) { |
286 if (input_handler_client_) | 289 if (input_handler_client_) |
287 input_handler_client_->Animate(monotonic_time); | 290 input_handler_client_->Animate(monotonic_time); |
288 AnimatePageScale(monotonic_time); | 291 AnimatePageScale(monotonic_time); |
289 AnimateLayers(monotonic_time, wall_clock_time); | 292 AnimateLayers(monotonic_time, wall_clock_time); |
290 AnimateScrollbars(monotonic_time); | 293 AnimateScrollbars(monotonic_time); |
291 AnimateTopControls(monotonic_time); | 294 AnimateTopControls(monotonic_time); |
292 } | 295 } |
293 | 296 |
294 void LayerTreeHostImpl::ManageTiles() { | 297 void LayerTreeHostImpl::ManageTiles() { |
295 DCHECK(tile_manager_); | 298 if (!tile_manager_) |
| 299 return; |
| 300 if (!manage_tiles_needed_) |
| 301 return; |
| 302 manage_tiles_needed_ = false; |
296 tile_manager_->ManageTiles(); | 303 tile_manager_->ManageTiles(); |
297 | 304 |
298 size_t memory_required_bytes; | 305 size_t memory_required_bytes; |
299 size_t memory_nice_to_have_bytes; | 306 size_t memory_nice_to_have_bytes; |
300 size_t memory_used_bytes; | 307 size_t memory_used_bytes; |
301 tile_manager_->GetMemoryStats(&memory_required_bytes, | 308 tile_manager_->GetMemoryStats(&memory_required_bytes, |
302 &memory_nice_to_have_bytes, | 309 &memory_nice_to_have_bytes, |
303 &memory_used_bytes); | 310 &memory_used_bytes); |
304 SendManagedMemoryStats(memory_required_bytes, | 311 SendManagedMemoryStats(memory_required_bytes, |
305 memory_nice_to_have_bytes, | 312 memory_nice_to_have_bytes, |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 // possible. crbug.com/224475 | 970 // possible. crbug.com/224475 |
964 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( | 971 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( |
965 (static_cast<int64>(new_state.memory_limit_in_bytes) * | 972 (static_cast<int64>(new_state.memory_limit_in_bytes) * |
966 settings_.max_unused_resource_memory_percentage) / 100); | 973 settings_.max_unused_resource_memory_percentage) / 100); |
967 new_state.memory_limit_policy = | 974 new_state.memory_limit_policy = |
968 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( | 975 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( |
969 visible_ ? | 976 visible_ ? |
970 policy.priority_cutoff_when_visible : | 977 policy.priority_cutoff_when_visible : |
971 policy.priority_cutoff_when_not_visible); | 978 policy.priority_cutoff_when_not_visible); |
972 tile_manager_->SetGlobalState(new_state); | 979 tile_manager_->SetGlobalState(new_state); |
| 980 manage_tiles_needed_ = true; |
973 } | 981 } |
974 | 982 |
975 bool LayerTreeHostImpl::HasImplThread() const { | 983 bool LayerTreeHostImpl::HasImplThread() const { |
976 return proxy_->HasImplThread(); | 984 return proxy_->HasImplThread(); |
977 } | 985 } |
978 | 986 |
979 void LayerTreeHostImpl::ScheduleManageTiles() { | |
980 if (client_) | |
981 client_->SetNeedsManageTilesOnImplThread(); | |
982 } | |
983 | |
984 void LayerTreeHostImpl::DidInitializeVisibleTile() { | 987 void LayerTreeHostImpl::DidInitializeVisibleTile() { |
985 // TODO(reveman): Determine tiles that changed and only damage | 988 // TODO(reveman): Determine tiles that changed and only damage |
986 // what's necessary. | 989 // what's necessary. |
987 SetFullRootLayerDamage(); | 990 SetFullRootLayerDamage(); |
988 if (client_) | 991 if (client_) |
989 client_->DidInitializeVisibleTileOnImplThread(); | 992 client_->DidInitializeVisibleTileOnImplThread(); |
990 } | 993 } |
991 | 994 |
992 bool LayerTreeHostImpl:: | 995 bool LayerTreeHostImpl:: |
993 ShouldForceTileUploadsRequiredForActivationToComplete() const { | 996 ShouldForceTileUploadsRequiredForActivationToComplete() const { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 } | 1334 } |
1332 | 1335 |
1333 bool LayerTreeHostImpl::ActivatePendingTreeIfNeeded() { | 1336 bool LayerTreeHostImpl::ActivatePendingTreeIfNeeded() { |
1334 if (!pending_tree_) | 1337 if (!pending_tree_) |
1335 return false; | 1338 return false; |
1336 | 1339 |
1337 CHECK(settings_.impl_side_painting); | 1340 CHECK(settings_.impl_side_painting); |
1338 | 1341 |
1339 // TODO(enne): This needs to be moved somewhere else (post-animate?) | 1342 // TODO(enne): This needs to be moved somewhere else (post-animate?) |
1340 pending_tree_->UpdateDrawProperties(); | 1343 pending_tree_->UpdateDrawProperties(); |
| 1344 // Note: This will likely cause ManageTiles to be needed. However, |
| 1345 // it is only out of date as far as the last commit or the last draw. |
| 1346 // For performance reasons, don't call ManageTiles again here. |
1341 | 1347 |
1342 TRACE_EVENT_ASYNC_STEP1( | 1348 TRACE_EVENT_ASYNC_STEP1( |
1343 "cc", | 1349 "cc", |
1344 "PendingTree", pending_tree_.get(), "activate", | 1350 "PendingTree", pending_tree_.get(), "activate", |
1345 "state", TracedValue::FromValue(ActivationStateAsValue().release())); | 1351 "state", TracedValue::FromValue(ActivationStateAsValue().release())); |
1346 | 1352 |
1347 if (tile_manager_) { | 1353 if (tile_manager_) { |
1348 tile_manager_->CheckForCompletedTileUploads(); | 1354 tile_manager_->CheckForCompletedTileUploads(); |
1349 if (!tile_manager_->AreTilesRequiredForActivationReady()) | 1355 if (!tile_manager_->AreTilesRequiredForActivationReady()) |
1350 return false; | 1356 return false; |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { | 2230 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
2225 if (!tile_manager_) | 2231 if (!tile_manager_) |
2226 return; | 2232 return; |
2227 | 2233 |
2228 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); | 2234 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); |
2229 if (new_state.tree_priority == priority) | 2235 if (new_state.tree_priority == priority) |
2230 return; | 2236 return; |
2231 | 2237 |
2232 new_state.tree_priority = priority; | 2238 new_state.tree_priority = priority; |
2233 tile_manager_->SetGlobalState(new_state); | 2239 tile_manager_->SetGlobalState(new_state); |
| 2240 manage_tiles_needed_ = true; |
2234 } | 2241 } |
2235 | 2242 |
2236 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { | 2243 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { |
2237 current_frame_timeticks_ = base::TimeTicks(); | 2244 current_frame_timeticks_ = base::TimeTicks(); |
2238 current_frame_time_ = base::Time(); | 2245 current_frame_time_ = base::Time(); |
2239 } | 2246 } |
2240 | 2247 |
2241 static void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) { | 2248 static void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) { |
2242 if (ticks->is_null()) { | 2249 if (ticks->is_null()) { |
2243 DCHECK(now->is_null()); | 2250 DCHECK(now->is_null()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 } | 2312 } |
2306 | 2313 |
2307 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2314 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2308 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2315 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2309 paint_time_counter_->ClearHistory(); | 2316 paint_time_counter_->ClearHistory(); |
2310 | 2317 |
2311 debug_state_ = debug_state; | 2318 debug_state_ = debug_state; |
2312 } | 2319 } |
2313 | 2320 |
2314 } // namespace cc | 2321 } // namespace cc |
OLD | NEW |