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

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

Issue 2795683003: [cc]Replace use of SurfaceFactory with CompositorFrameSinkSupport in tests (Closed)
Patch Set: Created 3 years, 8 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/compositor_frame_sink_support.h"
8 #include "cc/surfaces/local_surface_id_allocator.h" 9 #include "cc/surfaces/local_surface_id_allocator.h"
9 #include "cc/surfaces/surface.h" 10 #include "cc/surfaces/surface.h"
10 #include "cc/surfaces/surface_factory.h"
11 #include "cc/surfaces/surface_factory_client.h"
12 #include "cc/surfaces/surface_hittest.h" 11 #include "cc/surfaces/surface_hittest.h"
13 #include "cc/surfaces/surface_manager.h" 12 #include "cc/surfaces/surface_manager.h"
14 #include "cc/test/surface_hittest_test_helpers.h" 13 #include "cc/test/surface_hittest_test_helpers.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
17 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
18 17
19 namespace cc { 18 namespace cc {
20 19
21 namespace { 20 namespace {
(...skipping 29 matching lines...) Expand all
51 test.input_surface_id, test.expected_compositor_frame_sink_id, 50 test.input_surface_id, test.expected_compositor_frame_sink_id,
52 &target_transform)); 51 &target_transform));
53 EXPECT_EQ(transform, target_transform); 52 EXPECT_EQ(transform, target_transform);
54 } 53 }
55 } 54 }
56 55
57 } // namespace 56 } // namespace
58 57
59 using namespace test; 58 using namespace test;
60 59
60 static constexpr bool is_root = true;
61 static constexpr bool is_root_child = false;
62 static constexpr bool handles_frame_sink_id_invalidation = true;
63 static constexpr bool needs_sync_points = true;
Fady Samuel 2017/04/03 22:33:25 Put these in the anonymous namespace above and dro
Alex Z. 2017/04/04 14:10:33 Done.
64
61 // This test verifies that hit testing on a surface that does not exist does 65 // This test verifies that hit testing on a surface that does not exist does
62 // not crash. 66 // not crash.
63 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { 67 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
64 SurfaceManager manager; 68 SurfaceManager manager;
65 EmptySurfaceFactoryClient client;
66 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); 69 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId);
67 SurfaceFactory root_factory(root_frame_sink_id, &manager, &client); 70 CompositorFrameSinkSupport root_support(
71 nullptr, &manager, kArbitraryFrameSinkId, is_root,
72 handles_frame_sink_id_invalidation, needs_sync_points);
68 73
69 // Creates a root surface. 74 // Creates a root surface.
70 gfx::Rect root_rect(300, 300); 75 gfx::Rect root_rect(300, 300);
71 RenderPass* root_pass = nullptr; 76 RenderPass* root_pass = nullptr;
72 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 77 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
73 78
74 // Add a reference to a non-existant child surface on the root surface. 79 // Add a reference to a non-existant child surface on the root surface.
75 SurfaceId child_surface_id( 80 SurfaceId child_surface_id(
76 kArbitraryFrameSinkId, 81 kArbitraryFrameSinkId,
77 LocalSurfaceId(0xdeadbeef, base::UnguessableToken::Create())); 82 LocalSurfaceId(0xdeadbeef, base::UnguessableToken::Create()));
78 gfx::Rect child_rect(200, 200); 83 gfx::Rect child_rect(200, 200);
79 CreateSurfaceDrawQuad(root_pass, 84 CreateSurfaceDrawQuad(root_pass,
80 gfx::Transform(), 85 gfx::Transform(),
81 root_rect, 86 root_rect,
82 child_rect, 87 child_rect,
83 child_surface_id); 88 child_surface_id);
84 89
85 // Submit the root frame. 90 // Submit the root frame.
86 LocalSurfaceIdAllocator root_allocator; 91 LocalSurfaceIdAllocator root_allocator;
87 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 92 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
88 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 93 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
89 root_factory.SubmitCompositorFrame(root_local_surface_id, 94 root_support.SubmitCompositorFrame(root_local_surface_id,
90 std::move(root_frame), 95 std::move(root_frame));
91 SurfaceFactory::DrawCallback());
92 96
93 { 97 {
94 SurfaceHittest hittest(nullptr, &manager); 98 SurfaceHittest hittest(nullptr, &manager);
95 // It is expected this test will complete without crashes. 99 // It is expected this test will complete without crashes.
96 gfx::Transform transform; 100 gfx::Transform transform;
97 EXPECT_EQ(root_surface_id, 101 EXPECT_EQ(root_surface_id,
98 hittest.GetTargetSurfaceAtPoint( 102 hittest.GetTargetSurfaceAtPoint(
99 root_surface_id, gfx::Point(100, 100), &transform)); 103 root_surface_id, gfx::Point(100, 100), &transform));
100 } 104 }
101 105
102 root_factory.EvictSurface(); 106 root_support.EvictFrame();
103 } 107 }
104 108
105 TEST(SurfaceHittestTest, Hittest_SingleSurface) { 109 TEST(SurfaceHittestTest, Hittest_SingleSurface) {
106 SurfaceManager manager; 110 SurfaceManager manager;
107 111
108 // Set up root FrameSink. 112 // Set up root FrameSink.
109 EmptySurfaceFactoryClient root_client;
110 FrameSinkId root_frame_sink_id(1, 1); 113 FrameSinkId root_frame_sink_id(1, 1);
111 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 114 CompositorFrameSinkSupport root_support(
115 nullptr, &manager, root_frame_sink_id, is_root,
116 handles_frame_sink_id_invalidation, needs_sync_points);
112 117
113 // Creates a root surface. 118 // Creates a root surface.
114 gfx::Rect root_rect(300, 300); 119 gfx::Rect root_rect(300, 300);
115 RenderPass* root_pass = nullptr; 120 RenderPass* root_pass = nullptr;
116 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 121 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
117 122
118 // Submit the root frame. 123 // Submit the root frame.
119 LocalSurfaceIdAllocator root_allocator; 124 LocalSurfaceIdAllocator root_allocator;
120 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 125 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
121 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 126 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
122 root_factory.SubmitCompositorFrame(root_local_surface_id, 127 root_support.SubmitCompositorFrame(root_local_surface_id,
123 std::move(root_frame), 128 std::move(root_frame));
124 SurfaceFactory::DrawCallback());
125 TestCase tests[] = { 129 TestCase tests[] = {
126 { 130 {
127 root_surface_id, 131 root_surface_id,
128 gfx::Point(100, 100), 132 gfx::Point(100, 100),
129 root_surface_id, 133 root_surface_id,
130 gfx::Point(100, 100) 134 gfx::Point(100, 100)
131 }, 135 },
132 }; 136 };
133 137
134 RunTests(nullptr, &manager, tests, arraysize(tests)); 138 RunTests(nullptr, &manager, tests, arraysize(tests));
135 139
136 root_factory.EvictSurface(); 140 root_support.EvictFrame();
137 } 141 }
138 142
139 TEST(SurfaceHittestTest, Hittest_ChildSurface) { 143 TEST(SurfaceHittestTest, Hittest_ChildSurface) {
140 SurfaceManager manager; 144 SurfaceManager manager;
141 145
142 // Set up root FrameSink. 146 // Set up root FrameSink.
143 EmptySurfaceFactoryClient root_client;
144 FrameSinkId root_frame_sink_id(1, 1); 147 FrameSinkId root_frame_sink_id(1, 1);
145 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 148 CompositorFrameSinkSupport root_support(
149 nullptr, &manager, root_frame_sink_id, is_root,
150 handles_frame_sink_id_invalidation, needs_sync_points);
146 151
147 // Set up child FrameSink. 152 // Set up child FrameSink.
148 EmptySurfaceFactoryClient child_client;
149 FrameSinkId child_frame_sink_id(2, 2); 153 FrameSinkId child_frame_sink_id(2, 2);
150 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 154 CompositorFrameSinkSupport child_support(
155 nullptr, &manager, child_frame_sink_id, is_root_child,
156 handles_frame_sink_id_invalidation, needs_sync_points);
151 157
152 // Creates a root surface. 158 // Creates a root surface.
153 gfx::Rect root_rect(300, 300); 159 gfx::Rect root_rect(300, 300);
154 RenderPass* root_pass = nullptr; 160 RenderPass* root_pass = nullptr;
155 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 161 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
156 162
157 // Add a reference to the child surface on the root surface. 163 // Add a reference to the child surface on the root surface.
158 LocalSurfaceIdAllocator child_allocator; 164 LocalSurfaceIdAllocator child_allocator;
159 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 165 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
160 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 166 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
161 gfx::Rect child_rect(200, 200); 167 gfx::Rect child_rect(200, 200);
162 CreateSurfaceDrawQuad(root_pass, 168 CreateSurfaceDrawQuad(root_pass,
163 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 169 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
164 0.0f, 1.0f, 0.0f, 50.0f, 170 0.0f, 1.0f, 0.0f, 50.0f,
165 0.0f, 0.0f, 1.0f, 0.0f, 171 0.0f, 0.0f, 1.0f, 0.0f,
166 0.0f, 0.0f, 0.0f, 1.0f), 172 0.0f, 0.0f, 0.0f, 1.0f),
167 root_rect, 173 root_rect,
168 child_rect, 174 child_rect,
169 child_surface_id); 175 child_surface_id);
170 176
171 // Submit the root frame. 177 // Submit the root frame.
172 LocalSurfaceIdAllocator root_allocator; 178 LocalSurfaceIdAllocator root_allocator;
173 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 179 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
174 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 180 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
175 root_factory.SubmitCompositorFrame(root_local_surface_id, 181 root_support.SubmitCompositorFrame(root_local_surface_id,
176 std::move(root_frame), 182 std::move(root_frame));
177 SurfaceFactory::DrawCallback());
178 183
179 // Creates a child surface. 184 // Creates a child surface.
180 RenderPass* child_pass = nullptr; 185 RenderPass* child_pass = nullptr;
181 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 186 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
182 187
183 // Add a solid quad in the child surface. 188 // Add a solid quad in the child surface.
184 gfx::Rect child_solid_quad_rect(100, 100); 189 gfx::Rect child_solid_quad_rect(100, 100);
185 CreateSolidColorDrawQuad( 190 CreateSolidColorDrawQuad(
186 child_pass, 191 child_pass,
187 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 192 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
188 0.0f, 1.0f, 0.0f, 50.0f, 193 0.0f, 1.0f, 0.0f, 50.0f,
189 0.0f, 0.0f, 1.0f, 0.0f, 194 0.0f, 0.0f, 1.0f, 0.0f,
190 0.0f, 0.0f, 0.0f, 1.0f), 195 0.0f, 0.0f, 0.0f, 1.0f),
191 root_rect, child_solid_quad_rect); 196 root_rect, child_solid_quad_rect);
192 197
193 // Submit the frame. 198 // Submit the frame.
194 child_factory.SubmitCompositorFrame(child_local_surface_id, 199 child_support.SubmitCompositorFrame(child_local_surface_id,
195 std::move(child_frame), 200 std::move(child_frame));
196 SurfaceFactory::DrawCallback());
197 201
198 TestCase tests[] = { 202 TestCase tests[] = {
199 { 203 {
200 root_surface_id, 204 root_surface_id,
201 gfx::Point(10, 10), 205 gfx::Point(10, 10),
202 root_surface_id, 206 root_surface_id,
203 gfx::Point(10, 10) 207 gfx::Point(10, 10)
204 }, 208 },
205 { 209 {
206 root_surface_id, 210 root_surface_id,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Submit another root frame, with a slightly perturbed child Surface. 243 // Submit another root frame, with a slightly perturbed child Surface.
240 root_frame = CreateCompositorFrame(root_rect, &root_pass); 244 root_frame = CreateCompositorFrame(root_rect, &root_pass);
241 CreateSurfaceDrawQuad(root_pass, 245 CreateSurfaceDrawQuad(root_pass,
242 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, 246 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f,
243 0.0f, 1.0f, 0.0f, 75.0f, 247 0.0f, 1.0f, 0.0f, 75.0f,
244 0.0f, 0.0f, 1.0f, 0.0f, 248 0.0f, 0.0f, 1.0f, 0.0f,
245 0.0f, 0.0f, 0.0f, 1.0f), 249 0.0f, 0.0f, 0.0f, 1.0f),
246 root_rect, 250 root_rect,
247 child_rect, 251 child_rect,
248 child_surface_id); 252 child_surface_id);
249 root_factory.SubmitCompositorFrame(root_local_surface_id, 253 root_support.SubmitCompositorFrame(root_local_surface_id,
250 std::move(root_frame), 254 std::move(root_frame));
251 SurfaceFactory::DrawCallback());
252 255
253 // Verify that point (100, 100) no longer falls on the child surface. 256 // Verify that point (100, 100) no longer falls on the child surface.
254 // Verify that the transform to the child surface's space has also shifted. 257 // Verify that the transform to the child surface's space has also shifted.
255 { 258 {
256 SurfaceHittest hittest(nullptr, &manager); 259 SurfaceHittest hittest(nullptr, &manager);
257 260
258 gfx::Point point(100, 100); 261 gfx::Point point(100, 100);
259 gfx::Transform transform; 262 gfx::Transform transform;
260 EXPECT_EQ(root_surface_id, 263 EXPECT_EQ(root_surface_id,
261 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, 264 hittest.GetTargetSurfaceAtPoint(root_surface_id, point,
262 &transform)); 265 &transform));
263 transform.TransformPoint(&point); 266 transform.TransformPoint(&point);
264 EXPECT_EQ(gfx::Point(100, 100), point); 267 EXPECT_EQ(gfx::Point(100, 100), point);
265 268
266 gfx::Point point_in_target_space(100, 100); 269 gfx::Point point_in_target_space(100, 100);
267 gfx::Transform target_transform; 270 gfx::Transform target_transform;
268 EXPECT_TRUE(hittest.GetTransformToTargetSurface( 271 EXPECT_TRUE(hittest.GetTransformToTargetSurface(
269 root_surface_id, child_surface_id, &target_transform)); 272 root_surface_id, child_surface_id, &target_transform));
270 target_transform.TransformPoint(&point_in_target_space); 273 target_transform.TransformPoint(&point_in_target_space);
271 EXPECT_NE(transform, target_transform); 274 EXPECT_NE(transform, target_transform);
272 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); 275 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space);
273 } 276 }
274 277
275 root_factory.EvictSurface(); 278 root_support.EvictFrame();
276 child_factory.EvictSurface(); 279 child_support.EvictFrame();
277 } 280 }
278 281
279 // This test verifies that hit testing will progress to the next quad if it 282 // This test verifies that hit testing will progress to the next quad if it
280 // encounters an invalid RenderPassDrawQuad for whatever reason. 283 // encounters an invalid RenderPassDrawQuad for whatever reason.
281 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { 284 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
282 SurfaceManager manager; 285 SurfaceManager manager;
283 286
284 // Set up root FrameSink. 287 // Set up root FrameSink.
285 EmptySurfaceFactoryClient root_client;
286 FrameSinkId root_frame_sink_id(1, 1); 288 FrameSinkId root_frame_sink_id(1, 1);
287 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 289 CompositorFrameSinkSupport root_support(
290 nullptr, &manager, root_frame_sink_id, is_root,
291 handles_frame_sink_id_invalidation, needs_sync_points);
288 292
289 // Set up child FrameSink. 293 // Set up child FrameSink.
290 EmptySurfaceFactoryClient child_client;
291 FrameSinkId child_frame_sink_id(2, 2); 294 FrameSinkId child_frame_sink_id(2, 2);
292 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 295 CompositorFrameSinkSupport child_support(
296 nullptr, &manager, child_frame_sink_id, is_root_child,
297 handles_frame_sink_id_invalidation, needs_sync_points);
293 298
294 // Creates a root surface. 299 // Creates a root surface.
295 gfx::Rect root_rect(300, 300); 300 gfx::Rect root_rect(300, 300);
296 RenderPass* root_pass = nullptr; 301 RenderPass* root_pass = nullptr;
297 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 302 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
298 303
299 // Create a RenderPassDrawQuad to a non-existant RenderPass. 304 // Create a RenderPassDrawQuad to a non-existant RenderPass.
300 int invalid_render_pass_id = 1337; 305 int invalid_render_pass_id = 1337;
301 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect, 306 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect,
302 invalid_render_pass_id); 307 invalid_render_pass_id);
303 308
304 // Add a reference to the child surface on the root surface. 309 // Add a reference to the child surface on the root surface.
305 LocalSurfaceIdAllocator child_allocator; 310 LocalSurfaceIdAllocator child_allocator;
306 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 311 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
307 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 312 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
308 gfx::Rect child_rect(200, 200); 313 gfx::Rect child_rect(200, 200);
309 CreateSurfaceDrawQuad(root_pass, 314 CreateSurfaceDrawQuad(root_pass,
310 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 315 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
311 0.0f, 1.0f, 0.0f, 50.0f, 316 0.0f, 1.0f, 0.0f, 50.0f,
312 0.0f, 0.0f, 1.0f, 0.0f, 317 0.0f, 0.0f, 1.0f, 0.0f,
313 0.0f, 0.0f, 0.0f, 1.0f), 318 0.0f, 0.0f, 0.0f, 1.0f),
314 root_rect, 319 root_rect,
315 child_rect, 320 child_rect,
316 child_surface_id); 321 child_surface_id);
317 322
318 // Submit the root frame. 323 // Submit the root frame.
319 LocalSurfaceIdAllocator root_allocator; 324 LocalSurfaceIdAllocator root_allocator;
320 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 325 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
321 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 326 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
322 root_factory.SubmitCompositorFrame(root_local_surface_id, 327 root_support.SubmitCompositorFrame(root_local_surface_id,
323 std::move(root_frame), 328 std::move(root_frame));
324 SurfaceFactory::DrawCallback());
325 329
326 // Creates a child surface. 330 // Creates a child surface.
327 RenderPass* child_pass = nullptr; 331 RenderPass* child_pass = nullptr;
328 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 332 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
329 333
330 // Add a solid quad in the child surface. 334 // Add a solid quad in the child surface.
331 gfx::Rect child_solid_quad_rect(100, 100); 335 gfx::Rect child_solid_quad_rect(100, 100);
332 CreateSolidColorDrawQuad(child_pass, 336 CreateSolidColorDrawQuad(child_pass,
333 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 337 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
334 0.0f, 1.0f, 0.0f, 50.0f, 338 0.0f, 1.0f, 0.0f, 50.0f,
335 0.0f, 0.0f, 1.0f, 0.0f, 339 0.0f, 0.0f, 1.0f, 0.0f,
336 0.0f, 0.0f, 0.0f, 1.0f), 340 0.0f, 0.0f, 0.0f, 1.0f),
337 root_rect, 341 root_rect,
338 child_solid_quad_rect); 342 child_solid_quad_rect);
339 343
340 // Submit the frame. 344 // Submit the frame.
341 child_factory.SubmitCompositorFrame(child_local_surface_id, 345 child_support.SubmitCompositorFrame(child_local_surface_id,
342 std::move(child_frame), 346 std::move(child_frame));
343 SurfaceFactory::DrawCallback());
344 347
345 TestCase tests[] = { 348 TestCase tests[] = {
346 { 349 {
347 root_surface_id, 350 root_surface_id,
348 gfx::Point(10, 10), 351 gfx::Point(10, 10),
349 root_surface_id, 352 root_surface_id,
350 gfx::Point(10, 10) 353 gfx::Point(10, 10)
351 }, 354 },
352 { 355 {
353 root_surface_id, 356 root_surface_id,
(...skipping 22 matching lines...) Expand all
376 { 379 {
377 root_surface_id, 380 root_surface_id,
378 gfx::Point(290, 290), 381 gfx::Point(290, 290),
379 root_surface_id, 382 root_surface_id,
380 gfx::Point(290, 290) 383 gfx::Point(290, 290)
381 } 384 }
382 }; 385 };
383 386
384 RunTests(nullptr, &manager, tests, arraysize(tests)); 387 RunTests(nullptr, &manager, tests, arraysize(tests));
385 388
386 root_factory.EvictSurface(); 389 root_support.EvictFrame();
387 child_factory.EvictSurface(); 390 child_support.EvictFrame();
388 } 391 }
389 392
390 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { 393 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
391 SurfaceManager manager; 394 SurfaceManager manager;
392 EmptySurfaceFactoryClient client;
393 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); 395 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId);
394 SurfaceFactory factory(root_frame_sink_id, &manager, &client); 396 CompositorFrameSinkSupport support(
397 nullptr, &manager, root_frame_sink_id, is_root,
398 handles_frame_sink_id_invalidation, needs_sync_points);
395 399
396 // Create a CompostiorFrame with two RenderPasses. 400 // Create a CompostiorFrame with two RenderPasses.
397 gfx::Rect root_rect(300, 300); 401 gfx::Rect root_rect(300, 300);
398 CompositorFrame root_frame; 402 CompositorFrame root_frame;
399 RenderPassList& render_pass_list = root_frame.render_pass_list; 403 RenderPassList& render_pass_list = root_frame.render_pass_list;
400 404
401 // Create a child RenderPass. 405 // Create a child RenderPass.
402 int child_render_pass_id = 3; 406 int child_render_pass_id = 3;
403 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, 407 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f,
404 0.0f, 1.0f, 0.0f, 50.0f, 408 0.0f, 1.0f, 0.0f, 50.0f,
(...skipping 25 matching lines...) Expand all
430 gfx::Rect child_solid_quad_rect(100, 100); 434 gfx::Rect child_solid_quad_rect(100, 100);
431 CreateSolidColorDrawQuad(child_render_pass, 435 CreateSolidColorDrawQuad(child_render_pass,
432 gfx::Transform(), 436 gfx::Transform(),
433 gfx::Rect(100, 100), 437 gfx::Rect(100, 100),
434 child_solid_quad_rect); 438 child_solid_quad_rect);
435 439
436 // Submit the root frame. 440 // Submit the root frame.
437 LocalSurfaceIdAllocator root_allocator; 441 LocalSurfaceIdAllocator root_allocator;
438 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 442 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
439 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 443 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
440 factory.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame), 444 support.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame));
441 SurfaceFactory::DrawCallback());
442 445
443 TestCase tests[] = { 446 TestCase tests[] = {
444 // These tests just miss the RenderPassDrawQuad. 447 // These tests just miss the RenderPassDrawQuad.
445 { 448 {
446 root_surface_id, 449 root_surface_id,
447 gfx::Point(49, 49), 450 gfx::Point(49, 49),
448 root_surface_id, 451 root_surface_id,
449 gfx::Point(49, 49) 452 gfx::Point(49, 49)
450 }, 453 },
451 { 454 {
(...skipping 27 matching lines...) Expand all
479 { 482 {
480 root_surface_id, 483 root_surface_id,
481 gfx::Point(100, 100), 484 gfx::Point(100, 100),
482 root_surface_id, 485 root_surface_id,
483 gfx::Point(100, 100) 486 gfx::Point(100, 100)
484 } 487 }
485 }; 488 };
486 489
487 RunTests(nullptr, &manager, tests, arraysize(tests)); 490 RunTests(nullptr, &manager, tests, arraysize(tests));
488 491
489 factory.EvictSurface(); 492 support.EvictFrame();
490 } 493 }
491 494
492 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { 495 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
493 SurfaceManager manager; 496 SurfaceManager manager;
494 497
495 // Set up root FrameSink. 498 // Set up root FrameSink.
496 EmptySurfaceFactoryClient root_client;
497 FrameSinkId root_frame_sink_id(1, 1); 499 FrameSinkId root_frame_sink_id(1, 1);
498 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 500 CompositorFrameSinkSupport root_support(
501 nullptr, &manager, root_frame_sink_id, is_root,
502 handles_frame_sink_id_invalidation, needs_sync_points);
499 503
500 // Set up child FrameSink. 504 // Set up child FrameSink.
501 EmptySurfaceFactoryClient child_client;
502 FrameSinkId child_frame_sink_id(2, 2); 505 FrameSinkId child_frame_sink_id(2, 2);
503 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 506 CompositorFrameSinkSupport child_support(
507 nullptr, &manager, child_frame_sink_id, is_root,
508 handles_frame_sink_id_invalidation, needs_sync_points);
504 509
505 // Creates a root surface. 510 // Creates a root surface.
506 gfx::Rect root_rect(300, 300); 511 gfx::Rect root_rect(300, 300);
507 RenderPass* root_pass = nullptr; 512 RenderPass* root_pass = nullptr;
508 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 513 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
509 514
510 // Add a reference to the child surface on the root surface. 515 // Add a reference to the child surface on the root surface.
511 LocalSurfaceIdAllocator child_allocator; 516 LocalSurfaceIdAllocator child_allocator;
512 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 517 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
513 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 518 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
514 gfx::Rect child_rect(200, 200); 519 gfx::Rect child_rect(200, 200);
515 CreateSurfaceDrawQuad( 520 CreateSurfaceDrawQuad(
516 root_pass, 521 root_pass,
517 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 522 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
518 0.0f, 1.0f, 0.0f, 50.0f, 523 0.0f, 1.0f, 0.0f, 50.0f,
519 0.0f, 0.0f, 1.0f, 0.0f, 524 0.0f, 0.0f, 1.0f, 0.0f,
520 0.0f, 0.0f, 0.0f, 1.0f), 525 0.0f, 0.0f, 0.0f, 1.0f),
521 root_rect, child_rect, child_surface_id); 526 root_rect, child_rect, child_surface_id);
522 527
523 // Submit the root frame. 528 // Submit the root frame.
524 LocalSurfaceIdAllocator root_allocator; 529 LocalSurfaceIdAllocator root_allocator;
525 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 530 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
526 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 531 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
527 root_factory.SubmitCompositorFrame(root_local_surface_id, 532 root_support.SubmitCompositorFrame(root_local_surface_id,
528 std::move(root_frame), 533 std::move(root_frame));
529 SurfaceFactory::DrawCallback());
530 534
531 // Creates a child surface. 535 // Creates a child surface.
532 RenderPass* child_pass = nullptr; 536 RenderPass* child_pass = nullptr;
533 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 537 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
534 538
535 // Add a solid quad in the child surface. 539 // Add a solid quad in the child surface.
536 gfx::Rect child_solid_quad_rect(190, 190); 540 gfx::Rect child_solid_quad_rect(190, 190);
537 CreateSolidColorDrawQuad( 541 CreateSolidColorDrawQuad(
538 child_pass, 542 child_pass,
539 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, 543 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f,
540 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), 544 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
541 root_rect, child_solid_quad_rect); 545 root_rect, child_solid_quad_rect);
542 546
543 // Submit the frame. 547 // Submit the frame.
544 child_factory.SubmitCompositorFrame(child_local_surface_id, 548 child_support.SubmitCompositorFrame(child_local_surface_id,
545 std::move(child_frame), 549 std::move(child_frame));
546 SurfaceFactory::DrawCallback());
547 550
548 TestCase test_expectations_without_insets[] = { 551 TestCase test_expectations_without_insets[] = {
549 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, 552 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)},
550 {root_surface_id, gfx::Point(60, 60), child_surface_id, 553 {root_surface_id, gfx::Point(60, 60), child_surface_id,
551 gfx::Point(10, 10)}, 554 gfx::Point(10, 10)},
552 {root_surface_id, gfx::Point(239, 239), child_surface_id, 555 {root_surface_id, gfx::Point(239, 239), child_surface_id,
553 gfx::Point(189, 189)}, 556 gfx::Point(189, 189)},
554 {root_surface_id, gfx::Point(244, 244), child_surface_id, 557 {root_surface_id, gfx::Point(244, 244), child_surface_id,
555 gfx::Point(194, 194)}, 558 gfx::Point(194, 194)},
556 {root_surface_id, gfx::Point(50, 50), root_surface_id, 559 {root_surface_id, gfx::Point(50, 50), root_surface_id,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 TestSurfaceHittestDelegate accept_delegate; 618 TestSurfaceHittestDelegate accept_delegate;
616 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, 619 accept_delegate.AddInsetsForAcceptSurface(child_surface_id,
617 gfx::Insets(5, 5, 5, 5)); 620 gfx::Insets(5, 5, 5, 5));
618 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, 621 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets,
619 arraysize(test_expectations_with_accept_insets)); 622 arraysize(test_expectations_with_accept_insets));
620 623
621 // Verify that insets have affected hit targeting. 624 // Verify that insets have affected hit targeting.
622 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); 625 EXPECT_EQ(0, accept_delegate.reject_target_overrides());
623 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); 626 EXPECT_EQ(2, accept_delegate.accept_target_overrides());
624 627
625 root_factory.EvictSurface(); 628 root_support.EvictFrame();
626 child_factory.EvictSurface(); 629 child_support.EvictFrame();
627 } 630 }
628 631
629 } // namespace cc 632 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698