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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 12280014: cc: Don't consider HUD layer for touches (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved funcs around Created 7 years, 10 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
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('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 "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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 318
319 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint ) 319 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint )
320 { 320 {
321 if (!ensureRenderSurfaceLayerList()) 321 if (!ensureRenderSurfaceLayerList())
322 return false; 322 return false;
323 323
324 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor); 324 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor);
325 325
326 // First find out which layer was hit from the saved list of visible layers 326 // First find out which layer was hit from the saved list of visible layers
327 // in the most recent frame. 327 // in the most recent frame.
328 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); 328 LayerImpl* layerImpl = findLayerThatIsHitByPoint(deviceViewportPoint, active Tree()->RenderSurfaceLayerList());
329 329
330 // Walk up the hierarchy and look for a layer with a touch event handler reg ion that the given point hits. 330 // Walk up the hierarchy and look for a layer with a touch event handler reg ion that the given point hits.
331 for (; layerImpl; layerImpl = layerImpl->parent()) { 331 for (; layerImpl; layerImpl = layerImpl->parent()) {
332 if (LayerTreeHostCommon::layerHasTouchEventHandlersAt(deviceViewportPoint, layerImpl)) 332 if (LayerTreeHostCommon::layerHasTouchEventHandlersAt(deviceViewportPoint, layerImpl))
333 return true; 333 return true;
334 } 334 }
335 335
336 return false; 336 return false;
337 } 337 }
338 338
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 DCHECK(!currentlyScrollingLayer()); 1182 DCHECK(!currentlyScrollingLayer());
1183 clearCurrentlyScrollingLayer(); 1183 clearCurrentlyScrollingLayer();
1184 1184
1185 if (!ensureRenderSurfaceLayerList()) 1185 if (!ensureRenderSurfaceLayerList())
1186 return ScrollIgnored; 1186 return ScrollIgnored;
1187 1187
1188 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor); 1188 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor);
1189 1189
1190 // First find out which layer was hit from the saved list of visible layers 1190 // First find out which layer was hit from the saved list of visible layers
1191 // in the most recent frame. 1191 // in the most recent frame.
1192 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); 1192 LayerImpl* layerImpl = findLayerThatIsHitByPoint(deviceViewportPoint, active Tree()->RenderSurfaceLayerList());
1193 1193
1194 // Walk up the hierarchy and look for a scrollable layer. 1194 // Walk up the hierarchy and look for a scrollable layer.
1195 LayerImpl* potentiallyScrollingLayerImpl = 0; 1195 LayerImpl* potentiallyScrollingLayerImpl = 0;
1196 for (; layerImpl; layerImpl = layerImpl->parent()) { 1196 for (; layerImpl; layerImpl = layerImpl->parent()) {
1197 // The content layer can also block attempts to scroll outside the main thread. 1197 // The content layer can also block attempts to scroll outside the main thread.
1198 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) { 1198 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) {
1199 m_numMainThreadScrolls++; 1199 m_numMainThreadScrolls++;
1200 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); 1200 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true);
1201 return ScrollOnMainThread; 1201 return ScrollOnMainThread;
1202 } 1202 }
(...skipping 20 matching lines...) Expand all
1223 m_shouldBubbleScrolls = (type != NonBubblingGesture); 1223 m_shouldBubbleScrolls = (type != NonBubblingGesture);
1224 m_wheelScrolling = (type == Wheel); 1224 m_wheelScrolling = (type == Wheel);
1225 m_numImplThreadScrolls++; 1225 m_numImplThreadScrolls++;
1226 m_client->renewTreePriority(); 1226 m_client->renewTreePriority();
1227 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); 1227 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false);
1228 return ScrollStarted; 1228 return ScrollStarted;
1229 } 1229 }
1230 return ScrollIgnored; 1230 return ScrollIgnored;
1231 } 1231 }
1232 1232
1233 LayerImpl* LayerTreeHostImpl::findLayerThatIsHitByPoint(const gfx::PointF& scree nSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList)
1234 {
1235 LayerImpl* foundLayer = 0;
1236
1237 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType;
1238 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList);
1239 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList ); it != end; ++it) {
1240 // We don't want to consider renderSurfaces for hit testing.
1241 if (!it.representsItself())
1242 continue;
1243
1244 LayerImpl* currentLayer = (*it);
1245
1246 // Don't consider the hud layer as a viable target for hits.
1247 if (currentLayer == activeTree()->hud_layer())
danakj 2013/02/18 19:18:49 I don't understand why we would need to move aroun
1248 continue;
1249
1250 gfx::RectF contentRect(gfx::PointF(), currentLayer->contentBounds());
1251 if (!MathUtil::pointHitsRect(screenSpacePoint, currentLayer->screenSpace Transform(), contentRect))
1252 continue;
1253
1254 // At this point, we think the point does hit the layer, but we need to walk up
1255 // the parents to ensure that the layer was not clipped in such a way th at the
1256 // hit point actually should not hit the layer.
1257 if (LayerTreeHostCommon::pointIsClippedBySurfaceOrClipRect(screenSpacePo int, currentLayer))
1258 continue;
1259
1260 foundLayer = currentLayer;
1261 break;
1262 }
1263
1264 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer.
1265 return foundLayer;
1266 }
1267
1268
1233 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx:: Vector2dF viewportDelta) 1269 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx:: Vector2dF viewportDelta)
1234 { 1270 {
1235 // Layers with non-invertible screen space transforms should not have passed the scroll hit 1271 // Layers with non-invertible screen space transforms should not have passed the scroll hit
1236 // test in the first place. 1272 // test in the first place.
1237 DCHECK(layerImpl->screenSpaceTransform().IsInvertible()); 1273 DCHECK(layerImpl->screenSpaceTransform().IsInvertible());
1238 gfx::Transform inverseScreenSpaceTransform(gfx::Transform::kSkipInitializati on); 1274 gfx::Transform inverseScreenSpaceTransform(gfx::Transform::kSkipInitializati on);
1239 bool didInvert = layerImpl->screenSpaceTransform().GetInverse(&inverseScreen SpaceTransform); 1275 bool didInvert = layerImpl->screenSpaceTransform().GetInverse(&inverseScreen SpaceTransform);
1240 // TODO: With the advent of impl-side crolling for non-root layers, we may 1276 // TODO: With the advent of impl-side crolling for non-root layers, we may
1241 // need to explicitly handle uninvertible transforms here. 1277 // need to explicitly handle uninvertible transforms here.
1242 DCHECK(didInvert); 1278 DCHECK(didInvert);
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats ()); 1819 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats ());
1784 } 1820 }
1785 1821
1786 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber) 1822 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber)
1787 { 1823 {
1788 DCHECK(m_debugState.continuousPainting); 1824 DCHECK(m_debugState.continuousPainting);
1789 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber); 1825 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber);
1790 } 1826 }
1791 1827
1792 } // namespace cc 1828 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698