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

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: Make it work in single tread mode. Get rid of active concept. 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
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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1028
1028 // First find out which layer was hit from the saved list of visible layers 1029 // First find out which layer was hit from the saved list of visible layers
1029 // in the most recent frame. 1030 // in the most recent frame.
1030 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi ewportPoint, m_renderSurfaceLayerList); 1031 CCLayerImpl* layerImpl = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(vi ewportPoint, m_renderSurfaceLayerList);
1031 1032
1032 // Walk up the hierarchy and look for a scrollable layer. 1033 // Walk up the hierarchy and look for a scrollable layer.
1033 CCLayerImpl* potentiallyScrollingLayerImpl = 0; 1034 CCLayerImpl* potentiallyScrollingLayerImpl = 0;
1034 for (; layerImpl; layerImpl = layerImpl->parent()) { 1035 for (; layerImpl; layerImpl = layerImpl->parent()) {
1035 // The content layer can also block attempts to scroll outside the main thread. 1036 // The content layer can also block attempts to scroll outside the main thread.
1036 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) { 1037 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) {
1037 m_numMainThreadScrolls++; 1038 m_mainThreadScrollCount++;
1038 return ScrollOnMainThread; 1039 return ScrollOnMainThread;
1039 } 1040 }
1040 1041
1041 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl) ; 1042 CCLayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl) ;
1042 if (!scrollLayerImpl) 1043 if (!scrollLayerImpl)
1043 continue; 1044 continue;
1044 1045
1045 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type); 1046 ScrollStatus status = scrollLayerImpl->tryScroll(viewportPoint, type);
1046 1047
1047 // If any layer wants to divert the scroll event to the main thread, abo rt. 1048 // If any layer wants to divert the scroll event to the main thread, abo rt.
1048 if (status == ScrollOnMainThread) { 1049 if (status == ScrollOnMainThread) {
1049 m_numMainThreadScrolls++; 1050 m_mainThreadScrollCount++;
1050 return ScrollOnMainThread; 1051 return ScrollOnMainThread;
1051 } 1052 }
1052 1053
1053 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) 1054 if (status == ScrollStarted && !potentiallyScrollingLayerImpl)
1054 potentiallyScrollingLayerImpl = scrollLayerImpl; 1055 potentiallyScrollingLayerImpl = scrollLayerImpl;
1055 } 1056 }
1056 1057
1057 if (potentiallyScrollingLayerImpl) { 1058 if (potentiallyScrollingLayerImpl) {
1058 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; 1059 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl;
1059 // Gesture events need to be transformed from screen coordinates to loca l layer coordinates 1060 // Gesture events need to be transformed from screen coordinates to loca l layer coordinates
1060 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel 1061 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel
1061 // events are already in local layer coordinates so we can just apply th em directly. 1062 // events are already in local layer coordinates so we can just apply th em directly.
1062 m_scrollDeltaIsInScreenSpace = (type == Gesture); 1063 m_scrollDeltaIsInScreenSpace = (type == Gesture);
1063 m_numImplThreadScrolls++; 1064 m_implThreadScrollCount++;
1064 return ScrollStarted; 1065 return ScrollStarted;
1065 } 1066 }
1066 return ScrollIgnored; 1067 return ScrollIgnored;
1067 } 1068 }
1068 1069
1069 static FloatSize scrollLayerWithScreenSpaceDelta(CCPinchZoomViewport* viewport, CCLayerImpl& layerImpl, const FloatPoint& screenSpacePoint, const FloatSize& scr eenSpaceDelta) 1070 static FloatSize scrollLayerWithScreenSpaceDelta(CCPinchZoomViewport* viewport, CCLayerImpl& layerImpl, const FloatPoint& screenSpacePoint, const FloatSize& scr eenSpaceDelta)
1070 { 1071 {
1071 // Layers with non-invertible screen space transforms should not have passed the scroll hit 1072 // Layers with non-invertible screen space transforms should not have passed the scroll hit
1072 // test in the first place. 1073 // test in the first place.
1073 ASSERT(layerImpl.screenSpaceTransform().isInvertible()); 1074 ASSERT(layerImpl.screenSpaceTransform().isInvertible());
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 m_pageScaleAnimation.reset(); 1355 m_pageScaleAnimation.reset();
1355 m_client->setNeedsCommitOnImplThread(); 1356 m_client->setNeedsCommitOnImplThread();
1356 } 1357 }
1357 } 1358 }
1358 1359
1359 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi me) 1360 void CCLayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTi me)
1360 { 1361 {
1361 if (!CCSettings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || ! m_rootLayerImpl) 1362 if (!CCSettings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || ! m_rootLayerImpl)
1362 return; 1363 return;
1363 1364
1365 m_animationFrameCount++;
1364 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::animateLayers"); 1366 TRACE_EVENT0("cc", "CCLayerTreeHostImpl::animateLayers");
1365 1367
1366 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEv entsVector)); 1368 scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEv entsVector));
1367 1369
1368 bool didAnimate = false; 1370 bool didAnimate = false;
1369 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers); 1371 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers);
1370 1372
1371 if (!events->empty()) 1373 if (!events->empty())
1372 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime); 1374 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime);
1373 1375
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 dumpRenderSurfaces(str, indent, layer->children()[i]); 1430 dumpRenderSurfaces(str, indent, layer->children()[i]);
1429 } 1431 }
1430 1432
1431 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const 1433 int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const
1432 { 1434 {
1433 return fpsCounter()->currentFrameNumber(); 1435 return fpsCounter()->currentFrameNumber();
1434 } 1436 }
1435 1437
1436 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const 1438 void CCLayerTreeHostImpl::renderingStats(CCRenderingStats* stats) const
1437 { 1439 {
1438 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); 1440 fpsCounter()->renderingStats(stats);
1439 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); 1441 stats->implThreadScrollCount = m_implThreadScrollCount;
1440 stats->numImplThreadScrolls = m_numImplThreadScrolls; 1442 stats->mainThreadScrollCount = m_mainThreadScrollCount;
1441 stats->numMainThreadScrolls = m_numMainThreadScrolls; 1443 stats->implAnimationFrameCount = m_animationFrameCount;
1442 } 1444 }
1443 1445
1444 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime) 1446 void CCLayerTreeHostImpl::animateScrollbars(double monotonicTime)
1445 { 1447 {
1446 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime); 1448 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime);
1447 } 1449 }
1448 1450
1449 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double monotonicTime) 1451 void CCLayerTreeHostImpl::animateScrollbarsRecursive(CCLayerImpl* layer, double monotonicTime)
1450 { 1452 {
1451 if (!layer) 1453 if (!layer)
1452 return; 1454 return;
1453 1455
1454 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat ionController(); 1456 CCScrollbarAnimationController* scrollbarController = layer->scrollbarAnimat ionController();
1455 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1457 if (scrollbarController && scrollbarController->animate(monotonicTime))
1456 m_client->setNeedsRedrawOnImplThread(); 1458 m_client->setNeedsRedrawOnImplThread();
1457 1459
1458 for (size_t i = 0; i < layer->children().size(); ++i) 1460 for (size_t i = 0; i < layer->children().size(); ++i)
1459 animateScrollbarsRecursive(layer->children()[i], monotonicTime); 1461 animateScrollbarsRecursive(layer->children()[i], monotonicTime);
1460 } 1462 }
1461 1463
1462 } // namespace cc 1464 } // namespace cc
OLDNEW
« cc/frame_rate_counter.cc ('K') | « 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