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

Side by Side Diff: cc/layer_tree_host_common.cc

Issue 11402002: Add API for hit testing layer_impl touchEventHandlerRegions from the host (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing compositor_bindings call Created 8 years, 1 month 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_common.h ('k') | cc/layer_tree_host_impl.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 "cc/layer_tree_host_common.h" 7 #include "cc/layer_tree_host_common.h"
8 8
9 #include "cc/layer.h" 9 #include "cc/layer.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
11 #include "cc/layer_iterator.h" 11 #include "cc/layer_iterator.h"
12 #include "cc/layer_sorter.h" 12 #include "cc/layer_sorter.h"
13 #include "cc/math_util.h" 13 #include "cc/math_util.h"
14 #include "cc/render_surface.h" 14 #include "cc/render_surface.h"
15 #include "cc/render_surface_impl.h" 15 #include "cc/render_surface_impl.h"
16 #include "ui/gfx/point_conversions.h"
16 #include "ui/gfx/rect_conversions.h" 17 #include "ui/gfx/rect_conversions.h"
17 #include <algorithm> 18 #include <algorithm>
18 #include <public/WebTransformationMatrix.h> 19 #include <public/WebTransformationMatrix.h>
19 20
20 using WebKit::WebTransformationMatrix; 21 using WebKit::WebTransformationMatrix;
21 22
22 namespace cc { 23 namespace cc {
23 24
24 ScrollAndScaleSet::ScrollAndScaleSet() 25 ScrollAndScaleSet::ScrollAndScaleSet()
25 { 26 {
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 bool clipped = false; 870 bool clipped = false;
870 gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(localSpaceToSc reenSpaceTransform.inverse(), screenSpacePoint, clipped); 871 gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(localSpaceToSc reenSpaceTransform.inverse(), screenSpacePoint, clipped);
871 872
872 // If projectPoint could not project to a valid value, then we assume that t his point doesn't hit this rect. 873 // If projectPoint could not project to a valid value, then we assume that t his point doesn't hit this rect.
873 if (clipped) 874 if (clipped)
874 return false; 875 return false;
875 876
876 return localSpaceRect.Contains(hitTestPointInLocalSpace); 877 return localSpaceRect.Contains(hitTestPointInLocalSpace);
877 } 878 }
878 879
880 static bool pointHitsRegion(const gfx::PointF& screenSpacePoint, const WebTransf ormationMatrix& localSpaceToScreenSpaceTransform, Region localSpaceRegion)
danakj 2012/11/08 01:30:38 just call the transform "screenSpaceTransform" as
Yusuf 2012/11/08 01:53:42 Done.
881 {
882 // If the transform is not invertible, then assume that this point doesn't h it this rect.
883 if (!localSpaceToScreenSpaceTransform.isInvertible())
884 return false;
885
886 // Transform the hit test point from screen space to the local space of the given rect.
887 bool clipped = false;
888 gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(localSpaceToSc reenSpaceTransform.inverse(), screenSpacePoint, clipped);
danakj 2012/11/08 01:30:38 See LayerImpl::tryScroll() for how to do this, I f
Yusuf 2012/11/08 01:53:42 Done.
889
890 // If projectPoint could not project to a valid value, then we assume that t his point doesn't hit this rect.
891 if (clipped)
892 return false;
893
894 return localSpaceRegion.Contains(gfx::ToRoundedPoint(hitTestPointInLocalSpac e));
895 }
896
879 static bool pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoin t, LayerImpl* layer) 897 static bool pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoin t, LayerImpl* layer)
880 { 898 {
881 LayerImpl* currentLayer = layer; 899 LayerImpl* currentLayer = layer;
882 900
883 // Walk up the layer tree and hit-test any renderSurfaces and any layer clip Rects that are active. 901 // Walk up the layer tree and hit-test any renderSurfaces and any layer clip Rects that are active.
884 while (currentLayer) { 902 while (currentLayer) {
885 if (currentLayer->renderSurface() && !pointHitsRect(screenSpacePoint, cu rrentLayer->renderSurface()->screenSpaceTransform(), currentLayer->renderSurface ()->contentRect())) 903 if (currentLayer->renderSurface() && !pointHitsRect(screenSpacePoint, cu rrentLayer->renderSurface()->screenSpaceTransform(), currentLayer->renderSurface ()->contentRect()))
886 return true; 904 return true;
887 905
888 // Note that drawableContentRects are actually in targetSurface space, s o the transform we 906 // Note that drawableContentRects are actually in targetSurface space, s o the transform we
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 continue; 941 continue;
924 942
925 foundLayer = currentLayer; 943 foundLayer = currentLayer;
926 break; 944 break;
927 } 945 }
928 946
929 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer. 947 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer.
930 return foundLayer; 948 return foundLayer;
931 } 949 }
932 950
951 LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(co nst gfx::PointF& screenSpacePoint, std::vector<LayerImpl*>& renderSurfaceLayerLi st)
952 {
953 LayerImpl* foundLayer = 0;
954
955 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType;
956 LayerIteratorType end = LayerIteratorType::end(&renderSurfaceLayerList);
957
958 for (LayerIteratorType it = LayerIteratorType::begin(&renderSurfaceLayerList ); it != end; ++it) {
959 // We don't want to consider renderSurfaces for hit testing.
960 if (!it.representsItself())
961 continue;
962
963 LayerImpl* currentLayer = (*it);
964
965 if (currentLayer->touchEventHandlerRegion().IsEmpty())
966 continue;
967
968 if (!pointHitsRegion(screenSpacePoint, currentLayer->screenSpaceTransfor m(), currentLayer->touchEventHandlerRegion()))
969 continue;
970
971 // At this point, we think the point does hit the touch event handler re gion on the layer, but we need to walk up
972 // the parents to ensure that the layer was not clipped in such a way th at the
973 // hit point actually should not hit the layer.
974 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, currentLayer))
975 continue;
976
977 foundLayer = currentLayer;
978 break;
979 }
980
981 // This can potentially return 0, which means the screenSpacePoint did not s uccessfully hit test any layers, not even the root layer.
982 return foundLayer;
983 }
984
933 } // namespace cc 985 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common.h ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698