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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll
ocationLimit()) | 122 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll
ocationLimit()) |
123 , m_pageScale(1) | 123 , m_pageScale(1) |
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_animationFrameCount(0) |
132 , m_fpsCounter(CCFrameRateCounter::create()) | 133 , m_fpsCounter(CCFrameRateCounter::create()) |
133 , m_debugRectHistory(CCDebugRectHistory::create()) | 134 , m_debugRectHistory(CCDebugRectHistory::create()) |
134 , m_numImplThreadScrolls(0) | 135 , m_implThreadScrollCount(0) |
135 , m_numMainThreadScrolls(0) | 136 , m_mainThreadScrollCount(0) |
136 { | 137 { |
137 ASSERT(CCProxy::isImplThread()); | 138 ASSERT(CCProxy::isImplThread()); |
138 didVisibilityChange(this, m_visible); | 139 didVisibilityChange(this, m_visible); |
139 } | 140 } |
140 | 141 |
141 CCLayerTreeHostImpl::~CCLayerTreeHostImpl() | 142 CCLayerTreeHostImpl::~CCLayerTreeHostImpl() |
142 { | 143 { |
143 ASSERT(CCProxy::isImplThread()); | 144 ASSERT(CCProxy::isImplThread()); |
144 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()"); | 145 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()"); |
145 | 146 |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 | 922 |
922 // First find out which layer was hit from the saved list of visible layers | 923 // First find out which layer was hit from the saved list of visible layers |
923 // in the most recent frame. | 924 // in the most recent frame. |
924 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi
ewportPoint, m_renderSurfaceLayerList); | 925 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi
ewportPoint, m_renderSurfaceLayerList); |
925 | 926 |
926 // Walk up the hierarchy and look for a scrollable layer. | 927 // Walk up the hierarchy and look for a scrollable layer. |
927 CCLayerImpl* potentiallyScrollingLayerImpl = 0; | 928 CCLayerImpl* potentiallyScrollingLayerImpl = 0; |
928 for (; layerImpl; layerImpl = layerImpl->parent()) { | 929 for (; layerImpl; layerImpl = layerImpl->parent()) { |
929 // The content layer can also block attempts to scroll outside the main
thread. | 930 // The content layer can also block attempts to scroll outside the main
thread. |
930 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) { | 931 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) { |
931 m_numMainThreadScrolls++; | 932 m_mainThreadScrollCount++; |
932 return ScrollOnMainThread; | 933 return ScrollOnMainThread; |
933 } | 934 } |
934 | 935 |
935 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl)
; | 936 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl)
; |
936 if (!scrollLayerImpl) | 937 if (!scrollLayerImpl) |
937 continue; | 938 continue; |
938 | 939 |
939 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type); | 940 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type); |
940 | 941 |
941 // If any layer wants to divert the scroll event to the main thread, abo
rt. | 942 // If any layer wants to divert the scroll event to the main thread, abo
rt. |
942 if (status == ScrollOnMainThread) { | 943 if (status == ScrollOnMainThread) { |
943 m_numMainThreadScrolls++; | 944 m_mainThreadScrollCount++; |
944 return ScrollOnMainThread; | 945 return ScrollOnMainThread; |
945 } | 946 } |
946 | 947 |
947 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) | 948 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) |
948 potentiallyScrollingLayerImpl = scrollLayerImpl; | 949 potentiallyScrollingLayerImpl = scrollLayerImpl; |
949 } | 950 } |
950 | 951 |
951 if (potentiallyScrollingLayerImpl) { | 952 if (potentiallyScrollingLayerImpl) { |
952 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; | 953 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; |
953 // Gesture events need to be transformed from screen coordinates to loca
l layer coordinates | 954 // Gesture events need to be transformed from screen coordinates to loca
l layer coordinates |
954 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel | 955 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel |
955 // events are already in local layer coordinates so we can just apply th
em directly. | 956 // events are already in local layer coordinates so we can just apply th
em directly. |
956 m_scrollDeltaIsInScreenSpace = (type == Gesture); | 957 m_scrollDeltaIsInScreenSpace = (type == Gesture); |
957 m_numImplThreadScrolls++; | 958 m_implThreadScrollCount++; |
958 return ScrollStarted; | 959 return ScrollStarted; |
959 } | 960 } |
960 return ScrollIgnored; | 961 return ScrollIgnored; |
961 } | 962 } |
962 | 963 |
963 static FloatSize scrollLayerWithScreenSpaceDelta(CCLayerImpl& layerImpl, const F
loatPoint& screenSpacePoint, const FloatSize& screenSpaceDelta) | 964 static FloatSize scrollLayerWithScreenSpaceDelta(CCLayerImpl& layerImpl, const F
loatPoint& screenSpacePoint, const FloatSize& screenSpaceDelta) |
964 { | 965 { |
965 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 966 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
966 // test in the first place. | 967 // test in the first place. |
967 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); | 968 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 m_pageScaleAnimation.clear(); | 1224 m_pageScaleAnimation.clear(); |
1224 m_client->setNeedsCommitOnImplThread(); | 1225 m_client->setNeedsCommitOnImplThread(); |
1225 } | 1226 } |
1226 } | 1227 } |
1227 | 1228 |
1228 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi
me) | 1229 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi
me) |
1229 { | 1230 { |
1230 if (!CCSettings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || !
m_rootLayerImpl) | 1231 if (!CCSettings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || !
m_rootLayerImpl) |
1231 return; | 1232 return; |
1232 | 1233 |
| 1234 m_animationFrameCount++; |
1233 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::animateLayers"); | 1235 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::animateLayers"); |
1234 | 1236 |
1235 OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)
); | 1237 OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)
); |
1236 | 1238 |
1237 bool didAnimate = false; | 1239 bool didAnimate = false; |
1238 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime,
events.get(), didAnimate, m_needsAnimateLayers); | 1240 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime,
events.get(), didAnimate, m_needsAnimateLayers); |
1239 | 1241 |
1240 if (!events->isEmpty()) | 1242 if (!events->isEmpty()) |
1241 m_client->postAnimationEventsToMainThreadOnImplThread(events.release(),
wallClockTime); | 1243 m_client->postAnimationEventsToMainThreadOnImplThread(events.release(),
wallClockTime); |
1242 | 1244 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 dumpRenderSurfaces(str, indent, layer->children()[i]); | 1299 dumpRenderSurfaces(str, indent, layer->children()[i]); |
1298 } | 1300 } |
1299 | 1301 |
1300 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const | 1302 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const |
1301 { | 1303 { |
1302 return fpsCounter()->currentFrameNumber(); | 1304 return fpsCounter()->currentFrameNumber(); |
1303 } | 1305 } |
1304 | 1306 |
1305 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const | 1307 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const |
1306 { | 1308 { |
1307 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); | 1309 stats->compositorFrameCount = fpsCounter()->currentFrameNumber(); |
1308 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); | 1310 stats->implThreadScrollCount = m_implThreadScrollCount; |
1309 stats->numImplThreadScrolls = m_numImplThreadScrolls; | 1311 stats->mainThreadScrollCount = m_mainThreadScrollCount; |
1310 stats->numMainThreadScrolls = m_numMainThreadScrolls; | 1312 stats->implAnimationFrameCount = m_animationFrameCount; |
1311 } | 1313 } |
1312 | 1314 |
1313 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime) | 1315 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime) |
1314 { | 1316 { |
1315 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime); | 1317 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime); |
1316 } | 1318 } |
1317 | 1319 |
1318 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double
monotonicTime) | 1320 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double
monotonicTime) |
1319 { | 1321 { |
1320 if (!layer) | 1322 if (!layer) |
1321 return; | 1323 return; |
1322 | 1324 |
1323 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); | 1325 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat
ionController(); |
1324 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1326 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1325 m_client->setNeedsRedrawOnImplThread(); | 1327 m_client->setNeedsRedrawOnImplThread(); |
1326 | 1328 |
1327 for (size_t i = 0; i < layer->children().size(); ++i) | 1329 for (size_t i = 0; i < layer->children().size(); ++i) |
1328 animateScrollbarsRecursive(layer->children()[i], monotonicTime); | 1330 animateScrollbarsRecursive(layer->children()[i], monotonicTime); |
1329 } | 1331 } |
1330 | 1332 |
1331 } // namespace cc | 1333 } // namespace cc |
OLD | NEW |