| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 "cc", "LayerTreeHostImpl::CanDraw viewport size recently changed", | 301 "cc", "LayerTreeHostImpl::CanDraw viewport size recently changed", |
| 302 TRACE_EVENT_SCOPE_THREAD); | 302 TRACE_EVENT_SCOPE_THREAD); |
| 303 return false; | 303 return false; |
| 304 } | 304 } |
| 305 if (active_tree_->ContentsTexturesPurged()) { | 305 if (active_tree_->ContentsTexturesPurged()) { |
| 306 TRACE_EVENT_INSTANT0( | 306 TRACE_EVENT_INSTANT0( |
| 307 "cc", "LayerTreeHostImpl::CanDraw contents textures purged", | 307 "cc", "LayerTreeHostImpl::CanDraw contents textures purged", |
| 308 TRACE_EVENT_SCOPE_THREAD); | 308 TRACE_EVENT_SCOPE_THREAD); |
| 309 return false; | 309 return false; |
| 310 } | 310 } |
| 311 if (active_tree_->ui_resource_eviction_count_acked() != |
| 312 ui_resource_eviction_count()) { |
| 313 TRACE_EVENT_INSTANT0( |
| 314 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted", |
| 315 TRACE_EVENT_SCOPE_THREAD); |
| 316 return false; |
| 317 } |
| 311 return true; | 318 return true; |
| 312 } | 319 } |
| 313 | 320 |
| 314 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, | 321 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, |
| 315 base::Time wall_clock_time) { | 322 base::Time wall_clock_time) { |
| 316 if (input_handler_client_) | 323 if (input_handler_client_) |
| 317 input_handler_client_->Animate(monotonic_time); | 324 input_handler_client_->Animate(monotonic_time); |
| 318 AnimatePageScale(monotonic_time); | 325 AnimatePageScale(monotonic_time); |
| 319 AnimateLayers(monotonic_time, wall_clock_time); | 326 AnimateLayers(monotonic_time, wall_clock_time); |
| 320 AnimateScrollbars(monotonic_time); | 327 AnimateScrollbars(monotonic_time); |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 | 1523 |
| 1517 void LayerTreeHostImpl::SetVisible(bool visible) { | 1524 void LayerTreeHostImpl::SetVisible(bool visible) { |
| 1518 DCHECK(proxy_->IsImplThread()); | 1525 DCHECK(proxy_->IsImplThread()); |
| 1519 | 1526 |
| 1520 if (visible_ == visible) | 1527 if (visible_ == visible) |
| 1521 return; | 1528 return; |
| 1522 visible_ = visible; | 1529 visible_ = visible; |
| 1523 DidVisibilityChange(this, visible_); | 1530 DidVisibilityChange(this, visible_); |
| 1524 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1531 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
| 1525 | 1532 |
| 1533 if (!visible_) |
| 1534 DeleteAllUIResources(); |
| 1535 |
| 1526 // Evict tiles immediately if invisible since this tab may never get another | 1536 // Evict tiles immediately if invisible since this tab may never get another |
| 1527 // draw or timer tick. | 1537 // draw or timer tick. |
| 1528 if (!visible_) | 1538 if (!visible_) |
| 1529 ManageTiles(); | 1539 ManageTiles(); |
| 1530 | 1540 |
| 1531 if (!renderer_) | 1541 if (!renderer_) |
| 1532 return; | 1542 return; |
| 1533 | 1543 |
| 1534 renderer_->SetVisible(visible); | 1544 renderer_->SetVisible(visible); |
| 1535 } | 1545 } |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 | 2578 |
| 2569 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2579 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 2570 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2580 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2571 if (id) { | 2581 if (id) { |
| 2572 resource_provider_->DeleteResource(id); | 2582 resource_provider_->DeleteResource(id); |
| 2573 ui_resource_map_.erase(uid); | 2583 ui_resource_map_.erase(uid); |
| 2574 } | 2584 } |
| 2575 } | 2585 } |
| 2576 | 2586 |
| 2577 void LayerTreeHostImpl::DeleteAllUIResources() { | 2587 void LayerTreeHostImpl::DeleteAllUIResources() { |
| 2588 if (ui_resource_map_.empty()) |
| 2589 return; |
| 2590 |
| 2578 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); | 2591 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); |
| 2579 iter != ui_resource_map_.end(); | 2592 iter != ui_resource_map_.end(); |
| 2580 ++iter) { | 2593 ++iter) { |
| 2581 resource_provider_->DeleteResource(iter->second); | 2594 resource_provider_->DeleteResource(iter->second); |
| 2582 } | 2595 } |
| 2583 ui_resource_map_.clear(); | 2596 ui_resource_map_.clear(); |
| 2597 |
| 2598 ui_resource_eviction_count_ += 1; |
| 2599 client_->SetNeedsCommitOnImplThread(); |
| 2600 client_->OnCanDrawStateChanged(CanDraw()); |
| 2601 client_->RenewTreePriority(); |
| 2584 } | 2602 } |
| 2585 | 2603 |
| 2586 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2604 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2587 UIResourceId uid) const { | 2605 UIResourceId uid) const { |
| 2588 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2606 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2589 if (iter != ui_resource_map_.end()) | 2607 if (iter != ui_resource_map_.end()) |
| 2590 return iter->second; | 2608 return iter->second; |
| 2591 return 0; | 2609 return 0; |
| 2592 } | 2610 } |
| 2593 | 2611 |
| 2594 } // namespace cc | 2612 } // namespace cc |
| OLD | NEW |