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

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

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