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_->ui_resource_eviction_count_recreated() != | |
316 ui_resource_eviction_count()) { | |
317 TRACE_EVENT_INSTANT0( | |
318 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", | |
319 TRACE_EVENT_SCOPE_THREAD); | |
320 return false; | |
321 } | |
314 return true; | 322 return true; |
315 } | 323 } |
316 | 324 |
317 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, | 325 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, |
318 base::Time wall_clock_time) { | 326 base::Time wall_clock_time) { |
319 if (input_handler_client_) | 327 if (input_handler_client_) |
320 input_handler_client_->Animate(monotonic_time); | 328 input_handler_client_->Animate(monotonic_time); |
321 AnimatePageScale(monotonic_time); | 329 AnimatePageScale(monotonic_time); |
322 AnimateLayers(monotonic_time, wall_clock_time); | 330 AnimateLayers(monotonic_time, wall_clock_time); |
323 AnimateScrollbars(monotonic_time); | 331 AnimateScrollbars(monotonic_time); |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1551 | 1559 |
1552 void LayerTreeHostImpl::SetVisible(bool visible) { | 1560 void LayerTreeHostImpl::SetVisible(bool visible) { |
1553 DCHECK(proxy_->IsImplThread()); | 1561 DCHECK(proxy_->IsImplThread()); |
1554 | 1562 |
1555 if (visible_ == visible) | 1563 if (visible_ == visible) |
1556 return; | 1564 return; |
1557 visible_ = visible; | 1565 visible_ = visible; |
1558 DidVisibilityChange(this, visible_); | 1566 DidVisibilityChange(this, visible_); |
1559 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1567 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
1560 | 1568 |
1569 if (!visible_) | |
1570 DeleteAllUIResources(); | |
1571 | |
1561 // Evict tiles immediately if invisible since this tab may never get another | 1572 // Evict tiles immediately if invisible since this tab may never get another |
1562 // draw or timer tick. | 1573 // draw or timer tick. |
1563 if (!visible_) | 1574 if (!visible_) |
1564 ManageTiles(); | 1575 ManageTiles(); |
1565 | 1576 |
1566 if (!renderer_) | 1577 if (!renderer_) |
1567 return; | 1578 return; |
1568 | 1579 |
1569 renderer_->SetVisible(visible); | 1580 renderer_->SetVisible(visible); |
1570 } | 1581 } |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2632 | 2643 |
2633 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2644 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
2634 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2645 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
2635 if (id) { | 2646 if (id) { |
2636 resource_provider_->DeleteResource(id); | 2647 resource_provider_->DeleteResource(id); |
2637 ui_resource_map_.erase(uid); | 2648 ui_resource_map_.erase(uid); |
2638 } | 2649 } |
2639 } | 2650 } |
2640 | 2651 |
2641 void LayerTreeHostImpl::DeleteAllUIResources() { | 2652 void LayerTreeHostImpl::DeleteAllUIResources() { |
2653 if (ui_resource_map_.empty()) | |
2654 return; | |
2655 | |
2642 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); | 2656 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); |
2643 iter != ui_resource_map_.end(); | 2657 iter != ui_resource_map_.end(); |
2644 ++iter) { | 2658 ++iter) { |
2645 resource_provider_->DeleteResource(iter->second); | 2659 resource_provider_->DeleteResource(iter->second); |
2646 } | 2660 } |
2647 ui_resource_map_.clear(); | 2661 ui_resource_map_.clear(); |
2662 | |
2663 ui_resource_eviction_count_ += 1; | |
2664 client_->SetNeedsCommitOnImplThread(); | |
2665 client_->OnCanDrawStateChanged(CanDraw()); | |
2666 client_->RenewTreePriority(); | |
powei
2013/09/09 20:34:25
Maybe a stupid question, but what's the purpose of
ccameron
2013/09/09 21:01:16
Oops! I needed to update RenewTreePriority to "pre
| |
2648 } | 2667 } |
2649 | 2668 |
2650 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2669 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2651 UIResourceId uid) const { | 2670 UIResourceId uid) const { |
2652 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2671 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2653 if (iter != ui_resource_map_.end()) | 2672 if (iter != ui_resource_map_.end()) |
2654 return iter->second; | 2673 return iter->second; |
2655 return 0; | 2674 return 0; |
2656 } | 2675 } |
2657 | 2676 |
2658 } // namespace cc | 2677 } // namespace cc |
OLD | NEW |