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

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

Issue 2033163003: cc : Fix hit testing bug in resourceless software draw mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | cc/trees/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 "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 EXPECT_TRUE(leaf_node2->is_clipped()); 2416 EXPECT_TRUE(leaf_node2->is_clipped());
2417 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect()); 2417 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect());
2418 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect()); 2418 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
2419 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect()); 2419 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect());
2420 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect()); 2420 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect());
2421 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect()); 2421 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect());
2422 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node1->clip_rect()); 2422 EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node1->clip_rect());
2423 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect()); 2423 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
2424 } 2424 }
2425 2425
2426 TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) {
2427 LayerImpl* root = root_layer();
2428 LayerImpl* parent = AddChild<LayerImpl>(root);
2429 LayerImpl* child = AddChild<LayerImpl>(parent);
2430 LayerImpl* grand_child = AddChild<LayerImpl>(child);
2431 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
2432
2433 root->SetDrawsContent(true);
2434 parent->SetDrawsContent(true);
2435 child->SetDrawsContent(true);
2436 grand_child->SetDrawsContent(true);
2437 leaf_node->SetDrawsContent(true);
2438
2439 const gfx::Transform identity_matrix;
2440
2441 // child and grand_child will get render surfaces if surfaces are enabled.
2442 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
2443 gfx::PointF(), gfx::Size(100, 100), true, false,
2444 true);
2445 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
2446 gfx::PointF(2.f, 2.f), gfx::Size(400, 400), true,
2447 false, false);
2448 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
2449 gfx::PointF(4.f, 4.f), gfx::Size(800, 800), true,
2450 false, true);
2451 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
2452 gfx::PointF(8.f, 8.f), gfx::Size(1500, 1500),
2453 true, false, true);
2454 SetLayerPropertiesForTesting(leaf_node, identity_matrix, gfx::Point3F(),
2455 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000),
2456 true, false, false);
2457
2458 parent->SetMasksToBounds(true);
2459 child->SetMasksToBounds(true);
2460
2461 root->SetHasRenderSurface(true);
2462 child->SetHasRenderSurface(true);
2463 grand_child->SetHasRenderSurface(true);
2464
2465 host_impl()->set_resourceless_software_draw_for_testing();
2466 ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
2467 gfx::PointF test_point(90.f, 90.f);
2468 LayerImpl* result_layer =
2469 root->layer_tree_impl()->FindLayerThatIsHitByPoint(test_point);
2470 ASSERT_TRUE(result_layer);
2471 EXPECT_EQ(leaf_node, result_layer);
2472 }
2473
2426 TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) { 2474 TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) {
2427 // Tests that draw properties are computed correctly when we disable and then 2475 // Tests that draw properties are computed correctly when we disable and then
2428 // re-enable separate surfaces. 2476 // re-enable separate surfaces.
2429 LayerImpl* root = root_layer(); 2477 LayerImpl* root = root_layer();
2430 LayerImpl* parent = AddChild<LayerImpl>(root); 2478 LayerImpl* parent = AddChild<LayerImpl>(root);
2431 LayerImpl* child = AddChild<LayerImpl>(parent); 2479 LayerImpl* child = AddChild<LayerImpl>(parent);
2432 LayerImpl* grand_child = AddChild<LayerImpl>(child); 2480 LayerImpl* grand_child = AddChild<LayerImpl>(child);
2433 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child); 2481 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
2434 2482
2435 root->SetDrawsContent(true); 2483 root->SetDrawsContent(true);
(...skipping 7656 matching lines...) Expand 10 before | Expand all | Expand 10 after
10092 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10140 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10093 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10141 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10094 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10142 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10095 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10143 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10096 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10144 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10097 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10145 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10098 } 10146 }
10099 10147
10100 } // namespace 10148 } // namespace
10101 } // namespace cc 10149 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698