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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCLayerTreeHostImpl.h" | 7 #include "CCLayerTreeHostImpl.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "CCAppendQuadsData.h" | 10 #include "CCAppendQuadsData.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 , m_pageScaleDelta(1) | 124 , m_pageScaleDelta(1) |
125 , m_sentPageScaleDelta(1) | 125 , m_sentPageScaleDelta(1) |
126 , m_minPageScale(0) | 126 , m_minPageScale(0) |
127 , m_maxPageScale(0) | 127 , m_maxPageScale(0) |
128 , m_backgroundColor(0) | 128 , m_backgroundColor(0) |
129 , m_hasTransparentBackground(false) | 129 , m_hasTransparentBackground(false) |
130 , m_needsAnimateLayers(false) | 130 , m_needsAnimateLayers(false) |
131 , m_pinchGestureActive(false) | 131 , m_pinchGestureActive(false) |
132 , m_fpsCounter(CCFrameRateCounter::create()) | 132 , m_fpsCounter(CCFrameRateCounter::create()) |
133 , m_debugRectHistory(CCDebugRectHistory::create()) | 133 , m_debugRectHistory(CCDebugRectHistory::create()) |
| 134 , m_numImplThreadScrolls(0) |
| 135 , m_numMainThreadScrolls(0) |
134 { | 136 { |
135 ASSERT(CCProxy::isImplThread()); | 137 ASSERT(CCProxy::isImplThread()); |
136 didVisibilityChange(this, m_visible); | 138 didVisibilityChange(this, m_visible); |
137 } | 139 } |
138 | 140 |
139 CCLayerTreeHostImpl::~CCLayerTreeHostImpl() | 141 CCLayerTreeHostImpl::~CCLayerTreeHostImpl() |
140 { | 142 { |
141 ASSERT(CCProxy::isImplThread()); | 143 ASSERT(CCProxy::isImplThread()); |
142 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()"); | 144 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()"); |
143 | 145 |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 deviceViewportPoint.scale(m_deviceScaleFactor, m_deviceScaleFactor); | 920 deviceViewportPoint.scale(m_deviceScaleFactor, m_deviceScaleFactor); |
919 | 921 |
920 // First find out which layer was hit from the saved list of visible layers | 922 // First find out which layer was hit from the saved list of visible layers |
921 // in the most recent frame. | 923 // in the most recent frame. |
922 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi
ewportPoint, m_renderSurfaceLayerList); | 924 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi
ewportPoint, m_renderSurfaceLayerList); |
923 | 925 |
924 // Walk up the hierarchy and look for a scrollable layer. | 926 // Walk up the hierarchy and look for a scrollable layer. |
925 CCLayerImpl* potentiallyScrollingLayerImpl = 0; | 927 CCLayerImpl* potentiallyScrollingLayerImpl = 0; |
926 for (; layerImpl; layerImpl = layerImpl->parent()) { | 928 for (; layerImpl; layerImpl = layerImpl->parent()) { |
927 // The content layer can also block attempts to scroll outside the main
thread. | 929 // The content layer can also block attempts to scroll outside the main
thread. |
928 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) | 930 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) { |
| 931 m_numMainThreadScrolls++; |
929 return ScrollOnMainThread; | 932 return ScrollOnMainThread; |
| 933 } |
930 | 934 |
931 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl)
; | 935 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl)
; |
932 if (!scrollLayerImpl) | 936 if (!scrollLayerImpl) |
933 continue; | 937 continue; |
934 | 938 |
935 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type); | 939 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type); |
936 | 940 |
937 // If any layer wants to divert the scroll event to the main thread, abo
rt. | 941 // If any layer wants to divert the scroll event to the main thread, abo
rt. |
938 if (status == ScrollOnMainThread) | 942 if (status == ScrollOnMainThread) { |
| 943 m_numMainThreadScrolls++; |
939 return ScrollOnMainThread; | 944 return ScrollOnMainThread; |
| 945 } |
940 | 946 |
941 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) | 947 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) |
942 potentiallyScrollingLayerImpl = scrollLayerImpl; | 948 potentiallyScrollingLayerImpl = scrollLayerImpl; |
943 } | 949 } |
944 | 950 |
945 if (potentiallyScrollingLayerImpl) { | 951 if (potentiallyScrollingLayerImpl) { |
946 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; | 952 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; |
947 // Gesture events need to be transformed from screen coordinates to loca
l layer coordinates | 953 // Gesture events need to be transformed from screen coordinates to loca
l layer coordinates |
948 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel | 954 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel |
949 // events are already in local layer coordinates so we can just apply th
em directly. | 955 // events are already in local layer coordinates so we can just apply th
em directly. |
950 m_scrollDeltaIsInScreenSpace = (type == Gesture); | 956 m_scrollDeltaIsInScreenSpace = (type == Gesture); |
| 957 m_numImplThreadScrolls++; |
951 return ScrollStarted; | 958 return ScrollStarted; |
952 } | 959 } |
953 return ScrollIgnored; | 960 return ScrollIgnored; |
954 } | 961 } |
955 | 962 |
956 static FloatSize scrollLayerWithScreenSpaceDelta(CCLayerImpl& layerImpl, const F
loatPoint& screenSpacePoint, const FloatSize& screenSpaceDelta) | 963 static FloatSize scrollLayerWithScreenSpaceDelta(CCLayerImpl& layerImpl, const F
loatPoint& screenSpacePoint, const FloatSize& screenSpaceDelta) |
957 { | 964 { |
958 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 965 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
959 // test in the first place. | 966 // test in the first place. |
960 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); | 967 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 | 1299 |
1293 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const | 1300 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const |
1294 { | 1301 { |
1295 return fpsCounter()->currentFrameNumber(); | 1302 return fpsCounter()->currentFrameNumber(); |
1296 } | 1303 } |
1297 | 1304 |
1298 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const | 1305 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const |
1299 { | 1306 { |
1300 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); | 1307 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); |
1301 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); | 1308 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); |
| 1309 stats->numImplThreadScrolls = m_numImplThreadScrolls; |
| 1310 stats->numMainThreadScrolls = m_numMainThreadScrolls; |
1302 } | 1311 } |
1303 | 1312 |
1304 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime) | 1313 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime) |
1305 { | 1314 { |
1306 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime); | 1315 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime); |
1307 } | 1316 } |
1308 | 1317 |
1309 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double
monotonicTime) | 1318 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double
monotonicTime) |
1310 { | 1319 { |
1311 if (!layer) | 1320 if (!layer) |
1312 return; | 1321 return; |
1313 | 1322 |
1314 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); | 1323 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); |
1315 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1324 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1316 m_client->setNeedsRedrawOnImplThread(); | 1325 m_client->setNeedsRedrawOnImplThread(); |
1317 | 1326 |
1318 for (size_t i = 0; i < layer->children().size(); ++i) | 1327 for (size_t i = 0; i < layer->children().size(); ++i) |
1319 animateScrollbarsRecursive(layer->children()[i], monotonicTime); | 1328 animateScrollbarsRecursive(layer->children()[i], monotonicTime); |
1320 } | 1329 } |
1321 | 1330 |
1322 } // namespace cc | 1331 } // namespace cc |
OLD | NEW |