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

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

Issue 1455023002: cc: Replace Pass() with std::move() in some subdirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-cc
Patch Set: pass-cc2: . Created 5 years, 1 month 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_factory_unittest.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 "cc/output/compositor_frame.h" 5 #include "cc/output/compositor_frame.h"
6 #include "cc/surfaces/surface.h" 6 #include "cc/surfaces/surface.h"
7 #include "cc/surfaces/surface_factory.h" 7 #include "cc/surfaces/surface_factory.h"
8 #include "cc/surfaces/surface_factory_client.h" 8 #include "cc/surfaces/surface_factory_client.h"
9 #include "cc/surfaces/surface_hittest.h" 9 #include "cc/surfaces/surface_hittest.h"
10 #include "cc/surfaces/surface_id_allocator.h" 10 #include "cc/surfaces/surface_id_allocator.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 CreateSurfaceDrawQuad(root_pass, 72 CreateSurfaceDrawQuad(root_pass,
73 gfx::Transform(), 73 gfx::Transform(),
74 root_rect, 74 root_rect,
75 child_rect, 75 child_rect,
76 child_surface_id); 76 child_surface_id);
77 77
78 // Submit the root frame. 78 // Submit the root frame.
79 SurfaceIdAllocator root_allocator(2); 79 SurfaceIdAllocator root_allocator(2);
80 SurfaceId root_surface_id = root_allocator.GenerateId(); 80 SurfaceId root_surface_id = root_allocator.GenerateId();
81 factory.Create(root_surface_id); 81 factory.Create(root_surface_id);
82 factory.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), 82 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
83 SurfaceFactory::DrawCallback()); 83 SurfaceFactory::DrawCallback());
84 84
85 { 85 {
86 SurfaceHittest hittest(&manager); 86 SurfaceHittest hittest(&manager);
87 // It is expected this test will complete without crashes. 87 // It is expected this test will complete without crashes.
88 gfx::Transform transform; 88 gfx::Transform transform;
89 EXPECT_EQ(root_surface_id, 89 EXPECT_EQ(root_surface_id,
90 hittest.GetTargetSurfaceAtPoint( 90 hittest.GetTargetSurfaceAtPoint(
91 root_surface_id, gfx::Point(100, 100), &transform)); 91 root_surface_id, gfx::Point(100, 100), &transform));
92 } 92 }
93 93
94 factory.Destroy(root_surface_id); 94 factory.Destroy(root_surface_id);
95 } 95 }
96 96
97 TEST(SurfaceHittestTest, Hittest_SingleSurface) { 97 TEST(SurfaceHittestTest, Hittest_SingleSurface) {
98 SurfaceManager manager; 98 SurfaceManager manager;
99 EmptySurfaceFactoryClient client; 99 EmptySurfaceFactoryClient client;
100 SurfaceFactory factory(&manager, &client); 100 SurfaceFactory factory(&manager, &client);
101 101
102 // Creates a root surface. 102 // Creates a root surface.
103 gfx::Rect root_rect(300, 300); 103 gfx::Rect root_rect(300, 300);
104 RenderPass* root_pass = nullptr; 104 RenderPass* root_pass = nullptr;
105 scoped_ptr<CompositorFrame> root_frame = 105 scoped_ptr<CompositorFrame> root_frame =
106 CreateCompositorFrame(root_rect, &root_pass); 106 CreateCompositorFrame(root_rect, &root_pass);
107 107
108 // Submit the root frame. 108 // Submit the root frame.
109 SurfaceIdAllocator root_allocator(2); 109 SurfaceIdAllocator root_allocator(2);
110 SurfaceId root_surface_id = root_allocator.GenerateId(); 110 SurfaceId root_surface_id = root_allocator.GenerateId();
111 factory.Create(root_surface_id); 111 factory.Create(root_surface_id);
112 factory.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), 112 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
113 SurfaceFactory::DrawCallback()); 113 SurfaceFactory::DrawCallback());
114 TestCase tests[] = { 114 TestCase tests[] = {
115 { 115 {
116 root_surface_id, 116 root_surface_id,
117 gfx::Point(100, 100), 117 gfx::Point(100, 100),
118 root_surface_id, 118 root_surface_id,
119 gfx::Point(100, 100) 119 gfx::Point(100, 100)
120 }, 120 },
121 }; 121 };
122 122
(...skipping 23 matching lines...) Expand all
146 0.0f, 0.0f, 1.0f, 0.0f, 146 0.0f, 0.0f, 1.0f, 0.0f,
147 0.0f, 0.0f, 0.0f, 1.0f), 147 0.0f, 0.0f, 0.0f, 1.0f),
148 root_rect, 148 root_rect,
149 child_rect, 149 child_rect,
150 child_surface_id); 150 child_surface_id);
151 151
152 // Submit the root frame. 152 // Submit the root frame.
153 SurfaceIdAllocator root_allocator(2); 153 SurfaceIdAllocator root_allocator(2);
154 SurfaceId root_surface_id = root_allocator.GenerateId(); 154 SurfaceId root_surface_id = root_allocator.GenerateId();
155 factory.Create(root_surface_id); 155 factory.Create(root_surface_id);
156 factory.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), 156 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
157 SurfaceFactory::DrawCallback()); 157 SurfaceFactory::DrawCallback());
158 158
159 // Creates a child surface. 159 // Creates a child surface.
160 RenderPass* child_pass = nullptr; 160 RenderPass* child_pass = nullptr;
161 scoped_ptr<CompositorFrame> child_frame = 161 scoped_ptr<CompositorFrame> child_frame =
162 CreateCompositorFrame(child_rect, &child_pass); 162 CreateCompositorFrame(child_rect, &child_pass);
163 163
164 // Add a solid quad in the child surface. 164 // Add a solid quad in the child surface.
165 gfx::Rect child_solid_quad_rect(100, 100); 165 gfx::Rect child_solid_quad_rect(100, 100);
166 CreateSolidColorDrawQuad( 166 CreateSolidColorDrawQuad(
167 child_pass, 167 child_pass,
168 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 168 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
169 0.0f, 1.0f, 0.0f, 50.0f, 169 0.0f, 1.0f, 0.0f, 50.0f,
170 0.0f, 0.0f, 1.0f, 0.0f, 170 0.0f, 0.0f, 1.0f, 0.0f,
171 0.0f, 0.0f, 0.0f, 1.0f), 171 0.0f, 0.0f, 0.0f, 1.0f),
172 root_rect, child_solid_quad_rect); 172 root_rect, child_solid_quad_rect);
173 173
174 // Submit the frame. 174 // Submit the frame.
175 factory.Create(child_surface_id); 175 factory.Create(child_surface_id);
176 factory.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), 176 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
177 SurfaceFactory::DrawCallback()); 177 SurfaceFactory::DrawCallback());
178 178
179 TestCase tests[] = { 179 TestCase tests[] = {
180 { 180 {
181 root_surface_id, 181 root_surface_id,
182 gfx::Point(10, 10), 182 gfx::Point(10, 10),
183 root_surface_id, 183 root_surface_id,
184 gfx::Point(10, 10) 184 gfx::Point(10, 10)
185 }, 185 },
186 { 186 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Submit another root frame, with a slightly perturbed child Surface. 220 // Submit another root frame, with a slightly perturbed child Surface.
221 root_frame = CreateCompositorFrame(root_rect, &root_pass); 221 root_frame = CreateCompositorFrame(root_rect, &root_pass);
222 CreateSurfaceDrawQuad(root_pass, 222 CreateSurfaceDrawQuad(root_pass,
223 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, 223 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f,
224 0.0f, 1.0f, 0.0f, 75.0f, 224 0.0f, 1.0f, 0.0f, 75.0f,
225 0.0f, 0.0f, 1.0f, 0.0f, 225 0.0f, 0.0f, 1.0f, 0.0f,
226 0.0f, 0.0f, 0.0f, 1.0f), 226 0.0f, 0.0f, 0.0f, 1.0f),
227 root_rect, 227 root_rect,
228 child_rect, 228 child_rect,
229 child_surface_id); 229 child_surface_id);
230 factory.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), 230 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
231 SurfaceFactory::DrawCallback()); 231 SurfaceFactory::DrawCallback());
232 232
233 // Verify that point (100, 100) no longer falls on the child surface. 233 // Verify that point (100, 100) no longer falls on the child surface.
234 // Verify that the transform to the child surface's space has also shifted. 234 // Verify that the transform to the child surface's space has also shifted.
235 { 235 {
236 SurfaceHittest hittest(&manager); 236 SurfaceHittest hittest(&manager);
237 237
238 gfx::Point point(100, 100); 238 gfx::Point point(100, 100);
239 gfx::Transform transform; 239 gfx::Transform transform;
240 EXPECT_EQ(root_surface_id, 240 EXPECT_EQ(root_surface_id,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 0.0f, 0.0f, 1.0f, 0.0f, 286 0.0f, 0.0f, 1.0f, 0.0f,
287 0.0f, 0.0f, 0.0f, 1.0f), 287 0.0f, 0.0f, 0.0f, 1.0f),
288 root_rect, 288 root_rect,
289 child_rect, 289 child_rect,
290 child_surface_id); 290 child_surface_id);
291 291
292 // Submit the root frame. 292 // Submit the root frame.
293 SurfaceIdAllocator root_allocator(2); 293 SurfaceIdAllocator root_allocator(2);
294 SurfaceId root_surface_id = root_allocator.GenerateId(); 294 SurfaceId root_surface_id = root_allocator.GenerateId();
295 factory.Create(root_surface_id); 295 factory.Create(root_surface_id);
296 factory.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), 296 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
297 SurfaceFactory::DrawCallback()); 297 SurfaceFactory::DrawCallback());
298 298
299 // Creates a child surface. 299 // Creates a child surface.
300 RenderPass* child_pass = nullptr; 300 RenderPass* child_pass = nullptr;
301 scoped_ptr<CompositorFrame> child_frame = 301 scoped_ptr<CompositorFrame> child_frame =
302 CreateCompositorFrame(child_rect, &child_pass); 302 CreateCompositorFrame(child_rect, &child_pass);
303 303
304 // Add a solid quad in the child surface. 304 // Add a solid quad in the child surface.
305 gfx::Rect child_solid_quad_rect(100, 100); 305 gfx::Rect child_solid_quad_rect(100, 100);
306 CreateSolidColorDrawQuad(child_pass, 306 CreateSolidColorDrawQuad(child_pass,
307 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 307 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
308 0.0f, 1.0f, 0.0f, 50.0f, 308 0.0f, 1.0f, 0.0f, 50.0f,
309 0.0f, 0.0f, 1.0f, 0.0f, 309 0.0f, 0.0f, 1.0f, 0.0f,
310 0.0f, 0.0f, 0.0f, 1.0f), 310 0.0f, 0.0f, 0.0f, 1.0f),
311 root_rect, 311 root_rect,
312 child_solid_quad_rect); 312 child_solid_quad_rect);
313 313
314 // Submit the frame. 314 // Submit the frame.
315 factory.Create(child_surface_id); 315 factory.Create(child_surface_id);
316 factory.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), 316 factory.SubmitCompositorFrame(child_surface_id, std::move(child_frame),
317 SurfaceFactory::DrawCallback()); 317 SurfaceFactory::DrawCallback());
318 318
319 TestCase tests[] = { 319 TestCase tests[] = {
320 { 320 {
321 root_surface_id, 321 root_surface_id,
322 gfx::Point(10, 10), 322 gfx::Point(10, 10),
323 root_surface_id, 323 root_surface_id,
324 gfx::Point(10, 10) 324 gfx::Point(10, 10)
325 }, 325 },
326 { 326 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 gfx::Rect child_solid_quad_rect(100, 100); 405 gfx::Rect child_solid_quad_rect(100, 100);
406 CreateSolidColorDrawQuad(child_render_pass, 406 CreateSolidColorDrawQuad(child_render_pass,
407 gfx::Transform(), 407 gfx::Transform(),
408 gfx::Rect(100, 100), 408 gfx::Rect(100, 100),
409 child_solid_quad_rect); 409 child_solid_quad_rect);
410 410
411 // Submit the root frame. 411 // Submit the root frame.
412 SurfaceIdAllocator root_allocator(1); 412 SurfaceIdAllocator root_allocator(1);
413 SurfaceId root_surface_id = root_allocator.GenerateId(); 413 SurfaceId root_surface_id = root_allocator.GenerateId();
414 factory.Create(root_surface_id); 414 factory.Create(root_surface_id);
415 factory.SubmitCompositorFrame(root_surface_id, root_frame.Pass(), 415 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
416 SurfaceFactory::DrawCallback()); 416 SurfaceFactory::DrawCallback());
417 417
418 TestCase tests[] = { 418 TestCase tests[] = {
419 // These tests just miss the RenderPassDrawQuad. 419 // These tests just miss the RenderPassDrawQuad.
420 { 420 {
421 root_surface_id, 421 root_surface_id,
422 gfx::Point(49, 49), 422 gfx::Point(49, 49),
423 root_surface_id, 423 root_surface_id,
424 gfx::Point(49, 49) 424 gfx::Point(49, 49)
425 }, 425 },
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 gfx::Point(100, 100) 458 gfx::Point(100, 100)
459 } 459 }
460 }; 460 };
461 461
462 RunTests(&manager, tests, arraysize(tests)); 462 RunTests(&manager, tests, arraysize(tests));
463 463
464 factory.Destroy(root_surface_id); 464 factory.Destroy(root_surface_id);
465 } 465 }
466 466
467 } // namespace cc 467 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory_unittest.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698