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

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

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

Powered by Google App Engine
This is Rietveld 408576698