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

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

Issue 2795683003: [cc]Replace use of SurfaceFactory with CompositorFrameSinkSupport in tests (Closed)
Patch Set: Update returned_resources_ in FakeCompositorFrameSinkSupportClient::DidReceiveCompositorFrameAck 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
« no previous file with comments | « cc/surfaces/surface_aggregator_unittest.cc ('k') | cc/surfaces/surface_manager_ref_unittest.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/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;
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 std::unique_ptr<CompositorFrameSinkSupport> root_support =
70 CompositorFrameSinkSupport::Create(
71 nullptr, &manager, kArbitraryFrameSinkId, kIsRoot,
72 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
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 std::unique_ptr<CompositorFrameSinkSupport> root_support =
115 CompositorFrameSinkSupport::Create(
116 nullptr, &manager, root_frame_sink_id, kIsRoot,
117 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
112 118
113 // Creates a root surface. 119 // Creates a root surface.
114 gfx::Rect root_rect(300, 300); 120 gfx::Rect root_rect(300, 300);
115 RenderPass* root_pass = nullptr; 121 RenderPass* root_pass = nullptr;
116 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 122 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
117 123
118 // Submit the root frame. 124 // Submit the root frame.
119 LocalSurfaceIdAllocator root_allocator; 125 LocalSurfaceIdAllocator root_allocator;
120 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 126 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
121 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 127 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
122 root_factory.SubmitCompositorFrame(root_local_surface_id, 128 root_support->SubmitCompositorFrame(root_local_surface_id,
123 std::move(root_frame), 129 std::move(root_frame));
124 SurfaceFactory::DrawCallback());
125 TestCase tests[] = { 130 TestCase tests[] = {
126 { 131 {
127 root_surface_id, 132 root_surface_id,
128 gfx::Point(100, 100), 133 gfx::Point(100, 100),
129 root_surface_id, 134 root_surface_id,
130 gfx::Point(100, 100) 135 gfx::Point(100, 100)
131 }, 136 },
132 }; 137 };
133 138
134 RunTests(nullptr, &manager, tests, arraysize(tests)); 139 RunTests(nullptr, &manager, tests, arraysize(tests));
135 140
136 root_factory.EvictSurface(); 141 root_support->EvictFrame();
137 } 142 }
138 143
139 TEST(SurfaceHittestTest, Hittest_ChildSurface) { 144 TEST(SurfaceHittestTest, Hittest_ChildSurface) {
140 SurfaceManager manager; 145 SurfaceManager manager;
141 146
142 // Set up root FrameSink. 147 // Set up root FrameSink.
143 EmptySurfaceFactoryClient root_client;
144 FrameSinkId root_frame_sink_id(1, 1); 148 FrameSinkId root_frame_sink_id(1, 1);
145 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 149 std::unique_ptr<CompositorFrameSinkSupport> root_support =
150 CompositorFrameSinkSupport::Create(
151 nullptr, &manager, root_frame_sink_id, kIsRoot,
152 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
146 153
147 // Set up child FrameSink. 154 // Set up child FrameSink.
148 EmptySurfaceFactoryClient child_client;
149 FrameSinkId child_frame_sink_id(2, 2); 155 FrameSinkId child_frame_sink_id(2, 2);
150 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 156 std::unique_ptr<CompositorFrameSinkSupport> child_support =
157 CompositorFrameSinkSupport::Create(
158 nullptr, &manager, child_frame_sink_id, kIsChildRoot,
159 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
151 160
152 // Creates a root surface. 161 // Creates a root surface.
153 gfx::Rect root_rect(300, 300); 162 gfx::Rect root_rect(300, 300);
154 RenderPass* root_pass = nullptr; 163 RenderPass* root_pass = nullptr;
155 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 164 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
156 165
157 // Add a reference to the child surface on the root surface. 166 // Add a reference to the child surface on the root surface.
158 LocalSurfaceIdAllocator child_allocator; 167 LocalSurfaceIdAllocator child_allocator;
159 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 168 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
160 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 169 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
161 gfx::Rect child_rect(200, 200); 170 gfx::Rect child_rect(200, 200);
162 CreateSurfaceDrawQuad(root_pass, 171 CreateSurfaceDrawQuad(root_pass,
163 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 172 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
164 0.0f, 1.0f, 0.0f, 50.0f, 173 0.0f, 1.0f, 0.0f, 50.0f,
165 0.0f, 0.0f, 1.0f, 0.0f, 174 0.0f, 0.0f, 1.0f, 0.0f,
166 0.0f, 0.0f, 0.0f, 1.0f), 175 0.0f, 0.0f, 0.0f, 1.0f),
167 root_rect, 176 root_rect,
168 child_rect, 177 child_rect,
169 child_surface_id); 178 child_surface_id);
170 179
171 // Submit the root frame. 180 // Submit the root frame.
172 LocalSurfaceIdAllocator root_allocator; 181 LocalSurfaceIdAllocator root_allocator;
173 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 182 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
174 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 183 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
175 root_factory.SubmitCompositorFrame(root_local_surface_id, 184 root_support->SubmitCompositorFrame(root_local_surface_id,
176 std::move(root_frame), 185 std::move(root_frame));
177 SurfaceFactory::DrawCallback());
178 186
179 // Creates a child surface. 187 // Creates a child surface.
180 RenderPass* child_pass = nullptr; 188 RenderPass* child_pass = nullptr;
181 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 189 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
182 190
183 // Add a solid quad in the child surface. 191 // Add a solid quad in the child surface.
184 gfx::Rect child_solid_quad_rect(100, 100); 192 gfx::Rect child_solid_quad_rect(100, 100);
185 CreateSolidColorDrawQuad( 193 CreateSolidColorDrawQuad(
186 child_pass, 194 child_pass,
187 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 195 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
188 0.0f, 1.0f, 0.0f, 50.0f, 196 0.0f, 1.0f, 0.0f, 50.0f,
189 0.0f, 0.0f, 1.0f, 0.0f, 197 0.0f, 0.0f, 1.0f, 0.0f,
190 0.0f, 0.0f, 0.0f, 1.0f), 198 0.0f, 0.0f, 0.0f, 1.0f),
191 root_rect, child_solid_quad_rect); 199 root_rect, child_solid_quad_rect);
192 200
193 // Submit the frame. 201 // Submit the frame.
194 child_factory.SubmitCompositorFrame(child_local_surface_id, 202 child_support->SubmitCompositorFrame(child_local_surface_id,
195 std::move(child_frame), 203 std::move(child_frame));
196 SurfaceFactory::DrawCallback());
197 204
198 TestCase tests[] = { 205 TestCase tests[] = {
199 { 206 {
200 root_surface_id, 207 root_surface_id,
201 gfx::Point(10, 10), 208 gfx::Point(10, 10),
202 root_surface_id, 209 root_surface_id,
203 gfx::Point(10, 10) 210 gfx::Point(10, 10)
204 }, 211 },
205 { 212 {
206 root_surface_id, 213 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. 246 // Submit another root frame, with a slightly perturbed child Surface.
240 root_frame = CreateCompositorFrame(root_rect, &root_pass); 247 root_frame = CreateCompositorFrame(root_rect, &root_pass);
241 CreateSurfaceDrawQuad(root_pass, 248 CreateSurfaceDrawQuad(root_pass,
242 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f, 249 gfx::Transform(1.0f, 0.0f, 0.0f, 75.0f,
243 0.0f, 1.0f, 0.0f, 75.0f, 250 0.0f, 1.0f, 0.0f, 75.0f,
244 0.0f, 0.0f, 1.0f, 0.0f, 251 0.0f, 0.0f, 1.0f, 0.0f,
245 0.0f, 0.0f, 0.0f, 1.0f), 252 0.0f, 0.0f, 0.0f, 1.0f),
246 root_rect, 253 root_rect,
247 child_rect, 254 child_rect,
248 child_surface_id); 255 child_surface_id);
249 root_factory.SubmitCompositorFrame(root_local_surface_id, 256 root_support->SubmitCompositorFrame(root_local_surface_id,
250 std::move(root_frame), 257 std::move(root_frame));
251 SurfaceFactory::DrawCallback());
252 258
253 // Verify that point (100, 100) no longer falls on the child surface. 259 // 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. 260 // Verify that the transform to the child surface's space has also shifted.
255 { 261 {
256 SurfaceHittest hittest(nullptr, &manager); 262 SurfaceHittest hittest(nullptr, &manager);
257 263
258 gfx::Point point(100, 100); 264 gfx::Point point(100, 100);
259 gfx::Transform transform; 265 gfx::Transform transform;
260 EXPECT_EQ(root_surface_id, 266 EXPECT_EQ(root_surface_id,
261 hittest.GetTargetSurfaceAtPoint(root_surface_id, point, 267 hittest.GetTargetSurfaceAtPoint(root_surface_id, point,
262 &transform)); 268 &transform));
263 transform.TransformPoint(&point); 269 transform.TransformPoint(&point);
264 EXPECT_EQ(gfx::Point(100, 100), point); 270 EXPECT_EQ(gfx::Point(100, 100), point);
265 271
266 gfx::Point point_in_target_space(100, 100); 272 gfx::Point point_in_target_space(100, 100);
267 gfx::Transform target_transform; 273 gfx::Transform target_transform;
268 EXPECT_TRUE(hittest.GetTransformToTargetSurface( 274 EXPECT_TRUE(hittest.GetTransformToTargetSurface(
269 root_surface_id, child_surface_id, &target_transform)); 275 root_surface_id, child_surface_id, &target_transform));
270 target_transform.TransformPoint(&point_in_target_space); 276 target_transform.TransformPoint(&point_in_target_space);
271 EXPECT_NE(transform, target_transform); 277 EXPECT_NE(transform, target_transform);
272 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space); 278 EXPECT_EQ(gfx::Point(25, 25), point_in_target_space);
273 } 279 }
274 280
275 root_factory.EvictSurface(); 281 root_support->EvictFrame();
276 child_factory.EvictSurface(); 282 child_support->EvictFrame();
277 } 283 }
278 284
279 // This test verifies that hit testing will progress to the next quad if it 285 // This test verifies that hit testing will progress to the next quad if it
280 // encounters an invalid RenderPassDrawQuad for whatever reason. 286 // encounters an invalid RenderPassDrawQuad for whatever reason.
281 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { 287 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
282 SurfaceManager manager; 288 SurfaceManager manager;
283 289
284 // Set up root FrameSink. 290 // Set up root FrameSink.
285 EmptySurfaceFactoryClient root_client;
286 FrameSinkId root_frame_sink_id(1, 1); 291 FrameSinkId root_frame_sink_id(1, 1);
287 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 292 std::unique_ptr<CompositorFrameSinkSupport> root_support =
293 CompositorFrameSinkSupport::Create(
294 nullptr, &manager, root_frame_sink_id, kIsRoot,
295 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
288 296
289 // Set up child FrameSink. 297 // Set up child FrameSink.
290 EmptySurfaceFactoryClient child_client;
291 FrameSinkId child_frame_sink_id(2, 2); 298 FrameSinkId child_frame_sink_id(2, 2);
292 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 299 std::unique_ptr<CompositorFrameSinkSupport> child_support =
300 CompositorFrameSinkSupport::Create(
301 nullptr, &manager, child_frame_sink_id, kIsChildRoot,
302 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
293 303
294 // Creates a root surface. 304 // Creates a root surface.
295 gfx::Rect root_rect(300, 300); 305 gfx::Rect root_rect(300, 300);
296 RenderPass* root_pass = nullptr; 306 RenderPass* root_pass = nullptr;
297 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 307 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
298 308
299 // Create a RenderPassDrawQuad to a non-existant RenderPass. 309 // Create a RenderPassDrawQuad to a non-existant RenderPass.
300 int invalid_render_pass_id = 1337; 310 int invalid_render_pass_id = 1337;
301 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect, 311 CreateRenderPassDrawQuad(root_pass, gfx::Transform(), root_rect, root_rect,
302 invalid_render_pass_id); 312 invalid_render_pass_id);
303 313
304 // Add a reference to the child surface on the root surface. 314 // Add a reference to the child surface on the root surface.
305 LocalSurfaceIdAllocator child_allocator; 315 LocalSurfaceIdAllocator child_allocator;
306 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 316 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
307 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 317 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
308 gfx::Rect child_rect(200, 200); 318 gfx::Rect child_rect(200, 200);
309 CreateSurfaceDrawQuad(root_pass, 319 CreateSurfaceDrawQuad(root_pass,
310 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 320 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
311 0.0f, 1.0f, 0.0f, 50.0f, 321 0.0f, 1.0f, 0.0f, 50.0f,
312 0.0f, 0.0f, 1.0f, 0.0f, 322 0.0f, 0.0f, 1.0f, 0.0f,
313 0.0f, 0.0f, 0.0f, 1.0f), 323 0.0f, 0.0f, 0.0f, 1.0f),
314 root_rect, 324 root_rect,
315 child_rect, 325 child_rect,
316 child_surface_id); 326 child_surface_id);
317 327
318 // Submit the root frame. 328 // Submit the root frame.
319 LocalSurfaceIdAllocator root_allocator; 329 LocalSurfaceIdAllocator root_allocator;
320 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 330 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
321 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 331 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
322 root_factory.SubmitCompositorFrame(root_local_surface_id, 332 root_support->SubmitCompositorFrame(root_local_surface_id,
323 std::move(root_frame), 333 std::move(root_frame));
324 SurfaceFactory::DrawCallback());
325 334
326 // Creates a child surface. 335 // Creates a child surface.
327 RenderPass* child_pass = nullptr; 336 RenderPass* child_pass = nullptr;
328 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 337 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
329 338
330 // Add a solid quad in the child surface. 339 // Add a solid quad in the child surface.
331 gfx::Rect child_solid_quad_rect(100, 100); 340 gfx::Rect child_solid_quad_rect(100, 100);
332 CreateSolidColorDrawQuad(child_pass, 341 CreateSolidColorDrawQuad(child_pass,
333 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 342 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
334 0.0f, 1.0f, 0.0f, 50.0f, 343 0.0f, 1.0f, 0.0f, 50.0f,
335 0.0f, 0.0f, 1.0f, 0.0f, 344 0.0f, 0.0f, 1.0f, 0.0f,
336 0.0f, 0.0f, 0.0f, 1.0f), 345 0.0f, 0.0f, 0.0f, 1.0f),
337 root_rect, 346 root_rect,
338 child_solid_quad_rect); 347 child_solid_quad_rect);
339 348
340 // Submit the frame. 349 // Submit the frame.
341 child_factory.SubmitCompositorFrame(child_local_surface_id, 350 child_support->SubmitCompositorFrame(child_local_surface_id,
342 std::move(child_frame), 351 std::move(child_frame));
343 SurfaceFactory::DrawCallback());
344 352
345 TestCase tests[] = { 353 TestCase tests[] = {
346 { 354 {
347 root_surface_id, 355 root_surface_id,
348 gfx::Point(10, 10), 356 gfx::Point(10, 10),
349 root_surface_id, 357 root_surface_id,
350 gfx::Point(10, 10) 358 gfx::Point(10, 10)
351 }, 359 },
352 { 360 {
353 root_surface_id, 361 root_surface_id,
(...skipping 22 matching lines...) Expand all
376 { 384 {
377 root_surface_id, 385 root_surface_id,
378 gfx::Point(290, 290), 386 gfx::Point(290, 290),
379 root_surface_id, 387 root_surface_id,
380 gfx::Point(290, 290) 388 gfx::Point(290, 290)
381 } 389 }
382 }; 390 };
383 391
384 RunTests(nullptr, &manager, tests, arraysize(tests)); 392 RunTests(nullptr, &manager, tests, arraysize(tests));
385 393
386 root_factory.EvictSurface(); 394 root_support->EvictFrame();
387 child_factory.EvictSurface(); 395 child_support->EvictFrame();
388 } 396 }
389 397
390 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { 398 TEST(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
391 SurfaceManager manager; 399 SurfaceManager manager;
392 EmptySurfaceFactoryClient client;
393 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId); 400 FrameSinkId root_frame_sink_id(kArbitraryFrameSinkId);
394 SurfaceFactory factory(root_frame_sink_id, &manager, &client); 401 std::unique_ptr<CompositorFrameSinkSupport> support =
402 CompositorFrameSinkSupport::Create(
403 nullptr, &manager, root_frame_sink_id, kIsRoot,
404 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
395 405
396 // Create a CompostiorFrame with two RenderPasses. 406 // Create a CompostiorFrame with two RenderPasses.
397 gfx::Rect root_rect(300, 300); 407 gfx::Rect root_rect(300, 300);
398 CompositorFrame root_frame; 408 CompositorFrame root_frame;
399 RenderPassList& render_pass_list = root_frame.render_pass_list; 409 RenderPassList& render_pass_list = root_frame.render_pass_list;
400 410
401 // Create a child RenderPass. 411 // Create a child RenderPass.
402 int child_render_pass_id = 3; 412 int child_render_pass_id = 3;
403 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f, 413 gfx::Transform transform_to_root_target(1.0f, 0.0f, 0.0f, 50.0f,
404 0.0f, 1.0f, 0.0f, 50.0f, 414 0.0f, 1.0f, 0.0f, 50.0f,
(...skipping 25 matching lines...) Expand all
430 gfx::Rect child_solid_quad_rect(100, 100); 440 gfx::Rect child_solid_quad_rect(100, 100);
431 CreateSolidColorDrawQuad(child_render_pass, 441 CreateSolidColorDrawQuad(child_render_pass,
432 gfx::Transform(), 442 gfx::Transform(),
433 gfx::Rect(100, 100), 443 gfx::Rect(100, 100),
434 child_solid_quad_rect); 444 child_solid_quad_rect);
435 445
436 // Submit the root frame. 446 // Submit the root frame.
437 LocalSurfaceIdAllocator root_allocator; 447 LocalSurfaceIdAllocator root_allocator;
438 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 448 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
439 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 449 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
440 factory.SubmitCompositorFrame(root_local_surface_id, std::move(root_frame), 450 support->SubmitCompositorFrame(root_local_surface_id, std::move(root_frame));
441 SurfaceFactory::DrawCallback());
442 451
443 TestCase tests[] = { 452 TestCase tests[] = {
444 // These tests just miss the RenderPassDrawQuad. 453 // These tests just miss the RenderPassDrawQuad.
445 { 454 {
446 root_surface_id, 455 root_surface_id,
447 gfx::Point(49, 49), 456 gfx::Point(49, 49),
448 root_surface_id, 457 root_surface_id,
449 gfx::Point(49, 49) 458 gfx::Point(49, 49)
450 }, 459 },
451 { 460 {
(...skipping 27 matching lines...) Expand all
479 { 488 {
480 root_surface_id, 489 root_surface_id,
481 gfx::Point(100, 100), 490 gfx::Point(100, 100),
482 root_surface_id, 491 root_surface_id,
483 gfx::Point(100, 100) 492 gfx::Point(100, 100)
484 } 493 }
485 }; 494 };
486 495
487 RunTests(nullptr, &manager, tests, arraysize(tests)); 496 RunTests(nullptr, &manager, tests, arraysize(tests));
488 497
489 factory.EvictSurface(); 498 support->EvictFrame();
490 } 499 }
491 500
492 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { 501 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
493 SurfaceManager manager; 502 SurfaceManager manager;
494 503
495 // Set up root FrameSink. 504 // Set up root FrameSink.
496 EmptySurfaceFactoryClient root_client;
497 FrameSinkId root_frame_sink_id(1, 1); 505 FrameSinkId root_frame_sink_id(1, 1);
498 SurfaceFactory root_factory(root_frame_sink_id, &manager, &root_client); 506 std::unique_ptr<CompositorFrameSinkSupport> root_support =
507 CompositorFrameSinkSupport::Create(
508 nullptr, &manager, root_frame_sink_id, kIsRoot,
509 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
499 510
500 // Set up child FrameSink. 511 // Set up child FrameSink.
501 EmptySurfaceFactoryClient child_client;
502 FrameSinkId child_frame_sink_id(2, 2); 512 FrameSinkId child_frame_sink_id(2, 2);
503 SurfaceFactory child_factory(child_frame_sink_id, &manager, &child_client); 513 std::unique_ptr<CompositorFrameSinkSupport> child_support =
514 CompositorFrameSinkSupport::Create(
515 nullptr, &manager, child_frame_sink_id, kIsRoot,
516 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
504 517
505 // Creates a root surface. 518 // Creates a root surface.
506 gfx::Rect root_rect(300, 300); 519 gfx::Rect root_rect(300, 300);
507 RenderPass* root_pass = nullptr; 520 RenderPass* root_pass = nullptr;
508 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass); 521 CompositorFrame root_frame = CreateCompositorFrame(root_rect, &root_pass);
509 522
510 // Add a reference to the child surface on the root surface. 523 // Add a reference to the child surface on the root surface.
511 LocalSurfaceIdAllocator child_allocator; 524 LocalSurfaceIdAllocator child_allocator;
512 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); 525 LocalSurfaceId child_local_surface_id = child_allocator.GenerateId();
513 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id); 526 SurfaceId child_surface_id(child_frame_sink_id, child_local_surface_id);
514 gfx::Rect child_rect(200, 200); 527 gfx::Rect child_rect(200, 200);
515 CreateSurfaceDrawQuad( 528 CreateSurfaceDrawQuad(
516 root_pass, 529 root_pass,
517 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 530 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
518 0.0f, 1.0f, 0.0f, 50.0f, 531 0.0f, 1.0f, 0.0f, 50.0f,
519 0.0f, 0.0f, 1.0f, 0.0f, 532 0.0f, 0.0f, 1.0f, 0.0f,
520 0.0f, 0.0f, 0.0f, 1.0f), 533 0.0f, 0.0f, 0.0f, 1.0f),
521 root_rect, child_rect, child_surface_id); 534 root_rect, child_rect, child_surface_id);
522 535
523 // Submit the root frame. 536 // Submit the root frame.
524 LocalSurfaceIdAllocator root_allocator; 537 LocalSurfaceIdAllocator root_allocator;
525 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId(); 538 LocalSurfaceId root_local_surface_id = root_allocator.GenerateId();
526 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id); 539 SurfaceId root_surface_id(root_frame_sink_id, root_local_surface_id);
527 root_factory.SubmitCompositorFrame(root_local_surface_id, 540 root_support->SubmitCompositorFrame(root_local_surface_id,
528 std::move(root_frame), 541 std::move(root_frame));
529 SurfaceFactory::DrawCallback());
530 542
531 // Creates a child surface. 543 // Creates a child surface.
532 RenderPass* child_pass = nullptr; 544 RenderPass* child_pass = nullptr;
533 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass); 545 CompositorFrame child_frame = CreateCompositorFrame(child_rect, &child_pass);
534 546
535 // Add a solid quad in the child surface. 547 // Add a solid quad in the child surface.
536 gfx::Rect child_solid_quad_rect(190, 190); 548 gfx::Rect child_solid_quad_rect(190, 190);
537 CreateSolidColorDrawQuad( 549 CreateSolidColorDrawQuad(
538 child_pass, 550 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, 551 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), 552 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
541 root_rect, child_solid_quad_rect); 553 root_rect, child_solid_quad_rect);
542 554
543 // Submit the frame. 555 // Submit the frame.
544 child_factory.SubmitCompositorFrame(child_local_surface_id, 556 child_support->SubmitCompositorFrame(child_local_surface_id,
545 std::move(child_frame), 557 std::move(child_frame));
546 SurfaceFactory::DrawCallback());
547 558
548 TestCase test_expectations_without_insets[] = { 559 TestCase test_expectations_without_insets[] = {
549 {root_surface_id, gfx::Point(55, 55), child_surface_id, gfx::Point(5, 5)}, 560 {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, 561 {root_surface_id, gfx::Point(60, 60), child_surface_id,
551 gfx::Point(10, 10)}, 562 gfx::Point(10, 10)},
552 {root_surface_id, gfx::Point(239, 239), child_surface_id, 563 {root_surface_id, gfx::Point(239, 239), child_surface_id,
553 gfx::Point(189, 189)}, 564 gfx::Point(189, 189)},
554 {root_surface_id, gfx::Point(244, 244), child_surface_id, 565 {root_surface_id, gfx::Point(244, 244), child_surface_id,
555 gfx::Point(194, 194)}, 566 gfx::Point(194, 194)},
556 {root_surface_id, gfx::Point(50, 50), root_surface_id, 567 {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; 626 TestSurfaceHittestDelegate accept_delegate;
616 accept_delegate.AddInsetsForAcceptSurface(child_surface_id, 627 accept_delegate.AddInsetsForAcceptSurface(child_surface_id,
617 gfx::Insets(5, 5, 5, 5)); 628 gfx::Insets(5, 5, 5, 5));
618 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets, 629 RunTests(&accept_delegate, &manager, test_expectations_with_accept_insets,
619 arraysize(test_expectations_with_accept_insets)); 630 arraysize(test_expectations_with_accept_insets));
620 631
621 // Verify that insets have affected hit targeting. 632 // Verify that insets have affected hit targeting.
622 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); 633 EXPECT_EQ(0, accept_delegate.reject_target_overrides());
623 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); 634 EXPECT_EQ(2, accept_delegate.accept_target_overrides());
624 635
625 root_factory.EvictSurface(); 636 root_support->EvictFrame();
626 child_factory.EvictSurface(); 637 child_support->EvictFrame();
627 } 638 }
628 639
629 } // namespace cc 640 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator_unittest.cc ('k') | cc/surfaces/surface_manager_ref_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698