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

Side by Side Diff: cc/surfaces/surface_hittest_unittest.cc

Issue 2098953003: Make cc::CompositorFrames movable [Part 2 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed exo unittests Created 4 years, 5 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 | « cc/surfaces/surface_hittest.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('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 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 CreateSurfaceDrawQuad(root_pass, 74 CreateSurfaceDrawQuad(root_pass,
75 gfx::Transform(), 75 gfx::Transform(),
76 root_rect, 76 root_rect,
77 child_rect, 77 child_rect,
78 child_surface_id); 78 child_surface_id);
79 79
80 // Submit the root frame. 80 // Submit the root frame.
81 SurfaceIdAllocator root_allocator(2); 81 SurfaceIdAllocator root_allocator(2);
82 SurfaceId root_surface_id = root_allocator.GenerateId(); 82 SurfaceId root_surface_id = root_allocator.GenerateId();
83 factory.Create(root_surface_id); 83 factory.Create(root_surface_id);
84 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); 84 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
85 *root_frame_copy = std::move(root_frame);
86 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy),
87 SurfaceFactory::DrawCallback()); 85 SurfaceFactory::DrawCallback());
88 86
89 { 87 {
90 SurfaceHittest hittest(nullptr, &manager); 88 SurfaceHittest hittest(nullptr, &manager);
91 // It is expected this test will complete without crashes. 89 // It is expected this test will complete without crashes.
92 gfx::Transform transform; 90 gfx::Transform transform;
93 EXPECT_EQ(root_surface_id, 91 EXPECT_EQ(root_surface_id,
94 hittest.GetTargetSurfaceAtPoint( 92 hittest.GetTargetSurfaceAtPoint(
95 root_surface_id, gfx::Point(100, 100), &transform)); 93 root_surface_id, gfx::Point(100, 100), &transform));
96 } 94 }
97 95
98 factory.Destroy(root_surface_id); 96 factory.Destroy(root_surface_id);
99 } 97 }
100 98
101 TEST(SurfaceHittestTest, Hittest_SingleSurface) { 99 TEST(SurfaceHittestTest, Hittest_SingleSurface) {
102 SurfaceManager manager; 100 SurfaceManager manager;
103 EmptySurfaceFactoryClient client; 101 EmptySurfaceFactoryClient client;
104 SurfaceFactory factory(&manager, &client); 102 SurfaceFactory factory(&manager, &client);
105 103
106 // Creates a root surface. 104 // Creates a root surface.
107 gfx::Rect root_rect(300, 300); 105 gfx::Rect root_rect(300, 300);
108 RenderPass* root_pass = nullptr; 106 RenderPass* root_pass = nullptr;
109 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 107 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
110 108
111 // Submit the root frame. 109 // Submit the root frame.
112 SurfaceIdAllocator root_allocator(2); 110 SurfaceIdAllocator root_allocator(2);
113 SurfaceId root_surface_id = root_allocator.GenerateId(); 111 SurfaceId root_surface_id = root_allocator.GenerateId();
114 factory.Create(root_surface_id); 112 factory.Create(root_surface_id);
115 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); 113 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
116 *root_frame_copy = std::move(root_frame);
117 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy),
118 SurfaceFactory::DrawCallback()); 114 SurfaceFactory::DrawCallback());
119 TestCase tests[] = { 115 TestCase tests[] = {
120 { 116 {
121 root_surface_id, 117 root_surface_id,
122 gfx::Point(100, 100), 118 gfx::Point(100, 100),
123 root_surface_id, 119 root_surface_id,
124 gfx::Point(100, 100) 120 gfx::Point(100, 100)
125 }, 121 },
126 }; 122 };
127 123
(...skipping 22 matching lines...) Expand all
150 0.0f, 0.0f, 1.0f, 0.0f, 146 0.0f, 0.0f, 1.0f, 0.0f,
151 0.0f, 0.0f, 0.0f, 1.0f), 147 0.0f, 0.0f, 0.0f, 1.0f),
152 root_rect, 148 root_rect,
153 child_rect, 149 child_rect,
154 child_surface_id); 150 child_surface_id);
155 151
156 // Submit the root frame. 152 // Submit the root frame.
157 SurfaceIdAllocator root_allocator(2); 153 SurfaceIdAllocator root_allocator(2);
158 SurfaceId root_surface_id = root_allocator.GenerateId(); 154 SurfaceId root_surface_id = root_allocator.GenerateId();
159 factory.Create(root_surface_id); 155 factory.Create(root_surface_id);
160 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); 156 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
161 *root_frame_copy = std::move(root_frame);
162 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy),
163 SurfaceFactory::DrawCallback()); 157 SurfaceFactory::DrawCallback());
164 158
165 // Creates a child surface. 159 // Creates a child surface.
166 RenderPass* child_pass = nullptr; 160 RenderPass* child_pass = nullptr;
167 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 161 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
168 162
169 // Add a solid quad in the child surface. 163 // Add a solid quad in the child surface.
170 gfx::Rect child_solid_quad_rect(100, 100); 164 gfx::Rect child_solid_quad_rect(100, 100);
171 CreateSolidColorDrawQuad( 165 CreateSolidColorDrawQuad(
172 child_pass, 166 child_pass,
173 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 167 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
174 0.0f, 1.0f, 0.0f, 50.0f, 168 0.0f, 1.0f, 0.0f, 50.0f,
175 0.0f, 0.0f, 1.0f, 0.0f, 169 0.0f, 0.0f, 1.0f, 0.0f,
176 0.0f, 0.0f, 0.0f, 1.0f), 170 0.0f, 0.0f, 0.0f, 1.0f),
177 root_rect, child_solid_quad_rect); 171 root_rect, child_solid_quad_rect);
178 172
179 // Submit the frame. 173 // Submit the frame.
180 factory.Create(child_surface_id); 174 factory.Create(child_surface_id);
181 std::unique_ptr<CompositorFrame> child_frame_copy(new CompositorFrame); 175 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
182 *child_frame_copy = std::move(child_frame);
183 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame_copy),
184 SurfaceFactory::DrawCallback()); 176 SurfaceFactory::DrawCallback());
185 177
186 TestCase tests[] = { 178 TestCase tests[] = {
187 { 179 {
188 root_surface_id, 180 root_surface_id,
189 gfx::Point(10, 10), 181 gfx::Point(10, 10),
190 root_surface_id, 182 root_surface_id,
191 gfx::Point(10, 10) 183 gfx::Point(10, 10)
192 }, 184 },
193 { 185 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // Submit another root frame, with a slightly perturbed child Surface. 219 // Submit another root frame, with a slightly perturbed child Surface.
228 root_frame = CreateCompositorFrame(root_rect, &root_pass); 220 root_frame = CreateCompositorFrame(root_rect, &root_pass);
229 CreateSurfaceDrawQuad(root_pass, 221 CreateSurfaceDrawQuad(root_pass,
230 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, 222 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f,
231 0.0f, 1.0f, 0.0f, 75.0f, 223 0.0f, 1.0f, 0.0f, 75.0f,
232 0.0f, 0.0f, 1.0f, 0.0f, 224 0.0f, 0.0f, 1.0f, 0.0f,
233 0.0f, 0.0f, 0.0f, 1.0f), 225 0.0f, 0.0f, 0.0f, 1.0f),
234 root_rect, 226 root_rect,
235 child_rect, 227 child_rect,
236 child_surface_id); 228 child_surface_id);
237 root_frame_copy.reset(new CompositorFrame); 229 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
238 *root_frame_copy = std::move(root_frame);
239 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy),
240 SurfaceFactory::DrawCallback()); 230 SurfaceFactory::DrawCallback());
241 231
242 // Verify that point (100, 100) no longer falls on the child surface. 232 // Verify that point (100, 100) no longer falls on the child surface.
243 // Verify that the transform to the child surface's space has also shifted. 233 // Verify that the transform to the child surface's space has also shifted.
244 { 234 {
245 SurfaceHittest hittest(nullptr, &manager); 235 SurfaceHittest hittest(nullptr, &manager);
246 236
247 gfx::Point point(100, 100); 237 gfx::Point point(100, 100);
248 gfx::Transform transform; 238 gfx::Transform transform;
249 EXPECT_EQ(root_surface_id, 239 EXPECT_EQ(root_surface_id,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 0.0f, 0.0f, 1.0f, 0.0f, 284 0.0f, 0.0f, 1.0f, 0.0f,
295 0.0f, 0.0f, 0.0f, 1.0f), 285 0.0f, 0.0f, 0.0f, 1.0f),
296 root_rect, 286 root_rect,
297 child_rect, 287 child_rect,
298 child_surface_id); 288 child_surface_id);
299 289
300 // Submit the root frame. 290 // Submit the root frame.
301 SurfaceIdAllocator root_allocator(2); 291 SurfaceIdAllocator root_allocator(2);
302 SurfaceId root_surface_id = root_allocator.GenerateId(); 292 SurfaceId root_surface_id = root_allocator.GenerateId();
303 factory.Create(root_surface_id); 293 factory.Create(root_surface_id);
304 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); 294 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
305 *root_frame_copy = std::move(root_frame);
306 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy),
307 SurfaceFactory::DrawCallback()); 295 SurfaceFactory::DrawCallback());
308 296
309 // Creates a child surface. 297 // Creates a child surface.
310 RenderPass* child_pass = nullptr; 298 RenderPass* child_pass = nullptr;
311 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 299 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
312 300
313 // Add a solid quad in the child surface. 301 // Add a solid quad in the child surface.
314 gfx::Rect child_solid_quad_rect(100, 100); 302 gfx::Rect child_solid_quad_rect(100, 100);
315 CreateSolidColorDrawQuad(child_pass, 303 CreateSolidColorDrawQuad(child_pass,
316 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 304 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
317 0.0f, 1.0f, 0.0f, 50.0f, 305 0.0f, 1.0f, 0.0f, 50.0f,
318 0.0f, 0.0f, 1.0f, 0.0f, 306 0.0f, 0.0f, 1.0f, 0.0f,
319 0.0f, 0.0f, 0.0f, 1.0f), 307 0.0f, 0.0f, 0.0f, 1.0f),
320 root_rect, 308 root_rect,
321 child_solid_quad_rect); 309 child_solid_quad_rect);
322 310
323 // Submit the frame. 311 // Submit the frame.
324 factory.Create(child_surface_id); 312 factory.Create(child_surface_id);
325 std::unique_ptr<CompositorFrame> child_frame_copy(new CompositorFrame); 313 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
326 *child_frame_copy = std::move(child_frame);
327 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame_copy),
328 SurfaceFactory::DrawCallback()); 314 SurfaceFactory::DrawCallback());
329 315
330 TestCase tests[] = { 316 TestCase tests[] = {
331 { 317 {
332 root_surface_id, 318 root_surface_id,
333 gfx::Point(10, 10), 319 gfx::Point(10, 10),
334 root_surface_id, 320 root_surface_id,
335 gfx::Point(10, 10) 321 gfx::Point(10, 10)
336 }, 322 },
337 { 323 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 gfx::Rect child_solid_quad_rect(100, 100); 402 gfx::Rect child_solid_quad_rect(100, 100);
417 CreateSolidColorDrawQuad(child_render_pass, 403 CreateSolidColorDrawQuad(child_render_pass,
418 gfx::Transform(), 404 gfx::Transform(),
419 gfx::Rect(100, 100), 405 gfx::Rect(100, 100),
420 child_solid_quad_rect); 406 child_solid_quad_rect);
421 407
422 // Submit the root frame. 408 // Submit the root frame.
423 SurfaceIdAllocator root_allocator(1); 409 SurfaceIdAllocator root_allocator(1);
424 SurfaceId root_surface_id = root_allocator.GenerateId(); 410 SurfaceId root_surface_id = root_allocator.GenerateId();
425 factory.Create(root_surface_id); 411 factory.Create(root_surface_id);
426 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); 412 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
427 *root_frame_copy = std::move(root_frame);
428 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy),
429 SurfaceFactory::DrawCallback()); 413 SurfaceFactory::DrawCallback());
430 414
431 TestCase tests[] = { 415 TestCase tests[] = {
432 // These tests just miss the RenderPassDrawQuad. 416 // These tests just miss the RenderPassDrawQuad.
433 { 417 {
434 root_surface_id, 418 root_surface_id,
435 gfx::Point(49, 49), 419 gfx::Point(49, 49),
436 root_surface_id, 420 root_surface_id,
437 gfx::Point(49, 49) 421 gfx::Point(49, 49)
438 }, 422 },
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 480 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
497 0.0f, 1.0f, 0.0f, 50.0f, 481 0.0f, 1.0f, 0.0f, 50.0f,
498 0.0f, 0.0f, 1.0f, 0.0f, 482 0.0f, 0.0f, 1.0f, 0.0f,
499 0.0f, 0.0f, 0.0f, 1.0f), 483 0.0f, 0.0f, 0.0f, 1.0f),
500 root_rect, child_rect, child_surface_id); 484 root_rect, child_rect, child_surface_id);
501 485
502 // Submit the root frame. 486 // Submit the root frame.
503 SurfaceIdAllocator root_allocator(2); 487 SurfaceIdAllocator root_allocator(2);
504 SurfaceId root_surface_id = root_allocator.GenerateId(); 488 SurfaceId root_surface_id = root_allocator.GenerateId();
505 factory.Create(root_surface_id); 489 factory.Create(root_surface_id);
506 std::unique_ptr<CompositorFrame> root_frame_copy(new CompositorFrame); 490 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
507 *root_frame_copy = std::move(root_frame);
508 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame_copy),
509 SurfaceFactory::DrawCallback()); 491 SurfaceFactory::DrawCallback());
510 492
511 // Creates a child surface. 493 // Creates a child surface.
512 RenderPass* child_pass = nullptr; 494 RenderPass* child_pass = nullptr;
513 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 495 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
514 496
515 // Add a solid quad in the child surface. 497 // Add a solid quad in the child surface.
516 gfx::Rect child_solid_quad_rect(190, 190); 498 gfx::Rect child_solid_quad_rect(190, 190);
517 CreateSolidColorDrawQuad( 499 CreateSolidColorDrawQuad(
518 child_pass, 500 child_pass,
519 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, 501 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f,
520 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), 502 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
521 root_rect, child_solid_quad_rect); 503 root_rect, child_solid_quad_rect);
522 504
523 // Submit the frame. 505 // Submit the frame.
524 factory.Create(child_surface_id); 506 factory.Create(child_surface_id);
525 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame); 507 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
526 *frame_copy = std::move(child_frame);
527 factory.SubmitCompositorFrame(child_surface_id, std::move(frame_copy),
528 SurfaceFactory::DrawCallback()); 508 SurfaceFactory::DrawCallback());
529 509
530 TestCase test_expectations_without_insets[] = { 510 TestCase test_expectations_without_insets[] = {
531 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, 511 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
532 {root_surface_id, gfx::Point(60, 60), child_surface_id, 512 {root_surface_id, gfx::Point(60, 60), child_surface_id,
533 gfx::Point(10, 10)}, 513 gfx::Point(10, 10)},
534 {root_surface_id, gfx::Point(239, 239), child_surface_id, 514 {root_surface_id, gfx::Point(239, 239), child_surface_id,
535 gfx::Point(189, 189)}, 515 gfx::Point(189, 189)},
536 {root_surface_id, gfx::Point(244, 244), child_surface_id, 516 {root_surface_id, gfx::Point(244, 244), child_surface_id,
537 gfx::Point(194, 194)}, 517 gfx::Point(194, 194)},
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 arraysize(test_expectations_with_accept_insets)); 581 arraysize(test_expectations_with_accept_insets));
602 582
603 // Verify that insets have affected hit targeting. 583 // Verify that insets have affected hit targeting.
604 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); 584 EXPECT_EQ(0, accept_delegate.reject_target_overrides());
605 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); 585 EXPECT_EQ(2, accept_delegate.accept_target_overrides());
606 586
607 factory.Destroy(root_surface_id); 587 factory.Destroy(root_surface_id);
608 } 588 }
609 589
610 } // namespace cc 590 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_hittest.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698