OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/surfaces/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 protected: | 77 protected: |
78 SurfaceManager manager_; | 78 SurfaceManager manager_; |
79 EmptySurfaceFactoryClient empty_client_; | 79 EmptySurfaceFactoryClient empty_client_; |
80 SurfaceFactory factory_; | 80 SurfaceFactory factory_; |
81 SurfaceAggregator aggregator_; | 81 SurfaceAggregator aggregator_; |
82 }; | 82 }; |
83 | 83 |
84 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 84 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
85 LocalFrameId local_frame_id(7, base::UnguessableToken::Create()); | 85 LocalFrameId local_frame_id(7, base::UnguessableToken::Create()); |
86 SurfaceId one_id(kArbitraryFrameSinkId, local_frame_id); | 86 SurfaceId one_id(kArbitraryFrameSinkId, local_frame_id); |
87 factory_.Create(local_frame_id); | 87 factory_.SubmitCompositorFrame(local_frame_id, CompositorFrame(), |
88 SurfaceFactory::DrawCallback()); | |
88 | 89 |
89 CompositorFrame frame = aggregator_.Aggregate(one_id); | 90 CompositorFrame frame = aggregator_.Aggregate(one_id); |
90 EXPECT_TRUE(frame.render_pass_list.empty()); | 91 EXPECT_TRUE(frame.render_pass_list.empty()); |
91 | |
92 factory_.Destroy(local_frame_id); | |
93 } | 92 } |
94 | 93 |
95 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 94 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
96 public: | 95 public: |
97 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 96 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
98 : SurfaceAggregatorTest(use_damage_rect), | 97 : SurfaceAggregatorTest(use_damage_rect), |
99 child_factory_(kArbitraryChildFrameSinkId, | 98 child_factory_(kArbitraryChildFrameSinkId, |
100 &manager_, | 99 &manager_, |
101 &empty_child_client_) {} | 100 &empty_child_client_) {} |
102 SurfaceAggregatorValidSurfaceTest() | 101 SurfaceAggregatorValidSurfaceTest() |
103 : SurfaceAggregatorValidSurfaceTest(false) {} | 102 : SurfaceAggregatorValidSurfaceTest(false) {} |
104 | 103 |
105 void SetUp() override { | 104 void SetUp() override { |
106 SurfaceAggregatorTest::SetUp(); | 105 SurfaceAggregatorTest::SetUp(); |
107 root_local_frame_id_ = allocator_.GenerateId(); | 106 root_local_frame_id_ = allocator_.GenerateId(); |
108 factory_.Create(root_local_frame_id_); | |
109 root_surface_ = manager_.GetSurfaceForId( | 107 root_surface_ = manager_.GetSurfaceForId( |
110 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); | 108 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); |
111 } | 109 } |
112 | 110 |
113 void TearDown() override { | 111 void TearDown() override { |
114 factory_.Destroy(root_local_frame_id_); | |
115 SurfaceAggregatorTest::TearDown(); | 112 SurfaceAggregatorTest::TearDown(); |
116 } | 113 } |
117 | 114 |
118 void AggregateAndVerify(test::Pass* expected_passes, | 115 void AggregateAndVerify(test::Pass* expected_passes, |
119 size_t expected_pass_count, | 116 size_t expected_pass_count, |
120 SurfaceId* surface_ids, | 117 SurfaceId* surface_ids, |
121 size_t expected_surface_count) { | 118 size_t expected_surface_count) { |
122 CompositorFrame aggregated_frame = aggregator_.Aggregate( | 119 CompositorFrame aggregated_frame = aggregator_.Aggregate( |
123 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); | 120 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); |
124 | 121 |
(...skipping 28 matching lines...) Expand all Loading... | |
153 void SubmitCompositorFrame(SurfaceFactory* factory, | 150 void SubmitCompositorFrame(SurfaceFactory* factory, |
154 test::Pass* passes, | 151 test::Pass* passes, |
155 size_t pass_count, | 152 size_t pass_count, |
156 const LocalFrameId& local_frame_id) { | 153 const LocalFrameId& local_frame_id) { |
157 RenderPassList pass_list; | 154 RenderPassList pass_list; |
158 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); | 155 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); |
159 SubmitPassListAsFrame(factory, local_frame_id, &pass_list); | 156 SubmitPassListAsFrame(factory, local_frame_id, &pass_list); |
160 } | 157 } |
161 | 158 |
162 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, | 159 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, |
163 const LocalFrameId& local_frame_id) { | 160 const LocalFrameId& local_frame_id, |
161 SurfaceFactory* factory) { | |
164 CompositorFrame child_frame; | 162 CompositorFrame child_frame; |
165 child_frame.render_pass_list.push_back(std::move(pass)); | 163 child_frame.render_pass_list.push_back(std::move(pass)); |
166 | 164 |
167 factory_.SubmitCompositorFrame(local_frame_id, std::move(child_frame), | 165 factory->SubmitCompositorFrame(local_frame_id, std::move(child_frame), |
168 SurfaceFactory::DrawCallback()); | 166 SurfaceFactory::DrawCallback()); |
169 } | 167 } |
170 | 168 |
171 protected: | 169 protected: |
172 LocalFrameId root_local_frame_id_; | 170 LocalFrameId root_local_frame_id_; |
173 Surface* root_surface_; | 171 Surface* root_surface_; |
174 SurfaceIdAllocator allocator_; | 172 SurfaceIdAllocator allocator_; |
175 EmptySurfaceFactoryClient empty_child_client_; | 173 EmptySurfaceFactoryClient empty_child_client_; |
176 SurfaceFactory child_factory_; | 174 SurfaceFactory child_factory_; |
177 SurfaceIdAllocator child_allocator_; | 175 SurfaceIdAllocator child_allocator_; |
(...skipping 13 matching lines...) Expand all Loading... | |
191 SurfaceId ids[] = {root_surface_id}; | 189 SurfaceId ids[] = {root_surface_id}; |
192 | 190 |
193 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 191 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
194 | 192 |
195 // Check that WillDrawSurface was called. | 193 // Check that WillDrawSurface was called. |
196 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); | 194 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); |
197 EXPECT_EQ(root_local_frame_id_, empty_client_.last_local_frame_id_); | 195 EXPECT_EQ(root_local_frame_id_, empty_client_.last_local_frame_id_); |
198 } | 196 } |
199 | 197 |
200 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 198 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
199 SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_, | |
200 &empty_client_); | |
201 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 201 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
202 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 202 SurfaceId embedded_surface_id(factory_.frame_sink_id(), |
203 embedded_local_frame_id); | 203 embedded_local_frame_id); |
204 factory_.Create(embedded_local_frame_id); | |
205 | 204 |
206 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 205 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
207 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 206 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
208 test::Pass embedded_passes[] = { | 207 test::Pass embedded_passes[] = { |
209 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 208 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
210 | 209 |
211 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 210 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
212 embedded_local_frame_id); | 211 arraysize(embedded_passes), embedded_local_frame_id); |
213 | 212 |
214 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 213 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
215 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 214 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
216 | 215 |
217 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 216 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
218 root_local_frame_id_); | 217 root_local_frame_id_); |
219 | 218 |
220 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 219 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
221 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 220 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
222 | 221 |
223 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); | 222 RenderPassList& render_pass_list(aggregated_frame.render_pass_list); |
224 ASSERT_EQ(2u, render_pass_list.size()); | 223 ASSERT_EQ(2u, render_pass_list.size()); |
225 SharedQuadStateList& shared_quad_state_list( | 224 SharedQuadStateList& shared_quad_state_list( |
226 render_pass_list[0]->shared_quad_state_list); | 225 render_pass_list[0]->shared_quad_state_list); |
227 ASSERT_EQ(2u, shared_quad_state_list.size()); | 226 ASSERT_EQ(2u, shared_quad_state_list.size()); |
228 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); | 227 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); |
229 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); | 228 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); |
230 | 229 |
231 SharedQuadStateList& shared_quad_state_list2( | 230 SharedQuadStateList& shared_quad_state_list2( |
232 render_pass_list[1]->shared_quad_state_list); | 231 render_pass_list[1]->shared_quad_state_list); |
233 ASSERT_EQ(1u, shared_quad_state_list2.size()); | 232 ASSERT_EQ(1u, shared_quad_state_list2.size()); |
234 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); | 233 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); |
235 | |
236 factory_.Destroy(embedded_local_frame_id); | |
237 } | 234 } |
238 | 235 |
239 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { | 236 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { |
240 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 237 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
241 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 238 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
242 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 239 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
243 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 240 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
244 test::Pass passes[] = { | 241 test::Pass passes[] = { |
245 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), | 242 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), |
246 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; | 243 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; |
247 | 244 |
248 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 245 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
249 root_local_frame_id_); | 246 root_local_frame_id_); |
250 | 247 |
251 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 248 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
252 SurfaceId ids[] = {root_surface_id}; | 249 SurfaceId ids[] = {root_surface_id}; |
253 | 250 |
254 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 251 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
255 } | 252 } |
256 | 253 |
257 // This tests very simple embedding. root_surface has a frame containing a few | 254 // This tests very simple embedding. root_surface has a frame containing a few |
258 // solid color quads and a surface quad referencing embedded_surface. | 255 // solid color quads and a surface quad referencing embedded_surface. |
259 // embedded_surface has a frame containing only a solid color quad. The solid | 256 // embedded_surface has a frame containing only a solid color quad. The solid |
260 // color quad should be aggregated into the final frame. | 257 // color quad should be aggregated into the final frame. |
261 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 258 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
259 SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_, | |
260 &empty_client_); | |
262 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 261 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
263 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 262 SurfaceId embedded_surface_id(factory_.frame_sink_id(), |
264 embedded_local_frame_id); | 263 embedded_local_frame_id); |
265 factory_.Create(embedded_local_frame_id); | |
266 | 264 |
267 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 265 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
268 test::Pass embedded_passes[] = { | 266 test::Pass embedded_passes[] = { |
269 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 267 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
270 | 268 |
271 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 269 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
272 embedded_local_frame_id); | 270 arraysize(embedded_passes), embedded_local_frame_id); |
273 | 271 |
274 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 272 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
275 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 273 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
276 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 274 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
277 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 275 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
278 | 276 |
279 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 277 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
280 root_local_frame_id_); | 278 root_local_frame_id_); |
281 | 279 |
282 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 280 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
283 test::Quad::SolidColorQuad(SK_ColorGREEN), | 281 test::Quad::SolidColorQuad(SK_ColorGREEN), |
284 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 282 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
285 test::Pass expected_passes[] = { | 283 test::Pass expected_passes[] = { |
286 test::Pass(expected_quads, arraysize(expected_quads))}; | 284 test::Pass(expected_quads, arraysize(expected_quads))}; |
287 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 285 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
288 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; | 286 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; |
289 AggregateAndVerify( | 287 AggregateAndVerify( |
290 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 288 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
291 | |
292 factory_.Destroy(embedded_local_frame_id); | |
293 } | 289 } |
294 | 290 |
295 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 291 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
292 SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_, | |
293 &empty_client_); | |
296 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 294 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
297 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 295 SurfaceId embedded_surface_id(factory_.frame_sink_id(), |
298 embedded_local_frame_id); | 296 embedded_local_frame_id); |
299 factory_.Create(embedded_local_frame_id); | |
300 | 297 |
301 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 298 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
302 test::Pass embedded_passes[] = { | 299 test::Pass embedded_passes[] = { |
303 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 300 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
304 | 301 |
305 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 302 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
306 embedded_local_frame_id); | 303 arraysize(embedded_passes), embedded_local_frame_id); |
307 std::unique_ptr<CopyOutputRequest> copy_request( | 304 std::unique_ptr<CopyOutputRequest> copy_request( |
308 CopyOutputRequest::CreateEmptyRequest()); | 305 CopyOutputRequest::CreateEmptyRequest()); |
309 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 306 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
310 factory_.RequestCopyOfSurface(embedded_local_frame_id, | 307 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); |
311 std::move(copy_request)); | |
312 | 308 |
313 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 309 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
314 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 310 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
315 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 311 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
316 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 312 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
317 | 313 |
318 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), | 314 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), |
319 root_local_frame_id_); | 315 root_local_frame_id_); |
320 | 316 |
321 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 317 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
(...skipping 14 matching lines...) Expand all Loading... | |
336 aggregated_frame.render_pass_list[0]->copy_requests[0].get()); | 332 aggregated_frame.render_pass_list[0]->copy_requests[0].get()); |
337 | 333 |
338 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; | 334 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; |
339 EXPECT_EQ(arraysize(surface_ids), | 335 EXPECT_EQ(arraysize(surface_ids), |
340 aggregator_.previous_contained_surfaces().size()); | 336 aggregator_.previous_contained_surfaces().size()); |
341 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 337 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
342 EXPECT_TRUE( | 338 EXPECT_TRUE( |
343 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 339 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
344 aggregator_.previous_contained_surfaces().end()); | 340 aggregator_.previous_contained_surfaces().end()); |
345 } | 341 } |
346 | |
347 factory_.Destroy(embedded_local_frame_id); | |
348 } | 342 } |
349 | 343 |
350 // Root surface may contain copy requests. | 344 // Root surface may contain copy requests. |
351 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 345 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
346 SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_, | |
347 &empty_client_); | |
352 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 348 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
353 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 349 SurfaceId embedded_surface_id(factory_.frame_sink_id(), |
354 embedded_local_frame_id); | 350 embedded_local_frame_id); |
355 factory_.Create(embedded_local_frame_id); | |
356 | 351 |
357 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 352 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
358 test::Pass embedded_passes[] = { | 353 test::Pass embedded_passes[] = { |
359 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 354 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
360 | 355 |
361 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 356 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
362 embedded_local_frame_id); | 357 arraysize(embedded_passes), embedded_local_frame_id); |
363 std::unique_ptr<CopyOutputRequest> copy_request( | 358 std::unique_ptr<CopyOutputRequest> copy_request( |
364 CopyOutputRequest::CreateEmptyRequest()); | 359 CopyOutputRequest::CreateEmptyRequest()); |
365 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 360 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
366 std::unique_ptr<CopyOutputRequest> copy_request2( | 361 std::unique_ptr<CopyOutputRequest> copy_request2( |
367 CopyOutputRequest::CreateEmptyRequest()); | 362 CopyOutputRequest::CreateEmptyRequest()); |
368 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); | 363 CopyOutputRequest* copy_request2_ptr = copy_request2.get(); |
369 | 364 |
370 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 365 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
371 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 366 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
372 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 367 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 aggregator_.previous_contained_surfaces().end()); | 409 aggregator_.previous_contained_surfaces().end()); |
415 } | 410 } |
416 | 411 |
417 // Ensure copy requests have been removed from root surface. | 412 // Ensure copy requests have been removed from root surface. |
418 const CompositorFrame& original_frame = | 413 const CompositorFrame& original_frame = |
419 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame(); | 414 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame(); |
420 const RenderPassList& original_pass_list = original_frame.render_pass_list; | 415 const RenderPassList& original_pass_list = original_frame.render_pass_list; |
421 ASSERT_EQ(2u, original_pass_list.size()); | 416 ASSERT_EQ(2u, original_pass_list.size()); |
422 DCHECK(original_pass_list[0]->copy_requests.empty()); | 417 DCHECK(original_pass_list[0]->copy_requests.empty()); |
423 DCHECK(original_pass_list[1]->copy_requests.empty()); | 418 DCHECK(original_pass_list[1]->copy_requests.empty()); |
424 | |
425 factory_.Destroy(embedded_local_frame_id); | |
426 } | 419 } |
427 | 420 |
428 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 421 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
422 SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_, | |
423 &empty_client_); | |
429 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); | 424 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); |
430 SurfaceId embedded_surface_id(factory_.frame_sink_id(), | 425 SurfaceId embedded_surface_id(factory_.frame_sink_id(), |
431 embedded_local_frame_id); | 426 embedded_local_frame_id); |
432 SurfaceId nonexistent_surface_id(factory_.frame_sink_id(), | 427 SurfaceId nonexistent_surface_id(factory_.frame_sink_id(), |
433 allocator_.GenerateId()); | 428 allocator_.GenerateId()); |
434 factory_.Create(embedded_local_frame_id); | |
435 | 429 |
436 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 430 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
437 test::Pass embedded_passes[] = { | 431 test::Pass embedded_passes[] = { |
438 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 432 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
439 | 433 |
440 SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes), | 434 SubmitCompositorFrame(&embedded_factory, embedded_passes, |
441 embedded_local_frame_id); | 435 arraysize(embedded_passes), embedded_local_frame_id); |
442 std::unique_ptr<CopyOutputRequest> copy_request( | 436 std::unique_ptr<CopyOutputRequest> copy_request( |
443 CopyOutputRequest::CreateEmptyRequest()); | 437 CopyOutputRequest::CreateEmptyRequest()); |
444 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 438 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
445 factory_.RequestCopyOfSurface(embedded_local_frame_id, | 439 embedded_factory.RequestCopyOfSurface(std::move(copy_request)); |
446 std::move(copy_request)); | |
447 | 440 |
448 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); | 441 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); |
442 SurfaceFactory parent_factory(kArbitraryFrameSinkId, &manager_, | |
443 &empty_client_); | |
449 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); | 444 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); |
450 factory_.Create(parent_local_frame_id); | |
451 | 445 |
452 test::Quad parent_quads[] = { | 446 test::Quad parent_quads[] = { |
453 test::Quad::SolidColorQuad(SK_ColorWHITE), | 447 test::Quad::SolidColorQuad(SK_ColorWHITE), |
454 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 448 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
455 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 449 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
456 test::Pass parent_passes[] = { | 450 test::Pass parent_passes[] = { |
457 test::Pass(parent_quads, arraysize(parent_quads))}; | 451 test::Pass(parent_quads, arraysize(parent_quads))}; |
458 | 452 |
459 { | 453 { |
460 CompositorFrame frame; | 454 CompositorFrame frame; |
461 | 455 |
462 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, | 456 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, |
463 arraysize(parent_passes)); | 457 arraysize(parent_passes)); |
464 | 458 |
465 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); | 459 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); |
466 | 460 |
467 factory_.SubmitCompositorFrame(parent_local_frame_id, std::move(frame), | 461 parent_factory.SubmitCompositorFrame(parent_local_frame_id, |
468 SurfaceFactory::DrawCallback()); | 462 std::move(frame), |
463 SurfaceFactory::DrawCallback()); | |
469 } | 464 } |
470 | 465 |
471 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 466 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
472 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 467 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
473 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 468 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
474 | 469 |
475 { | 470 { |
476 CompositorFrame frame; | 471 CompositorFrame frame; |
477 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 472 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
478 arraysize(root_passes)); | 473 arraysize(root_passes)); |
(...skipping 27 matching lines...) Expand all Loading... | |
506 SurfaceId surface_ids[] = { | 501 SurfaceId surface_ids[] = { |
507 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_), | 502 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_), |
508 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; | 503 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; |
509 EXPECT_EQ(arraysize(surface_ids), | 504 EXPECT_EQ(arraysize(surface_ids), |
510 aggregator_.previous_contained_surfaces().size()); | 505 aggregator_.previous_contained_surfaces().size()); |
511 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 506 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
512 EXPECT_TRUE( | 507 EXPECT_TRUE( |
513 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 508 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
514 aggregator_.previous_contained_surfaces().end()); | 509 aggregator_.previous_contained_surfaces().end()); |
515 } | 510 } |
516 | |
517 factory_.Destroy(parent_local_frame_id); | |
518 factory_.Destroy(embedded_local_frame_id); | |
519 } | 511 } |
520 | 512 |
521 // This tests referencing a surface that has multiple render passes. | 513 // This tests referencing a surface that has multiple render passes. |
522 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 514 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
523 LocalFrameId embedded_local_frame_id = child_allocator_.GenerateId(); | 515 LocalFrameId embedded_local_frame_id = child_allocator_.GenerateId(); |
524 SurfaceId embedded_surface_id(child_factory_.frame_sink_id(), | 516 SurfaceId embedded_surface_id(child_factory_.frame_sink_id(), |
525 embedded_local_frame_id); | 517 embedded_local_frame_id); |
526 child_factory_.Create(embedded_local_frame_id); | |
527 | 518 |
528 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), | 519 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), |
529 RenderPassId(1, 3)}; | 520 RenderPassId(1, 3)}; |
530 | 521 |
531 test::Quad embedded_quads[][2] = { | 522 test::Quad embedded_quads[][2] = { |
532 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 523 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
533 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 524 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
534 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 525 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
535 test::Pass embedded_passes[] = { | 526 test::Pass embedded_passes[] = { |
536 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 527 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 // The last quad in the last pass will reference the second pass from the | 638 // The last quad in the last pass will reference the second pass from the |
648 // root surface, which after aggregating is the fourth pass in the overall | 639 // root surface, which after aggregating is the fourth pass in the overall |
649 // list. | 640 // list. |
650 ASSERT_EQ(DrawQuad::RENDER_PASS, | 641 ASSERT_EQ(DrawQuad::RENDER_PASS, |
651 fifth_pass_quad_list.ElementAt(1)->material); | 642 fifth_pass_quad_list.ElementAt(1)->material); |
652 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = | 643 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = |
653 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); | 644 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); |
654 EXPECT_EQ(actual_pass_ids[3], | 645 EXPECT_EQ(actual_pass_ids[3], |
655 fifth_pass_render_pass_draw_quad->render_pass_id); | 646 fifth_pass_render_pass_draw_quad->render_pass_id); |
656 } | 647 } |
657 child_factory_.Destroy(embedded_local_frame_id); | |
658 } | 648 } |
659 | 649 |
660 // Tests an invalid surface reference in a frame. The surface quad should just | 650 // Tests an invalid surface reference in a frame. The surface quad should just |
661 // be dropped. | 651 // be dropped. |
662 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { | 652 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { |
663 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 653 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
664 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), | 654 test::Quad::SurfaceQuad(InvalidSurfaceId(), 1.f), |
665 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 655 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
666 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 656 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
667 | 657 |
(...skipping 10 matching lines...) Expand all Loading... | |
678 AggregateAndVerify( | 668 AggregateAndVerify( |
679 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 669 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
680 } | 670 } |
681 | 671 |
682 // Tests a reference to a valid surface with no submitted frame. This quad | 672 // Tests a reference to a valid surface with no submitted frame. This quad |
683 // should also just be dropped. | 673 // should also just be dropped. |
684 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 674 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
685 LocalFrameId empty_local_frame_id = allocator_.GenerateId(); | 675 LocalFrameId empty_local_frame_id = allocator_.GenerateId(); |
686 SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(), | 676 SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(), |
687 empty_local_frame_id); | 677 empty_local_frame_id); |
688 factory_.Create(empty_local_frame_id); | |
689 | 678 |
690 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 679 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
691 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), | 680 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), |
692 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 681 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
693 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 682 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
694 | 683 |
695 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 684 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
696 root_local_frame_id_); | 685 root_local_frame_id_); |
697 | 686 |
698 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 687 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
699 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 688 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
700 test::Pass expected_passes[] = { | 689 test::Pass expected_passes[] = { |
701 test::Pass(expected_quads, arraysize(expected_quads))}; | 690 test::Pass(expected_quads, arraysize(expected_quads))}; |
702 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 691 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
703 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; | 692 SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id}; |
704 AggregateAndVerify( | 693 AggregateAndVerify( |
705 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 694 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
706 factory_.Destroy(empty_local_frame_id); | |
707 } | 695 } |
708 | 696 |
709 // Tests a surface quad referencing itself, generating a trivial cycle. | 697 // Tests a surface quad referencing itself, generating a trivial cycle. |
710 // The quad creating the cycle should be dropped from the final frame. | 698 // The quad creating the cycle should be dropped from the final frame. |
711 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 699 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
712 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 700 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
713 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id, 1.f), | 701 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id, 1.f), |
714 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 702 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
715 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 703 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
716 | 704 |
717 SubmitCompositorFrame(&factory_, passes, arraysize(passes), | 705 SubmitCompositorFrame(&factory_, passes, arraysize(passes), |
718 root_local_frame_id_); | 706 root_local_frame_id_); |
719 | 707 |
720 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 708 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
721 test::Pass expected_passes[] = { | 709 test::Pass expected_passes[] = { |
722 test::Pass(expected_quads, arraysize(expected_quads))}; | 710 test::Pass(expected_quads, arraysize(expected_quads))}; |
723 SurfaceId ids[] = {root_surface_id}; | 711 SurfaceId ids[] = {root_surface_id}; |
724 AggregateAndVerify( | 712 AggregateAndVerify( |
725 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 713 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
726 } | 714 } |
727 | 715 |
728 // Tests a more complex cycle with one intermediate surface. | 716 // Tests a more complex cycle with one intermediate surface. |
729 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 717 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
718 SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, | |
719 &empty_client_); | |
730 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 720 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
731 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 721 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); |
732 factory_.Create(child_local_frame_id); | |
733 | 722 |
734 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 723 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
735 test::Quad::SurfaceQuad(child_surface_id, 1.f), | 724 test::Quad::SurfaceQuad(child_surface_id, 1.f), |
736 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 725 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
737 test::Pass parent_passes[] = { | 726 test::Pass parent_passes[] = { |
738 test::Pass(parent_quads, arraysize(parent_quads))}; | 727 test::Pass(parent_quads, arraysize(parent_quads))}; |
739 | 728 |
740 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), | 729 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), |
741 root_local_frame_id_); | 730 root_local_frame_id_); |
742 | 731 |
743 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 732 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
744 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 733 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
745 test::Quad::SurfaceQuad(root_surface_id, 1.f), | 734 test::Quad::SurfaceQuad(root_surface_id, 1.f), |
746 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; | 735 test::Quad::SolidColorQuad(SK_ColorMAGENTA)}; |
747 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; | 736 test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))}; |
748 | 737 |
749 SubmitCompositorFrame(&factory_, child_passes, arraysize(child_passes), | 738 SubmitCompositorFrame(&child_factory, child_passes, arraysize(child_passes), |
750 child_local_frame_id); | 739 child_local_frame_id); |
751 | 740 |
752 // The child surface's reference to the root_surface_ will be dropped, so | 741 // The child surface's reference to the root_surface_ will be dropped, so |
753 // we'll end up with: | 742 // we'll end up with: |
754 // SK_ColorBLUE from the parent | 743 // SK_ColorBLUE from the parent |
755 // SK_ColorGREEN from the child | 744 // SK_ColorGREEN from the child |
756 // SK_ColorMAGENTA from the child | 745 // SK_ColorMAGENTA from the child |
757 // SK_ColorCYAN from the parent | 746 // SK_ColorCYAN from the parent |
758 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 747 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
759 test::Quad::SolidColorQuad(SK_ColorGREEN), | 748 test::Quad::SolidColorQuad(SK_ColorGREEN), |
760 test::Quad::SolidColorQuad(SK_ColorMAGENTA), | 749 test::Quad::SolidColorQuad(SK_ColorMAGENTA), |
761 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 750 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
762 test::Pass expected_passes[] = { | 751 test::Pass expected_passes[] = { |
763 test::Pass(expected_quads, arraysize(expected_quads))}; | 752 test::Pass(expected_quads, arraysize(expected_quads))}; |
764 SurfaceId ids[] = {root_surface_id, child_surface_id}; | 753 SurfaceId ids[] = {root_surface_id, child_surface_id}; |
765 AggregateAndVerify( | 754 AggregateAndVerify( |
766 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 755 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
767 factory_.Destroy(child_local_frame_id); | |
768 } | 756 } |
769 | 757 |
770 // Tests that we map render pass IDs from different surfaces into a unified | 758 // Tests that we map render pass IDs from different surfaces into a unified |
771 // namespace and update RenderPassDrawQuad's id references to match. | 759 // namespace and update RenderPassDrawQuad's id references to match. |
772 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 760 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
761 SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, | |
762 &empty_client_); | |
773 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 763 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
774 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 764 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); |
775 factory_.Create(child_local_frame_id); | |
776 | 765 |
777 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 766 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
778 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 767 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
779 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 768 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
780 test::Pass surface_passes[] = { | 769 test::Pass surface_passes[] = { |
781 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 770 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
782 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 771 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
783 | 772 |
784 SubmitCompositorFrame(&factory_, surface_passes, arraysize(surface_passes), | 773 SubmitCompositorFrame(&child_factory, surface_passes, |
785 child_local_frame_id); | 774 arraysize(surface_passes), child_local_frame_id); |
786 | 775 |
787 // Pass IDs from the parent surface may collide with ones from the child. | 776 // Pass IDs from the parent surface may collide with ones from the child. |
788 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; | 777 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; |
789 test::Quad parent_quad[][1] = { | 778 test::Quad parent_quad[][1] = { |
790 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, | 779 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, |
791 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 780 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
792 test::Pass parent_passes[] = { | 781 test::Pass parent_passes[] = { |
793 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 782 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
794 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 783 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
795 | 784 |
(...skipping 23 matching lines...) Expand all Loading... | |
819 aggregated_pass_list[2]->quad_list.front()}; | 808 aggregated_pass_list[2]->quad_list.front()}; |
820 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); | 809 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); |
821 EXPECT_EQ( | 810 EXPECT_EQ( |
822 actual_pass_ids[0], | 811 actual_pass_ids[0], |
823 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); | 812 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); |
824 | 813 |
825 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); | 814 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); |
826 EXPECT_EQ( | 815 EXPECT_EQ( |
827 actual_pass_ids[1], | 816 actual_pass_ids[1], |
828 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); | 817 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); |
829 factory_.Destroy(child_local_frame_id); | |
830 } | 818 } |
831 | 819 |
832 void AddSolidColorQuadWithBlendMode(const gfx::Size& size, | 820 void AddSolidColorQuadWithBlendMode(const gfx::Size& size, |
833 RenderPass* pass, | 821 RenderPass* pass, |
834 const SkXfermode::Mode blend_mode) { | 822 const SkXfermode::Mode blend_mode) { |
835 const gfx::Transform layer_to_target_transform; | 823 const gfx::Transform layer_to_target_transform; |
836 const gfx::Size layer_bounds(size); | 824 const gfx::Size layer_bounds(size); |
837 const gfx::Rect visible_layer_rect(size); | 825 const gfx::Rect visible_layer_rect(size); |
838 const gfx::Rect clip_rect(size); | 826 const gfx::Rect clip_rect(size); |
839 | 827 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { | 870 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { |
883 const SkXfermode::Mode blend_modes[] = {SkXfermode::kClear_Mode, // 0 | 871 const SkXfermode::Mode blend_modes[] = {SkXfermode::kClear_Mode, // 0 |
884 SkXfermode::kSrc_Mode, // 1 | 872 SkXfermode::kSrc_Mode, // 1 |
885 SkXfermode::kDst_Mode, // 2 | 873 SkXfermode::kDst_Mode, // 2 |
886 SkXfermode::kSrcOver_Mode, // 3 | 874 SkXfermode::kSrcOver_Mode, // 3 |
887 SkXfermode::kDstOver_Mode, // 4 | 875 SkXfermode::kDstOver_Mode, // 4 |
888 SkXfermode::kSrcIn_Mode, // 5 | 876 SkXfermode::kSrcIn_Mode, // 5 |
889 SkXfermode::kDstIn_Mode, // 6 | 877 SkXfermode::kDstIn_Mode, // 6 |
890 }; | 878 }; |
891 | 879 |
880 SurfaceFactory grandchild_factory(kArbitraryFrameSinkId, &manager_, | |
881 &empty_client_); | |
882 SurfaceFactory child_one_factory(kArbitraryFrameSinkId, &manager_, | |
883 &empty_client_); | |
884 SurfaceFactory child_two_factory(kArbitraryFrameSinkId, &manager_, | |
885 &empty_client_); | |
892 RenderPassId pass_id(1, 1); | 886 RenderPassId pass_id(1, 1); |
893 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); | 887 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); |
894 SurfaceId grandchild_surface_id(factory_.frame_sink_id(), | 888 SurfaceId grandchild_surface_id(factory_.frame_sink_id(), |
895 grandchild_local_frame_id); | 889 grandchild_local_frame_id); |
896 factory_.Create(grandchild_local_frame_id); | 890 grandchild_factory.SubmitCompositorFrame(grandchild_local_frame_id, |
891 CompositorFrame(), | |
892 SurfaceFactory::DrawCallback()); | |
897 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 893 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
898 gfx::Rect output_rect(SurfaceSize()); | 894 gfx::Rect output_rect(SurfaceSize()); |
899 gfx::Rect damage_rect(SurfaceSize()); | 895 gfx::Rect damage_rect(SurfaceSize()); |
900 gfx::Transform transform_to_root_target; | 896 gfx::Transform transform_to_root_target; |
901 grandchild_pass->SetNew( | 897 grandchild_pass->SetNew( |
902 pass_id, output_rect, damage_rect, transform_to_root_target); | 898 pass_id, output_rect, damage_rect, transform_to_root_target); |
903 AddSolidColorQuadWithBlendMode( | 899 AddSolidColorQuadWithBlendMode( |
904 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 900 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
905 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id); | 901 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id, |
902 &grandchild_factory); | |
906 | 903 |
907 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); | 904 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); |
908 SurfaceId child_one_surface_id(factory_.frame_sink_id(), | 905 SurfaceId child_one_surface_id(factory_.frame_sink_id(), |
909 child_one_local_frame_id); | 906 child_one_local_frame_id); |
910 factory_.Create(child_one_local_frame_id); | 907 child_one_factory.SubmitCompositorFrame(child_one_local_frame_id, |
908 CompositorFrame(), | |
909 SurfaceFactory::DrawCallback()); | |
911 | 910 |
912 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 911 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
913 child_one_pass->SetNew( | 912 child_one_pass->SetNew( |
914 pass_id, output_rect, damage_rect, transform_to_root_target); | 913 pass_id, output_rect, damage_rect, transform_to_root_target); |
915 AddSolidColorQuadWithBlendMode( | 914 AddSolidColorQuadWithBlendMode( |
916 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 915 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
917 SurfaceDrawQuad* grandchild_surface_quad = | 916 SurfaceDrawQuad* grandchild_surface_quad = |
918 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 917 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
919 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), | 918 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), |
920 gfx::Rect(SurfaceSize()), | 919 gfx::Rect(SurfaceSize()), |
921 gfx::Rect(SurfaceSize()), | 920 gfx::Rect(SurfaceSize()), |
922 grandchild_surface_id); | 921 grandchild_surface_id); |
923 AddSolidColorQuadWithBlendMode( | 922 AddSolidColorQuadWithBlendMode( |
924 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 923 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
925 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id); | 924 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id, |
925 &child_one_factory); | |
926 | 926 |
927 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); | 927 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); |
928 SurfaceId child_two_surface_id(factory_.frame_sink_id(), | 928 SurfaceId child_two_surface_id(factory_.frame_sink_id(), |
929 child_two_local_frame_id); | 929 child_two_local_frame_id); |
930 factory_.Create(child_two_local_frame_id); | 930 child_two_factory.SubmitCompositorFrame(child_two_local_frame_id, |
931 CompositorFrame(), | |
932 SurfaceFactory::DrawCallback()); | |
931 | 933 |
932 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 934 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
933 child_two_pass->SetNew( | 935 child_two_pass->SetNew( |
934 pass_id, output_rect, damage_rect, transform_to_root_target); | 936 pass_id, output_rect, damage_rect, transform_to_root_target); |
935 AddSolidColorQuadWithBlendMode( | 937 AddSolidColorQuadWithBlendMode( |
936 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 938 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
937 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id); | 939 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id, |
940 &child_two_factory); | |
938 | 941 |
939 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); | 942 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); |
940 root_pass->SetNew( | 943 root_pass->SetNew( |
941 pass_id, output_rect, damage_rect, transform_to_root_target); | 944 pass_id, output_rect, damage_rect, transform_to_root_target); |
942 | 945 |
943 AddSolidColorQuadWithBlendMode( | 946 AddSolidColorQuadWithBlendMode( |
944 SurfaceSize(), root_pass.get(), blend_modes[0]); | 947 SurfaceSize(), root_pass.get(), blend_modes[0]); |
945 SurfaceDrawQuad* child_one_surface_quad = | 948 SurfaceDrawQuad* child_one_surface_quad = |
946 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 949 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
947 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 950 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
948 gfx::Rect(SurfaceSize()), | 951 gfx::Rect(SurfaceSize()), |
949 gfx::Rect(SurfaceSize()), | 952 gfx::Rect(SurfaceSize()), |
950 child_one_surface_id); | 953 child_one_surface_id); |
951 AddSolidColorQuadWithBlendMode( | 954 AddSolidColorQuadWithBlendMode( |
952 SurfaceSize(), root_pass.get(), blend_modes[4]); | 955 SurfaceSize(), root_pass.get(), blend_modes[4]); |
953 SurfaceDrawQuad* child_two_surface_quad = | 956 SurfaceDrawQuad* child_two_surface_quad = |
954 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 957 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
955 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 958 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
956 gfx::Rect(SurfaceSize()), | 959 gfx::Rect(SurfaceSize()), |
957 gfx::Rect(SurfaceSize()), | 960 gfx::Rect(SurfaceSize()), |
958 child_two_surface_id); | 961 child_two_surface_id); |
959 AddSolidColorQuadWithBlendMode( | 962 AddSolidColorQuadWithBlendMode( |
960 SurfaceSize(), root_pass.get(), blend_modes[6]); | 963 SurfaceSize(), root_pass.get(), blend_modes[6]); |
961 | 964 |
962 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_); | 965 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_, &factory_); |
963 | 966 |
964 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 967 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
965 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 968 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
966 | 969 |
967 const RenderPassList& aggregated_pass_list = | 970 const RenderPassList& aggregated_pass_list = |
968 aggregated_frame.render_pass_list; | 971 aggregated_frame.render_pass_list; |
969 | 972 |
970 ASSERT_EQ(1u, aggregated_pass_list.size()); | 973 ASSERT_EQ(1u, aggregated_pass_list.size()); |
971 | 974 |
972 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 975 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
973 | 976 |
974 ASSERT_EQ(7u, aggregated_quad_list.size()); | 977 ASSERT_EQ(7u, aggregated_quad_list.size()); |
975 | 978 |
976 for (auto iter = aggregated_quad_list.cbegin(); | 979 for (auto iter = aggregated_quad_list.cbegin(); |
977 iter != aggregated_quad_list.cend(); | 980 iter != aggregated_quad_list.cend(); |
978 ++iter) { | 981 ++iter) { |
979 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) | 982 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) |
980 << iter.index(); | 983 << iter.index(); |
981 } | 984 } |
982 factory_.Destroy(child_one_local_frame_id); | |
983 factory_.Destroy(child_two_local_frame_id); | |
984 factory_.Destroy(grandchild_local_frame_id); | |
985 } | 985 } |
986 | 986 |
987 // This tests that when aggregating a frame with multiple render passes that we | 987 // This tests that when aggregating a frame with multiple render passes that we |
988 // map the transforms for the root pass but do not modify the transform on child | 988 // map the transforms for the root pass but do not modify the transform on child |
989 // passes. | 989 // passes. |
990 // | 990 // |
991 // The root surface has one pass with a surface quad transformed by +10 in the y | 991 // The root surface has one pass with a surface quad transformed by +10 in the y |
992 // direction. | 992 // direction. |
993 // | 993 // |
994 // The middle surface has one pass with a surface quad scaled by 2 in the x | 994 // The middle surface has one pass with a surface quad scaled by 2 in the x |
995 // and 3 in the y directions. | 995 // and 3 in the y directions. |
996 // | 996 // |
997 // The child surface has two passes. The first pass has a quad with a transform | 997 // The child surface has two passes. The first pass has a quad with a transform |
998 // of +5 in the x direction. The second pass has a reference to the first pass' | 998 // of +5 in the x direction. The second pass has a reference to the first pass' |
999 // pass id and a transform of +8 in the x direction. | 999 // pass id and a transform of +8 in the x direction. |
1000 // | 1000 // |
1001 // After aggregation, the child surface's root pass quad should have all | 1001 // After aggregation, the child surface's root pass quad should have all |
1002 // transforms concatenated for a total transform of +23 x, +10 y. The | 1002 // transforms concatenated for a total transform of +23 x, +10 y. The |
1003 // contributing render pass' transform in the aggregate frame should not be | 1003 // contributing render pass' transform in the aggregate frame should not be |
1004 // affected. | 1004 // affected. |
1005 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { | 1005 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { |
1006 // Innermost child surface. | 1006 // Innermost child surface. |
1007 SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, | |
1008 &empty_client_); | |
1007 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1009 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
1008 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1010 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); |
1009 factory_.Create(child_local_frame_id); | |
1010 { | 1011 { |
1011 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 1012 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
1012 test::Quad child_quads[][1] = { | 1013 test::Quad child_quads[][1] = { |
1013 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 1014 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
1014 {test::Quad::RenderPassQuad(child_pass_id[0])}, | 1015 {test::Quad::RenderPassQuad(child_pass_id[0])}, |
1015 }; | 1016 }; |
1016 test::Pass child_passes[] = { | 1017 test::Pass child_passes[] = { |
1017 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), | 1018 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), |
1018 test::Pass(child_quads[1], arraysize(child_quads[1]), | 1019 test::Pass(child_quads[1], arraysize(child_quads[1]), |
1019 child_pass_id[1])}; | 1020 child_pass_id[1])}; |
1020 | 1021 |
1021 CompositorFrame child_frame; | 1022 CompositorFrame child_frame; |
1022 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1023 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1023 child_passes, arraysize(child_passes)); | 1024 child_passes, arraysize(child_passes)); |
1024 | 1025 |
1025 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); | 1026 RenderPass* child_nonroot_pass = child_frame.render_pass_list[0].get(); |
1026 child_nonroot_pass->transform_to_root_target.Translate(8, 0); | 1027 child_nonroot_pass->transform_to_root_target.Translate(8, 0); |
1027 SharedQuadState* child_nonroot_pass_sqs = | 1028 SharedQuadState* child_nonroot_pass_sqs = |
1028 child_nonroot_pass->shared_quad_state_list.front(); | 1029 child_nonroot_pass->shared_quad_state_list.front(); |
1029 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); | 1030 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); |
1030 | 1031 |
1031 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); | 1032 RenderPass* child_root_pass = child_frame.render_pass_list[1].get(); |
1032 SharedQuadState* child_root_pass_sqs = | 1033 SharedQuadState* child_root_pass_sqs = |
1033 child_root_pass->shared_quad_state_list.front(); | 1034 child_root_pass->shared_quad_state_list.front(); |
1034 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1035 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1035 child_root_pass_sqs->is_clipped = true; | 1036 child_root_pass_sqs->is_clipped = true; |
1036 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); | 1037 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); |
1037 | 1038 |
1038 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1039 child_factory.SubmitCompositorFrame(child_local_frame_id, |
1039 SurfaceFactory::DrawCallback()); | 1040 std::move(child_frame), |
1041 SurfaceFactory::DrawCallback()); | |
1040 } | 1042 } |
1041 | 1043 |
1042 // Middle child surface. | 1044 // Middle child surface. |
1045 SurfaceFactory middle_factory(kArbitraryFrameSinkId, &manager_, | |
1046 &empty_client_); | |
1043 LocalFrameId middle_local_frame_id = allocator_.GenerateId(); | 1047 LocalFrameId middle_local_frame_id = allocator_.GenerateId(); |
1044 SurfaceId middle_surface_id(factory_.frame_sink_id(), middle_local_frame_id); | 1048 SurfaceId middle_surface_id(factory_.frame_sink_id(), middle_local_frame_id); |
1045 factory_.Create(middle_local_frame_id); | |
1046 { | 1049 { |
1047 test::Quad middle_quads[] = { | 1050 test::Quad middle_quads[] = { |
1048 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1051 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1049 test::Pass middle_passes[] = { | 1052 test::Pass middle_passes[] = { |
1050 test::Pass(middle_quads, arraysize(middle_quads)), | 1053 test::Pass(middle_quads, arraysize(middle_quads)), |
1051 }; | 1054 }; |
1052 | 1055 |
1053 CompositorFrame middle_frame; | 1056 CompositorFrame middle_frame; |
1054 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1057 AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1055 middle_passes, arraysize(middle_passes)); | 1058 middle_passes, arraysize(middle_passes)); |
1056 | 1059 |
1057 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); | 1060 RenderPass* middle_root_pass = middle_frame.render_pass_list[0].get(); |
1058 middle_root_pass->quad_list.ElementAt(0)->visible_rect = | 1061 middle_root_pass->quad_list.ElementAt(0)->visible_rect = |
1059 gfx::Rect(0, 1, 100, 7); | 1062 gfx::Rect(0, 1, 100, 7); |
1060 SharedQuadState* middle_root_pass_sqs = | 1063 SharedQuadState* middle_root_pass_sqs = |
1061 middle_root_pass->shared_quad_state_list.front(); | 1064 middle_root_pass->shared_quad_state_list.front(); |
1062 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); | 1065 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); |
1063 | 1066 |
1064 factory_.SubmitCompositorFrame(middle_local_frame_id, | 1067 middle_factory.SubmitCompositorFrame(middle_local_frame_id, |
1065 std::move(middle_frame), | 1068 std::move(middle_frame), |
1066 SurfaceFactory::DrawCallback()); | 1069 SurfaceFactory::DrawCallback()); |
1067 } | 1070 } |
1068 | 1071 |
1069 // Root surface. | 1072 // Root surface. |
1070 test::Quad secondary_quads[] = { | 1073 test::Quad secondary_quads[] = { |
1071 test::Quad::SolidColorQuad(1), | 1074 test::Quad::SolidColorQuad(1), |
1072 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; | 1075 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; |
1073 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; | 1076 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; |
1074 test::Pass root_passes[] = { | 1077 test::Pass root_passes[] = { |
1075 test::Pass(secondary_quads, arraysize(secondary_quads)), | 1078 test::Pass(secondary_quads, arraysize(secondary_quads)), |
1076 test::Pass(root_quads, arraysize(root_quads))}; | 1079 test::Pass(root_quads, arraysize(root_quads))}; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1158 EXPECT_TRUE( | 1161 EXPECT_TRUE( |
1159 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); | 1162 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); |
1160 | 1163 |
1161 // The second quad in the root pass is aggregated from the child, so its | 1164 // The second quad in the root pass is aggregated from the child, so its |
1162 // clip rect must be transformed by the child's translation/scale and | 1165 // clip rect must be transformed by the child's translation/scale and |
1163 // clipped be the visible_rects for both children. | 1166 // clipped be the visible_rects for both children. |
1164 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), | 1167 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), |
1165 aggregated_pass_list[1] | 1168 aggregated_pass_list[1] |
1166 ->shared_quad_state_list.ElementAt(1) | 1169 ->shared_quad_state_list.ElementAt(1) |
1167 ->clip_rect.ToString()); | 1170 ->clip_rect.ToString()); |
1168 | |
1169 factory_.Destroy(middle_local_frame_id); | |
1170 factory_.Destroy(child_local_frame_id); | |
1171 } | 1171 } |
1172 | 1172 |
1173 // Tests that damage rects are aggregated correctly when surfaces change. | 1173 // Tests that damage rects are aggregated correctly when surfaces change. |
1174 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { | 1174 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { |
1175 SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, | |
1176 &empty_client_); | |
1177 SurfaceFactory parent_factory(kArbitraryFrameSinkId, &manager_, | |
1178 &empty_client_); | |
1175 test::Quad child_quads[] = {test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1179 test::Quad child_quads[] = {test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
1176 test::Pass child_passes[] = { | 1180 test::Pass child_passes[] = { |
1177 test::Pass(child_quads, arraysize(child_quads), RenderPassId(1, 1))}; | 1181 test::Pass(child_quads, arraysize(child_quads), RenderPassId(1, 1))}; |
1178 | 1182 |
1179 CompositorFrame child_frame; | 1183 CompositorFrame child_frame; |
1180 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1184 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1181 child_passes, arraysize(child_passes)); | 1185 child_passes, arraysize(child_passes)); |
1182 | 1186 |
1183 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1187 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
1184 SharedQuadState* child_root_pass_sqs = | 1188 SharedQuadState* child_root_pass_sqs = |
1185 child_root_pass->shared_quad_state_list.front(); | 1189 child_root_pass->shared_quad_state_list.front(); |
1186 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1190 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1187 | 1191 |
1188 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1192 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
1189 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1193 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); |
1190 factory_.Create(child_local_frame_id); | 1194 child_factory.SubmitCompositorFrame(child_local_frame_id, |
1191 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1195 std::move(child_frame), |
1192 SurfaceFactory::DrawCallback()); | 1196 SurfaceFactory::DrawCallback()); |
1193 | 1197 |
1194 test::Quad parent_surface_quads[] = { | 1198 test::Quad parent_surface_quads[] = { |
1195 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1199 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1196 test::Pass parent_surface_passes[] = { | 1200 test::Pass parent_surface_passes[] = { |
1197 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), | 1201 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), |
1198 RenderPassId(1, 1))}; | 1202 RenderPassId(1, 1))}; |
1199 | 1203 |
1200 // Parent surface is only used to test if the transform is applied correctly | 1204 // Parent surface is only used to test if the transform is applied correctly |
1201 // to the child surface's damage. | 1205 // to the child surface's damage. |
1202 CompositorFrame parent_surface_frame; | 1206 CompositorFrame parent_surface_frame; |
1203 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1207 AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1204 parent_surface_passes, arraysize(parent_surface_passes)); | 1208 parent_surface_passes, arraysize(parent_surface_passes)); |
1205 | 1209 |
1206 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); | 1210 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); |
1207 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); | 1211 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); |
1208 factory_.Create(parent_local_frame_id); | 1212 parent_factory.SubmitCompositorFrame(parent_local_frame_id, |
1209 factory_.SubmitCompositorFrame(parent_local_frame_id, | 1213 std::move(parent_surface_frame), |
1210 std::move(parent_surface_frame), | 1214 SurfaceFactory::DrawCallback()); |
1211 SurfaceFactory::DrawCallback()); | |
1212 | 1215 |
1213 test::Quad root_surface_quads[] = { | 1216 test::Quad root_surface_quads[] = { |
1214 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; | 1217 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; |
1215 test::Quad root_render_pass_quads[] = { | 1218 test::Quad root_render_pass_quads[] = { |
1216 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1219 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
1217 | 1220 |
1218 test::Pass root_passes[] = { | 1221 test::Pass root_passes[] = { |
1219 test::Pass(root_surface_quads, arraysize(root_surface_quads), | 1222 test::Pass(root_surface_quads, arraysize(root_surface_quads), |
1220 RenderPassId(1, 1)), | 1223 RenderPassId(1, 1)), |
1221 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), | 1224 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), |
(...skipping 28 matching lines...) Expand all Loading... | |
1250 CompositorFrame child_frame; | 1253 CompositorFrame child_frame; |
1251 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1254 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1252 child_passes, arraysize(child_passes)); | 1255 child_passes, arraysize(child_passes)); |
1253 | 1256 |
1254 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); | 1257 RenderPass* child_root_pass = child_frame.render_pass_list[0].get(); |
1255 SharedQuadState* child_root_pass_sqs = | 1258 SharedQuadState* child_root_pass_sqs = |
1256 child_root_pass->shared_quad_state_list.front(); | 1259 child_root_pass->shared_quad_state_list.front(); |
1257 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1260 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1258 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 1261 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
1259 | 1262 |
1260 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 1263 child_factory.SubmitCompositorFrame(child_local_frame_id, |
1261 SurfaceFactory::DrawCallback()); | 1264 std::move(child_frame), |
1265 SurfaceFactory::DrawCallback()); | |
1262 | 1266 |
1263 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); | 1267 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); |
1264 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1268 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
1265 | 1269 |
1266 const RenderPassList& aggregated_pass_list = | 1270 const RenderPassList& aggregated_pass_list = |
1267 aggregated_frame.render_pass_list; | 1271 aggregated_frame.render_pass_list; |
1268 | 1272 |
1269 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1273 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1270 | 1274 |
1271 // Outer surface didn't change, so transformed inner damage rect should be | 1275 // Outer surface didn't change, so transformed inner damage rect should be |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1335 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1339 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
1336 | 1340 |
1337 const RenderPassList& aggregated_pass_list = | 1341 const RenderPassList& aggregated_pass_list = |
1338 aggregated_frame.render_pass_list; | 1342 aggregated_frame.render_pass_list; |
1339 | 1343 |
1340 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1344 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1341 | 1345 |
1342 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1346 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1343 gfx::Rect(SurfaceSize()))); | 1347 gfx::Rect(SurfaceSize()))); |
1344 } | 1348 } |
1345 | |
1346 factory_.Destroy(child_local_frame_id); | |
1347 } | 1349 } |
1348 | 1350 |
1349 // Check that damage is correctly calculated for surfaces with | 1351 // Check that damage is correctly calculated for surfaces with |
1350 // SetPreviousFrameSurface. | 1352 // SetPreviousFrameSurface. |
danakj
2016/11/12 00:27:21
You deleted this function, so what is this testing
Saman Sami
2016/11/14 23:39:01
It can still test whether SubmitCompositorFrame co
danakj
2016/11/15 00:43:40
Thanks, was looking for the comment to be updated
| |
1351 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { | 1353 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { |
1352 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; | 1354 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; |
1353 | 1355 |
1354 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, | 1356 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, |
1355 arraysize(root_render_pass_quads), | 1357 arraysize(root_render_pass_quads), |
1356 RenderPassId(2, 1))}; | 1358 RenderPassId(2, 1))}; |
1357 | 1359 |
1358 CompositorFrame root_frame; | 1360 CompositorFrame root_frame; |
1359 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1361 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1360 arraysize(root_passes)); | 1362 arraysize(root_passes)); |
(...skipping 26 matching lines...) Expand all Loading... | |
1387 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, | 1389 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, |
1388 arraysize(root_render_pass_quads), | 1390 arraysize(root_render_pass_quads), |
1389 RenderPassId(2, 1))}; | 1391 RenderPassId(2, 1))}; |
1390 | 1392 |
1391 CompositorFrame root_frame; | 1393 CompositorFrame root_frame; |
1392 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1394 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
1393 root_passes, arraysize(root_passes)); | 1395 root_passes, arraysize(root_passes)); |
1394 | 1396 |
1395 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); | 1397 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); |
1396 | 1398 |
1397 factory_.Create(second_root_local_frame_id); | |
1398 factory_.SubmitCompositorFrame(second_root_local_frame_id, | 1399 factory_.SubmitCompositorFrame(second_root_local_frame_id, |
1399 std::move(root_frame), | 1400 std::move(root_frame), |
1400 SurfaceFactory::DrawCallback()); | 1401 SurfaceFactory::DrawCallback()); |
1401 factory_.SetPreviousFrameSurface(second_root_local_frame_id, | |
1402 root_local_frame_id_); | |
1403 } | 1402 } |
1404 { | 1403 { |
1405 CompositorFrame aggregated_frame = | 1404 CompositorFrame aggregated_frame = |
1406 aggregator_.Aggregate(second_root_surface_id); | 1405 aggregator_.Aggregate(second_root_surface_id); |
1407 | 1406 |
1408 const RenderPassList& aggregated_pass_list = | 1407 const RenderPassList& aggregated_pass_list = |
1409 aggregated_frame.render_pass_list; | 1408 aggregated_frame.render_pass_list; |
1410 | 1409 |
1411 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1410 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1412 | 1411 |
1413 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect | 1412 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect |
danakj
2016/11/12 00:27:21
This comment and expectation is referring to a fun
Saman Sami
2016/11/14 23:39:01
Done.
| |
1414 // from new surface should be used. | 1413 // from new surface should be used. |
1415 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); | 1414 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); |
1416 } | 1415 } |
1417 { | 1416 { |
1418 CompositorFrame aggregated_frame = | 1417 CompositorFrame aggregated_frame = |
1419 aggregator_.Aggregate(second_root_surface_id); | 1418 aggregator_.Aggregate(second_root_surface_id); |
1420 | 1419 |
1421 const RenderPassList& aggregated_pass_list = | 1420 const RenderPassList& aggregated_pass_list = |
1422 aggregated_frame.render_pass_list; | 1421 aggregated_frame.render_pass_list; |
1423 | 1422 |
1424 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1423 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1425 | 1424 |
1426 // No new frame, so no new damage. | 1425 // No new frame, so no new damage. |
1427 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1426 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
1428 } | 1427 } |
1429 factory_.Destroy(second_root_local_frame_id); | |
1430 } | 1428 } |
1431 | 1429 |
1432 class SurfaceAggregatorPartialSwapTest | 1430 class SurfaceAggregatorPartialSwapTest |
1433 : public SurfaceAggregatorValidSurfaceTest { | 1431 : public SurfaceAggregatorValidSurfaceTest { |
1434 public: | 1432 public: |
1435 SurfaceAggregatorPartialSwapTest() | 1433 SurfaceAggregatorPartialSwapTest() |
1436 : SurfaceAggregatorValidSurfaceTest(true) {} | 1434 : SurfaceAggregatorValidSurfaceTest(true) {} |
1437 }; | 1435 }; |
1438 | 1436 |
1439 // Tests that quads outside the damage rect are ignored. | 1437 // Tests that quads outside the damage rect are ignored. |
1440 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { | 1438 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { |
1439 SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, | |
1440 &empty_client_); | |
1441 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 1441 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
1442 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 1442 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); |
1443 factory_.Create(child_local_frame_id); | |
1444 // The child surface has three quads, one with a visible rect of 13,13 4x4 and | 1443 // The child surface has three quads, one with a visible rect of 13,13 4x4 and |
1445 // the other other with a visible rect of 10,10 2x2 (relative to root target | 1444 // the other other with a visible rect of 10,10 2x2 (relative to root target |
1446 // space), and one with a non-invertible transform. | 1445 // space), and one with a non-invertible transform. |
1447 { | 1446 { |
1448 RenderPassId child_pass_id = RenderPassId(1, 1); | 1447 RenderPassId child_pass_id = RenderPassId(1, 1); |
1449 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1448 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1450 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1449 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1451 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1450 test::Quad child_quads3[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1452 test::Pass child_passes[] = { | 1451 test::Pass child_passes[] = { |
1453 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), | 1452 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), |
(...skipping 16 matching lines...) Expand all Loading... | |
1470 | 1469 |
1471 SharedQuadState* child_noninvertible_sqs = | 1470 SharedQuadState* child_noninvertible_sqs = |
1472 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); | 1471 child_pass_list[2]->shared_quad_state_list.ElementAt(0u); |
1473 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, | 1472 child_noninvertible_sqs->quad_to_target_transform.matrix().setDouble(0, 0, |
1474 0.0); | 1473 0.0); |
1475 EXPECT_FALSE( | 1474 EXPECT_FALSE( |
1476 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); | 1475 child_noninvertible_sqs->quad_to_target_transform.IsInvertible()); |
1477 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = | 1476 child_pass_list[2]->quad_list.ElementAt(0)->visible_rect = |
1478 gfx::Rect(0, 0, 2, 2); | 1477 gfx::Rect(0, 0, 2, 2); |
1479 | 1478 |
1480 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list); | 1479 SubmitPassListAsFrame(&child_factory, child_local_frame_id, |
1480 &child_pass_list); | |
1481 } | 1481 } |
1482 | 1482 |
1483 { | 1483 { |
1484 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1484 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1485 | 1485 |
1486 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1486 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
1487 | 1487 |
1488 RenderPassList root_pass_list; | 1488 RenderPassList root_pass_list; |
1489 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1489 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1490 arraysize(root_passes)); | 1490 arraysize(root_passes)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1568 child_sqs->quad_to_target_transform.Scale(2, 2); | 1568 child_sqs->quad_to_target_transform.Scale(2, 2); |
1569 | 1569 |
1570 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = | 1570 child_pass_list[1]->quad_list.ElementAt(0)->visible_rect = |
1571 gfx::Rect(0, 0, 2, 2); | 1571 gfx::Rect(0, 0, 2, 2); |
1572 | 1572 |
1573 RenderPass* child_root_pass = child_pass_list[1].get(); | 1573 RenderPass* child_root_pass = child_pass_list[1].get(); |
1574 | 1574 |
1575 child_root_pass->copy_requests.push_back( | 1575 child_root_pass->copy_requests.push_back( |
1576 CopyOutputRequest::CreateEmptyRequest()); | 1576 CopyOutputRequest::CreateEmptyRequest()); |
1577 child_root_pass->damage_rect = gfx::Rect(); | 1577 child_root_pass->damage_rect = gfx::Rect(); |
1578 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list); | 1578 SubmitPassListAsFrame(&child_factory, child_local_frame_id, |
1579 &child_pass_list); | |
1579 } | 1580 } |
1580 | 1581 |
1581 { | 1582 { |
1582 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1583 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
1583 | 1584 |
1584 const RenderPassList& aggregated_pass_list = | 1585 const RenderPassList& aggregated_pass_list = |
1585 aggregated_frame.render_pass_list; | 1586 aggregated_frame.render_pass_list; |
1586 | 1587 |
1587 // Output frame should have no damage, but all quads included. | 1588 // Output frame should have no damage, but all quads included. |
1588 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1589 ASSERT_EQ(3u, aggregated_pass_list.size()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1695 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1696 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1696 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); | 1697 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); |
1697 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1698 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
1698 | 1699 |
1699 // First render pass draw quad is outside damage rect, so shouldn't be | 1700 // First render pass draw quad is outside damage rect, so shouldn't be |
1700 // drawn. SurfaceDrawQuad is after background filter, so corresponding | 1701 // drawn. SurfaceDrawQuad is after background filter, so corresponding |
1701 // RenderPassDrawQuad should be drawn. | 1702 // RenderPassDrawQuad should be drawn. |
1702 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); | 1703 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); |
1703 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | 1704 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); |
1704 } | 1705 } |
1705 | |
1706 factory_.Destroy(child_local_frame_id); | |
1707 } | 1706 } |
1708 | 1707 |
1709 class SurfaceAggregatorWithResourcesTest : public testing::Test { | 1708 class SurfaceAggregatorWithResourcesTest : public testing::Test { |
1710 public: | 1709 public: |
1711 void SetUp() override { | 1710 void SetUp() override { |
1712 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 1711 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
1713 resource_provider_ = | 1712 resource_provider_ = |
1714 FakeResourceProvider::Create(nullptr, shared_bitmap_manager_.get()); | 1713 FakeResourceProvider::Create(nullptr, shared_bitmap_manager_.get()); |
1715 | 1714 |
1716 aggregator_.reset( | 1715 aggregator_.reset( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1791 frame.render_pass_list.push_back(std::move(pass)); | 1790 frame.render_pass_list.push_back(std::move(pass)); |
1792 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame), | 1791 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame), |
1793 SurfaceFactory::DrawCallback()); | 1792 SurfaceFactory::DrawCallback()); |
1794 } | 1793 } |
1795 | 1794 |
1796 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1795 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
1797 ResourceTrackingSurfaceFactoryClient client; | 1796 ResourceTrackingSurfaceFactoryClient client; |
1798 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1797 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
1799 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); | 1798 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); |
1800 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); | 1799 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); |
1801 factory.Create(local_frame_id); | |
1802 | 1800 |
1803 ResourceId ids[] = {11, 12, 13}; | 1801 ResourceId ids[] = {11, 12, 13}; |
1804 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1802 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1805 &factory, surface_id); | 1803 &factory, surface_id); |
1806 | 1804 |
1807 CompositorFrame frame = aggregator_->Aggregate(surface_id); | 1805 CompositorFrame frame = aggregator_->Aggregate(surface_id); |
1808 | 1806 |
1809 // Nothing should be available to be returned yet. | 1807 // Nothing should be available to be returned yet. |
1810 EXPECT_TRUE(client.returned_resources().empty()); | 1808 EXPECT_TRUE(client.returned_resources().empty()); |
1811 | 1809 |
1812 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1810 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, |
1813 surface_id); | 1811 surface_id); |
1814 | 1812 |
1815 frame = aggregator_->Aggregate(surface_id); | 1813 frame = aggregator_->Aggregate(surface_id); |
1816 | 1814 |
1817 ASSERT_EQ(3u, client.returned_resources().size()); | 1815 ASSERT_EQ(3u, client.returned_resources().size()); |
1818 ResourceId returned_ids[3]; | 1816 ResourceId returned_ids[3]; |
1819 for (size_t i = 0; i < 3; ++i) { | 1817 for (size_t i = 0; i < 3; ++i) { |
1820 returned_ids[i] = client.returned_resources()[i].id; | 1818 returned_ids[i] = client.returned_resources()[i].id; |
1821 } | 1819 } |
1822 EXPECT_THAT(returned_ids, | 1820 EXPECT_THAT(returned_ids, |
1823 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1821 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1824 factory.Destroy(local_frame_id); | |
1825 } | 1822 } |
1826 | 1823 |
1827 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 1824 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
1828 ResourceTrackingSurfaceFactoryClient client; | 1825 ResourceTrackingSurfaceFactoryClient client; |
1829 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1826 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); |
1830 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); | 1827 LocalFrameId local_frame_id(7u, base::UnguessableToken::Create()); |
1831 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); | 1828 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); |
1832 factory.Create(local_frame_id); | |
1833 | 1829 |
1834 CompositorFrame frame; | 1830 CompositorFrame frame; |
1835 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1831 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
1836 pass->id = RenderPassId(1, 1); | 1832 pass->id = RenderPassId(1, 1); |
1837 TransferableResource resource; | 1833 TransferableResource resource; |
1838 resource.id = 11; | 1834 resource.id = 11; |
1839 // ResourceProvider is software but resource is not, so it should be | 1835 // ResourceProvider is software but resource is not, so it should be |
1840 // ignored. | 1836 // ignored. |
1841 resource.is_software = false; | 1837 resource.is_software = false; |
1842 frame.resource_list.push_back(resource); | 1838 frame.resource_list.push_back(resource); |
1843 frame.render_pass_list.push_back(std::move(pass)); | 1839 frame.render_pass_list.push_back(std::move(pass)); |
1844 factory.SubmitCompositorFrame(local_frame_id, std::move(frame), | 1840 factory.SubmitCompositorFrame(local_frame_id, std::move(frame), |
1845 SurfaceFactory::DrawCallback()); | 1841 SurfaceFactory::DrawCallback()); |
1846 | 1842 |
1847 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); | 1843 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); |
1848 | 1844 |
1849 // Nothing should be available to be returned yet. | 1845 // Nothing should be available to be returned yet. |
1850 EXPECT_TRUE(client.returned_resources().empty()); | 1846 EXPECT_TRUE(client.returned_resources().empty()); |
1851 | 1847 |
1852 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1848 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
1853 surface_id); | 1849 surface_id); |
1854 ASSERT_EQ(1u, client.returned_resources().size()); | 1850 ASSERT_EQ(1u, client.returned_resources().size()); |
1855 EXPECT_EQ(11u, client.returned_resources()[0].id); | 1851 EXPECT_EQ(11u, client.returned_resources()[0].id); |
1856 | |
1857 factory.Destroy(local_frame_id); | |
1858 } | 1852 } |
1859 | 1853 |
1860 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1854 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
1861 ResourceTrackingSurfaceFactoryClient client; | 1855 ResourceTrackingSurfaceFactoryClient client; |
1862 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1856 SurfaceFactory factory1(kArbitraryFrameSinkId, &manager_, &client); |
1857 SurfaceFactory factory2(kArbitraryFrameSinkId, &manager_, &client); | |
1863 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); | 1858 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); |
1864 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); | 1859 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); |
1865 factory.Create(local_frame1_id); | |
1866 | 1860 |
1867 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); | 1861 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); |
1868 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); | 1862 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); |
1869 factory.Create(local_frame2_id); | |
1870 | 1863 |
1871 ResourceId ids[] = {11, 12, 13}; | 1864 ResourceId ids[] = {11, 12, 13}; |
1872 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1865 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1873 &factory, surface1_id); | 1866 &factory1, surface1_id); |
1874 ResourceId ids2[] = {14, 15, 16}; | 1867 ResourceId ids2[] = {14, 15, 16}; |
1875 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), | 1868 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), |
1876 &factory, surface2_id); | 1869 &factory2, surface2_id); |
1877 | 1870 |
1878 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 1871 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
1879 | 1872 |
1880 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1873 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory1, |
1881 surface1_id); | 1874 surface1_id); |
1882 | 1875 |
1883 // Nothing should be available to be returned yet. | 1876 // Nothing should be available to be returned yet. |
1884 EXPECT_TRUE(client.returned_resources().empty()); | 1877 EXPECT_TRUE(client.returned_resources().empty()); |
1885 | 1878 |
1886 frame = aggregator_->Aggregate(surface2_id); | 1879 frame = aggregator_->Aggregate(surface2_id); |
1887 | 1880 |
1888 // surface1_id wasn't referenced, so its resources should be returned. | 1881 // surface1_id wasn't referenced, so its resources should be returned. |
1889 ASSERT_EQ(3u, client.returned_resources().size()); | 1882 ASSERT_EQ(3u, client.returned_resources().size()); |
1890 ResourceId returned_ids[3]; | 1883 ResourceId returned_ids[3]; |
1891 for (size_t i = 0; i < 3; ++i) { | 1884 for (size_t i = 0; i < 3; ++i) { |
1892 returned_ids[i] = client.returned_resources()[i].id; | 1885 returned_ids[i] = client.returned_resources()[i].id; |
1893 } | 1886 } |
1894 EXPECT_THAT(returned_ids, | 1887 EXPECT_THAT(returned_ids, |
1895 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1888 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1896 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1889 EXPECT_EQ(3u, resource_provider_->num_resources()); |
1897 factory.Destroy(local_frame1_id); | |
1898 factory.Destroy(local_frame2_id); | |
1899 } | 1890 } |
1900 | 1891 |
1901 // Ensure that aggregator completely ignores Surfaces that reference invalid | 1892 // Ensure that aggregator completely ignores Surfaces that reference invalid |
1902 // resources. | 1893 // resources. |
1903 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 1894 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
1904 ResourceTrackingSurfaceFactoryClient client; | 1895 ResourceTrackingSurfaceFactoryClient client; |
1905 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1896 SurfaceFactory root_factory(kArbitraryFrameSinkId, &manager_, &client); |
1897 SurfaceFactory middle_factory(kArbitraryFrameSinkId, &manager_, &client); | |
1898 SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, &client); | |
1906 LocalFrameId root_local_frame_id(7u, kArbitraryToken); | 1899 LocalFrameId root_local_frame_id(7u, kArbitraryToken); |
1907 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); | 1900 SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id); |
1908 factory.Create(root_local_frame_id); | |
1909 LocalFrameId middle_local_frame_id(8u, kArbitraryToken); | 1901 LocalFrameId middle_local_frame_id(8u, kArbitraryToken); |
1910 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); | 1902 SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id); |
1911 factory.Create(middle_local_frame_id); | |
1912 LocalFrameId child_local_frame_id(9u, kArbitraryToken); | 1903 LocalFrameId child_local_frame_id(9u, kArbitraryToken); |
1913 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); | 1904 SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id); |
1914 factory.Create(child_local_frame_id); | |
1915 | 1905 |
1916 ResourceId ids[] = {14, 15, 16}; | 1906 ResourceId ids[] = {14, 15, 16}; |
1917 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1907 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1918 &factory, child_surface_id); | 1908 &child_factory, child_surface_id); |
1919 | 1909 |
1920 ResourceId ids2[] = {17, 18, 19}; | 1910 ResourceId ids2[] = {17, 18, 19}; |
1921 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 1911 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
1922 child_surface_id, &factory, | 1912 child_surface_id, &middle_factory, |
1923 middle_surface_id); | 1913 middle_surface_id); |
1924 | 1914 |
1925 ResourceId ids3[] = {20, 21, 22}; | 1915 ResourceId ids3[] = {20, 21, 22}; |
1926 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 1916 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
1927 middle_surface_id, &factory, | 1917 middle_surface_id, &root_factory, |
1928 root_surface_id); | 1918 root_surface_id); |
1929 | 1919 |
1930 CompositorFrame frame; | 1920 CompositorFrame frame; |
1931 frame = aggregator_->Aggregate(root_surface_id); | 1921 frame = aggregator_->Aggregate(root_surface_id); |
1932 | 1922 |
1933 RenderPassList* pass_list = &frame.render_pass_list; | 1923 RenderPassList* pass_list = &frame.render_pass_list; |
1934 ASSERT_EQ(1u, pass_list->size()); | 1924 ASSERT_EQ(1u, pass_list->size()); |
1935 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 1925 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
1936 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 1926 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
1937 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 1927 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
1938 child_surface_id, &factory, | 1928 child_surface_id, &middle_factory, |
1939 middle_surface_id); | 1929 middle_surface_id); |
1940 | 1930 |
1941 frame = aggregator_->Aggregate(root_surface_id); | 1931 frame = aggregator_->Aggregate(root_surface_id); |
1942 | 1932 |
1943 pass_list = &frame.render_pass_list; | 1933 pass_list = &frame.render_pass_list; |
1944 ASSERT_EQ(1u, pass_list->size()); | 1934 ASSERT_EQ(1u, pass_list->size()); |
1945 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 1935 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
1946 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 1936 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
1947 | |
1948 factory.Destroy(root_local_frame_id); | |
1949 factory.Destroy(child_local_frame_id); | |
1950 factory.Destroy(middle_local_frame_id); | |
1951 } | 1937 } |
1952 | 1938 |
1953 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { | 1939 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { |
1954 ResourceTrackingSurfaceFactoryClient client; | 1940 ResourceTrackingSurfaceFactoryClient client; |
1955 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); | 1941 SurfaceFactory factory1(kArbitraryFrameSinkId, &manager_, &client); |
1942 SurfaceFactory factory2(kArbitraryFrameSinkId, &manager_, &client); | |
1956 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); | 1943 LocalFrameId local_frame1_id(7u, base::UnguessableToken::Create()); |
1957 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); | 1944 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); |
1958 factory.Create(local_frame1_id); | |
1959 | 1945 |
1960 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); | 1946 LocalFrameId local_frame2_id(8u, base::UnguessableToken::Create()); |
1961 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); | 1947 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); |
1962 factory.Create(local_frame2_id); | |
1963 | 1948 |
1964 ResourceId ids[] = {11, 12, 13}; | 1949 ResourceId ids[] = {11, 12, 13}; |
1965 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1950 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1966 &factory, surface1_id); | 1951 &factory1, surface1_id); |
1967 | 1952 |
1968 CompositorFrame frame = aggregator_->Aggregate(surface1_id); | 1953 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
1969 | 1954 |
1970 RenderPass* render_pass = frame.render_pass_list.back().get(); | 1955 RenderPass* render_pass = frame.render_pass_list.back().get(); |
1971 | 1956 |
1972 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); | 1957 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); |
1973 | 1958 |
1974 { | 1959 { |
1975 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1960 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
1976 pass->id = RenderPassId(1, 1); | 1961 pass->id = RenderPassId(1, 1); |
1977 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 1962 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
1978 sqs->opacity = 1.f; | 1963 sqs->opacity = 1.f; |
1979 SurfaceDrawQuad* surface_quad = | 1964 SurfaceDrawQuad* surface_quad = |
1980 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1965 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
1966 | |
1981 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 1967 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
1982 surface1_id); | 1968 surface1_id); |
1983 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 1969 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
1984 | 1970 |
1985 CompositorFrame frame; | 1971 CompositorFrame frame; |
1986 frame.render_pass_list.push_back(std::move(pass)); | 1972 frame.render_pass_list.push_back(std::move(pass)); |
1987 | 1973 |
1988 factory.SubmitCompositorFrame(local_frame2_id, std::move(frame), | 1974 factory2.SubmitCompositorFrame(local_frame2_id, std::move(frame), |
1989 SurfaceFactory::DrawCallback()); | 1975 SurfaceFactory::DrawCallback()); |
1990 } | 1976 } |
1991 | 1977 |
1992 frame = aggregator_->Aggregate(surface2_id); | 1978 frame = aggregator_->Aggregate(surface2_id); |
1993 EXPECT_EQ(1u, frame.render_pass_list.size()); | 1979 EXPECT_EQ(1u, frame.render_pass_list.size()); |
1994 render_pass = frame.render_pass_list.front().get(); | 1980 render_pass = frame.render_pass_list.front().get(); |
1995 | 1981 |
1996 // Parent has copy request, so texture should not be drawn. | 1982 // Parent has copy request, so texture should not be drawn. |
1997 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 1983 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
1998 | 1984 |
1999 frame = aggregator_->Aggregate(surface2_id); | 1985 frame = aggregator_->Aggregate(surface2_id); |
2000 EXPECT_EQ(1u, frame.render_pass_list.size()); | 1986 EXPECT_EQ(1u, frame.render_pass_list.size()); |
2001 render_pass = frame.render_pass_list.front().get(); | 1987 render_pass = frame.render_pass_list.front().get(); |
2002 | 1988 |
2003 // Copy request has been executed earlier, so texture should be drawn. | 1989 // Copy request has been executed earlier, so texture should be drawn. |
2004 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, | 1990 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, |
2005 render_pass->quad_list.front()->material); | 1991 render_pass->quad_list.front()->material); |
2006 | 1992 |
2007 aggregator_->set_output_is_secure(false); | 1993 aggregator_->set_output_is_secure(false); |
2008 | 1994 |
2009 frame = aggregator_->Aggregate(surface2_id); | 1995 frame = aggregator_->Aggregate(surface2_id); |
2010 render_pass = frame.render_pass_list.back().get(); | 1996 render_pass = frame.render_pass_list.back().get(); |
2011 | 1997 |
2012 // Output is insecure, so texture should be drawn. | 1998 // Output is insecure, so texture should be drawn. |
2013 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 1999 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
2014 | |
2015 factory.Destroy(local_frame1_id); | |
2016 factory.Destroy(local_frame2_id); | |
2017 } | 2000 } |
2018 | 2001 |
2019 } // namespace | 2002 } // namespace |
2020 } // namespace cc | 2003 } // namespace cc |
2021 | 2004 |
OLD | NEW |