OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/surfaces/compositor_frame_sink_support.h" | 8 #include "cc/surfaces/compositor_frame_sink_support.h" |
9 #include "cc/surfaces/local_surface_id_allocator.h" | 9 #include "cc/surfaces/local_surface_id_allocator.h" |
10 #include "cc/surfaces/surface.h" | 10 #include "cc/surfaces/surface.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 { | 98 { |
99 SurfaceHittest hittest(nullptr, &manager); | 99 SurfaceHittest hittest(nullptr, &manager); |
100 // It is expected this test will complete without crashes. | 100 // It is expected this test will complete without crashes. |
101 gfx::Transform transform; | 101 gfx::Transform transform; |
102 EXPECT_EQ(root_surface_id, | 102 EXPECT_EQ(root_surface_id, |
103 hittest.GetTargetSurfaceAtPoint( | 103 hittest.GetTargetSurfaceAtPoint( |
104 root_surface_id, gfx::Point(100, 100), &transform)); | 104 root_surface_id, gfx::Point(100, 100), &transform)); |
105 } | 105 } |
106 | 106 |
107 root_support->EvictFrame(); | 107 root_support->EvictCurrentSurface(); |
108 } | 108 } |
109 | 109 |
110 TEST(SurfaceHittestTest, Hittest_SingleSurface) { | 110 TEST(SurfaceHittestTest, Hittest_SingleSurface) { |
111 SurfaceManager manager; | 111 SurfaceManager manager; |
112 | 112 |
113 // Set up root FrameSink. | 113 // Set up root FrameSink. |
114 FrameSinkId root_frame_sink_id(1, 1); | 114 FrameSinkId root_frame_sink_id(1, 1); |
115 std::unique_ptr<CompositorFrameSinkSupport> root_support = | 115 std::unique_ptr<CompositorFrameSinkSupport> root_support = |
116 CompositorFrameSinkSupport::Create( | 116 CompositorFrameSinkSupport::Create( |
117 nullptr, &manager, root_frame_sink_id, kIsRoot, | 117 nullptr, &manager, root_frame_sink_id, kIsRoot, |
(...skipping 14 matching lines...) Expand all Loading... |
132 { | 132 { |
133 root_surface_id, | 133 root_surface_id, |
134 gfx::Point(100, 100), | 134 gfx::Point(100, 100), |
135 root_surface_id, | 135 root_surface_id, |
136 gfx::Point(100, 100) | 136 gfx::Point(100, 100) |
137 }, | 137 }, |
138 }; | 138 }; |
139 | 139 |
140 RunTests(nullptr, &manager, tests, arraysize(tests)); | 140 RunTests(nullptr, &manager, tests, arraysize(tests)); |
141 | 141 |
142 root_support->EvictFrame(); | 142 root_support->EvictCurrentSurface(); |
143 } | 143 } |
144 | 144 |
145 TEST(SurfaceHittestTest, Hittest_ChildSurface) { | 145 TEST(SurfaceHittestTest, Hittest_ChildSurface) { |
146 SurfaceManager manager; | 146 SurfaceManager manager; |
147 | 147 |
148 // Set up root FrameSink. | 148 // Set up root FrameSink. |
149 FrameSinkId root_frame_sink_id(1, 1); | 149 FrameSinkId root_frame_sink_id(1, 1); |
150 std::unique_ptr<CompositorFrameSinkSupport> root_support = | 150 std::unique_ptr<CompositorFrameSinkSupport> root_support = |
151 CompositorFrameSinkSupport::Create( | 151 CompositorFrameSinkSupport::Create( |
152 nullptr, &manager, root_frame_sink_id, kIsRoot, | 152 nullptr, &manager, root_frame_sink_id, kIsRoot, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 gfx::Point point_in_target_space(100, 100); | 273 gfx::Point point_in_target_space(100, 100); |
274 gfx::Transform target_transform; | 274 gfx::Transform target_transform; |
275 EXPECT_TRUE(hittest.GetTransformToTargetSurface( | 275 EXPECT_TRUE(hittest.GetTransformToTargetSurface( |
276 root_surface_id, child_surface_id, &target_transform)); | 276 root_surface_id, child_surface_id, &target_transform)); |
277 target_transform.TransformPoint(&point_in_target_space); | 277 target_transform.TransformPoint(&point_in_target_space); |
278 EXPECT_NE(transform, target_transform); | 278 EXPECT_NE(transform, target_transform); |
279 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); | 279 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); |
280 } | 280 } |
281 | 281 |
282 root_support->EvictFrame(); | 282 root_support->EvictCurrentSurface(); |
283 child_support->EvictFrame(); | 283 child_support->EvictCurrentSurface(); |
284 } | 284 } |
285 | 285 |
286 // This test verifies that hit testing will progress to the next quad if it | 286 // This test verifies that hit testing will progress to the next quad if it |
287 // encounters an invalid RenderPassDrawQuad for whatever reason. | 287 // encounters an invalid RenderPassDrawQuad for whatever reason. |
288 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { | 288 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { |
289 SurfaceManager manager; | 289 SurfaceManager manager; |
290 | 290 |
291 // Set up root FrameSink. | 291 // Set up root FrameSink. |
292 FrameSinkId root_frame_sink_id(1, 1); | 292 FrameSinkId root_frame_sink_id(1, 1); |
293 std::unique_ptr<CompositorFrameSinkSupport> root_support = | 293 std::unique_ptr<CompositorFrameSinkSupport> root_support = |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 { | 385 { |
386 root_surface_id, | 386 root_surface_id, |
387 gfx::Point(290, 290), | 387 gfx::Point(290, 290), |
388 root_surface_id, | 388 root_surface_id, |
389 gfx::Point(290, 290) | 389 gfx::Point(290, 290) |
390 } | 390 } |
391 }; | 391 }; |
392 | 392 |
393 RunTests(nullptr, &manager, tests, arraysize(tests)); | 393 RunTests(nullptr, &manager, tests, arraysize(tests)); |
394 | 394 |
395 root_support->EvictFrame(); | 395 root_support->EvictCurrentSurface(); |
396 child_support->EvictFrame(); | 396 child_support->EvictCurrentSurface(); |
397 } | 397 } |
398 | 398 |
399 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { | 399 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { |
400 SurfaceManager manager; | 400 SurfaceManager manager; |
401 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); | 401 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); |
402 std::unique_ptr<CompositorFrameSinkSupport> support = | 402 std::unique_ptr<CompositorFrameSinkSupport> support = |
403 CompositorFrameSinkSupport::Create( | 403 CompositorFrameSinkSupport::Create( |
404 nullptr, &manager, root_frame_sink_id, kIsRoot, | 404 nullptr, &manager, root_frame_sink_id, kIsRoot, |
405 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 405 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
406 | 406 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 { | 489 { |
490 root_surface_id, | 490 root_surface_id, |
491 gfx::Point(100, 100), | 491 gfx::Point(100, 100), |
492 root_surface_id, | 492 root_surface_id, |
493 gfx::Point(100, 100) | 493 gfx::Point(100, 100) |
494 } | 494 } |
495 }; | 495 }; |
496 | 496 |
497 RunTests(nullptr, &manager, tests, arraysize(tests)); | 497 RunTests(nullptr, &manager, tests, arraysize(tests)); |
498 | 498 |
499 support->EvictFrame(); | 499 support->EvictCurrentSurface(); |
500 } | 500 } |
501 | 501 |
502 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { | 502 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { |
503 SurfaceManager manager; | 503 SurfaceManager manager; |
504 | 504 |
505 // Set up root FrameSink. | 505 // Set up root FrameSink. |
506 FrameSinkId root_frame_sink_id(1, 1); | 506 FrameSinkId root_frame_sink_id(1, 1); |
507 std::unique_ptr<CompositorFrameSinkSupport> root_support = | 507 std::unique_ptr<CompositorFrameSinkSupport> root_support = |
508 CompositorFrameSinkSupport::Create( | 508 CompositorFrameSinkSupport::Create( |
509 nullptr, &manager, root_frame_sink_id, kIsRoot, | 509 nullptr, &manager, root_frame_sink_id, kIsRoot, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 TestSurfaceHittestDelegate accept_delegate; | 627 TestSurfaceHittestDelegate accept_delegate; |
628 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, | 628 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, |
629 gfx::Insets(5, 5, 5, 5)); | 629 gfx::Insets(5, 5, 5, 5)); |
630 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, | 630 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, |
631 arraysize(test_expectations_with_accept_insets)); | 631 arraysize(test_expectations_with_accept_insets)); |
632 | 632 |
633 // Verify that insets have affected hit targeting. | 633 // Verify that insets have affected hit targeting. |
634 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); | 634 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); |
635 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); | 635 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); |
636 | 636 |
637 root_support->EvictFrame(); | 637 root_support->EvictCurrentSurface(); |
638 child_support->EvictFrame(); | 638 child_support->EvictCurrentSurface(); |
639 } | 639 } |
640 | 640 |
641 } // namespace cc | 641 } // namespace cc |
OLD | NEW |