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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 const LayerTreeSettings& settings, | 167 const LayerTreeSettings& settings, |
168 LayerTreeHostImplClient* client, | 168 LayerTreeHostImplClient* client, |
169 Proxy* proxy, | 169 Proxy* proxy, |
170 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 170 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
171 : client_(client), | 171 : client_(client), |
172 proxy_(proxy), | 172 proxy_(proxy), |
173 input_handler_client_(NULL), | 173 input_handler_client_(NULL), |
174 did_lock_scrolling_layer_(false), | 174 did_lock_scrolling_layer_(false), |
175 should_bubble_scrolls_(false), | 175 should_bubble_scrolls_(false), |
176 wheel_scrolling_(false), | 176 wheel_scrolling_(false), |
177 manage_tiles_needed_(false), | 177 tile_priorities_dirty_(false), |
178 root_layer_scroll_offset_delegate_(NULL), | 178 root_layer_scroll_offset_delegate_(NULL), |
179 settings_(settings), | 179 settings_(settings), |
180 visible_(true), | 180 visible_(true), |
181 cached_managed_memory_policy_( | 181 cached_managed_memory_policy_( |
182 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 182 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
183 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, | 183 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, |
184 0, | 184 0, |
185 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, | 185 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, |
186 ManagedMemoryPolicy::kDefaultNumResourcesLimit), | 186 ManagedMemoryPolicy::kDefaultNumResourcesLimit), |
187 pinch_gesture_active_(false), | 187 pinch_gesture_active_(false), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 248 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
249 | 249 |
250 if (settings_.impl_side_painting) { | 250 if (settings_.impl_side_painting) { |
251 // Impl-side painting needs an update immediately post-commit to have the | 251 // Impl-side painting needs an update immediately post-commit to have the |
252 // opportunity to create tilings. Other paths can call UpdateDrawProperties | 252 // opportunity to create tilings. Other paths can call UpdateDrawProperties |
253 // more lazily when needed prior to drawing. | 253 // more lazily when needed prior to drawing. |
254 pending_tree()->ApplyScrollDeltasSinceBeginFrame(); | 254 pending_tree()->ApplyScrollDeltasSinceBeginFrame(); |
255 pending_tree_->set_needs_update_draw_properties(); | 255 pending_tree_->set_needs_update_draw_properties(); |
256 pending_tree_->UpdateDrawProperties(); | 256 pending_tree_->UpdateDrawProperties(); |
257 // Start working on newly created tiles immediately if needed. | 257 // Start working on newly created tiles immediately if needed. |
258 if (!tile_manager_ || !manage_tiles_needed_) | 258 if (!tile_manager_ || !tile_priorities_dirty_) |
259 NotifyReadyToActivate(); | 259 NotifyReadyToActivate(); |
260 else | 260 else |
261 ManageTiles(); | 261 ManageTiles(); |
brianderson
2013/09/11 17:10:30
Will this ManageTiles() be a redundant call now th
epennerAtGoogle
2013/09/11 18:43:00
This isn't redundant unless we replicate this beha
| |
262 } else { | 262 } else { |
263 active_tree_->set_needs_update_draw_properties(); | 263 active_tree_->set_needs_update_draw_properties(); |
264 if (time_source_client_adapter_ && time_source_client_adapter_->Active()) | 264 if (time_source_client_adapter_ && time_source_client_adapter_->Active()) |
265 DCHECK(active_tree_->root_layer()); | 265 DCHECK(active_tree_->root_layer()); |
266 } | 266 } |
267 | 267 |
268 client_->SendManagedMemoryStats(); | 268 client_->SendManagedMemoryStats(); |
269 } | 269 } |
270 | 270 |
271 bool LayerTreeHostImpl::CanDraw() const { | 271 bool LayerTreeHostImpl::CanDraw() const { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 input_handler_client_->Animate(monotonic_time); | 320 input_handler_client_->Animate(monotonic_time); |
321 AnimatePageScale(monotonic_time); | 321 AnimatePageScale(monotonic_time); |
322 AnimateLayers(monotonic_time, wall_clock_time); | 322 AnimateLayers(monotonic_time, wall_clock_time); |
323 AnimateScrollbars(monotonic_time); | 323 AnimateScrollbars(monotonic_time); |
324 AnimateTopControls(monotonic_time); | 324 AnimateTopControls(monotonic_time); |
325 } | 325 } |
326 | 326 |
327 void LayerTreeHostImpl::ManageTiles() { | 327 void LayerTreeHostImpl::ManageTiles() { |
328 if (!tile_manager_) | 328 if (!tile_manager_) |
329 return; | 329 return; |
330 if (!manage_tiles_needed_) | 330 if (!tile_priorities_dirty_) |
331 return; | 331 return; |
332 if (!device_viewport_valid_for_tile_management_) | 332 if (!device_viewport_valid_for_tile_management_) |
333 return; | 333 return; |
334 | 334 |
335 manage_tiles_needed_ = false; | 335 tile_priorities_dirty_ = false; |
336 tile_manager_->ManageTiles(); | 336 tile_manager_->ManageTiles(); |
337 | 337 |
338 size_t memory_required_bytes; | 338 size_t memory_required_bytes; |
339 size_t memory_nice_to_have_bytes; | 339 size_t memory_nice_to_have_bytes; |
340 size_t memory_allocated_bytes; | 340 size_t memory_allocated_bytes; |
341 size_t memory_used_bytes; | 341 size_t memory_used_bytes; |
342 tile_manager_->GetMemoryStats(&memory_required_bytes, | 342 tile_manager_->GetMemoryStats(&memory_required_bytes, |
343 &memory_nice_to_have_bytes, | 343 &memory_nice_to_have_bytes, |
344 &memory_allocated_bytes, | 344 &memory_allocated_bytes, |
345 &memory_used_bytes); | 345 &memory_used_bytes); |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1101 // possible. crbug.com/224475 | 1101 // possible. crbug.com/224475 |
1102 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( | 1102 new_state.unused_memory_limit_in_bytes = static_cast<size_t>( |
1103 (static_cast<int64>(new_state.memory_limit_in_bytes) * | 1103 (static_cast<int64>(new_state.memory_limit_in_bytes) * |
1104 settings_.max_unused_resource_memory_percentage) / 100); | 1104 settings_.max_unused_resource_memory_percentage) / 100); |
1105 new_state.memory_limit_policy = | 1105 new_state.memory_limit_policy = |
1106 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( | 1106 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( |
1107 visible_ ? | 1107 visible_ ? |
1108 policy.priority_cutoff_when_visible : | 1108 policy.priority_cutoff_when_visible : |
1109 policy.priority_cutoff_when_not_visible); | 1109 policy.priority_cutoff_when_not_visible); |
1110 new_state.num_resources_limit = policy.num_resources_limit; | 1110 new_state.num_resources_limit = policy.num_resources_limit; |
1111 | |
1112 WillModifyTilePriorities(); | |
1111 tile_manager_->SetGlobalState(new_state); | 1113 tile_manager_->SetGlobalState(new_state); |
1112 manage_tiles_needed_ = true; | 1114 } |
1115 | |
1116 void LayerTreeHostImpl::WillModifyTilePriorities() { | |
1117 // Mark priorities as dirty and schedule a ManageTiles(). | |
1118 tile_priorities_dirty_ = true; | |
1119 client_->SetNeedsManageTilesOnImplThread(); | |
1113 } | 1120 } |
1114 | 1121 |
1115 void LayerTreeHostImpl::DidInitializeVisibleTile() { | 1122 void LayerTreeHostImpl::DidInitializeVisibleTile() { |
1116 // TODO(reveman): Determine tiles that changed and only damage | 1123 // TODO(reveman): Determine tiles that changed and only damage |
1117 // what's necessary. | 1124 // what's necessary. |
1118 SetFullRootLayerDamage(); | 1125 SetFullRootLayerDamage(); |
1119 if (client_) | 1126 if (client_) |
1120 client_->DidInitializeVisibleTileOnImplThread(); | 1127 client_->DidInitializeVisibleTileOnImplThread(); |
1121 } | 1128 } |
1122 | 1129 |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2502 | 2509 |
2503 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { | 2510 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
2504 if (!tile_manager_) | 2511 if (!tile_manager_) |
2505 return; | 2512 return; |
2506 | 2513 |
2507 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); | 2514 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); |
2508 if (new_state.tree_priority == priority) | 2515 if (new_state.tree_priority == priority) |
2509 return; | 2516 return; |
2510 | 2517 |
2511 new_state.tree_priority = priority; | 2518 new_state.tree_priority = priority; |
2519 | |
2520 WillModifyTilePriorities(); | |
2512 tile_manager_->SetGlobalState(new_state); | 2521 tile_manager_->SetGlobalState(new_state); |
2513 manage_tiles_needed_ = true; | |
2514 } | 2522 } |
2515 | 2523 |
2516 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { | 2524 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { |
2517 current_frame_timeticks_ = base::TimeTicks(); | 2525 current_frame_timeticks_ = base::TimeTicks(); |
2518 current_frame_time_ = base::Time(); | 2526 current_frame_time_ = base::Time(); |
2519 } | 2527 } |
2520 | 2528 |
2521 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks, | 2529 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks, |
2522 base::Time* now) const { | 2530 base::Time* now) const { |
2523 if (ticks->is_null()) { | 2531 if (ticks->is_null()) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2631 | 2639 |
2632 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2640 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2633 UIResourceId uid) const { | 2641 UIResourceId uid) const { |
2634 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2642 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2635 if (iter != ui_resource_map_.end()) | 2643 if (iter != ui_resource_map_.end()) |
2636 return iter->second; | 2644 return iter->second; |
2637 return 0; | 2645 return 0; |
2638 } | 2646 } |
2639 | 2647 |
2640 } // namespace cc | 2648 } // namespace cc |
OLD | NEW |