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

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

Issue 2708153005: Rename SurfaceIdAllocator to LocalSurfaceIdAllocator (Closed)
Patch Set: Created 3 years, 10 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
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/local_surface_id_allocator.h"
8 #include "cc/surfaces/surface.h" 9 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_factory.h" 10 #include "cc/surfaces/surface_factory.h"
10 #include "cc/surfaces/surface_factory_client.h" 11 #include "cc/surfaces/surface_factory_client.h"
11 #include "cc/surfaces/surface_hittest.h" 12 #include "cc/surfaces/surface_hittest.h"
12 #include "cc/surfaces/surface_id_allocator.h"
13 #include "cc/surfaces/surface_manager.h" 13 #include "cc/surfaces/surface_manager.h"
14 #include "cc/test/surface_hittest_test_helpers.h" 14 #include "cc/test/surface_hittest_test_helpers.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
17 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 namespace { 21 namespace {
22 22
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 kArbitraryFrameSinkId, 76 kArbitraryFrameSinkId,
77 LocalSurfaceId(0xdeadbeef, base::UnguessableToken::Create())); 77 LocalSurfaceId(0xdeadbeef, base::UnguessableToken::Create()));
78 gfx::Rect child_rect(200, 200); 78 gfx::Rect child_rect(200, 200);
79 CreateSurfaceDrawQuad(root_pass, 79 CreateSurfaceDrawQuad(root_pass,
80 gfx::Transform(), 80 gfx::Transform(),
81 root_rect, 81 root_rect,
82 child_rect, 82 child_rect,
83 child_surface_id); 83 child_surface_id);
84 84
85 // Submit the root frame. 85 // Submit the root frame.
86 SurfaceIdAllocator root_allocator; 86 LocalSurfaceIdAllocator root_allocator;
87 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 87 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
88 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 88 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
89 root_factory.SubmitCompositorFrame(root_local_surface_id, 89 root_factory.SubmitCompositorFrame(root_local_surface_id,
90 std::move(root_frame), 90 std::move(root_frame),
91 SurfaceFactory::DrawCallback()); 91 SurfaceFactory::DrawCallback());
92 92
93 { 93 {
94 SurfaceHittest hittest(nullptr, &manager); 94 SurfaceHittest hittest(nullptr, &manager);
95 // It is expected this test will complete without crashes. 95 // It is expected this test will complete without crashes.
96 gfx::Transform transform; 96 gfx::Transform transform;
(...skipping 12 matching lines...) Expand all
109 EmptySurfaceFactoryClient root_client; 109 EmptySurfaceFactoryClient root_client;
110 FrameSinkId root_frame_sink_id(1, 1); 110 FrameSinkId root_frame_sink_id(1, 1);
111 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 111 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client);
112 112
113 // Creates a root surface. 113 // Creates a root surface.
114 gfx::Rect root_rect(300, 300); 114 gfx::Rect root_rect(300, 300);
115 RenderPass* root_pass = nullptr; 115 RenderPass* root_pass = nullptr;
116 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 116 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
117 117
118 // Submit the root frame. 118 // Submit the root frame.
119 SurfaceIdAllocator root_allocator; 119 LocalSurfaceIdAllocator root_allocator;
120 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 120 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
121 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 121 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
122 root_factory.SubmitCompositorFrame(root_local_surface_id, 122 root_factory.SubmitCompositorFrame(root_local_surface_id,
123 std::move(root_frame), 123 std::move(root_frame),
124 SurfaceFactory::DrawCallback()); 124 SurfaceFactory::DrawCallback());
125 TestCase tests[] = { 125 TestCase tests[] = {
126 { 126 {
127 root_surface_id, 127 root_surface_id,
128 gfx::Point(100, 100), 128 gfx::Point(100, 100),
129 root_surface_id, 129 root_surface_id,
(...skipping 18 matching lines...) Expand all
148 EmptySurfaceFactoryClient child_client; 148 EmptySurfaceFactoryClient child_client;
149 FrameSinkId child_frame_sink_id(2, 2); 149 FrameSinkId child_frame_sink_id(2, 2);
150 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 150 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
151 151
152 // Creates a root surface. 152 // Creates a root surface.
153 gfx::Rect root_rect(300, 300); 153 gfx::Rect root_rect(300, 300);
154 RenderPass* root_pass = nullptr; 154 RenderPass* root_pass = nullptr;
155 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 155 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
156 156
157 // Add a reference to the child surface on the root surface. 157 // Add a reference to the child surface on the root surface.
158 SurfaceIdAllocator child_allocator; 158 LocalSurfaceIdAllocator child_allocator;
159 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 159 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
160 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 160 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
161 gfx::Rect child_rect(200, 200); 161 gfx::Rect child_rect(200, 200);
162 CreateSurfaceDrawQuad(root_pass, 162 CreateSurfaceDrawQuad(root_pass,
163 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 163 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
164 0.0f, 1.0f, 0.0f, 50.0f, 164 0.0f, 1.0f, 0.0f, 50.0f,
165 0.0f, 0.0f, 1.0f, 0.0f, 165 0.0f, 0.0f, 1.0f, 0.0f,
166 0.0f, 0.0f, 0.0f, 1.0f), 166 0.0f, 0.0f, 0.0f, 1.0f),
167 root_rect, 167 root_rect,
168 child_rect, 168 child_rect,
169 child_surface_id); 169 child_surface_id);
170 170
171 // Submit the root frame. 171 // Submit the root frame.
172 SurfaceIdAllocator root_allocator; 172 LocalSurfaceIdAllocator root_allocator;
173 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 173 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
174 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 174 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
175 root_factory.SubmitCompositorFrame(root_local_surface_id, 175 root_factory.SubmitCompositorFrame(root_local_surface_id,
176 std::move(root_frame), 176 std::move(root_frame),
177 SurfaceFactory::DrawCallback()); 177 SurfaceFactory::DrawCallback());
178 178
179 // Creates a child surface. 179 // Creates a child surface.
180 RenderPass* child_pass = nullptr; 180 RenderPass* child_pass = nullptr;
181 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 181 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
182 182
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 gfx::Rect root_rect(300, 300); 295 gfx::Rect root_rect(300, 300);
296 RenderPass* root_pass = nullptr; 296 RenderPass* root_pass = nullptr;
297 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 297 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
298 298
299 // Create a RenderPassDrawQuad to a non-existant RenderPass. 299 // Create a RenderPassDrawQuad to a non-existant RenderPass.
300 int invalid_render_pass_id = 1337; 300 int invalid_render_pass_id = 1337;
301 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect, 301 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect,
302 invalid_render_pass_id); 302 invalid_render_pass_id);
303 303
304 // Add a reference to the child surface on the root surface. 304 // Add a reference to the child surface on the root surface.
305 SurfaceIdAllocator child_allocator; 305 LocalSurfaceIdAllocator child_allocator;
306 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 306 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
307 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 307 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
308 gfx::Rect child_rect(200, 200); 308 gfx::Rect child_rect(200, 200);
309 CreateSurfaceDrawQuad(root_pass, 309 CreateSurfaceDrawQuad(root_pass,
310 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 310 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
311 0.0f, 1.0f, 0.0f, 50.0f, 311 0.0f, 1.0f, 0.0f, 50.0f,
312 0.0f, 0.0f, 1.0f, 0.0f, 312 0.0f, 0.0f, 1.0f, 0.0f,
313 0.0f, 0.0f, 0.0f, 1.0f), 313 0.0f, 0.0f, 0.0f, 1.0f),
314 root_rect, 314 root_rect,
315 child_rect, 315 child_rect,
316 child_surface_id); 316 child_surface_id);
317 317
318 // Submit the root frame. 318 // Submit the root frame.
319 SurfaceIdAllocator root_allocator; 319 LocalSurfaceIdAllocator root_allocator;
320 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 320 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
321 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 321 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
322 root_factory.SubmitCompositorFrame(root_local_surface_id, 322 root_factory.SubmitCompositorFrame(root_local_surface_id,
323 std::move(root_frame), 323 std::move(root_frame),
324 SurfaceFactory::DrawCallback()); 324 SurfaceFactory::DrawCallback());
325 325
326 // Creates a child surface. 326 // Creates a child surface.
327 RenderPass* child_pass = nullptr; 327 RenderPass* child_pass = nullptr;
328 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 328 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
329 329
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 427
428 // Add a solid quad in the child render pass. 428 // Add a solid quad in the child render pass.
429 RenderPass* child_render_pass = root_frame.render_pass_list.front().get(); 429 RenderPass* child_render_pass = root_frame.render_pass_list.front().get();
430 gfx::Rect child_solid_quad_rect(100, 100); 430 gfx::Rect child_solid_quad_rect(100, 100);
431 CreateSolidColorDrawQuad(child_render_pass, 431 CreateSolidColorDrawQuad(child_render_pass,
432 gfx::Transform(), 432 gfx::Transform(),
433 gfx::Rect(100, 100), 433 gfx::Rect(100, 100),
434 child_solid_quad_rect); 434 child_solid_quad_rect);
435 435
436 // Submit the root frame. 436 // Submit the root frame.
437 SurfaceIdAllocator root_allocator; 437 LocalSurfaceIdAllocator root_allocator;
438 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 438 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
439 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 439 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
440 factory.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame), 440 factory.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame),
441 SurfaceFactory::DrawCallback()); 441 SurfaceFactory::DrawCallback());
442 442
443 TestCase tests[] = { 443 TestCase tests[] = {
444 // These tests just miss the RenderPassDrawQuad. 444 // These tests just miss the RenderPassDrawQuad.
445 { 445 {
446 root_surface_id, 446 root_surface_id,
447 gfx::Point(49, 49), 447 gfx::Point(49, 49),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 EmptySurfaceFactoryClient child_client; 501 EmptySurfaceFactoryClient child_client;
502 FrameSinkId child_frame_sink_id(2, 2); 502 FrameSinkId child_frame_sink_id(2, 2);
503 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 503 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client);
504 504
505 // Creates a root surface. 505 // Creates a root surface.
506 gfx::Rect root_rect(300, 300); 506 gfx::Rect root_rect(300, 300);
507 RenderPass* root_pass = nullptr; 507 RenderPass* root_pass = nullptr;
508 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 508 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
509 509
510 // Add a reference to the child surface on the root surface. 510 // Add a reference to the child surface on the root surface.
511 SurfaceIdAllocator child_allocator; 511 LocalSurfaceIdAllocator child_allocator;
512 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 512 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
513 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 513 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
514 gfx::Rect child_rect(200, 200); 514 gfx::Rect child_rect(200, 200);
515 CreateSurfaceDrawQuad( 515 CreateSurfaceDrawQuad(
516 root_pass, 516 root_pass,
517 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 517 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
518 0.0f, 1.0f, 0.0f, 50.0f, 518 0.0f, 1.0f, 0.0f, 50.0f,
519 0.0f, 0.0f, 1.0f, 0.0f, 519 0.0f, 0.0f, 1.0f, 0.0f,
520 0.0f, 0.0f, 0.0f, 1.0f), 520 0.0f, 0.0f, 0.0f, 1.0f),
521 root_rect, child_rect, child_surface_id); 521 root_rect, child_rect, child_surface_id);
522 522
523 // Submit the root frame. 523 // Submit the root frame.
524 SurfaceIdAllocator root_allocator; 524 LocalSurfaceIdAllocator root_allocator;
525 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 525 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
526 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 526 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
527 root_factory.SubmitCompositorFrame(root_local_surface_id, 527 root_factory.SubmitCompositorFrame(root_local_surface_id,
528 std::move(root_frame), 528 std::move(root_frame),
529 SurfaceFactory::DrawCallback()); 529 SurfaceFactory::DrawCallback());
530 530
531 // Creates a child surface. 531 // Creates a child surface.
532 RenderPass* child_pass = nullptr; 532 RenderPass* child_pass = nullptr;
533 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 533 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
534 534
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 620
621 // Verify that insets have affected hit targeting. 621 // Verify that insets have affected hit targeting.
622 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); 622 EXPECT_EQ(0, accept_delegate.reject_target_overrides());
623 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); 623 EXPECT_EQ(2, accept_delegate.accept_target_overrides());
624 624
625 root_factory.EvictSurface(); 625 root_factory.EvictSurface();
626 child_factory.EvictSurface(); 626 child_factory.EvictSurface();
627 } 627 }
628 628
629 } // namespace cc 629 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698