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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 27718006: cc: Fix touch hit-testing for overlapping layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "cc/animation/layer_animation_controller.h" 9 #include "cc/animation/layer_animation_controller.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 6007 matching lines...) Expand 10 before | Expand all | Expand 10 after
6018 EXPECT_EQ(456, result_layer->id()); 6018 EXPECT_EQ(456, result_layer->id());
6019 6019
6020 test_point = gfx::Point(34, 34); 6020 test_point = gfx::Point(34, 34);
6021 result_layer = 6021 result_layer =
6022 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( 6022 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
6023 test_point, render_surface_layer_list); 6023 test_point, render_surface_layer_list);
6024 ASSERT_TRUE(result_layer); 6024 ASSERT_TRUE(result_layer);
6025 EXPECT_EQ(456, result_layer->id()); 6025 EXPECT_EQ(456, result_layer->id());
6026 } 6026 }
6027 6027
6028 TEST_F(LayerTreeHostCommonTest,
6029 HitCheckingTouchHandlerOverlappingRegions) {
6030 gfx::Transform identity_matrix;
6031 gfx::PointF anchor;
6032
6033 FakeImplProxy proxy;
6034 FakeLayerTreeHostImpl host_impl(&proxy);
6035 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
6036 SetLayerPropertiesForTesting(root.get(),
6037 identity_matrix,
6038 identity_matrix,
6039 anchor,
6040 gfx::PointF(),
6041 gfx::Size(100, 100),
6042 false);
6043 {
6044 scoped_ptr<LayerImpl> touch_layer =
6045 LayerImpl::Create(host_impl.active_tree(), 123);
6046 // this layer is positioned, and hit testing should correctly know where the
6047 // layer is located.
6048 gfx::PointF position;
6049 gfx::Size bounds(50, 50);
6050 SetLayerPropertiesForTesting(touch_layer.get(),
6051 identity_matrix,
6052 identity_matrix,
6053 anchor,
6054 position,
6055 bounds,
6056 false);
6057 touch_layer->SetDrawsContent(true);
6058 touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50));
6059 root->AddChild(touch_layer.Pass());
6060 }
6061
6062 {
6063 scoped_ptr<LayerImpl> notouch_layer =
6064 LayerImpl::Create(host_impl.active_tree(), 1234);
6065 // this layer is positioned, and hit testing should correctly know where the
6066 // layer is located.
6067 gfx::PointF position(0, 25);
6068 gfx::Size bounds(50, 50);
6069 SetLayerPropertiesForTesting(notouch_layer.get(),
6070 identity_matrix,
6071 identity_matrix,
6072 anchor,
6073 position,
6074 bounds,
6075 false);
6076 notouch_layer->SetDrawsContent(true);
6077 root->AddChild(notouch_layer.Pass());
6078 }
6079
6080 LayerImplList render_surface_layer_list;
6081 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
6082 root.get(), root->bounds(), &render_surface_layer_list);
6083 inputs.can_adjust_raster_scales = true;
6084 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
6085
6086 // Sanity check the scenario we just created.
6087 ASSERT_EQ(1u, render_surface_layer_list.size());
6088 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
6089 ASSERT_EQ(123, root->render_surface()->layer_list().at(0)->id());
6090 ASSERT_EQ(1234, root->render_surface()->layer_list().at(1)->id());
6091
6092 gfx::Point test_point(35, 35);
6093 LayerImpl* result_layer =
6094 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
6095 test_point, render_surface_layer_list);
6096 EXPECT_FALSE(result_layer);
6097
6098 test_point = gfx::Point(35, 15);
6099 result_layer =
6100 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
6101 test_point, render_surface_layer_list);
6102 ASSERT_TRUE(result_layer);
6103 EXPECT_EQ(123, result_layer->id());
6104
6105 test_point = gfx::Point(35, 65);
6106 result_layer =
6107 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
6108 test_point, render_surface_layer_list);
6109 EXPECT_FALSE(result_layer);
6110 }
6111
6028 class NoScaleContentLayer : public ContentLayer { 6112 class NoScaleContentLayer : public ContentLayer {
6029 public: 6113 public:
6030 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { 6114 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) {
6031 return make_scoped_refptr(new NoScaleContentLayer(client)); 6115 return make_scoped_refptr(new NoScaleContentLayer(client));
6032 } 6116 }
6033 6117
6034 virtual void CalculateContentsScale(float ideal_contents_scale, 6118 virtual void CalculateContentsScale(float ideal_contents_scale,
6035 float device_scale_factor, 6119 float device_scale_factor,
6036 float page_scale_factor, 6120 float page_scale_factor,
6037 bool animating_transform_to_screen, 6121 bool animating_transform_to_screen,
(...skipping 3505 matching lines...) Expand 10 before | Expand all | Expand 10 after
9543 // due to layer sorting). 9627 // due to layer sorting).
9544 EXPECT_EQ(4u, root->render_surface()->layer_list().size()); 9628 EXPECT_EQ(4u, root->render_surface()->layer_list().size());
9545 EXPECT_EQ(5, root->render_surface()->layer_list().at(0)->id()); 9629 EXPECT_EQ(5, root->render_surface()->layer_list().at(0)->id());
9546 EXPECT_EQ(6, root->render_surface()->layer_list().at(1)->id()); 9630 EXPECT_EQ(6, root->render_surface()->layer_list().at(1)->id());
9547 EXPECT_EQ(7, root->render_surface()->layer_list().at(2)->id()); 9631 EXPECT_EQ(7, root->render_surface()->layer_list().at(2)->id());
9548 EXPECT_EQ(4, root->render_surface()->layer_list().at(3)->id()); 9632 EXPECT_EQ(4, root->render_surface()->layer_list().at(3)->id());
9549 } 9633 }
9550 9634
9551 } // namespace 9635 } // namespace
9552 } // namespace cc 9636 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698