Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11028021: cc: Improve frame/commit accounting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/rendering_stats.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "CCAppendQuadsData.h" 9 #include "CCAppendQuadsData.h"
10 #include "CCDamageTracker.h" 10 #include "CCDamageTracker.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 , m_scrollDeltaIsInScreenSpace(false) 221 , m_scrollDeltaIsInScreenSpace(false)
222 , m_settings(settings) 222 , m_settings(settings)
223 , m_deviceScaleFactor(1) 223 , m_deviceScaleFactor(1)
224 , m_visible(true) 224 , m_visible(true)
225 , m_contentsTexturesPurged(false) 225 , m_contentsTexturesPurged(false)
226 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll ocationLimit()) 226 , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAll ocationLimit())
227 , m_backgroundColor(0) 227 , m_backgroundColor(0)
228 , m_hasTransparentBackground(false) 228 , m_hasTransparentBackground(false)
229 , m_needsAnimateLayers(false) 229 , m_needsAnimateLayers(false)
230 , m_pinchGestureActive(false) 230 , m_pinchGestureActive(false)
231 , m_animationFrameCount(0)
231 , m_fpsCounter(CCFrameRateCounter::create()) 232 , m_fpsCounter(CCFrameRateCounter::create())
232 , m_debugRectHistory(CCDebugRectHistory::create()) 233 , m_debugRectHistory(CCDebugRectHistory::create())
233 , m_numImplThreadScrolls(0) 234 , m_implThreadScrollCount(0)
234 , m_numMainThreadScrolls(0) 235 , m_mainThreadScrollCount(0)
235 { 236 {
236 ASSERT(CCProxy::isImplThread()); 237 ASSERT(CCProxy::isImplThread());
237 didVisibilityChange(this, m_visible); 238 didVisibilityChange(this, m_visible);
238 } 239 }
239 240
240 CCLayerTreeHostImpl::~CCLayerTreeHostImpl() 241 CCLayerTreeHostImpl::~CCLayerTreeHostImpl()
241 { 242 {
242 ASSERT(CCProxy::isImplThread()); 243 ASSERT(CCProxy::isImplThread());
243 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()"); 244 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::~CCLayerTreeHostImpl()");
244 245
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 1029
1029 // First find out which layer was hit from the saved list of visible layers 1030 // First find out which layer was hit from the saved list of visible layers
1030 // in the most recent frame. 1031 // in the most recent frame.
1031 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi ewportPoint, m_renderSurfaceLayerList); 1032 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi ewportPoint, m_renderSurfaceLayerList);
1032 1033
1033 // Walk up the hierarchy and look for a scrollable layer. 1034 // Walk up the hierarchy and look for a scrollable layer.
1034 CCLayerImpl* potentiallyScrollingLayerImpl = 0; 1035 CCLayerImpl* potentiallyScrollingLayerImpl = 0;
1035 for (; layerImpl; layerImpl = layerImpl->parent()) { 1036 for (; layerImpl; layerImpl = layerImpl->parent()) {
1036 // The content layer can also block attempts to scroll outside the main thread. 1037 // The content layer can also block attempts to scroll outside the main thread.
1037 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) { 1038 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) {
1038 m_numMainThreadScrolls++; 1039 m_mainThreadScrollCount++;
1039 return ScrollOnMainThread; 1040 return ScrollOnMainThread;
1040 } 1041 }
1041 1042
1042 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl) ; 1043 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl) ;
1043 if (!scrollLayerImpl) 1044 if (!scrollLayerImpl)
1044 continue; 1045 continue;
1045 1046
1046 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type); 1047 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type);
1047 1048
1048 // If any layer wants to divert the scroll event to the main thread, abo rt. 1049 // If any layer wants to divert the scroll event to the main thread, abo rt.
1049 if (status == ScrollOnMainThread) { 1050 if (status == ScrollOnMainThread) {
1050 m_numMainThreadScrolls++; 1051 m_mainThreadScrollCount++;
1051 return ScrollOnMainThread; 1052 return ScrollOnMainThread;
1052 } 1053 }
1053 1054
1054 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) 1055 if (status == ScrollStarted && !potentiallyScrollingLayerImpl)
1055 potentiallyScrollingLayerImpl = scrollLayerImpl; 1056 potentiallyScrollingLayerImpl = scrollLayerImpl;
1056 } 1057 }
1057 1058
1058 if (potentiallyScrollingLayerImpl) { 1059 if (potentiallyScrollingLayerImpl) {
1059 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; 1060 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl;
1060 // Gesture events need to be transformed from screen coordinates to loca l layer coordinates 1061 // Gesture events need to be transformed from screen coordinates to loca l layer coordinates
1061 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel 1062 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel
1062 // events are already in local layer coordinates so we can just apply th em directly. 1063 // events are already in local layer coordinates so we can just apply th em directly.
1063 m_scrollDeltaIsInScreenSpace = (type == Gesture); 1064 m_scrollDeltaIsInScreenSpace = (type == Gesture);
1064 m_numImplThreadScrolls++; 1065 m_implThreadScrollCount++;
1065 return ScrollStarted; 1066 return ScrollStarted;
1066 } 1067 }
1067 return ScrollIgnored; 1068 return ScrollIgnored;
1068 } 1069 }
1069 1070
1070 static FloatSize scrollLayerWithScreenSpaceDelta(CCPinchZoomViewport* viewport, CCLayerImpl& layerImpl, const FloatPoint& screenSpacePoint, const FloatSize& scr eenSpaceDelta) 1071 static FloatSize scrollLayerWithScreenSpaceDelta(CCPinchZoomViewport* viewport, CCLayerImpl& layerImpl, const FloatPoint& screenSpacePoint, const FloatSize& scr eenSpaceDelta)
1071 { 1072 {
1072 // Layers with non-invertible screen space transforms should not have passed the scroll hit 1073 // Layers with non-invertible screen space transforms should not have passed the scroll hit
1073 // test in the first place. 1074 // test in the first place.
1074 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); 1075 ASSERT(layerImpl.screenSpaceTransform().isInvertible());
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 m_pageScaleAnimation.reset(); 1356 m_pageScaleAnimation.reset();
1356 m_client->setNeedsCommitOnImplThread(); 1357 m_client->setNeedsCommitOnImplThread();
1357 } 1358 }
1358 } 1359 }
1359 1360
1360 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi me) 1361 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi me)
1361 { 1362 {
1362 if (!CCSettings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || ! m_rootLayerImpl) 1363 if (!CCSettings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || ! m_rootLayerImpl)
1363 return; 1364 return;
1364 1365
1366 m_animationFrameCount++;
1365 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::animateLayers"); 1367 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::animateLayers");
1366 1368
1367 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEv entsVector)); 1369 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEv entsVector));
1368 1370
1369 bool didAnimate = false; 1371 bool didAnimate = false;
1370 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers); 1372 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers);
1371 1373
1372 if (!events->empty()) 1374 if (!events->empty())
1373 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime); 1375 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime);
1374 1376
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 dumpRenderSurfaces(str, indent, layer->children()[i]); 1431 dumpRenderSurfaces(str, indent, layer->children()[i]);
1430 } 1432 }
1431 1433
1432 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const 1434 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const
1433 { 1435 {
1434 return fpsCounter()->currentFrameNumber(); 1436 return fpsCounter()->currentFrameNumber();
1435 } 1437 }
1436 1438
1437 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const 1439 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const
1438 { 1440 {
1439 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); 1441 fpsCounter()->renderingStats(stats);
1440 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); 1442 stats->implThreadScrollCount = m_implThreadScrollCount;
1441 stats->numImplThreadScrolls = m_numImplThreadScrolls; 1443 stats->mainThreadScrollCount = m_mainThreadScrollCount;
1442 stats->numMainThreadScrolls = m_numMainThreadScrolls; 1444 stats->implAnimationFrameCount = m_animationFrameCount;
1443 } 1445 }
1444 1446
1445 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime) 1447 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime)
1446 { 1448 {
1447 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime); 1449 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime);
1448 } 1450 }
1449 1451
1450 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double monotonicTime) 1452 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double monotonicTime)
1451 { 1453 {
1452 if (!layer) 1454 if (!layer)
1453 return; 1455 return;
1454 1456
1455 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat ionController(); 1457 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat ionController();
1456 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1458 if (scrollbarController && scrollbarController->animate(monotonicTime))
1457 m_client->setNeedsRedrawOnImplThread(); 1459 m_client->setNeedsRedrawOnImplThread();
1458 1460
1459 for (size_t i = 0; i < layer->children().size(); ++i) 1461 for (size_t i = 0; i < layer->children().size(); ++i)
1460 animateScrollbarsRecursive(layer->children()[i], monotonicTime); 1462 animateScrollbarsRecursive(layer->children()[i], monotonicTime);
1461 } 1463 }
1462 1464
1463 } // namespace cc 1465 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/rendering_stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698