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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 12407002: Align physical pixels of scrolled layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
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 "cc/layer_tree_host_impl.h" 5 #include "cc/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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 LayerImpl* LayerTreeHostImpl::rootScrollLayer() const 912 LayerImpl* LayerTreeHostImpl::rootScrollLayer() const
913 { 913 {
914 return m_activeTree->RootScrollLayer(); 914 return m_activeTree->RootScrollLayer();
915 } 915 }
916 916
917 LayerImpl* LayerTreeHostImpl::currentlyScrollingLayer() const 917 LayerImpl* LayerTreeHostImpl::currentlyScrollingLayer() const
918 { 918 {
919 return m_activeTree->CurrentlyScrollingLayer(); 919 return m_activeTree->CurrentlyScrollingLayer();
920 } 920 }
921 921
922 // Content layers can be either directly scrollable or contained in an outer
923 // scrolling layer which applies the scroll transform. Given a content layer,
924 // this function returns the associated scroll layer if any.
925 static LayerImpl* findScrollLayerForContentLayer(LayerImpl* layerImpl)
926 {
927 if (!layerImpl)
928 return 0;
929
930 if (layerImpl->scrollable())
931 return layerImpl;
932
933 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()- >scrollable())
934 return layerImpl->parent();
935
936 return 0;
937 }
938
939 void LayerTreeHostImpl::createPendingTree() 922 void LayerTreeHostImpl::createPendingTree()
940 { 923 {
941 CHECK(!m_pendingTree); 924 CHECK(!m_pendingTree);
942 if (m_recycleTree) 925 if (m_recycleTree)
943 m_recycleTree.swap(m_pendingTree); 926 m_recycleTree.swap(m_pendingTree);
944 else 927 else
945 m_pendingTree = LayerTreeImpl::create(this); 928 m_pendingTree = LayerTreeImpl::create(this);
946 m_client->onCanDrawStateChanged(canDraw()); 929 m_client->onCanDrawStateChanged(canDraw());
947 m_client->onHasPendingTreeStateChanged(pendingTree()); 930 m_client->onHasPendingTreeStateChanged(pendingTree());
948 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", m_pendingTree.get()); 931 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree", m_pendingTree.get());
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 // Walk up the hierarchy and look for a scrollable layer. 1176 // Walk up the hierarchy and look for a scrollable layer.
1194 LayerImpl* potentiallyScrollingLayerImpl = 0; 1177 LayerImpl* potentiallyScrollingLayerImpl = 0;
1195 for (; layerImpl; layerImpl = layerImpl->parent()) { 1178 for (; layerImpl; layerImpl = layerImpl->parent()) {
1196 // The content layer can also block attempts to scroll outside the main thread. 1179 // The content layer can also block attempts to scroll outside the main thread.
1197 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) { 1180 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) {
1198 m_numMainThreadScrolls++; 1181 m_numMainThreadScrolls++;
1199 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); 1182 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true);
1200 return ScrollOnMainThread; 1183 return ScrollOnMainThread;
1201 } 1184 }
1202 1185
1203 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); 1186 LayerImpl* scrollLayerImpl = LayerTreeHostCommon::findScrollLayerForCont entLayer(layerImpl);
1204 if (!scrollLayerImpl) 1187 if (!scrollLayerImpl)
1205 continue; 1188 continue;
1206 1189
1207 ScrollStatus status = scrollLayerImpl->tryScroll(deviceViewportPoint, ty pe); 1190 ScrollStatus status = scrollLayerImpl->tryScroll(deviceViewportPoint, ty pe);
1208 1191
1209 // If any layer wants to divert the scroll event to the main thread, abo rt. 1192 // If any layer wants to divert the scroll event to the main thread, abo rt.
1210 if (status == ScrollOnMainThread) { 1193 if (status == ScrollOnMainThread) {
1211 m_numMainThreadScrolls++; 1194 m_numMainThreadScrolls++;
1212 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); 1195 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true);
1213 return ScrollOnMainThread; 1196 return ScrollOnMainThread;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats ()); 1707 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats ());
1725 } 1708 }
1726 1709
1727 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber) 1710 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber)
1728 { 1711 {
1729 DCHECK(m_debugState.continuousPainting); 1712 DCHECK(m_debugState.continuousPainting);
1730 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber); 1713 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber);
1731 } 1714 }
1732 1715
1733 } // namespace cc 1716 } // namespace cc
OLDNEW
« cc/layer_tree_host_common.cc ('K') | « cc/layer_tree_host_common_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698