Chromium Code Reviews| 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/local_surface_id_allocator.h" | 9 #include "cc/surfaces/local_surface_id_allocator.h" |
| 9 #include "cc/surfaces/surface.h" | 10 #include "cc/surfaces/surface.h" |
| 10 #include "cc/surfaces/surface_factory.h" | |
| 11 #include "cc/surfaces/surface_factory_client.h" | |
| 12 #include "cc/surfaces/surface_hittest.h" | 11 #include "cc/surfaces/surface_hittest.h" |
| 13 #include "cc/surfaces/surface_manager.h" | 12 #include "cc/surfaces/surface_manager.h" |
| 14 #include "cc/test/surface_hittest_test_helpers.h" | 13 #include "cc/test/surface_hittest_test_helpers.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 18 | 17 |
| 19 namespace cc { | 18 namespace cc { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 static constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | 22 constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); |
| 24 | 23 constexpr bool is_root = true; |
| 24 constexpr bool is_root_child = false; | |
| 25 constexpr bool handles_frame_sink_id_invalidation = true; | |
| 26 constexpr bool needs_sync_points = true; | |
|
Fady Samuel
2017/04/04 22:48:16
nit: linebreak.
Alex Z.
2017/04/05 14:38:55
Done.
| |
| 25 struct TestCase { | 27 struct TestCase { |
| 26 SurfaceId input_surface_id; | 28 SurfaceId input_surface_id; |
| 27 gfx::Point input_point; | 29 gfx::Point input_point; |
| 28 SurfaceId expected_compositor_frame_sink_id; | 30 SurfaceId expected_compositor_frame_sink_id; |
| 29 gfx::Point expected_output_point; | 31 gfx::Point expected_output_point; |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 void RunTests(SurfaceHittestDelegate* delegate, | 34 void RunTests(SurfaceHittestDelegate* delegate, |
| 33 SurfaceManager* manager, | 35 SurfaceManager* manager, |
| 34 TestCase* tests, | 36 TestCase* tests, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 55 } | 57 } |
| 56 | 58 |
| 57 } // namespace | 59 } // namespace |
| 58 | 60 |
| 59 using namespace test; | 61 using namespace test; |
| 60 | 62 |
| 61 // This test verifies that hit testing on a surface that does not exist does | 63 // This test verifies that hit testing on a surface that does not exist does |
| 62 // not crash. | 64 // not crash. |
| 63 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { | 65 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { |
| 64 SurfaceManager manager; | 66 SurfaceManager manager; |
| 65 EmptySurfaceFactoryClient client; | |
| 66 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); | 67 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); |
| 67 SurfaceFactory root_factory(root_frame_sink_id, &manager, &client); | 68 CompositorFrameSinkSupport root_support( |
| 69 nullptr, &manager, kArbitraryFrameSinkId, is_root, | |
| 70 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 68 | 71 |
| 69 // Creates a root surface. | 72 // Creates a root surface. |
| 70 gfx::Rect root_rect(300, 300); | 73 gfx::Rect root_rect(300, 300); |
| 71 RenderPass* root_pass = nullptr; | 74 RenderPass* root_pass = nullptr; |
| 72 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 75 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 73 | 76 |
| 74 // Add a reference to a non-existant child surface on the root surface. | 77 // Add a reference to a non-existant child surface on the root surface. |
| 75 SurfaceId child_surface_id( | 78 SurfaceId child_surface_id( |
| 76 kArbitraryFrameSinkId, | 79 kArbitraryFrameSinkId, |
| 77 LocalSurfaceId(0xdeadbeef, base::UnguessableToken::Create())); | 80 LocalSurfaceId(0xdeadbeef, base::UnguessableToken::Create())); |
| 78 gfx::Rect child_rect(200, 200); | 81 gfx::Rect child_rect(200, 200); |
| 79 CreateSurfaceDrawQuad(root_pass, | 82 CreateSurfaceDrawQuad(root_pass, |
| 80 gfx::Transform(), | 83 gfx::Transform(), |
| 81 root_rect, | 84 root_rect, |
| 82 child_rect, | 85 child_rect, |
| 83 child_surface_id); | 86 child_surface_id); |
| 84 | 87 |
| 85 // Submit the root frame. | 88 // Submit the root frame. |
| 86 LocalSurfaceIdAllocator root_allocator; | 89 LocalSurfaceIdAllocator root_allocator; |
| 87 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); | 90 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); |
| 88 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); | 91 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); |
| 89 root_factory.SubmitCompositorFrame(root_local_surface_id, | 92 root_support.SubmitCompositorFrame(root_local_surface_id, |
| 90 std::move(root_frame), | 93 std::move(root_frame)); |
| 91 SurfaceFactory::DrawCallback()); | |
| 92 | 94 |
| 93 { | 95 { |
| 94 SurfaceHittest hittest(nullptr, &manager); | 96 SurfaceHittest hittest(nullptr, &manager); |
| 95 // It is expected this test will complete without crashes. | 97 // It is expected this test will complete without crashes. |
| 96 gfx::Transform transform; | 98 gfx::Transform transform; |
| 97 EXPECT_EQ(root_surface_id, | 99 EXPECT_EQ(root_surface_id, |
| 98 hittest.GetTargetSurfaceAtPoint( | 100 hittest.GetTargetSurfaceAtPoint( |
| 99 root_surface_id, gfx::Point(100, 100), &transform)); | 101 root_surface_id, gfx::Point(100, 100), &transform)); |
| 100 } | 102 } |
| 101 | 103 |
| 102 root_factory.EvictSurface(); | 104 root_support.EvictFrame(); |
| 103 } | 105 } |
| 104 | 106 |
| 105 TEST(SurfaceHittestTest, Hittest_SingleSurface) { | 107 TEST(SurfaceHittestTest, Hittest_SingleSurface) { |
| 106 SurfaceManager manager; | 108 SurfaceManager manager; |
| 107 | 109 |
| 108 // Set up root FrameSink. | 110 // Set up root FrameSink. |
| 109 EmptySurfaceFactoryClient root_client; | |
| 110 FrameSinkId root_frame_sink_id(1, 1); | 111 FrameSinkId root_frame_sink_id(1, 1); |
| 111 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); | 112 CompositorFrameSinkSupport root_support( |
| 113 nullptr, &manager, root_frame_sink_id, is_root, | |
| 114 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 112 | 115 |
| 113 // Creates a root surface. | 116 // Creates a root surface. |
| 114 gfx::Rect root_rect(300, 300); | 117 gfx::Rect root_rect(300, 300); |
| 115 RenderPass* root_pass = nullptr; | 118 RenderPass* root_pass = nullptr; |
| 116 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 119 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 117 | 120 |
| 118 // Submit the root frame. | 121 // Submit the root frame. |
| 119 LocalSurfaceIdAllocator root_allocator; | 122 LocalSurfaceIdAllocator root_allocator; |
| 120 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); | 123 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); |
| 121 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); | 124 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); |
| 122 root_factory.SubmitCompositorFrame(root_local_surface_id, | 125 root_support.SubmitCompositorFrame(root_local_surface_id, |
| 123 std::move(root_frame), | 126 std::move(root_frame)); |
| 124 SurfaceFactory::DrawCallback()); | |
| 125 TestCase tests[] = { | 127 TestCase tests[] = { |
| 126 { | 128 { |
| 127 root_surface_id, | 129 root_surface_id, |
| 128 gfx::Point(100, 100), | 130 gfx::Point(100, 100), |
| 129 root_surface_id, | 131 root_surface_id, |
| 130 gfx::Point(100, 100) | 132 gfx::Point(100, 100) |
| 131 }, | 133 }, |
| 132 }; | 134 }; |
| 133 | 135 |
| 134 RunTests(nullptr, &manager, tests, arraysize(tests)); | 136 RunTests(nullptr, &manager, tests, arraysize(tests)); |
| 135 | 137 |
| 136 root_factory.EvictSurface(); | 138 root_support.EvictFrame(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 TEST(SurfaceHittestTest, Hittest_ChildSurface) { | 141 TEST(SurfaceHittestTest, Hittest_ChildSurface) { |
| 140 SurfaceManager manager; | 142 SurfaceManager manager; |
| 141 | 143 |
| 142 // Set up root FrameSink. | 144 // Set up root FrameSink. |
| 143 EmptySurfaceFactoryClient root_client; | |
| 144 FrameSinkId root_frame_sink_id(1, 1); | 145 FrameSinkId root_frame_sink_id(1, 1); |
| 145 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); | 146 CompositorFrameSinkSupport root_support( |
| 147 nullptr, &manager, root_frame_sink_id, is_root, | |
| 148 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 146 | 149 |
| 147 // Set up child FrameSink. | 150 // Set up child FrameSink. |
| 148 EmptySurfaceFactoryClient child_client; | |
| 149 FrameSinkId child_frame_sink_id(2, 2); | 151 FrameSinkId child_frame_sink_id(2, 2); |
| 150 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); | 152 CompositorFrameSinkSupport child_support( |
| 153 nullptr, &manager, child_frame_sink_id, is_root_child, | |
| 154 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 151 | 155 |
| 152 // Creates a root surface. | 156 // Creates a root surface. |
| 153 gfx::Rect root_rect(300, 300); | 157 gfx::Rect root_rect(300, 300); |
| 154 RenderPass* root_pass = nullptr; | 158 RenderPass* root_pass = nullptr; |
| 155 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 159 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 156 | 160 |
| 157 // Add a reference to the child surface on the root surface. | 161 // Add a reference to the child surface on the root surface. |
| 158 LocalSurfaceIdAllocator child_allocator; | 162 LocalSurfaceIdAllocator child_allocator; |
| 159 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); | 163 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); |
| 160 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); | 164 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); |
| 161 gfx::Rect child_rect(200, 200); | 165 gfx::Rect child_rect(200, 200); |
| 162 CreateSurfaceDrawQuad(root_pass, | 166 CreateSurfaceDrawQuad(root_pass, |
| 163 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 167 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 164 0.0f, 1.0f, 0.0f, 50.0f, | 168 0.0f, 1.0f, 0.0f, 50.0f, |
| 165 0.0f, 0.0f, 1.0f, 0.0f, | 169 0.0f, 0.0f, 1.0f, 0.0f, |
| 166 0.0f, 0.0f, 0.0f, 1.0f), | 170 0.0f, 0.0f, 0.0f, 1.0f), |
| 167 root_rect, | 171 root_rect, |
| 168 child_rect, | 172 child_rect, |
| 169 child_surface_id); | 173 child_surface_id); |
| 170 | 174 |
| 171 // Submit the root frame. | 175 // Submit the root frame. |
| 172 LocalSurfaceIdAllocator root_allocator; | 176 LocalSurfaceIdAllocator root_allocator; |
| 173 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); | 177 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); |
| 174 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); | 178 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); |
| 175 root_factory.SubmitCompositorFrame(root_local_surface_id, | 179 root_support.SubmitCompositorFrame(root_local_surface_id, |
| 176 std::move(root_frame), | 180 std::move(root_frame)); |
| 177 SurfaceFactory::DrawCallback()); | |
| 178 | 181 |
| 179 // Creates a child surface. | 182 // Creates a child surface. |
| 180 RenderPass* child_pass = nullptr; | 183 RenderPass* child_pass = nullptr; |
| 181 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 184 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 182 | 185 |
| 183 // Add a solid quad in the child surface. | 186 // Add a solid quad in the child surface. |
| 184 gfx::Rect child_solid_quad_rect(100, 100); | 187 gfx::Rect child_solid_quad_rect(100, 100); |
| 185 CreateSolidColorDrawQuad( | 188 CreateSolidColorDrawQuad( |
| 186 child_pass, | 189 child_pass, |
| 187 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 190 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 188 0.0f, 1.0f, 0.0f, 50.0f, | 191 0.0f, 1.0f, 0.0f, 50.0f, |
| 189 0.0f, 0.0f, 1.0f, 0.0f, | 192 0.0f, 0.0f, 1.0f, 0.0f, |
| 190 0.0f, 0.0f, 0.0f, 1.0f), | 193 0.0f, 0.0f, 0.0f, 1.0f), |
| 191 root_rect, child_solid_quad_rect); | 194 root_rect, child_solid_quad_rect); |
| 192 | 195 |
| 193 // Submit the frame. | 196 // Submit the frame. |
| 194 child_factory.SubmitCompositorFrame(child_local_surface_id, | 197 child_support.SubmitCompositorFrame(child_local_surface_id, |
| 195 std::move(child_frame), | 198 std::move(child_frame)); |
| 196 SurfaceFactory::DrawCallback()); | |
| 197 | 199 |
| 198 TestCase tests[] = { | 200 TestCase tests[] = { |
| 199 { | 201 { |
| 200 root_surface_id, | 202 root_surface_id, |
| 201 gfx::Point(10, 10), | 203 gfx::Point(10, 10), |
| 202 root_surface_id, | 204 root_surface_id, |
| 203 gfx::Point(10, 10) | 205 gfx::Point(10, 10) |
| 204 }, | 206 }, |
| 205 { | 207 { |
| 206 root_surface_id, | 208 root_surface_id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 // Submit another root frame, with a slightly perturbed child Surface. | 241 // Submit another root frame, with a slightly perturbed child Surface. |
| 240 root_frame = CreateCompositorFrame(root_rect, &root_pass); | 242 root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 241 CreateSurfaceDrawQuad(root_pass, | 243 CreateSurfaceDrawQuad(root_pass, |
| 242 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, | 244 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, |
| 243 0.0f, 1.0f, 0.0f, 75.0f, | 245 0.0f, 1.0f, 0.0f, 75.0f, |
| 244 0.0f, 0.0f, 1.0f, 0.0f, | 246 0.0f, 0.0f, 1.0f, 0.0f, |
| 245 0.0f, 0.0f, 0.0f, 1.0f), | 247 0.0f, 0.0f, 0.0f, 1.0f), |
| 246 root_rect, | 248 root_rect, |
| 247 child_rect, | 249 child_rect, |
| 248 child_surface_id); | 250 child_surface_id); |
| 249 root_factory.SubmitCompositorFrame(root_local_surface_id, | 251 root_support.SubmitCompositorFrame(root_local_surface_id, |
| 250 std::move(root_frame), | 252 std::move(root_frame)); |
| 251 SurfaceFactory::DrawCallback()); | |
| 252 | 253 |
| 253 // Verify that point (100, 100) no longer falls on the child surface. | 254 // Verify that point (100, 100) no longer falls on the child surface. |
| 254 // Verify that the transform to the child surface's space has also shifted. | 255 // Verify that the transform to the child surface's space has also shifted. |
| 255 { | 256 { |
| 256 SurfaceHittest hittest(nullptr, &manager); | 257 SurfaceHittest hittest(nullptr, &manager); |
| 257 | 258 |
| 258 gfx::Point point(100, 100); | 259 gfx::Point point(100, 100); |
| 259 gfx::Transform transform; | 260 gfx::Transform transform; |
| 260 EXPECT_EQ(root_surface_id, | 261 EXPECT_EQ(root_surface_id, |
| 261 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, | 262 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, |
| 262 &transform)); | 263 &transform)); |
| 263 transform.TransformPoint(&point); | 264 transform.TransformPoint(&point); |
| 264 EXPECT_EQ(gfx::Point(100, 100), point); | 265 EXPECT_EQ(gfx::Point(100, 100), point); |
| 265 | 266 |
| 266 gfx::Point point_in_target_space(100, 100); | 267 gfx::Point point_in_target_space(100, 100); |
| 267 gfx::Transform target_transform; | 268 gfx::Transform target_transform; |
| 268 EXPECT_TRUE(hittest.GetTransformToTargetSurface( | 269 EXPECT_TRUE(hittest.GetTransformToTargetSurface( |
| 269 root_surface_id, child_surface_id, &target_transform)); | 270 root_surface_id, child_surface_id, &target_transform)); |
| 270 target_transform.TransformPoint(&point_in_target_space); | 271 target_transform.TransformPoint(&point_in_target_space); |
| 271 EXPECT_NE(transform, target_transform); | 272 EXPECT_NE(transform, target_transform); |
| 272 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); | 273 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); |
| 273 } | 274 } |
| 274 | 275 |
| 275 root_factory.EvictSurface(); | 276 root_support.EvictFrame(); |
| 276 child_factory.EvictSurface(); | 277 child_support.EvictFrame(); |
| 277 } | 278 } |
| 278 | 279 |
| 279 // This test verifies that hit testing will progress to the next quad if it | 280 // This test verifies that hit testing will progress to the next quad if it |
| 280 // encounters an invalid RenderPassDrawQuad for whatever reason. | 281 // encounters an invalid RenderPassDrawQuad for whatever reason. |
| 281 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { | 282 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { |
| 282 SurfaceManager manager; | 283 SurfaceManager manager; |
| 283 | 284 |
| 284 // Set up root FrameSink. | 285 // Set up root FrameSink. |
| 285 EmptySurfaceFactoryClient root_client; | |
| 286 FrameSinkId root_frame_sink_id(1, 1); | 286 FrameSinkId root_frame_sink_id(1, 1); |
| 287 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); | 287 CompositorFrameSinkSupport root_support( |
| 288 nullptr, &manager, root_frame_sink_id, is_root, | |
| 289 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 288 | 290 |
| 289 // Set up child FrameSink. | 291 // Set up child FrameSink. |
| 290 EmptySurfaceFactoryClient child_client; | |
| 291 FrameSinkId child_frame_sink_id(2, 2); | 292 FrameSinkId child_frame_sink_id(2, 2); |
| 292 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); | 293 CompositorFrameSinkSupport child_support( |
| 294 nullptr, &manager, child_frame_sink_id, is_root_child, | |
| 295 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 293 | 296 |
| 294 // Creates a root surface. | 297 // Creates a root surface. |
| 295 gfx::Rect root_rect(300, 300); | 298 gfx::Rect root_rect(300, 300); |
| 296 RenderPass* root_pass = nullptr; | 299 RenderPass* root_pass = nullptr; |
| 297 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 300 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 298 | 301 |
| 299 // Create a RenderPassDrawQuad to a non-existant RenderPass. | 302 // Create a RenderPassDrawQuad to a non-existant RenderPass. |
| 300 int invalid_render_pass_id = 1337; | 303 int invalid_render_pass_id = 1337; |
| 301 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect, | 304 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect, |
| 302 invalid_render_pass_id); | 305 invalid_render_pass_id); |
| 303 | 306 |
| 304 // Add a reference to the child surface on the root surface. | 307 // Add a reference to the child surface on the root surface. |
| 305 LocalSurfaceIdAllocator child_allocator; | 308 LocalSurfaceIdAllocator child_allocator; |
| 306 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); | 309 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); |
| 307 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); | 310 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); |
| 308 gfx::Rect child_rect(200, 200); | 311 gfx::Rect child_rect(200, 200); |
| 309 CreateSurfaceDrawQuad(root_pass, | 312 CreateSurfaceDrawQuad(root_pass, |
| 310 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 313 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 311 0.0f, 1.0f, 0.0f, 50.0f, | 314 0.0f, 1.0f, 0.0f, 50.0f, |
| 312 0.0f, 0.0f, 1.0f, 0.0f, | 315 0.0f, 0.0f, 1.0f, 0.0f, |
| 313 0.0f, 0.0f, 0.0f, 1.0f), | 316 0.0f, 0.0f, 0.0f, 1.0f), |
| 314 root_rect, | 317 root_rect, |
| 315 child_rect, | 318 child_rect, |
| 316 child_surface_id); | 319 child_surface_id); |
| 317 | 320 |
| 318 // Submit the root frame. | 321 // Submit the root frame. |
| 319 LocalSurfaceIdAllocator root_allocator; | 322 LocalSurfaceIdAllocator root_allocator; |
| 320 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); | 323 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); |
| 321 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); | 324 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); |
| 322 root_factory.SubmitCompositorFrame(root_local_surface_id, | 325 root_support.SubmitCompositorFrame(root_local_surface_id, |
| 323 std::move(root_frame), | 326 std::move(root_frame)); |
| 324 SurfaceFactory::DrawCallback()); | |
| 325 | 327 |
| 326 // Creates a child surface. | 328 // Creates a child surface. |
| 327 RenderPass* child_pass = nullptr; | 329 RenderPass* child_pass = nullptr; |
| 328 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 330 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 329 | 331 |
| 330 // Add a solid quad in the child surface. | 332 // Add a solid quad in the child surface. |
| 331 gfx::Rect child_solid_quad_rect(100, 100); | 333 gfx::Rect child_solid_quad_rect(100, 100); |
| 332 CreateSolidColorDrawQuad(child_pass, | 334 CreateSolidColorDrawQuad(child_pass, |
| 333 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 335 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 334 0.0f, 1.0f, 0.0f, 50.0f, | 336 0.0f, 1.0f, 0.0f, 50.0f, |
| 335 0.0f, 0.0f, 1.0f, 0.0f, | 337 0.0f, 0.0f, 1.0f, 0.0f, |
| 336 0.0f, 0.0f, 0.0f, 1.0f), | 338 0.0f, 0.0f, 0.0f, 1.0f), |
| 337 root_rect, | 339 root_rect, |
| 338 child_solid_quad_rect); | 340 child_solid_quad_rect); |
| 339 | 341 |
| 340 // Submit the frame. | 342 // Submit the frame. |
| 341 child_factory.SubmitCompositorFrame(child_local_surface_id, | 343 child_support.SubmitCompositorFrame(child_local_surface_id, |
| 342 std::move(child_frame), | 344 std::move(child_frame)); |
| 343 SurfaceFactory::DrawCallback()); | |
| 344 | 345 |
| 345 TestCase tests[] = { | 346 TestCase tests[] = { |
| 346 { | 347 { |
| 347 root_surface_id, | 348 root_surface_id, |
| 348 gfx::Point(10, 10), | 349 gfx::Point(10, 10), |
| 349 root_surface_id, | 350 root_surface_id, |
| 350 gfx::Point(10, 10) | 351 gfx::Point(10, 10) |
| 351 }, | 352 }, |
| 352 { | 353 { |
| 353 root_surface_id, | 354 root_surface_id, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 376 { | 377 { |
| 377 root_surface_id, | 378 root_surface_id, |
| 378 gfx::Point(290, 290), | 379 gfx::Point(290, 290), |
| 379 root_surface_id, | 380 root_surface_id, |
| 380 gfx::Point(290, 290) | 381 gfx::Point(290, 290) |
| 381 } | 382 } |
| 382 }; | 383 }; |
| 383 | 384 |
| 384 RunTests(nullptr, &manager, tests, arraysize(tests)); | 385 RunTests(nullptr, &manager, tests, arraysize(tests)); |
| 385 | 386 |
| 386 root_factory.EvictSurface(); | 387 root_support.EvictFrame(); |
| 387 child_factory.EvictSurface(); | 388 child_support.EvictFrame(); |
| 388 } | 389 } |
| 389 | 390 |
| 390 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { | 391 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { |
| 391 SurfaceManager manager; | 392 SurfaceManager manager; |
| 392 EmptySurfaceFactoryClient client; | |
| 393 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); | 393 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); |
| 394 SurfaceFactory factory(root_frame_sink_id, &manager, &client); | 394 CompositorFrameSinkSupport support( |
| 395 nullptr, &manager, root_frame_sink_id, is_root, | |
| 396 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 395 | 397 |
| 396 // Create a CompostiorFrame with two RenderPasses. | 398 // Create a CompostiorFrame with two RenderPasses. |
| 397 gfx::Rect root_rect(300, 300); | 399 gfx::Rect root_rect(300, 300); |
| 398 CompositorFrame root_frame; | 400 CompositorFrame root_frame; |
| 399 RenderPassList& render_pass_list = root_frame.render_pass_list; | 401 RenderPassList& render_pass_list = root_frame.render_pass_list; |
| 400 | 402 |
| 401 // Create a child RenderPass. | 403 // Create a child RenderPass. |
| 402 int child_render_pass_id = 3; | 404 int child_render_pass_id = 3; |
| 403 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, | 405 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, |
| 404 0.0f, 1.0f, 0.0f, 50.0f, | 406 0.0f, 1.0f, 0.0f, 50.0f, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 430 gfx::Rect child_solid_quad_rect(100, 100); | 432 gfx::Rect child_solid_quad_rect(100, 100); |
| 431 CreateSolidColorDrawQuad(child_render_pass, | 433 CreateSolidColorDrawQuad(child_render_pass, |
| 432 gfx::Transform(), | 434 gfx::Transform(), |
| 433 gfx::Rect(100, 100), | 435 gfx::Rect(100, 100), |
| 434 child_solid_quad_rect); | 436 child_solid_quad_rect); |
| 435 | 437 |
| 436 // Submit the root frame. | 438 // Submit the root frame. |
| 437 LocalSurfaceIdAllocator root_allocator; | 439 LocalSurfaceIdAllocator root_allocator; |
| 438 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); | 440 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); |
| 439 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); | 441 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); |
| 440 factory.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame), | 442 support.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame)); |
| 441 SurfaceFactory::DrawCallback()); | |
| 442 | 443 |
| 443 TestCase tests[] = { | 444 TestCase tests[] = { |
| 444 // These tests just miss the RenderPassDrawQuad. | 445 // These tests just miss the RenderPassDrawQuad. |
| 445 { | 446 { |
| 446 root_surface_id, | 447 root_surface_id, |
| 447 gfx::Point(49, 49), | 448 gfx::Point(49, 49), |
| 448 root_surface_id, | 449 root_surface_id, |
| 449 gfx::Point(49, 49) | 450 gfx::Point(49, 49) |
| 450 }, | 451 }, |
| 451 { | 452 { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 479 { | 480 { |
| 480 root_surface_id, | 481 root_surface_id, |
| 481 gfx::Point(100, 100), | 482 gfx::Point(100, 100), |
| 482 root_surface_id, | 483 root_surface_id, |
| 483 gfx::Point(100, 100) | 484 gfx::Point(100, 100) |
| 484 } | 485 } |
| 485 }; | 486 }; |
| 486 | 487 |
| 487 RunTests(nullptr, &manager, tests, arraysize(tests)); | 488 RunTests(nullptr, &manager, tests, arraysize(tests)); |
| 488 | 489 |
| 489 factory.EvictSurface(); | 490 support.EvictFrame(); |
| 490 } | 491 } |
| 491 | 492 |
| 492 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { | 493 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { |
| 493 SurfaceManager manager; | 494 SurfaceManager manager; |
| 494 | 495 |
| 495 // Set up root FrameSink. | 496 // Set up root FrameSink. |
| 496 EmptySurfaceFactoryClient root_client; | |
| 497 FrameSinkId root_frame_sink_id(1, 1); | 497 FrameSinkId root_frame_sink_id(1, 1); |
| 498 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); | 498 CompositorFrameSinkSupport root_support( |
| 499 nullptr, &manager, root_frame_sink_id, is_root, | |
| 500 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 499 | 501 |
| 500 // Set up child FrameSink. | 502 // Set up child FrameSink. |
| 501 EmptySurfaceFactoryClient child_client; | |
| 502 FrameSinkId child_frame_sink_id(2, 2); | 503 FrameSinkId child_frame_sink_id(2, 2); |
| 503 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); | 504 CompositorFrameSinkSupport child_support( |
| 505 nullptr, &manager, child_frame_sink_id, is_root, | |
| 506 handles_frame_sink_id_invalidation, needs_sync_points); | |
| 504 | 507 |
| 505 // Creates a root surface. | 508 // Creates a root surface. |
| 506 gfx::Rect root_rect(300, 300); | 509 gfx::Rect root_rect(300, 300); |
| 507 RenderPass* root_pass = nullptr; | 510 RenderPass* root_pass = nullptr; |
| 508 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 511 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
| 509 | 512 |
| 510 // Add a reference to the child surface on the root surface. | 513 // Add a reference to the child surface on the root surface. |
| 511 LocalSurfaceIdAllocator child_allocator; | 514 LocalSurfaceIdAllocator child_allocator; |
| 512 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); | 515 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); |
| 513 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); | 516 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); |
| 514 gfx::Rect child_rect(200, 200); | 517 gfx::Rect child_rect(200, 200); |
| 515 CreateSurfaceDrawQuad( | 518 CreateSurfaceDrawQuad( |
| 516 root_pass, | 519 root_pass, |
| 517 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 520 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
| 518 0.0f, 1.0f, 0.0f, 50.0f, | 521 0.0f, 1.0f, 0.0f, 50.0f, |
| 519 0.0f, 0.0f, 1.0f, 0.0f, | 522 0.0f, 0.0f, 1.0f, 0.0f, |
| 520 0.0f, 0.0f, 0.0f, 1.0f), | 523 0.0f, 0.0f, 0.0f, 1.0f), |
| 521 root_rect, child_rect, child_surface_id); | 524 root_rect, child_rect, child_surface_id); |
| 522 | 525 |
| 523 // Submit the root frame. | 526 // Submit the root frame. |
| 524 LocalSurfaceIdAllocator root_allocator; | 527 LocalSurfaceIdAllocator root_allocator; |
| 525 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); | 528 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); |
| 526 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); | 529 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); |
| 527 root_factory.SubmitCompositorFrame(root_local_surface_id, | 530 root_support.SubmitCompositorFrame(root_local_surface_id, |
| 528 std::move(root_frame), | 531 std::move(root_frame)); |
| 529 SurfaceFactory::DrawCallback()); | |
| 530 | 532 |
| 531 // Creates a child surface. | 533 // Creates a child surface. |
| 532 RenderPass* child_pass = nullptr; | 534 RenderPass* child_pass = nullptr; |
| 533 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 535 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
| 534 | 536 |
| 535 // Add a solid quad in the child surface. | 537 // Add a solid quad in the child surface. |
| 536 gfx::Rect child_solid_quad_rect(190, 190); | 538 gfx::Rect child_solid_quad_rect(190, 190); |
| 537 CreateSolidColorDrawQuad( | 539 CreateSolidColorDrawQuad( |
| 538 child_pass, | 540 child_pass, |
| 539 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, | 541 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, |
| 540 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), | 542 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), |
| 541 root_rect, child_solid_quad_rect); | 543 root_rect, child_solid_quad_rect); |
| 542 | 544 |
| 543 // Submit the frame. | 545 // Submit the frame. |
| 544 child_factory.SubmitCompositorFrame(child_local_surface_id, | 546 child_support.SubmitCompositorFrame(child_local_surface_id, |
| 545 std::move(child_frame), | 547 std::move(child_frame)); |
| 546 SurfaceFactory::DrawCallback()); | |
| 547 | 548 |
| 548 TestCase test_expectations_without_insets[] = { | 549 TestCase test_expectations_without_insets[] = { |
| 549 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, | 550 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, |
| 550 {root_surface_id, gfx::Point(60, 60), child_surface_id, | 551 {root_surface_id, gfx::Point(60, 60), child_surface_id, |
| 551 gfx::Point(10, 10)}, | 552 gfx::Point(10, 10)}, |
| 552 {root_surface_id, gfx::Point(239, 239), child_surface_id, | 553 {root_surface_id, gfx::Point(239, 239), child_surface_id, |
| 553 gfx::Point(189, 189)}, | 554 gfx::Point(189, 189)}, |
| 554 {root_surface_id, gfx::Point(244, 244), child_surface_id, | 555 {root_surface_id, gfx::Point(244, 244), child_surface_id, |
| 555 gfx::Point(194, 194)}, | 556 gfx::Point(194, 194)}, |
| 556 {root_surface_id, gfx::Point(50, 50), root_surface_id, | 557 {root_surface_id, gfx::Point(50, 50), root_surface_id, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 TestSurfaceHittestDelegate accept_delegate; | 616 TestSurfaceHittestDelegate accept_delegate; |
| 616 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, | 617 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, |
| 617 gfx::Insets(5, 5, 5, 5)); | 618 gfx::Insets(5, 5, 5, 5)); |
| 618 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, | 619 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, |
| 619 arraysize(test_expectations_with_accept_insets)); | 620 arraysize(test_expectations_with_accept_insets)); |
| 620 | 621 |
| 621 // Verify that insets have affected hit targeting. | 622 // Verify that insets have affected hit targeting. |
| 622 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); | 623 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); |
| 623 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); | 624 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); |
| 624 | 625 |
| 625 root_factory.EvictSurface(); | 626 root_support.EvictFrame(); |
| 626 child_factory.EvictSurface(); | 627 child_support.EvictFrame(); |
| 627 } | 628 } |
| 628 | 629 |
| 629 } // namespace cc | 630 } // namespace cc |
| OLD | NEW |