Chromium Code Reviews| 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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1752 device_scale_factor_); | 1752 device_scale_factor_); |
| 1753 | 1753 |
| 1754 // First find out which layer was hit from the saved list of visible layers | 1754 // First find out which layer was hit from the saved list of visible layers |
| 1755 // in the most recent frame. | 1755 // in the most recent frame. |
| 1756 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 1756 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
| 1757 device_viewport_point, active_tree_->RenderSurfaceLayerList()); | 1757 device_viewport_point, active_tree_->RenderSurfaceLayerList()); |
| 1758 | 1758 |
| 1759 // Walk up the hierarchy and look for a scrollable layer. | 1759 // Walk up the hierarchy and look for a scrollable layer. |
| 1760 LayerImpl* potentially_scrolling_layer_impl = 0; | 1760 LayerImpl* potentially_scrolling_layer_impl = 0; |
| 1761 for (; layer_impl; layer_impl = layer_impl->parent()) { | 1761 for (; layer_impl; layer_impl = layer_impl->parent()) { |
| 1762 TRACE_EVENT_INSTANT1( | |
| 1763 "impl-scroll", "LayerTreeHostImpl::ScrollBegin considering layer", | |
| 1764 TRACE_EVENT_SCOPE_THREAD, | |
| 1765 "layerId", layer_impl->id()); | |
|
danakj
2013/07/29 17:16:08
layer_id ?
| |
| 1766 | |
| 1762 // The content layer can also block attempts to scroll outside the main | 1767 // The content layer can also block attempts to scroll outside the main |
| 1763 // thread. | 1768 // thread. |
| 1764 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 1769 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
| 1765 if (status == ScrollOnMainThread) { | 1770 if (status == ScrollOnMainThread) { |
| 1766 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); | 1771 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); |
| 1772 TRACE_EVENT_INSTANT0( | |
| 1773 "impl-scroll", | |
| 1774 "LayerTreeHostImpl::ScrollBegin return ScrollOnMainThread", | |
| 1775 TRACE_EVENT_SCOPE_THREAD); | |
| 1776 | |
| 1767 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1777 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1768 return ScrollOnMainThread; | 1778 return ScrollOnMainThread; |
| 1769 } | 1779 } |
| 1770 | 1780 |
| 1771 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 1781 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
| 1772 if (!scroll_layer_impl) | 1782 if (!scroll_layer_impl) |
| 1773 continue; | 1783 continue; |
| 1774 | 1784 |
| 1785 TRACE_EVENT_INSTANT1( | |
| 1786 "impl-scroll", | |
| 1787 "LayerTreeHostImpl::ScrollBegin considering scroll layer", | |
| 1788 TRACE_EVENT_SCOPE_THREAD, | |
| 1789 "layerId", scroll_layer_impl->id()); | |
|
danakj
2013/07/29 17:16:08
layer_id?
| |
| 1790 | |
| 1775 status = scroll_layer_impl->TryScroll(device_viewport_point, type); | 1791 status = scroll_layer_impl->TryScroll(device_viewport_point, type); |
| 1776 | 1792 |
| 1777 // If any layer wants to divert the scroll event to the main thread, abort. | 1793 // If any layer wants to divert the scroll event to the main thread, abort. |
| 1778 if (status == ScrollOnMainThread) { | 1794 if (status == ScrollOnMainThread) { |
| 1779 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); | 1795 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); |
| 1796 TRACE_EVENT_INSTANT0( | |
| 1797 "impl-scroll", | |
| 1798 "LayerTreeHostImpl::ScrollBegin return ScrollOnMainThread", | |
| 1799 TRACE_EVENT_SCOPE_THREAD); | |
| 1800 | |
| 1780 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1801 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1781 return ScrollOnMainThread; | 1802 return ScrollOnMainThread; |
| 1782 } | 1803 } |
| 1783 | 1804 |
| 1784 if (status == ScrollStarted && !potentially_scrolling_layer_impl) | 1805 if (status == ScrollStarted && !potentially_scrolling_layer_impl) { |
| 1785 potentially_scrolling_layer_impl = scroll_layer_impl; | 1806 potentially_scrolling_layer_impl = scroll_layer_impl; |
| 1807 TRACE_EVENT_INSTANT1( | |
| 1808 "impl-scroll", | |
| 1809 "LayerTreeHostImpl::ScrollBegin scroll layer is the potentially " | |
| 1810 "scrolling layer", | |
| 1811 TRACE_EVENT_SCOPE_THREAD, | |
| 1812 "layerId", scroll_layer_impl->id()); | |
|
danakj
2013/07/29 17:16:08
layer_id?
| |
| 1813 } | |
| 1786 } | 1814 } |
| 1787 | 1815 |
| 1788 // When hiding top controls is enabled and the controls are hidden or | 1816 // When hiding top controls is enabled and the controls are hidden or |
| 1789 // overlaying the content, force scrolls to be enabled on the root layer to | 1817 // overlaying the content, force scrolls to be enabled on the root layer to |
| 1790 // allow bringing the top controls back into view. | 1818 // allow bringing the top controls back into view. |
| 1791 if (!potentially_scrolling_layer_impl && top_controls_manager_ && | 1819 if (!potentially_scrolling_layer_impl && top_controls_manager_ && |
| 1792 top_controls_manager_->content_top_offset() != | 1820 top_controls_manager_->content_top_offset() != |
| 1793 settings_.top_controls_height) { | 1821 settings_.top_controls_height) { |
| 1794 potentially_scrolling_layer_impl = RootScrollLayer(); | 1822 potentially_scrolling_layer_impl = RootScrollLayer(); |
| 1795 } | 1823 } |
| 1796 | 1824 |
| 1797 if (potentially_scrolling_layer_impl) { | 1825 if (potentially_scrolling_layer_impl) { |
| 1798 active_tree_->SetCurrentlyScrollingLayer( | 1826 active_tree_->SetCurrentlyScrollingLayer( |
| 1799 potentially_scrolling_layer_impl); | 1827 potentially_scrolling_layer_impl); |
| 1800 should_bubble_scrolls_ = (type != NonBubblingGesture); | 1828 should_bubble_scrolls_ = (type != NonBubblingGesture); |
| 1801 wheel_scrolling_ = (type == Wheel); | 1829 wheel_scrolling_ = (type == Wheel); |
| 1802 rendering_stats_instrumentation_->IncrementImplThreadScrolls(); | 1830 rendering_stats_instrumentation_->IncrementImplThreadScrolls(); |
| 1803 client_->RenewTreePriority(); | 1831 client_->RenewTreePriority(); |
| 1832 TRACE_EVENT_INSTANT0( | |
| 1833 "impl-scroll", "LayerTreeHostImpl::ScrollBegin: start impl-scroll.", | |
|
enne (OOO)
2013/07/29 17:46:31
Would it make sense to do something with trace eve
| |
| 1834 TRACE_EVENT_SCOPE_THREAD); | |
| 1804 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 1835 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
| 1805 return ScrollStarted; | 1836 return ScrollStarted; |
| 1806 } | 1837 } |
| 1807 return ScrollIgnored; | 1838 return ScrollIgnored; |
| 1808 } | 1839 } |
| 1809 | 1840 |
| 1810 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( | 1841 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( |
| 1811 LayerImpl* layer_impl, | 1842 LayerImpl* layer_impl, |
| 1812 float scale_from_viewport_to_screen_space, | 1843 float scale_from_viewport_to_screen_space, |
| 1813 gfx::PointF viewport_point, | 1844 gfx::PointF viewport_point, |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2136 } | 2167 } |
| 2137 | 2168 |
| 2138 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 2169 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
| 2139 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 2170 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
| 2140 } | 2171 } |
| 2141 | 2172 |
| 2142 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 2173 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
| 2143 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 2174 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
| 2144 | 2175 |
| 2145 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 2176 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
| 2177 | |
| 2178 if (!scroll_info->scrolls.empty()) { | |
| 2179 TRACE_EVENT_INSTANT0( | |
| 2180 "impl-scroll", | |
| 2181 "LayerTreeHostImpl::ProcessScrollDeltas found and set scroll deltas", | |
| 2182 TRACE_EVENT_SCOPE_THREAD); | |
| 2183 } | |
| 2184 | |
| 2146 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); | 2185 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); |
| 2147 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); | 2186 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
| 2148 | 2187 |
| 2149 return scroll_info.Pass(); | 2188 return scroll_info.Pass(); |
| 2150 } | 2189 } |
| 2151 | 2190 |
| 2152 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 2191 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
| 2153 SetViewportDamage(gfx::Rect(device_viewport_size_)); | 2192 SetViewportDamage(gfx::Rect(device_viewport_size_)); |
| 2154 } | 2193 } |
| 2155 | 2194 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2405 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 2444 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
| 2406 return; | 2445 return; |
| 2407 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) | 2446 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) |
| 2408 paint_time_counter_->ClearHistory(); | 2447 paint_time_counter_->ClearHistory(); |
| 2409 | 2448 |
| 2410 debug_state_ = new_debug_state; | 2449 debug_state_ = new_debug_state; |
| 2411 SetFullRootLayerDamage(); | 2450 SetFullRootLayerDamage(); |
| 2412 } | 2451 } |
| 2413 | 2452 |
| 2414 } // namespace cc | 2453 } // namespace cc |
| OLD | NEW |