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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 last_sent_memory_visible_and_nearby_bytes_(0), | 194 last_sent_memory_visible_and_nearby_bytes_(0), |
195 last_sent_memory_use_bytes_(0), | 195 last_sent_memory_use_bytes_(0), |
196 zero_budget_(false), | 196 zero_budget_(false), |
197 device_scale_factor_(1.f), | 197 device_scale_factor_(1.f), |
198 overhang_ui_resource_id_(0), | 198 overhang_ui_resource_id_(0), |
199 overdraw_bottom_height_(0.f), | 199 overdraw_bottom_height_(0.f), |
200 device_viewport_valid_for_tile_management_(true), | 200 device_viewport_valid_for_tile_management_(true), |
201 external_stencil_test_enabled_(false), | 201 external_stencil_test_enabled_(false), |
202 animation_registrar_(AnimationRegistrar::Create()), | 202 animation_registrar_(AnimationRegistrar::Create()), |
203 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 203 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
204 need_to_update_visible_tiles_before_draw_(false) { | 204 need_to_update_visible_tiles_before_draw_(false), |
| 205 ui_resource_eviction_count_(0) { |
205 DCHECK(proxy_->IsImplThread()); | 206 DCHECK(proxy_->IsImplThread()); |
206 DidVisibilityChange(this, visible_); | 207 DidVisibilityChange(this, visible_); |
207 | 208 |
208 SetDebugState(settings.initial_debug_state); | 209 SetDebugState(settings.initial_debug_state); |
209 | 210 |
210 if (settings.calculate_top_controls_position) { | 211 if (settings.calculate_top_controls_position) { |
211 top_controls_manager_ = | 212 top_controls_manager_ = |
212 TopControlsManager::Create(this, | 213 TopControlsManager::Create(this, |
213 settings.top_controls_height, | 214 settings.top_controls_height, |
214 settings.top_controls_show_threshold, | 215 settings.top_controls_show_threshold, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 "cc", "LayerTreeHostImpl::CanDraw viewport size recently changed", | 305 "cc", "LayerTreeHostImpl::CanDraw viewport size recently changed", |
305 TRACE_EVENT_SCOPE_THREAD); | 306 TRACE_EVENT_SCOPE_THREAD); |
306 return false; | 307 return false; |
307 } | 308 } |
308 if (active_tree_->ContentsTexturesPurged()) { | 309 if (active_tree_->ContentsTexturesPurged()) { |
309 TRACE_EVENT_INSTANT0( | 310 TRACE_EVENT_INSTANT0( |
310 "cc", "LayerTreeHostImpl::CanDraw contents textures purged", | 311 "cc", "LayerTreeHostImpl::CanDraw contents textures purged", |
311 TRACE_EVENT_SCOPE_THREAD); | 312 TRACE_EVENT_SCOPE_THREAD); |
312 return false; | 313 return false; |
313 } | 314 } |
| 315 if (active_tree_->UIResourcesEvictedHaveNotBeenRecreated()) { |
| 316 TRACE_EVENT_INSTANT0( |
| 317 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", |
| 318 TRACE_EVENT_SCOPE_THREAD); |
| 319 return false; |
| 320 } |
314 return true; | 321 return true; |
315 } | 322 } |
316 | 323 |
317 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, | 324 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, |
318 base::Time wall_clock_time) { | 325 base::Time wall_clock_time) { |
319 if (input_handler_client_) | 326 if (input_handler_client_) |
320 input_handler_client_->Animate(monotonic_time); | 327 input_handler_client_->Animate(monotonic_time); |
321 AnimatePageScale(monotonic_time); | 328 AnimatePageScale(monotonic_time); |
322 AnimateLayers(monotonic_time, wall_clock_time); | 329 AnimateLayers(monotonic_time, wall_clock_time); |
323 AnimateScrollbars(monotonic_time); | 330 AnimateScrollbars(monotonic_time); |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1558 |
1552 void LayerTreeHostImpl::SetVisible(bool visible) { | 1559 void LayerTreeHostImpl::SetVisible(bool visible) { |
1553 DCHECK(proxy_->IsImplThread()); | 1560 DCHECK(proxy_->IsImplThread()); |
1554 | 1561 |
1555 if (visible_ == visible) | 1562 if (visible_ == visible) |
1556 return; | 1563 return; |
1557 visible_ = visible; | 1564 visible_ = visible; |
1558 DidVisibilityChange(this, visible_); | 1565 DidVisibilityChange(this, visible_); |
1559 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1566 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
1560 | 1567 |
| 1568 if (!visible_) |
| 1569 DeleteAllUIResources(); |
| 1570 |
1561 // Evict tiles immediately if invisible since this tab may never get another | 1571 // Evict tiles immediately if invisible since this tab may never get another |
1562 // draw or timer tick. | 1572 // draw or timer tick. |
1563 if (!visible_) | 1573 if (!visible_) |
1564 ManageTiles(); | 1574 ManageTiles(); |
1565 | 1575 |
1566 if (!renderer_) | 1576 if (!renderer_) |
1567 return; | 1577 return; |
1568 | 1578 |
1569 renderer_->SetVisible(visible); | 1579 renderer_->SetVisible(visible); |
1570 } | 1580 } |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 | 2642 |
2633 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2643 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
2634 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2644 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
2635 if (id) { | 2645 if (id) { |
2636 resource_provider_->DeleteResource(id); | 2646 resource_provider_->DeleteResource(id); |
2637 ui_resource_map_.erase(uid); | 2647 ui_resource_map_.erase(uid); |
2638 } | 2648 } |
2639 } | 2649 } |
2640 | 2650 |
2641 void LayerTreeHostImpl::DeleteAllUIResources() { | 2651 void LayerTreeHostImpl::DeleteAllUIResources() { |
| 2652 if (ui_resource_map_.empty()) |
| 2653 return; |
| 2654 |
2642 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); | 2655 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); |
2643 iter != ui_resource_map_.end(); | 2656 iter != ui_resource_map_.end(); |
2644 ++iter) { | 2657 ++iter) { |
2645 resource_provider_->DeleteResource(iter->second); | 2658 resource_provider_->DeleteResource(iter->second); |
2646 } | 2659 } |
2647 ui_resource_map_.clear(); | 2660 ui_resource_map_.clear(); |
| 2661 |
| 2662 ui_resource_eviction_count_ += 1; |
| 2663 client_->SetNeedsCommitOnImplThread(); |
| 2664 client_->OnCanDrawStateChanged(CanDraw()); |
| 2665 client_->RenewTreePriority(); |
2648 } | 2666 } |
2649 | 2667 |
2650 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2668 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2651 UIResourceId uid) const { | 2669 UIResourceId uid) const { |
2652 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2670 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2653 if (iter != ui_resource_map_.end()) | 2671 if (iter != ui_resource_map_.end()) |
2654 return iter->second; | 2672 return iter->second; |
2655 return 0; | 2673 return 0; |
2656 } | 2674 } |
2657 | 2675 |
2658 } // namespace cc | 2676 } // namespace cc |
OLD | NEW |