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 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 device_scale_factor_); | 1797 device_scale_factor_); |
1798 | 1798 |
1799 // First find out which layer was hit from the saved list of visible layers | 1799 // First find out which layer was hit from the saved list of visible layers |
1800 // in the most recent frame. | 1800 // in the most recent frame. |
1801 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( | 1801 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( |
1802 device_viewport_point, active_tree_->RenderSurfaceLayerList()); | 1802 device_viewport_point, active_tree_->RenderSurfaceLayerList()); |
1803 | 1803 |
1804 // Walk up the hierarchy and look for a scrollable layer. | 1804 // Walk up the hierarchy and look for a scrollable layer. |
1805 LayerImpl* potentially_scrolling_layer_impl = 0; | 1805 LayerImpl* potentially_scrolling_layer_impl = 0; |
1806 for (; layer_impl; layer_impl = layer_impl->parent()) { | 1806 for (; layer_impl; layer_impl = layer_impl->parent()) { |
| 1807 TRACE_EVENT_INSTANT1( |
| 1808 "impl-scroll", "LayerTreeHostImpl::ScrollBegin considering layer", |
| 1809 TRACE_EVENT_SCOPE_THREAD, |
| 1810 "layer_id", layer_impl->id()); |
| 1811 |
1807 // The content layer can also block attempts to scroll outside the main | 1812 // The content layer can also block attempts to scroll outside the main |
1808 // thread. | 1813 // thread. |
1809 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 1814 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
1810 if (status == ScrollOnMainThread) { | 1815 if (status == ScrollOnMainThread) { |
1811 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); | 1816 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); |
| 1817 TRACE_EVENT_INSTANT0( |
| 1818 "impl-scroll", |
| 1819 "LayerTreeHostImpl::ScrollBegin return ScrollOnMainThread", |
| 1820 TRACE_EVENT_SCOPE_THREAD); |
| 1821 |
1812 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1822 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
1813 return ScrollOnMainThread; | 1823 return ScrollOnMainThread; |
1814 } | 1824 } |
1815 | 1825 |
1816 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 1826 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
1817 if (!scroll_layer_impl) | 1827 if (!scroll_layer_impl) |
1818 continue; | 1828 continue; |
1819 | 1829 |
| 1830 TRACE_EVENT_INSTANT1( |
| 1831 "impl-scroll", |
| 1832 "LayerTreeHostImpl::ScrollBegin considering scroll layer", |
| 1833 TRACE_EVENT_SCOPE_THREAD, |
| 1834 "layer_id", scroll_layer_impl->id()); |
| 1835 |
1820 status = scroll_layer_impl->TryScroll(device_viewport_point, type); | 1836 status = scroll_layer_impl->TryScroll(device_viewport_point, type); |
1821 | 1837 |
1822 // If any layer wants to divert the scroll event to the main thread, abort. | 1838 // If any layer wants to divert the scroll event to the main thread, abort. |
1823 if (status == ScrollOnMainThread) { | 1839 if (status == ScrollOnMainThread) { |
1824 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); | 1840 rendering_stats_instrumentation_->IncrementMainThreadScrolls(); |
| 1841 TRACE_EVENT_INSTANT0( |
| 1842 "impl-scroll", |
| 1843 "LayerTreeHostImpl::ScrollBegin return ScrollOnMainThread", |
| 1844 TRACE_EVENT_SCOPE_THREAD); |
| 1845 |
1825 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1846 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
1826 return ScrollOnMainThread; | 1847 return ScrollOnMainThread; |
1827 } | 1848 } |
1828 | 1849 |
1829 if (status == ScrollStarted && !potentially_scrolling_layer_impl) | 1850 if (status == ScrollStarted && !potentially_scrolling_layer_impl) { |
1830 potentially_scrolling_layer_impl = scroll_layer_impl; | 1851 potentially_scrolling_layer_impl = scroll_layer_impl; |
| 1852 TRACE_EVENT_INSTANT1( |
| 1853 "impl-scroll", |
| 1854 "LayerTreeHostImpl::ScrollBegin scroll layer is the potentially " |
| 1855 "scrolling layer", |
| 1856 TRACE_EVENT_SCOPE_THREAD, |
| 1857 "layer_id", scroll_layer_impl->id()); |
| 1858 } |
1831 } | 1859 } |
1832 | 1860 |
1833 // When hiding top controls is enabled and the controls are hidden or | 1861 // When hiding top controls is enabled and the controls are hidden or |
1834 // overlaying the content, force scrolls to be enabled on the root layer to | 1862 // overlaying the content, force scrolls to be enabled on the root layer to |
1835 // allow bringing the top controls back into view. | 1863 // allow bringing the top controls back into view. |
1836 if (!potentially_scrolling_layer_impl && top_controls_manager_ && | 1864 if (!potentially_scrolling_layer_impl && top_controls_manager_ && |
1837 top_controls_manager_->content_top_offset() != | 1865 top_controls_manager_->content_top_offset() != |
1838 settings_.top_controls_height) { | 1866 settings_.top_controls_height) { |
1839 potentially_scrolling_layer_impl = RootScrollLayer(); | 1867 potentially_scrolling_layer_impl = RootScrollLayer(); |
1840 } | 1868 } |
1841 | 1869 |
1842 if (potentially_scrolling_layer_impl) { | 1870 if (potentially_scrolling_layer_impl) { |
1843 active_tree_->SetCurrentlyScrollingLayer( | 1871 active_tree_->SetCurrentlyScrollingLayer( |
1844 potentially_scrolling_layer_impl); | 1872 potentially_scrolling_layer_impl); |
1845 should_bubble_scrolls_ = (type != NonBubblingGesture); | 1873 should_bubble_scrolls_ = (type != NonBubblingGesture); |
1846 wheel_scrolling_ = (type == Wheel); | 1874 wheel_scrolling_ = (type == Wheel); |
1847 rendering_stats_instrumentation_->IncrementImplThreadScrolls(); | 1875 rendering_stats_instrumentation_->IncrementImplThreadScrolls(); |
1848 client_->RenewTreePriority(); | 1876 client_->RenewTreePriority(); |
| 1877 TRACE_EVENT_ASYNC_BEGIN0( |
| 1878 "impl-scroll", |
| 1879 "LayerTreeHostImpl::ScrollBegin", |
| 1880 this); |
1849 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 1881 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
1850 return ScrollStarted; | 1882 return ScrollStarted; |
1851 } | 1883 } |
1852 return ScrollIgnored; | 1884 return ScrollIgnored; |
1853 } | 1885 } |
1854 | 1886 |
1855 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( | 1887 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( |
1856 LayerImpl* layer_impl, | 1888 LayerImpl* layer_impl, |
1857 float scale_from_viewport_to_screen_space, | 1889 float scale_from_viewport_to_screen_space, |
1858 gfx::PointF viewport_point, | 1890 gfx::PointF viewport_point, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { | 2135 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { |
2104 active_tree_->ClearCurrentlyScrollingLayer(); | 2136 active_tree_->ClearCurrentlyScrollingLayer(); |
2105 did_lock_scrolling_layer_ = false; | 2137 did_lock_scrolling_layer_ = false; |
2106 accumulated_root_overscroll_ = gfx::Vector2dF(); | 2138 accumulated_root_overscroll_ = gfx::Vector2dF(); |
2107 current_fling_velocity_ = gfx::Vector2dF(); | 2139 current_fling_velocity_ = gfx::Vector2dF(); |
2108 } | 2140 } |
2109 | 2141 |
2110 void LayerTreeHostImpl::ScrollEnd() { | 2142 void LayerTreeHostImpl::ScrollEnd() { |
2111 if (top_controls_manager_) | 2143 if (top_controls_manager_) |
2112 top_controls_manager_->ScrollEnd(); | 2144 top_controls_manager_->ScrollEnd(); |
| 2145 TRACE_EVENT_ASYNC_END0( |
| 2146 "impl-scroll", |
| 2147 "LayerTreeHostImpl::ScrollBegin", |
| 2148 this); |
2113 ClearCurrentlyScrollingLayer(); | 2149 ClearCurrentlyScrollingLayer(); |
2114 StartScrollbarAnimation(); | 2150 StartScrollbarAnimation(); |
2115 } | 2151 } |
2116 | 2152 |
2117 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2153 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
2118 if (!active_tree_->CurrentlyScrollingLayer()) | 2154 if (!active_tree_->CurrentlyScrollingLayer()) |
2119 return ScrollIgnored; | 2155 return ScrollIgnored; |
2120 | 2156 |
2121 if (settings_.ignore_root_layer_flings && | 2157 if (settings_.ignore_root_layer_flings && |
2122 active_tree_->CurrentlyScrollingLayer() == | 2158 active_tree_->CurrentlyScrollingLayer() == |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2188 } | 2224 } |
2189 | 2225 |
2190 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 2226 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
2191 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 2227 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
2192 } | 2228 } |
2193 | 2229 |
2194 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 2230 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
2195 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 2231 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
2196 | 2232 |
2197 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 2233 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
| 2234 |
| 2235 if (!scroll_info->scrolls.empty()) { |
| 2236 TRACE_EVENT_INSTANT0( |
| 2237 "impl-scroll", |
| 2238 "LayerTreeHostImpl::ProcessScrollDeltas found and set scroll deltas", |
| 2239 TRACE_EVENT_SCOPE_THREAD); |
| 2240 } |
| 2241 |
2198 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); | 2242 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); |
2199 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); | 2243 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
2200 | 2244 |
2201 return scroll_info.Pass(); | 2245 return scroll_info.Pass(); |
2202 } | 2246 } |
2203 | 2247 |
2204 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 2248 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
2205 SetViewportDamage(gfx::Rect(device_viewport_size_)); | 2249 SetViewportDamage(gfx::Rect(device_viewport_size_)); |
2206 } | 2250 } |
2207 | 2251 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2495 | 2539 |
2496 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2540 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2497 UIResourceId uid) const { | 2541 UIResourceId uid) const { |
2498 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2542 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2499 if (iter != ui_resource_map_.end()) | 2543 if (iter != ui_resource_map_.end()) |
2500 return iter->second; | 2544 return iter->second; |
2501 return 0; | 2545 return 0; |
2502 } | 2546 } |
2503 | 2547 |
2504 } // namespace cc | 2548 } // namespace cc |
OLD | NEW |