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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 LayerTreeHostImpl::LayerTreeHostImpl( | 209 LayerTreeHostImpl::LayerTreeHostImpl( |
210 const LayerTreeSettings& settings, | 210 const LayerTreeSettings& settings, |
211 LayerTreeHostImplClient* client, | 211 LayerTreeHostImplClient* client, |
212 Proxy* proxy, | 212 Proxy* proxy, |
213 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 213 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
214 SharedBitmapManager* manager, | 214 SharedBitmapManager* manager, |
215 int id) | 215 int id) |
216 : client_(client), | 216 : client_(client), |
217 proxy_(proxy), | 217 proxy_(proxy), |
| 218 use_gpu_rasterization_(false), |
218 input_handler_client_(NULL), | 219 input_handler_client_(NULL), |
219 did_lock_scrolling_layer_(false), | 220 did_lock_scrolling_layer_(false), |
220 should_bubble_scrolls_(false), | 221 should_bubble_scrolls_(false), |
221 wheel_scrolling_(false), | 222 wheel_scrolling_(false), |
222 scroll_affects_scroll_handler_(false), | 223 scroll_affects_scroll_handler_(false), |
223 scroll_layer_id_when_mouse_over_scrollbar_(0), | 224 scroll_layer_id_when_mouse_over_scrollbar_(0), |
224 tile_priorities_dirty_(false), | 225 tile_priorities_dirty_(false), |
225 root_layer_scroll_offset_delegate_(NULL), | 226 root_layer_scroll_offset_delegate_(NULL), |
226 settings_(settings), | 227 settings_(settings), |
227 visible_(true), | 228 visible_(true), |
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 void LayerTreeHostImpl::FinishAllRendering() { | 1502 void LayerTreeHostImpl::FinishAllRendering() { |
1502 if (renderer_) | 1503 if (renderer_) |
1503 renderer_->Finish(); | 1504 renderer_->Finish(); |
1504 } | 1505 } |
1505 | 1506 |
1506 bool LayerTreeHostImpl::IsContextLost() { | 1507 bool LayerTreeHostImpl::IsContextLost() { |
1507 DCHECK(proxy_->IsImplThread()); | 1508 DCHECK(proxy_->IsImplThread()); |
1508 return renderer_ && renderer_->IsContextLost(); | 1509 return renderer_ && renderer_->IsContextLost(); |
1509 } | 1510 } |
1510 | 1511 |
| 1512 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { |
| 1513 if (use_gpu == use_gpu_rasterization_) |
| 1514 return; |
| 1515 |
| 1516 use_gpu_rasterization_ = use_gpu; |
| 1517 ReleaseTreeResources(); |
| 1518 |
| 1519 // We have released tilings for both active and pending tree. |
| 1520 // We would not have any content to draw until the pending tree is activated. |
| 1521 // Prevent the active tree from drawing until activation. |
| 1522 active_tree_->SetRequiresHighResToDraw(); |
| 1523 } |
| 1524 |
1511 const RendererCapabilitiesImpl& | 1525 const RendererCapabilitiesImpl& |
1512 LayerTreeHostImpl::GetRendererCapabilities() const { | 1526 LayerTreeHostImpl::GetRendererCapabilities() const { |
1513 return renderer_->Capabilities(); | 1527 return renderer_->Capabilities(); |
1514 } | 1528 } |
1515 | 1529 |
1516 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1530 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1517 active_tree()->ResetRequiresHighResToDraw(); | 1531 active_tree()->ResetRequiresHighResToDraw(); |
1518 if (frame.has_no_damage) { | 1532 if (frame.has_no_damage) { |
1519 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1533 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1520 return false; | 1534 return false; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 client_->SetNeedsAnimateOnImplThread(); | 1774 client_->SetNeedsAnimateOnImplThread(); |
1761 } | 1775 } |
1762 | 1776 |
1763 void LayerTreeHostImpl::SetNeedsRedraw() { | 1777 void LayerTreeHostImpl::SetNeedsRedraw() { |
1764 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1778 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
1765 client_->SetNeedsRedrawOnImplThread(); | 1779 client_->SetNeedsRedrawOnImplThread(); |
1766 } | 1780 } |
1767 | 1781 |
1768 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { | 1782 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { |
1769 ManagedMemoryPolicy actual = cached_managed_memory_policy_; | 1783 ManagedMemoryPolicy actual = cached_managed_memory_policy_; |
1770 bool any_tree_use_gpu_rasterization = | |
1771 (active_tree_ && active_tree_->use_gpu_rasterization()) || | |
1772 (pending_tree_ && pending_tree_->use_gpu_rasterization()); | |
1773 if (debug_state_.rasterize_only_visible_content) { | 1784 if (debug_state_.rasterize_only_visible_content) { |
1774 actual.priority_cutoff_when_visible = | 1785 actual.priority_cutoff_when_visible = |
1775 gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; | 1786 gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; |
1776 } else if (any_tree_use_gpu_rasterization) { | 1787 } else if (use_gpu_rasterization()) { |
1777 actual.priority_cutoff_when_visible = | 1788 actual.priority_cutoff_when_visible = |
1778 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 1789 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
1779 } | 1790 } |
1780 | 1791 |
1781 if (zero_budget_) { | 1792 if (zero_budget_) { |
1782 actual.bytes_limit_when_visible = 0; | 1793 actual.bytes_limit_when_visible = 0; |
1783 } | 1794 } |
1784 | 1795 |
1785 return actual; | 1796 return actual; |
1786 } | 1797 } |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3119 swap_promise_monitor_.erase(monitor); | 3130 swap_promise_monitor_.erase(monitor); |
3120 } | 3131 } |
3121 | 3132 |
3122 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3133 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3123 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3134 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3124 for (; it != swap_promise_monitor_.end(); it++) | 3135 for (; it != swap_promise_monitor_.end(); it++) |
3125 (*it)->OnSetNeedsRedrawOnImpl(); | 3136 (*it)->OnSetNeedsRedrawOnImpl(); |
3126 } | 3137 } |
3127 | 3138 |
3128 } // namespace cc | 3139 } // namespace cc |
OLD | NEW |