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/surface.h" | 8 #include "cc/surfaces/surface.h" |
9 #include "cc/surfaces/surface_factory.h" | 9 #include "cc/surfaces/surface_factory.h" |
10 #include "cc/surfaces/surface_factory_client.h" | 10 #include "cc/surfaces/surface_factory_client.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 using namespace test; | 59 using namespace test; |
60 | 60 |
61 // This test verifies that hit testing on a surface that does not exist does | 61 // This test verifies that hit testing on a surface that does not exist does |
62 // not crash. | 62 // not crash. |
63 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { | 63 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { |
64 SurfaceManager manager; | 64 SurfaceManager manager; |
65 EmptySurfaceFactoryClient client; | 65 EmptySurfaceFactoryClient client; |
66 SurfaceFactory factory(&manager, &client); | 66 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); |
| 67 SurfaceFactory root_factory(root_frame_sink_id, &manager, &client); |
67 | 68 |
68 // Creates a root surface. | 69 // Creates a root surface. |
69 gfx::Rect root_rect(300, 300); | 70 gfx::Rect root_rect(300, 300); |
70 RenderPass* root_pass = nullptr; | 71 RenderPass* root_pass = nullptr; |
71 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 72 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
72 | 73 |
73 // Add a reference to a non-existant child surface on the root surface. | 74 // Add a reference to a non-existant child surface on the root surface. |
74 SurfaceId child_surface_id(kArbitraryFrameSinkId, 0xdeadbeef, 0); | 75 SurfaceId child_surface_id(kArbitraryFrameSinkId, 0xdeadbeef, 0); |
75 gfx::Rect child_rect(200, 200); | 76 gfx::Rect child_rect(200, 200); |
76 CreateSurfaceDrawQuad(root_pass, | 77 CreateSurfaceDrawQuad(root_pass, |
77 gfx::Transform(), | 78 gfx::Transform(), |
78 root_rect, | 79 root_rect, |
79 child_rect, | 80 child_rect, |
80 child_surface_id); | 81 child_surface_id); |
81 | 82 |
82 // Submit the root frame. | 83 // Submit the root frame. |
83 SurfaceIdAllocator root_allocator(FrameSinkId(2, 2)); | 84 SurfaceIdAllocator root_allocator(root_frame_sink_id); |
84 SurfaceId root_surface_id = root_allocator.GenerateId(); | 85 SurfaceId root_surface_id = root_allocator.GenerateId(); |
85 factory.Create(root_surface_id); | 86 root_factory.Create(root_surface_id); |
86 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 87 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
87 SurfaceFactory::DrawCallback()); | 88 SurfaceFactory::DrawCallback()); |
88 | 89 |
89 { | 90 { |
90 SurfaceHittest hittest(nullptr, &manager); | 91 SurfaceHittest hittest(nullptr, &manager); |
91 // It is expected this test will complete without crashes. | 92 // It is expected this test will complete without crashes. |
92 gfx::Transform transform; | 93 gfx::Transform transform; |
93 EXPECT_EQ(root_surface_id, | 94 EXPECT_EQ(root_surface_id, |
94 hittest.GetTargetSurfaceAtPoint( | 95 hittest.GetTargetSurfaceAtPoint( |
95 root_surface_id, gfx::Point(100, 100), &transform)); | 96 root_surface_id, gfx::Point(100, 100), &transform)); |
96 } | 97 } |
97 | 98 |
98 factory.Destroy(root_surface_id); | 99 root_factory.Destroy(root_surface_id); |
99 } | 100 } |
100 | 101 |
101 TEST(SurfaceHittestTest, Hittest_SingleSurface) { | 102 TEST(SurfaceHittestTest, Hittest_SingleSurface) { |
102 SurfaceManager manager; | 103 SurfaceManager manager; |
103 EmptySurfaceFactoryClient client; | 104 |
104 SurfaceFactory factory(&manager, &client); | 105 // Set up root FrameSink. |
| 106 EmptySurfaceFactoryClient root_client; |
| 107 FrameSinkId root_frame_sink_id(1, 1); |
| 108 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); |
105 | 109 |
106 // Creates a root surface. | 110 // Creates a root surface. |
107 gfx::Rect root_rect(300, 300); | 111 gfx::Rect root_rect(300, 300); |
108 RenderPass* root_pass = nullptr; | 112 RenderPass* root_pass = nullptr; |
109 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 113 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
110 | 114 |
111 // Submit the root frame. | 115 // Submit the root frame. |
112 SurfaceIdAllocator root_allocator(FrameSinkId(2, 2)); | 116 SurfaceIdAllocator root_allocator(root_frame_sink_id); |
113 SurfaceId root_surface_id = root_allocator.GenerateId(); | 117 SurfaceId root_surface_id = root_allocator.GenerateId(); |
114 factory.Create(root_surface_id); | 118 root_factory.Create(root_surface_id); |
115 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 119 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
116 SurfaceFactory::DrawCallback()); | 120 SurfaceFactory::DrawCallback()); |
117 TestCase tests[] = { | 121 TestCase tests[] = { |
118 { | 122 { |
119 root_surface_id, | 123 root_surface_id, |
120 gfx::Point(100, 100), | 124 gfx::Point(100, 100), |
121 root_surface_id, | 125 root_surface_id, |
122 gfx::Point(100, 100) | 126 gfx::Point(100, 100) |
123 }, | 127 }, |
124 }; | 128 }; |
125 | 129 |
126 RunTests(nullptr, &manager, tests, arraysize(tests)); | 130 RunTests(nullptr, &manager, tests, arraysize(tests)); |
127 | 131 |
128 factory.Destroy(root_surface_id); | 132 root_factory.Destroy(root_surface_id); |
129 } | 133 } |
130 | 134 |
131 TEST(SurfaceHittestTest, Hittest_ChildSurface) { | 135 TEST(SurfaceHittestTest, Hittest_ChildSurface) { |
132 SurfaceManager manager; | 136 SurfaceManager manager; |
133 EmptySurfaceFactoryClient client; | 137 |
134 SurfaceFactory factory(&manager, &client); | 138 // Set up root FrameSink. |
| 139 EmptySurfaceFactoryClient root_client; |
| 140 FrameSinkId root_frame_sink_id(1, 1); |
| 141 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); |
| 142 |
| 143 // Set up child FrameSink. |
| 144 EmptySurfaceFactoryClient child_client; |
| 145 FrameSinkId child_frame_sink_id(2, 2); |
| 146 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); |
135 | 147 |
136 // Creates a root surface. | 148 // Creates a root surface. |
137 gfx::Rect root_rect(300, 300); | 149 gfx::Rect root_rect(300, 300); |
138 RenderPass* root_pass = nullptr; | 150 RenderPass* root_pass = nullptr; |
139 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 151 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
140 | 152 |
141 // Add a reference to the child surface on the root surface. | 153 // Add a reference to the child surface on the root surface. |
142 SurfaceIdAllocator child_allocator(FrameSinkId(3, 3)); | 154 SurfaceIdAllocator child_allocator(child_frame_sink_id); |
143 SurfaceId child_surface_id = child_allocator.GenerateId(); | 155 SurfaceId child_surface_id = child_allocator.GenerateId(); |
144 gfx::Rect child_rect(200, 200); | 156 gfx::Rect child_rect(200, 200); |
145 CreateSurfaceDrawQuad(root_pass, | 157 CreateSurfaceDrawQuad(root_pass, |
146 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 158 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
147 0.0f, 1.0f, 0.0f, 50.0f, | 159 0.0f, 1.0f, 0.0f, 50.0f, |
148 0.0f, 0.0f, 1.0f, 0.0f, | 160 0.0f, 0.0f, 1.0f, 0.0f, |
149 0.0f, 0.0f, 0.0f, 1.0f), | 161 0.0f, 0.0f, 0.0f, 1.0f), |
150 root_rect, | 162 root_rect, |
151 child_rect, | 163 child_rect, |
152 child_surface_id); | 164 child_surface_id); |
153 | 165 |
154 // Submit the root frame. | 166 // Submit the root frame. |
155 SurfaceIdAllocator root_allocator(FrameSinkId(2, 2)); | 167 SurfaceIdAllocator root_allocator(root_frame_sink_id); |
156 SurfaceId root_surface_id = root_allocator.GenerateId(); | 168 SurfaceId root_surface_id = root_allocator.GenerateId(); |
157 factory.Create(root_surface_id); | 169 root_factory.Create(root_surface_id); |
158 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 170 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
159 SurfaceFactory::DrawCallback()); | 171 SurfaceFactory::DrawCallback()); |
160 | 172 |
161 // Creates a child surface. | 173 // Creates a child surface. |
162 RenderPass* child_pass = nullptr; | 174 RenderPass* child_pass = nullptr; |
163 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 175 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
164 | 176 |
165 // Add a solid quad in the child surface. | 177 // Add a solid quad in the child surface. |
166 gfx::Rect child_solid_quad_rect(100, 100); | 178 gfx::Rect child_solid_quad_rect(100, 100); |
167 CreateSolidColorDrawQuad( | 179 CreateSolidColorDrawQuad( |
168 child_pass, | 180 child_pass, |
169 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 181 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
170 0.0f, 1.0f, 0.0f, 50.0f, | 182 0.0f, 1.0f, 0.0f, 50.0f, |
171 0.0f, 0.0f, 1.0f, 0.0f, | 183 0.0f, 0.0f, 1.0f, 0.0f, |
172 0.0f, 0.0f, 0.0f, 1.0f), | 184 0.0f, 0.0f, 0.0f, 1.0f), |
173 root_rect, child_solid_quad_rect); | 185 root_rect, child_solid_quad_rect); |
174 | 186 |
175 // Submit the frame. | 187 // Submit the frame. |
176 factory.Create(child_surface_id); | 188 child_factory.Create(child_surface_id); |
177 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 189 child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
178 SurfaceFactory::DrawCallback()); | 190 SurfaceFactory::DrawCallback()); |
179 | 191 |
180 TestCase tests[] = { | 192 TestCase tests[] = { |
181 { | 193 { |
182 root_surface_id, | 194 root_surface_id, |
183 gfx::Point(10, 10), | 195 gfx::Point(10, 10), |
184 root_surface_id, | 196 root_surface_id, |
185 gfx::Point(10, 10) | 197 gfx::Point(10, 10) |
186 }, | 198 }, |
187 { | 199 { |
188 root_surface_id, | 200 root_surface_id, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // Submit another root frame, with a slightly perturbed child Surface. | 233 // Submit another root frame, with a slightly perturbed child Surface. |
222 root_frame = CreateCompositorFrame(root_rect, &root_pass); | 234 root_frame = CreateCompositorFrame(root_rect, &root_pass); |
223 CreateSurfaceDrawQuad(root_pass, | 235 CreateSurfaceDrawQuad(root_pass, |
224 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, | 236 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, |
225 0.0f, 1.0f, 0.0f, 75.0f, | 237 0.0f, 1.0f, 0.0f, 75.0f, |
226 0.0f, 0.0f, 1.0f, 0.0f, | 238 0.0f, 0.0f, 1.0f, 0.0f, |
227 0.0f, 0.0f, 0.0f, 1.0f), | 239 0.0f, 0.0f, 0.0f, 1.0f), |
228 root_rect, | 240 root_rect, |
229 child_rect, | 241 child_rect, |
230 child_surface_id); | 242 child_surface_id); |
231 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 243 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
232 SurfaceFactory::DrawCallback()); | 244 SurfaceFactory::DrawCallback()); |
233 | 245 |
234 // Verify that point (100, 100) no longer falls on the child surface. | 246 // Verify that point (100, 100) no longer falls on the child surface. |
235 // Verify that the transform to the child surface's space has also shifted. | 247 // Verify that the transform to the child surface's space has also shifted. |
236 { | 248 { |
237 SurfaceHittest hittest(nullptr, &manager); | 249 SurfaceHittest hittest(nullptr, &manager); |
238 | 250 |
239 gfx::Point point(100, 100); | 251 gfx::Point point(100, 100); |
240 gfx::Transform transform; | 252 gfx::Transform transform; |
241 EXPECT_EQ(root_surface_id, | 253 EXPECT_EQ(root_surface_id, |
242 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, | 254 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, |
243 &transform)); | 255 &transform)); |
244 transform.TransformPoint(&point); | 256 transform.TransformPoint(&point); |
245 EXPECT_EQ(gfx::Point(100, 100), point); | 257 EXPECT_EQ(gfx::Point(100, 100), point); |
246 | 258 |
247 gfx::Point point_in_target_space(100, 100); | 259 gfx::Point point_in_target_space(100, 100); |
248 gfx::Transform target_transform; | 260 gfx::Transform target_transform; |
249 EXPECT_TRUE(hittest.GetTransformToTargetSurface( | 261 EXPECT_TRUE(hittest.GetTransformToTargetSurface( |
250 root_surface_id, child_surface_id, &target_transform)); | 262 root_surface_id, child_surface_id, &target_transform)); |
251 target_transform.TransformPoint(&point_in_target_space); | 263 target_transform.TransformPoint(&point_in_target_space); |
252 EXPECT_NE(transform, target_transform); | 264 EXPECT_NE(transform, target_transform); |
253 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); | 265 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); |
254 } | 266 } |
255 | 267 |
256 factory.Destroy(root_surface_id); | 268 root_factory.Destroy(root_surface_id); |
257 factory.Destroy(child_surface_id); | 269 child_factory.Destroy(child_surface_id); |
258 } | 270 } |
259 | 271 |
260 // This test verifies that hit testing will progress to the next quad if it | 272 // This test verifies that hit testing will progress to the next quad if it |
261 // encounters an invalid RenderPassDrawQuad for whatever reason. | 273 // encounters an invalid RenderPassDrawQuad for whatever reason. |
262 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { | 274 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { |
263 SurfaceManager manager; | 275 SurfaceManager manager; |
264 EmptySurfaceFactoryClient client; | 276 |
265 SurfaceFactory factory(&manager, &client); | 277 // Set up root FrameSink. |
| 278 EmptySurfaceFactoryClient root_client; |
| 279 FrameSinkId root_frame_sink_id(1, 1); |
| 280 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); |
| 281 |
| 282 // Set up child FrameSink. |
| 283 EmptySurfaceFactoryClient child_client; |
| 284 FrameSinkId child_frame_sink_id(2, 2); |
| 285 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); |
266 | 286 |
267 // Creates a root surface. | 287 // Creates a root surface. |
268 gfx::Rect root_rect(300, 300); | 288 gfx::Rect root_rect(300, 300); |
269 RenderPass* root_pass = nullptr; | 289 RenderPass* root_pass = nullptr; |
270 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 290 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
271 | 291 |
272 // Create a RenderPassDrawQuad to a non-existant RenderPass. | 292 // Create a RenderPassDrawQuad to a non-existant RenderPass. |
273 CreateRenderPassDrawQuad(root_pass, | 293 CreateRenderPassDrawQuad(root_pass, |
274 gfx::Transform(), | 294 gfx::Transform(), |
275 root_rect, | 295 root_rect, |
276 root_rect, | 296 root_rect, |
277 RenderPassId(1337, 1337)); | 297 RenderPassId(1337, 1337)); |
278 | 298 |
279 // Add a reference to the child surface on the root surface. | 299 // Add a reference to the child surface on the root surface. |
280 SurfaceIdAllocator child_allocator(FrameSinkId(3, 3)); | 300 SurfaceIdAllocator child_allocator(child_frame_sink_id); |
281 SurfaceId child_surface_id = child_allocator.GenerateId(); | 301 SurfaceId child_surface_id = child_allocator.GenerateId(); |
282 gfx::Rect child_rect(200, 200); | 302 gfx::Rect child_rect(200, 200); |
283 CreateSurfaceDrawQuad(root_pass, | 303 CreateSurfaceDrawQuad(root_pass, |
284 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 304 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
285 0.0f, 1.0f, 0.0f, 50.0f, | 305 0.0f, 1.0f, 0.0f, 50.0f, |
286 0.0f, 0.0f, 1.0f, 0.0f, | 306 0.0f, 0.0f, 1.0f, 0.0f, |
287 0.0f, 0.0f, 0.0f, 1.0f), | 307 0.0f, 0.0f, 0.0f, 1.0f), |
288 root_rect, | 308 root_rect, |
289 child_rect, | 309 child_rect, |
290 child_surface_id); | 310 child_surface_id); |
291 | 311 |
292 // Submit the root frame. | 312 // Submit the root frame. |
293 SurfaceIdAllocator root_allocator(FrameSinkId(2, 2)); | 313 SurfaceIdAllocator root_allocator(root_frame_sink_id); |
294 SurfaceId root_surface_id = root_allocator.GenerateId(); | 314 SurfaceId root_surface_id = root_allocator.GenerateId(); |
295 factory.Create(root_surface_id); | 315 root_factory.Create(root_surface_id); |
296 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 316 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
297 SurfaceFactory::DrawCallback()); | 317 SurfaceFactory::DrawCallback()); |
298 | 318 |
299 // Creates a child surface. | 319 // Creates a child surface. |
300 RenderPass* child_pass = nullptr; | 320 RenderPass* child_pass = nullptr; |
301 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 321 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
302 | 322 |
303 // Add a solid quad in the child surface. | 323 // Add a solid quad in the child surface. |
304 gfx::Rect child_solid_quad_rect(100, 100); | 324 gfx::Rect child_solid_quad_rect(100, 100); |
305 CreateSolidColorDrawQuad(child_pass, | 325 CreateSolidColorDrawQuad(child_pass, |
306 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 326 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
307 0.0f, 1.0f, 0.0f, 50.0f, | 327 0.0f, 1.0f, 0.0f, 50.0f, |
308 0.0f, 0.0f, 1.0f, 0.0f, | 328 0.0f, 0.0f, 1.0f, 0.0f, |
309 0.0f, 0.0f, 0.0f, 1.0f), | 329 0.0f, 0.0f, 0.0f, 1.0f), |
310 root_rect, | 330 root_rect, |
311 child_solid_quad_rect); | 331 child_solid_quad_rect); |
312 | 332 |
313 // Submit the frame. | 333 // Submit the frame. |
314 factory.Create(child_surface_id); | 334 child_factory.Create(child_surface_id); |
315 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 335 child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
316 SurfaceFactory::DrawCallback()); | 336 SurfaceFactory::DrawCallback()); |
317 | 337 |
318 TestCase tests[] = { | 338 TestCase tests[] = { |
319 { | 339 { |
320 root_surface_id, | 340 root_surface_id, |
321 gfx::Point(10, 10), | 341 gfx::Point(10, 10), |
322 root_surface_id, | 342 root_surface_id, |
323 gfx::Point(10, 10) | 343 gfx::Point(10, 10) |
324 }, | 344 }, |
325 { | 345 { |
326 root_surface_id, | 346 root_surface_id, |
(...skipping 22 matching lines...) Expand all Loading... |
349 { | 369 { |
350 root_surface_id, | 370 root_surface_id, |
351 gfx::Point(290, 290), | 371 gfx::Point(290, 290), |
352 root_surface_id, | 372 root_surface_id, |
353 gfx::Point(290, 290) | 373 gfx::Point(290, 290) |
354 } | 374 } |
355 }; | 375 }; |
356 | 376 |
357 RunTests(nullptr, &manager, tests, arraysize(tests)); | 377 RunTests(nullptr, &manager, tests, arraysize(tests)); |
358 | 378 |
359 factory.Destroy(root_surface_id); | 379 root_factory.Destroy(root_surface_id); |
360 factory.Destroy(child_surface_id); | 380 child_factory.Destroy(child_surface_id); |
361 } | 381 } |
362 | 382 |
363 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { | 383 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { |
364 SurfaceManager manager; | 384 SurfaceManager manager; |
365 EmptySurfaceFactoryClient client; | 385 EmptySurfaceFactoryClient client; |
366 SurfaceFactory factory(&manager, &client); | 386 SurfaceFactory factory(kArbitraryFrameSinkId, &manager, &client); |
367 | 387 |
368 // Create a CompostiorFrame with two RenderPasses. | 388 // Create a CompostiorFrame with two RenderPasses. |
369 gfx::Rect root_rect(300, 300); | 389 gfx::Rect root_rect(300, 300); |
370 RenderPassList render_pass_list; | 390 RenderPassList render_pass_list; |
371 | 391 |
372 // Create a child RenderPass. | 392 // Create a child RenderPass. |
373 RenderPassId child_render_pass_id(1, 3); | 393 RenderPassId child_render_pass_id(1, 3); |
374 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, | 394 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, |
375 0.0f, 1.0f, 0.0f, 50.0f, | 395 0.0f, 1.0f, 0.0f, 50.0f, |
376 0.0f, 0.0f, 1.0f, 0.0f, | 396 0.0f, 0.0f, 1.0f, 0.0f, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 } | 478 } |
459 }; | 479 }; |
460 | 480 |
461 RunTests(nullptr, &manager, tests, arraysize(tests)); | 481 RunTests(nullptr, &manager, tests, arraysize(tests)); |
462 | 482 |
463 factory.Destroy(root_surface_id); | 483 factory.Destroy(root_surface_id); |
464 } | 484 } |
465 | 485 |
466 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { | 486 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { |
467 SurfaceManager manager; | 487 SurfaceManager manager; |
468 EmptySurfaceFactoryClient client; | 488 |
469 SurfaceFactory factory(&manager, &client); | 489 // Set up root FrameSink. |
| 490 EmptySurfaceFactoryClient root_client; |
| 491 FrameSinkId root_frame_sink_id(1, 1); |
| 492 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); |
| 493 |
| 494 // Set up child FrameSink. |
| 495 EmptySurfaceFactoryClient child_client; |
| 496 FrameSinkId child_frame_sink_id(2, 2); |
| 497 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); |
470 | 498 |
471 // Creates a root surface. | 499 // Creates a root surface. |
472 gfx::Rect root_rect(300, 300); | 500 gfx::Rect root_rect(300, 300); |
473 RenderPass* root_pass = nullptr; | 501 RenderPass* root_pass = nullptr; |
474 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); | 502 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); |
475 | 503 |
476 // Add a reference to the child surface on the root surface. | 504 // Add a reference to the child surface on the root surface. |
477 SurfaceIdAllocator child_allocator(FrameSinkId(3, 3)); | 505 SurfaceIdAllocator child_allocator(child_frame_sink_id); |
478 SurfaceId child_surface_id = child_allocator.GenerateId(); | 506 SurfaceId child_surface_id = child_allocator.GenerateId(); |
479 gfx::Rect child_rect(200, 200); | 507 gfx::Rect child_rect(200, 200); |
480 CreateSurfaceDrawQuad( | 508 CreateSurfaceDrawQuad( |
481 root_pass, | 509 root_pass, |
482 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, | 510 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, |
483 0.0f, 1.0f, 0.0f, 50.0f, | 511 0.0f, 1.0f, 0.0f, 50.0f, |
484 0.0f, 0.0f, 1.0f, 0.0f, | 512 0.0f, 0.0f, 1.0f, 0.0f, |
485 0.0f, 0.0f, 0.0f, 1.0f), | 513 0.0f, 0.0f, 0.0f, 1.0f), |
486 root_rect, child_rect, child_surface_id); | 514 root_rect, child_rect, child_surface_id); |
487 | 515 |
488 // Submit the root frame. | 516 // Submit the root frame. |
489 SurfaceIdAllocator root_allocator(FrameSinkId(2, 2)); | 517 SurfaceIdAllocator root_allocator(root_frame_sink_id); |
490 SurfaceId root_surface_id = root_allocator.GenerateId(); | 518 SurfaceId root_surface_id = root_allocator.GenerateId(); |
491 factory.Create(root_surface_id); | 519 root_factory.Create(root_surface_id); |
492 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 520 root_factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
493 SurfaceFactory::DrawCallback()); | 521 SurfaceFactory::DrawCallback()); |
494 | 522 |
495 // Creates a child surface. | 523 // Creates a child surface. |
496 RenderPass* child_pass = nullptr; | 524 RenderPass* child_pass = nullptr; |
497 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); | 525 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); |
498 | 526 |
499 // Add a solid quad in the child surface. | 527 // Add a solid quad in the child surface. |
500 gfx::Rect child_solid_quad_rect(190, 190); | 528 gfx::Rect child_solid_quad_rect(190, 190); |
501 CreateSolidColorDrawQuad( | 529 CreateSolidColorDrawQuad( |
502 child_pass, | 530 child_pass, |
503 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, | 531 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, |
504 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), | 532 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), |
505 root_rect, child_solid_quad_rect); | 533 root_rect, child_solid_quad_rect); |
506 | 534 |
507 // Submit the frame. | 535 // Submit the frame. |
508 factory.Create(child_surface_id); | 536 child_factory.Create(child_surface_id); |
509 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 537 child_factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
510 SurfaceFactory::DrawCallback()); | 538 SurfaceFactory::DrawCallback()); |
511 | 539 |
512 TestCase test_expectations_without_insets[] = { | 540 TestCase test_expectations_without_insets[] = { |
513 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, | 541 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, |
514 {root_surface_id, gfx::Point(60, 60), child_surface_id, | 542 {root_surface_id, gfx::Point(60, 60), child_surface_id, |
515 gfx::Point(10, 10)}, | 543 gfx::Point(10, 10)}, |
516 {root_surface_id, gfx::Point(239, 239), child_surface_id, | 544 {root_surface_id, gfx::Point(239, 239), child_surface_id, |
517 gfx::Point(189, 189)}, | 545 gfx::Point(189, 189)}, |
518 {root_surface_id, gfx::Point(244, 244), child_surface_id, | 546 {root_surface_id, gfx::Point(244, 244), child_surface_id, |
519 gfx::Point(194, 194)}, | 547 gfx::Point(194, 194)}, |
520 {root_surface_id, gfx::Point(50, 50), root_surface_id, | 548 {root_surface_id, gfx::Point(50, 50), root_surface_id, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 TestSurfaceHittestDelegate accept_delegate; | 607 TestSurfaceHittestDelegate accept_delegate; |
580 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, | 608 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, |
581 gfx::Insets(5, 5, 5, 5)); | 609 gfx::Insets(5, 5, 5, 5)); |
582 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, | 610 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, |
583 arraysize(test_expectations_with_accept_insets)); | 611 arraysize(test_expectations_with_accept_insets)); |
584 | 612 |
585 // Verify that insets have affected hit targeting. | 613 // Verify that insets have affected hit targeting. |
586 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); | 614 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); |
587 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); | 615 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); |
588 | 616 |
589 factory.Destroy(root_surface_id); | 617 root_factory.Destroy(root_surface_id); |
| 618 child_factory.Destroy(child_surface_id); |
590 } | 619 } |
591 | 620 |
592 } // namespace cc | 621 } // namespace cc |
OLD | NEW |