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

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

Issue 1551333003: cc:: Use clip tree instead of layer tree during hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« cc/trees/layer_tree_impl.cc ('K') | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "cc/layers/heads_up_display_layer_impl.h" 7 #include "cc/layers/heads_up_display_layer_impl.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
10 #include "cc/test/fake_impl_task_runner_provider.h" 10 #include "cc/test/fake_impl_task_runner_provider.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 result_layer = 373 result_layer =
374 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 374 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
375 ASSERT_FALSE(result_layer); 375 ASSERT_FALSE(result_layer);
376 376
377 test_point = gfx::PointF(-1.f, 50.f); 377 test_point = gfx::PointF(-1.f, 50.f);
378 result_layer = 378 result_layer =
379 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 379 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
380 ASSERT_FALSE(result_layer); 380 ASSERT_FALSE(result_layer);
381 } 381 }
382 382
383 TEST_F(LayerTreeImplTest, HitTestingSiblings) {
384 // This tests hit testing when the test point hits only one of the siblings.
385 gfx::Transform identity_matrix;
386 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
387 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
388 gfx::PointF(), gfx::Size(100, 100), true, false,
389 true);
390 scoped_ptr<LayerImpl> child1 =
391 LayerImpl::Create(host_impl().active_tree(), 2);
392 SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(),
393 gfx::PointF(), gfx::Size(25, 25), true, false,
394 false);
395 child1->SetMasksToBounds(true);
396 child1->SetDrawsContent(true);
397 scoped_ptr<LayerImpl> child2 =
398 LayerImpl::Create(host_impl().active_tree(), 3);
399 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(),
400 gfx::PointF(), gfx::Size(75, 75), true, false,
401 false);
402 child2->SetMasksToBounds(true);
403 child2->SetDrawsContent(true);
404 root->AddChild(std::move(child1));
405 root->AddChild(std::move(child2));
406
407 host_impl().SetViewportSize(root->bounds());
408 host_impl().active_tree()->SetRootLayer(std::move(root));
409 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
410
411 gfx::PointF test_point(50.f, 50.f);
412 LayerImpl* result_layer =
413 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
414 ASSERT_TRUE(result_layer);
415 EXPECT_EQ(3, result_layer->id());
416 }
417
383 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { 418 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) {
384 scoped_ptr<LayerImpl> root = 419 scoped_ptr<LayerImpl> root =
385 LayerImpl::Create(host_impl().active_tree(), 12345); 420 LayerImpl::Create(host_impl().active_tree(), 12345);
386 421
387 gfx::Transform identity_matrix; 422 gfx::Transform identity_matrix;
388 423
389 // perspective_projection_about_center * translation_by_z is designed so that 424 // perspective_projection_about_center * translation_by_z is designed so that
390 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). 425 // the 100 x 100 layer becomes 50 x 50, and remains centered at (50, 50).
391 gfx::Transform perspective_projection_about_center; 426 gfx::Transform perspective_projection_about_center;
392 perspective_projection_about_center.Translate(50.0, 50.0); 427 perspective_projection_about_center.Translate(50.0, 50.0);
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); 2272 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers());
2238 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); 2273 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
2239 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); 2274 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2));
2240 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); 2275 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3));
2241 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); 2276 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4));
2242 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); 2277 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers());
2243 } 2278 }
2244 2279
2245 } // namespace 2280 } // namespace
2246 } // namespace cc 2281 } // namespace cc
OLDNEW
« cc/trees/layer_tree_impl.cc ('K') | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698