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/output/compositor_frame.h" | 5 #include "cc/output/compositor_frame.h" |
6 #include "cc/output/delegated_frame_data.h" | 6 #include "cc/output/delegated_frame_data.h" |
7 #include "cc/quads/render_pass.h" | 7 #include "cc/quads/render_pass.h" |
8 #include "cc/quads/render_pass_draw_quad.h" | 8 #include "cc/quads/render_pass_draw_quad.h" |
9 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 } | 36 } |
37 | 37 |
38 gfx::Size SurfaceSize() { | 38 gfx::Size SurfaceSize() { |
39 static gfx::Size size(5, 5); | 39 static gfx::Size size(5, 5); |
40 return size; | 40 return size; |
41 } | 41 } |
42 | 42 |
43 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { | 43 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { |
44 public: | 44 public: |
45 void ReturnResources(const ReturnedResourceArray& resources) override {} | 45 void ReturnResources(const ReturnedResourceArray& resources) override {} |
46 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} | |
47 }; | |
48 | |
49 class FakeSurfaceAggregatorClient : public SurfaceAggregatorClient { | |
50 public: | |
51 void AddSurface(Surface* surface) override { | |
52 EXPECT_FALSE(HasSurface(surface)); | |
53 surfaces_.insert(surface); | |
54 } | |
55 | |
56 void RemoveSurface(Surface* surface) override { | |
57 EXPECT_TRUE(HasSurface(surface)); | |
58 surfaces_.erase(surface); | |
59 } | |
60 | |
61 bool HasSurface(Surface* surface) const { | |
62 return surfaces_.count(surface) != 0; | |
63 } | |
64 | |
65 private: | |
66 std::set<Surface*> surfaces_; | |
46 }; | 67 }; |
47 | 68 |
48 class SurfaceAggregatorTest : public testing::Test { | 69 class SurfaceAggregatorTest : public testing::Test { |
49 public: | 70 public: |
50 explicit SurfaceAggregatorTest(bool use_damage_rect) | 71 explicit SurfaceAggregatorTest(bool use_damage_rect) |
51 : factory_(&manager_, &empty_client_), | 72 : factory_(&manager_, &empty_client_), |
52 aggregator_(&manager_, NULL, use_damage_rect) {} | 73 aggregator_(&surface_aggregator_client_, |
74 &manager_, | |
75 NULL, | |
76 use_damage_rect) {} | |
53 | 77 |
54 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} | 78 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} |
55 | 79 |
56 protected: | 80 protected: |
57 SurfaceManager manager_; | 81 SurfaceManager manager_; |
58 EmptySurfaceFactoryClient empty_client_; | 82 EmptySurfaceFactoryClient empty_client_; |
59 SurfaceFactory factory_; | 83 SurfaceFactory factory_; |
84 FakeSurfaceAggregatorClient surface_aggregator_client_; | |
60 SurfaceAggregator aggregator_; | 85 SurfaceAggregator aggregator_; |
61 }; | 86 }; |
62 | 87 |
63 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 88 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
64 SurfaceId one_id(7); | 89 SurfaceId one_id(7); |
65 factory_.Create(one_id); | 90 factory_.Create(one_id); |
91 Surface* surface = manager_.GetSurfaceForId(one_id); | |
92 | |
93 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
66 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); | 94 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); |
67 EXPECT_FALSE(frame); | 95 EXPECT_FALSE(frame); |
96 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
97 | |
68 factory_.Destroy(one_id); | 98 factory_.Destroy(one_id); |
69 } | 99 } |
70 | 100 |
71 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 101 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
72 public: | 102 public: |
73 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 103 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
74 : SurfaceAggregatorTest(use_damage_rect), | 104 : SurfaceAggregatorTest(use_damage_rect), |
75 allocator_(1u), | 105 allocator_(1u), |
76 child_allocator_(2u) {} | 106 child_allocator_(2u) {} |
77 SurfaceAggregatorValidSurfaceTest() | 107 SurfaceAggregatorValidSurfaceTest() |
78 : SurfaceAggregatorValidSurfaceTest(false) {} | 108 : SurfaceAggregatorValidSurfaceTest(false) {} |
79 | 109 |
80 void SetUp() override { | 110 void SetUp() override { |
81 SurfaceAggregatorTest::SetUp(); | 111 SurfaceAggregatorTest::SetUp(); |
82 root_surface_id_ = allocator_.GenerateId(); | 112 root_surface_id_ = allocator_.GenerateId(); |
83 factory_.Create(root_surface_id_); | 113 factory_.Create(root_surface_id_); |
114 root_surface_ = manager_.GetSurfaceForId(root_surface_id_); | |
84 } | 115 } |
85 | 116 |
86 void TearDown() override { | 117 void TearDown() override { |
87 factory_.Destroy(root_surface_id_); | 118 factory_.Destroy(root_surface_id_); |
88 SurfaceAggregatorTest::TearDown(); | 119 SurfaceAggregatorTest::TearDown(); |
89 } | 120 } |
90 | 121 |
91 void AggregateAndVerify(test::Pass* expected_passes, | 122 void AggregateAndVerify(test::Pass* expected_passes, |
92 size_t expected_pass_count, | 123 size_t expected_pass_count, |
93 SurfaceId* surface_ids, | 124 SurfaceId* surface_ids, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 175 |
145 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 176 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
146 child_frame->delegated_frame_data = delegated_frame_data.Pass(); | 177 child_frame->delegated_frame_data = delegated_frame_data.Pass(); |
147 | 178 |
148 factory_.SubmitCompositorFrame(surface_id, child_frame.Pass(), | 179 factory_.SubmitCompositorFrame(surface_id, child_frame.Pass(), |
149 SurfaceFactory::DrawCallback()); | 180 SurfaceFactory::DrawCallback()); |
150 } | 181 } |
151 | 182 |
152 protected: | 183 protected: |
153 SurfaceId root_surface_id_; | 184 SurfaceId root_surface_id_; |
185 Surface* root_surface_; | |
154 SurfaceIdAllocator allocator_; | 186 SurfaceIdAllocator allocator_; |
155 SurfaceIdAllocator child_allocator_; | 187 SurfaceIdAllocator child_allocator_; |
156 }; | 188 }; |
157 | 189 |
158 // Tests that a very simple frame containing only two solid color quads makes it | 190 // Tests that a very simple frame containing only two solid color quads makes it |
159 // through the aggregator correctly. | 191 // through the aggregator correctly. |
160 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { | 192 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { |
161 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), | 193 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), |
162 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 194 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
163 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 195 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
164 | 196 |
165 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 197 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
166 | 198 |
167 SurfaceId ids[] = {root_surface_id_}; | 199 SurfaceId ids[] = {root_surface_id_}; |
200 | |
201 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
168 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 202 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
203 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
169 } | 204 } |
170 | 205 |
171 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 206 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
172 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 207 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
173 factory_.Create(embedded_surface_id); | 208 factory_.Create(embedded_surface_id); |
209 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
210 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
174 | 211 |
175 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 212 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
176 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 213 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
177 test::Pass embedded_passes[] = { | 214 test::Pass embedded_passes[] = { |
178 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 215 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
179 | 216 |
180 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 217 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
181 embedded_surface_id); | 218 embedded_surface_id); |
182 | 219 |
183 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 220 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
184 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 221 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
185 | 222 |
186 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 223 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
187 | 224 |
225 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
226 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
mithro-old
2015/10/01 03:00:24
Thanks for adding these!
I wonder if would be a g
brianderson
2015/10/07 20:54:48
Might do it as a followup patch since I can't thin
| |
227 | |
188 scoped_ptr<CompositorFrame> aggregated_frame = | 228 scoped_ptr<CompositorFrame> aggregated_frame = |
189 aggregator_.Aggregate(root_surface_id_); | 229 aggregator_.Aggregate(root_surface_id_); |
190 | 230 |
231 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
232 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
233 | |
191 ASSERT_TRUE(aggregated_frame); | 234 ASSERT_TRUE(aggregated_frame); |
192 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 235 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
193 | 236 |
194 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 237 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
195 | 238 |
196 RenderPassList& render_pass_list(frame_data->render_pass_list); | 239 RenderPassList& render_pass_list(frame_data->render_pass_list); |
197 ASSERT_EQ(2u, render_pass_list.size()); | 240 ASSERT_EQ(2u, render_pass_list.size()); |
198 SharedQuadStateList& shared_quad_state_list( | 241 SharedQuadStateList& shared_quad_state_list( |
199 render_pass_list[0]->shared_quad_state_list); | 242 render_pass_list[0]->shared_quad_state_list); |
200 ASSERT_EQ(2u, shared_quad_state_list.size()); | 243 ASSERT_EQ(2u, shared_quad_state_list.size()); |
(...skipping 13 matching lines...) Expand all Loading... | |
214 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 257 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
215 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 258 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
216 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 259 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
217 test::Pass passes[] = { | 260 test::Pass passes[] = { |
218 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), | 261 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), |
219 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; | 262 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; |
220 | 263 |
221 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 264 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
222 | 265 |
223 SurfaceId ids[] = {root_surface_id_}; | 266 SurfaceId ids[] = {root_surface_id_}; |
267 | |
268 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
224 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 269 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
270 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
225 } | 271 } |
226 | 272 |
227 // This tests very simple embedding. root_surface has a frame containing a few | 273 // This tests very simple embedding. root_surface has a frame containing a few |
228 // solid color quads and a surface quad referencing embedded_surface. | 274 // solid color quads and a surface quad referencing embedded_surface. |
229 // embedded_surface has a frame containing only a solid color quad. The solid | 275 // embedded_surface has a frame containing only a solid color quad. The solid |
230 // color quad should be aggregated into the final frame. | 276 // color quad should be aggregated into the final frame. |
231 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 277 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
232 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 278 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
233 factory_.Create(embedded_surface_id); | 279 factory_.Create(embedded_surface_id); |
280 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
281 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
234 | 282 |
235 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 283 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
236 test::Pass embedded_passes[] = { | 284 test::Pass embedded_passes[] = { |
237 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 285 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
238 | 286 |
239 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 287 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
240 embedded_surface_id); | 288 embedded_surface_id); |
241 | 289 |
242 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 290 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
243 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 291 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
244 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 292 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
245 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 293 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
246 | 294 |
247 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 295 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
248 | 296 |
297 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
298 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
299 | |
249 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 300 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
250 test::Quad::SolidColorQuad(SK_ColorGREEN), | 301 test::Quad::SolidColorQuad(SK_ColorGREEN), |
251 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 302 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
252 test::Pass expected_passes[] = { | 303 test::Pass expected_passes[] = { |
253 test::Pass(expected_quads, arraysize(expected_quads))}; | 304 test::Pass(expected_quads, arraysize(expected_quads))}; |
254 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; | 305 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; |
255 AggregateAndVerify( | 306 AggregateAndVerify( |
256 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 307 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
257 | 308 |
309 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
310 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
311 | |
258 factory_.Destroy(embedded_surface_id); | 312 factory_.Destroy(embedded_surface_id); |
259 } | 313 } |
260 | 314 |
261 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 315 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
262 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 316 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
263 factory_.Create(embedded_surface_id); | 317 factory_.Create(embedded_surface_id); |
318 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
319 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
264 | 320 |
265 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 321 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
266 test::Pass embedded_passes[] = { | 322 test::Pass embedded_passes[] = { |
267 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 323 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
268 | 324 |
269 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 325 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
270 embedded_surface_id); | 326 embedded_surface_id); |
271 scoped_ptr<CopyOutputRequest> copy_request( | 327 scoped_ptr<CopyOutputRequest> copy_request( |
272 CopyOutputRequest::CreateEmptyRequest()); | 328 CopyOutputRequest::CreateEmptyRequest()); |
273 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 329 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
274 factory_.RequestCopyOfSurface(embedded_surface_id, copy_request.Pass()); | 330 factory_.RequestCopyOfSurface(embedded_surface_id, copy_request.Pass()); |
275 | 331 |
276 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 332 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
277 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 333 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
278 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 334 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
279 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 335 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
280 | 336 |
281 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 337 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
282 | 338 |
339 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
340 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
341 | |
283 scoped_ptr<CompositorFrame> aggregated_frame = | 342 scoped_ptr<CompositorFrame> aggregated_frame = |
284 aggregator_.Aggregate(root_surface_id_); | 343 aggregator_.Aggregate(root_surface_id_); |
285 | 344 |
345 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
346 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
347 | |
286 ASSERT_TRUE(aggregated_frame); | 348 ASSERT_TRUE(aggregated_frame); |
287 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 349 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
288 | 350 |
289 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 351 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
290 | 352 |
291 test::Quad expected_quads[] = { | 353 test::Quad expected_quads[] = { |
292 test::Quad::SolidColorQuad(SK_ColorWHITE), | 354 test::Quad::SolidColorQuad(SK_ColorWHITE), |
293 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), | 355 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), |
294 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 356 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
295 test::Pass expected_passes[] = { | 357 test::Pass expected_passes[] = { |
(...skipping 16 matching lines...) Expand all Loading... | |
312 aggregator_.previous_contained_surfaces().end()); | 374 aggregator_.previous_contained_surfaces().end()); |
313 } | 375 } |
314 | 376 |
315 factory_.Destroy(embedded_surface_id); | 377 factory_.Destroy(embedded_surface_id); |
316 } | 378 } |
317 | 379 |
318 // Root surface may contain copy requests. | 380 // Root surface may contain copy requests. |
319 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 381 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
320 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 382 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
321 factory_.Create(embedded_surface_id); | 383 factory_.Create(embedded_surface_id); |
384 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
385 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
322 | 386 |
323 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 387 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
324 test::Pass embedded_passes[] = { | 388 test::Pass embedded_passes[] = { |
325 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 389 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
326 | 390 |
327 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 391 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
328 embedded_surface_id); | 392 embedded_surface_id); |
329 scoped_ptr<CopyOutputRequest> copy_request( | 393 scoped_ptr<CopyOutputRequest> copy_request( |
330 CopyOutputRequest::CreateEmptyRequest()); | 394 CopyOutputRequest::CreateEmptyRequest()); |
331 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 395 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
(...skipping 20 matching lines...) Expand all Loading... | |
352 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 416 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
353 pass_list.swap(frame_data->render_pass_list); | 417 pass_list.swap(frame_data->render_pass_list); |
354 | 418 |
355 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 419 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
356 frame->delegated_frame_data = frame_data.Pass(); | 420 frame->delegated_frame_data = frame_data.Pass(); |
357 | 421 |
358 factory_.SubmitCompositorFrame(root_surface_id_, frame.Pass(), | 422 factory_.SubmitCompositorFrame(root_surface_id_, frame.Pass(), |
359 SurfaceFactory::DrawCallback()); | 423 SurfaceFactory::DrawCallback()); |
360 } | 424 } |
361 | 425 |
426 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
427 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
428 | |
362 scoped_ptr<CompositorFrame> aggregated_frame = | 429 scoped_ptr<CompositorFrame> aggregated_frame = |
363 aggregator_.Aggregate(root_surface_id_); | 430 aggregator_.Aggregate(root_surface_id_); |
364 | 431 |
432 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
433 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
434 | |
365 ASSERT_TRUE(aggregated_frame); | 435 ASSERT_TRUE(aggregated_frame); |
366 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 436 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
367 | 437 |
368 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 438 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
369 | 439 |
370 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 440 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
371 test::Quad::SolidColorQuad(SK_ColorGREEN), | 441 test::Quad::SolidColorQuad(SK_ColorGREEN), |
372 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 442 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
373 test::Pass expected_passes[] = { | 443 test::Pass expected_passes[] = { |
374 test::Pass(expected_quads, arraysize(expected_quads)), | 444 test::Pass(expected_quads, arraysize(expected_quads)), |
(...skipping 27 matching lines...) Expand all Loading... | |
402 DCHECK(original_pass_list[0]->copy_requests.empty()); | 472 DCHECK(original_pass_list[0]->copy_requests.empty()); |
403 DCHECK(original_pass_list[1]->copy_requests.empty()); | 473 DCHECK(original_pass_list[1]->copy_requests.empty()); |
404 | 474 |
405 factory_.Destroy(embedded_surface_id); | 475 factory_.Destroy(embedded_surface_id); |
406 } | 476 } |
407 | 477 |
408 // This tests referencing a surface that has multiple render passes. | 478 // This tests referencing a surface that has multiple render passes. |
409 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 479 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
410 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); | 480 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); |
411 factory_.Create(embedded_surface_id); | 481 factory_.Create(embedded_surface_id); |
482 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
483 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
412 | 484 |
413 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), | 485 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), |
414 RenderPassId(1, 3)}; | 486 RenderPassId(1, 3)}; |
415 | 487 |
416 test::Quad embedded_quads[][2] = { | 488 test::Quad embedded_quads[][2] = { |
417 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 489 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
418 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 490 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
419 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 491 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
420 test::Pass embedded_passes[] = { | 492 test::Pass embedded_passes[] = { |
421 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 493 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
422 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), | 494 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), |
423 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; | 495 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; |
424 | 496 |
425 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 497 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
426 embedded_surface_id); | 498 embedded_surface_id); |
427 | 499 |
428 test::Quad root_quads[][2] = { | 500 test::Quad root_quads[][2] = { |
429 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, | 501 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, |
430 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 502 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
431 test::Quad::RenderPassQuad(pass_ids[0])}, | 503 test::Quad::RenderPassQuad(pass_ids[0])}, |
432 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; | 504 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; |
433 test::Pass root_passes[] = { | 505 test::Pass root_passes[] = { |
434 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), | 506 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), |
435 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), | 507 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), |
436 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; | 508 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; |
437 | 509 |
438 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 510 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
439 | 511 |
512 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
513 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
514 | |
440 scoped_ptr<CompositorFrame> aggregated_frame = | 515 scoped_ptr<CompositorFrame> aggregated_frame = |
441 aggregator_.Aggregate(root_surface_id_); | 516 aggregator_.Aggregate(root_surface_id_); |
442 | 517 |
518 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
519 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
520 | |
443 ASSERT_TRUE(aggregated_frame); | 521 ASSERT_TRUE(aggregated_frame); |
444 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 522 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
445 | 523 |
446 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 524 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
447 | 525 |
448 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 526 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
449 | 527 |
450 ASSERT_EQ(5u, aggregated_pass_list.size()); | 528 ASSERT_EQ(5u, aggregated_pass_list.size()); |
451 RenderPassId actual_pass_ids[] = { | 529 RenderPassId actual_pass_ids[] = { |
452 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, | 530 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 630 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
553 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 631 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
554 | 632 |
555 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 633 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
556 | 634 |
557 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 635 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
558 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 636 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
559 test::Pass expected_passes[] = { | 637 test::Pass expected_passes[] = { |
560 test::Pass(expected_quads, arraysize(expected_quads))}; | 638 test::Pass(expected_quads, arraysize(expected_quads))}; |
561 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; | 639 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; |
640 | |
641 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
562 AggregateAndVerify( | 642 AggregateAndVerify( |
563 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 643 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
644 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
564 } | 645 } |
565 | 646 |
566 // Tests a reference to a valid surface with no submitted frame. This quad | 647 // Tests a reference to a valid surface with no submitted frame. This quad |
567 // should also just be dropped. | 648 // should also just be dropped. |
568 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 649 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
569 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); | 650 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); |
570 factory_.Create(surface_with_no_frame_id); | 651 factory_.Create(surface_with_no_frame_id); |
652 Surface* surface_with_no_frame = | |
653 manager_.GetSurfaceForId(surface_with_no_frame_id); | |
654 | |
571 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 655 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
572 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), | 656 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), |
573 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 657 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
574 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 658 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
575 | 659 |
576 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 660 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
577 | 661 |
578 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 662 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
579 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 663 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
580 test::Pass expected_passes[] = { | 664 test::Pass expected_passes[] = { |
581 test::Pass(expected_quads, arraysize(expected_quads))}; | 665 test::Pass(expected_quads, arraysize(expected_quads))}; |
582 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id}; | 666 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id}; |
667 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
668 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface_with_no_frame)); | |
583 AggregateAndVerify( | 669 AggregateAndVerify( |
584 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 670 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
671 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
672 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface_with_no_frame)); | |
585 factory_.Destroy(surface_with_no_frame_id); | 673 factory_.Destroy(surface_with_no_frame_id); |
586 } | 674 } |
587 | 675 |
588 // Tests a surface quad referencing itself, generating a trivial cycle. | 676 // Tests a surface quad referencing itself, generating a trivial cycle. |
589 // The quad creating the cycle should be dropped from the final frame. | 677 // The quad creating the cycle should be dropped from the final frame. |
590 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 678 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
591 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_, 1.f), | 679 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_, 1.f), |
592 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 680 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
593 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 681 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
594 | 682 |
595 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 683 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
596 | 684 |
597 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 685 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
598 test::Pass expected_passes[] = { | 686 test::Pass expected_passes[] = { |
599 test::Pass(expected_quads, arraysize(expected_quads))}; | 687 test::Pass(expected_quads, arraysize(expected_quads))}; |
600 SurfaceId ids[] = {root_surface_id_}; | 688 SurfaceId ids[] = {root_surface_id_}; |
689 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
601 AggregateAndVerify( | 690 AggregateAndVerify( |
602 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 691 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
692 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
603 } | 693 } |
604 | 694 |
605 // Tests a more complex cycle with one intermediate surface. | 695 // Tests a more complex cycle with one intermediate surface. |
606 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 696 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
607 SurfaceId child_surface_id = allocator_.GenerateId(); | 697 SurfaceId child_surface_id = allocator_.GenerateId(); |
608 factory_.Create(child_surface_id); | 698 factory_.Create(child_surface_id); |
699 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
700 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
609 | 701 |
610 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 702 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
611 test::Quad::SurfaceQuad(child_surface_id, 1.f), | 703 test::Quad::SurfaceQuad(child_surface_id, 1.f), |
612 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 704 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
613 test::Pass parent_passes[] = { | 705 test::Pass parent_passes[] = { |
614 test::Pass(parent_quads, arraysize(parent_quads))}; | 706 test::Pass(parent_quads, arraysize(parent_quads))}; |
615 | 707 |
616 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), | 708 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), |
617 root_surface_id_); | 709 root_surface_id_); |
618 | 710 |
(...skipping 11 matching lines...) Expand all Loading... | |
630 // SK_ColorGREEN from the child | 722 // SK_ColorGREEN from the child |
631 // SK_ColorMAGENTA from the child | 723 // SK_ColorMAGENTA from the child |
632 // SK_ColorCYAN from the parent | 724 // SK_ColorCYAN from the parent |
633 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 725 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
634 test::Quad::SolidColorQuad(SK_ColorGREEN), | 726 test::Quad::SolidColorQuad(SK_ColorGREEN), |
635 test::Quad::SolidColorQuad(SK_ColorMAGENTA), | 727 test::Quad::SolidColorQuad(SK_ColorMAGENTA), |
636 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 728 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
637 test::Pass expected_passes[] = { | 729 test::Pass expected_passes[] = { |
638 test::Pass(expected_quads, arraysize(expected_quads))}; | 730 test::Pass(expected_quads, arraysize(expected_quads))}; |
639 SurfaceId ids[] = {root_surface_id_, child_surface_id}; | 731 SurfaceId ids[] = {root_surface_id_, child_surface_id}; |
732 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
733 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
640 AggregateAndVerify( | 734 AggregateAndVerify( |
641 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 735 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
736 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
737 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
642 factory_.Destroy(child_surface_id); | 738 factory_.Destroy(child_surface_id); |
643 } | 739 } |
644 | 740 |
645 // Tests that we map render pass IDs from different surfaces into a unified | 741 // Tests that we map render pass IDs from different surfaces into a unified |
646 // namespace and update RenderPassDrawQuad's id references to match. | 742 // namespace and update RenderPassDrawQuad's id references to match. |
647 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 743 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
648 SurfaceId child_surface_id = allocator_.GenerateId(); | 744 SurfaceId child_surface_id = allocator_.GenerateId(); |
649 factory_.Create(child_surface_id); | 745 factory_.Create(child_surface_id); |
746 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
747 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
650 | 748 |
651 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 749 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
652 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 750 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
653 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 751 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
654 test::Pass surface_passes[] = { | 752 test::Pass surface_passes[] = { |
655 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 753 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
656 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 754 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
657 | 755 |
658 SubmitCompositorFrame(surface_passes, arraysize(surface_passes), | 756 SubmitCompositorFrame(surface_passes, arraysize(surface_passes), |
659 child_surface_id); | 757 child_surface_id); |
660 | 758 |
661 // Pass IDs from the parent surface may collide with ones from the child. | 759 // Pass IDs from the parent surface may collide with ones from the child. |
662 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; | 760 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; |
663 test::Quad parent_quad[][1] = { | 761 test::Quad parent_quad[][1] = { |
664 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, | 762 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, |
665 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 763 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
666 test::Pass parent_passes[] = { | 764 test::Pass parent_passes[] = { |
667 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 765 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
668 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 766 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
669 | 767 |
670 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), | 768 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), |
671 root_surface_id_); | 769 root_surface_id_); |
770 | |
771 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
772 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
773 | |
672 scoped_ptr<CompositorFrame> aggregated_frame = | 774 scoped_ptr<CompositorFrame> aggregated_frame = |
673 aggregator_.Aggregate(root_surface_id_); | 775 aggregator_.Aggregate(root_surface_id_); |
674 | 776 |
777 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
778 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
779 | |
675 ASSERT_TRUE(aggregated_frame); | 780 ASSERT_TRUE(aggregated_frame); |
676 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 781 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
677 | 782 |
678 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 783 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
679 | 784 |
680 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 785 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
681 | 786 |
682 ASSERT_EQ(3u, aggregated_pass_list.size()); | 787 ASSERT_EQ(3u, aggregated_pass_list.size()); |
683 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, | 788 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, |
684 aggregated_pass_list[1]->id, | 789 aggregated_pass_list[1]->id, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 SkXfermode::kDst_Mode, // 2 | 867 SkXfermode::kDst_Mode, // 2 |
763 SkXfermode::kSrcOver_Mode, // 3 | 868 SkXfermode::kSrcOver_Mode, // 3 |
764 SkXfermode::kDstOver_Mode, // 4 | 869 SkXfermode::kDstOver_Mode, // 4 |
765 SkXfermode::kSrcIn_Mode, // 5 | 870 SkXfermode::kSrcIn_Mode, // 5 |
766 SkXfermode::kDstIn_Mode, // 6 | 871 SkXfermode::kDstIn_Mode, // 6 |
767 }; | 872 }; |
768 | 873 |
769 RenderPassId pass_id(1, 1); | 874 RenderPassId pass_id(1, 1); |
770 SurfaceId grandchild_surface_id = allocator_.GenerateId(); | 875 SurfaceId grandchild_surface_id = allocator_.GenerateId(); |
771 factory_.Create(grandchild_surface_id); | 876 factory_.Create(grandchild_surface_id); |
877 Surface* grandchild_surface = manager_.GetSurfaceForId(grandchild_surface_id); | |
878 EXPECT_FALSE(surface_aggregator_client_.HasSurface(grandchild_surface)); | |
772 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 879 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
773 gfx::Rect output_rect(SurfaceSize()); | 880 gfx::Rect output_rect(SurfaceSize()); |
774 gfx::Rect damage_rect(SurfaceSize()); | 881 gfx::Rect damage_rect(SurfaceSize()); |
775 gfx::Transform transform_to_root_target; | 882 gfx::Transform transform_to_root_target; |
776 grandchild_pass->SetNew( | 883 grandchild_pass->SetNew( |
777 pass_id, output_rect, damage_rect, transform_to_root_target); | 884 pass_id, output_rect, damage_rect, transform_to_root_target); |
778 AddSolidColorQuadWithBlendMode( | 885 AddSolidColorQuadWithBlendMode( |
779 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 886 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
780 QueuePassAsFrame(grandchild_pass.Pass(), grandchild_surface_id); | 887 QueuePassAsFrame(grandchild_pass.Pass(), grandchild_surface_id); |
781 | 888 |
782 SurfaceId child_one_surface_id = allocator_.GenerateId(); | 889 SurfaceId child_one_surface_id = allocator_.GenerateId(); |
783 factory_.Create(child_one_surface_id); | 890 factory_.Create(child_one_surface_id); |
891 Surface* child_one_surface = manager_.GetSurfaceForId(child_one_surface_id); | |
892 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_one_surface)); | |
784 | 893 |
785 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 894 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
786 child_one_pass->SetNew( | 895 child_one_pass->SetNew( |
787 pass_id, output_rect, damage_rect, transform_to_root_target); | 896 pass_id, output_rect, damage_rect, transform_to_root_target); |
788 AddSolidColorQuadWithBlendMode( | 897 AddSolidColorQuadWithBlendMode( |
789 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 898 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
790 SurfaceDrawQuad* grandchild_surface_quad = | 899 SurfaceDrawQuad* grandchild_surface_quad = |
791 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 900 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
792 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), | 901 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), |
793 gfx::Rect(SurfaceSize()), | 902 gfx::Rect(SurfaceSize()), |
794 gfx::Rect(SurfaceSize()), | 903 gfx::Rect(SurfaceSize()), |
795 grandchild_surface_id); | 904 grandchild_surface_id); |
796 AddSolidColorQuadWithBlendMode( | 905 AddSolidColorQuadWithBlendMode( |
797 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 906 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
798 QueuePassAsFrame(child_one_pass.Pass(), child_one_surface_id); | 907 QueuePassAsFrame(child_one_pass.Pass(), child_one_surface_id); |
799 | 908 |
800 SurfaceId child_two_surface_id = allocator_.GenerateId(); | 909 SurfaceId child_two_surface_id = allocator_.GenerateId(); |
801 factory_.Create(child_two_surface_id); | 910 factory_.Create(child_two_surface_id); |
911 Surface* child_two_surface = manager_.GetSurfaceForId(child_two_surface_id); | |
912 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_two_surface)); | |
802 | 913 |
803 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 914 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
804 child_two_pass->SetNew( | 915 child_two_pass->SetNew( |
805 pass_id, output_rect, damage_rect, transform_to_root_target); | 916 pass_id, output_rect, damage_rect, transform_to_root_target); |
806 AddSolidColorQuadWithBlendMode( | 917 AddSolidColorQuadWithBlendMode( |
807 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 918 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
808 QueuePassAsFrame(child_two_pass.Pass(), child_two_surface_id); | 919 QueuePassAsFrame(child_two_pass.Pass(), child_two_surface_id); |
809 | 920 |
810 scoped_ptr<RenderPass> root_pass = RenderPass::Create(); | 921 scoped_ptr<RenderPass> root_pass = RenderPass::Create(); |
811 root_pass->SetNew( | 922 root_pass->SetNew( |
(...skipping 13 matching lines...) Expand all Loading... | |
825 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 936 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
826 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 937 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
827 gfx::Rect(SurfaceSize()), | 938 gfx::Rect(SurfaceSize()), |
828 gfx::Rect(SurfaceSize()), | 939 gfx::Rect(SurfaceSize()), |
829 child_two_surface_id); | 940 child_two_surface_id); |
830 AddSolidColorQuadWithBlendMode( | 941 AddSolidColorQuadWithBlendMode( |
831 SurfaceSize(), root_pass.get(), blend_modes[6]); | 942 SurfaceSize(), root_pass.get(), blend_modes[6]); |
832 | 943 |
833 QueuePassAsFrame(root_pass.Pass(), root_surface_id_); | 944 QueuePassAsFrame(root_pass.Pass(), root_surface_id_); |
834 | 945 |
946 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
947 EXPECT_FALSE(surface_aggregator_client_.HasSurface(grandchild_surface)); | |
948 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_one_surface)); | |
949 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_two_surface)); | |
950 | |
835 scoped_ptr<CompositorFrame> aggregated_frame = | 951 scoped_ptr<CompositorFrame> aggregated_frame = |
836 aggregator_.Aggregate(root_surface_id_); | 952 aggregator_.Aggregate(root_surface_id_); |
837 | 953 |
954 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
955 EXPECT_TRUE(surface_aggregator_client_.HasSurface(grandchild_surface)); | |
956 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_one_surface)); | |
957 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_two_surface)); | |
958 | |
838 ASSERT_TRUE(aggregated_frame); | 959 ASSERT_TRUE(aggregated_frame); |
839 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 960 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
840 | 961 |
841 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 962 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
842 | 963 |
843 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 964 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
844 | 965 |
845 ASSERT_EQ(1u, aggregated_pass_list.size()); | 966 ASSERT_EQ(1u, aggregated_pass_list.size()); |
846 | 967 |
847 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 968 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
(...skipping 25 matching lines...) Expand all Loading... | |
873 // of +5 in the x direction. The second pass has a reference to the first pass' | 994 // of +5 in the x direction. The second pass has a reference to the first pass' |
874 // pass id and a transform of +8 in the x direction. | 995 // pass id and a transform of +8 in the x direction. |
875 // | 996 // |
876 // After aggregation, the child surface's root pass quad should have all | 997 // After aggregation, the child surface's root pass quad should have all |
877 // transforms concatenated for a total transform of +23 x, +10 y. The | 998 // transforms concatenated for a total transform of +23 x, +10 y. The |
878 // contributing render pass' transform in the aggregate frame should not be | 999 // contributing render pass' transform in the aggregate frame should not be |
879 // affected. | 1000 // affected. |
880 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { | 1001 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { |
881 // Innermost child surface. | 1002 // Innermost child surface. |
882 SurfaceId child_surface_id = allocator_.GenerateId(); | 1003 SurfaceId child_surface_id = allocator_.GenerateId(); |
1004 factory_.Create(child_surface_id); | |
1005 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
1006 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
883 { | 1007 { |
884 factory_.Create(child_surface_id); | |
885 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 1008 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
886 test::Quad child_quads[][1] = { | 1009 test::Quad child_quads[][1] = { |
887 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 1010 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
888 {test::Quad::RenderPassQuad(child_pass_id[0])}, | 1011 {test::Quad::RenderPassQuad(child_pass_id[0])}, |
889 }; | 1012 }; |
890 test::Pass child_passes[] = { | 1013 test::Pass child_passes[] = { |
891 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), | 1014 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), |
892 test::Pass(child_quads[1], arraysize(child_quads[1]), | 1015 test::Pass(child_quads[1], arraysize(child_quads[1]), |
893 child_pass_id[1])}; | 1016 child_pass_id[1])}; |
894 | 1017 |
(...skipping 19 matching lines...) Expand all Loading... | |
914 | 1037 |
915 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1038 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
916 child_frame->delegated_frame_data = child_frame_data.Pass(); | 1039 child_frame->delegated_frame_data = child_frame_data.Pass(); |
917 | 1040 |
918 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), | 1041 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), |
919 SurfaceFactory::DrawCallback()); | 1042 SurfaceFactory::DrawCallback()); |
920 } | 1043 } |
921 | 1044 |
922 // Middle child surface. | 1045 // Middle child surface. |
923 SurfaceId middle_surface_id = allocator_.GenerateId(); | 1046 SurfaceId middle_surface_id = allocator_.GenerateId(); |
1047 factory_.Create(middle_surface_id); | |
1048 Surface* middle_surface = manager_.GetSurfaceForId(middle_surface_id); | |
1049 EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface)); | |
924 { | 1050 { |
925 factory_.Create(middle_surface_id); | |
926 test::Quad middle_quads[] = { | 1051 test::Quad middle_quads[] = { |
927 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1052 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
928 test::Pass middle_passes[] = { | 1053 test::Pass middle_passes[] = { |
929 test::Pass(middle_quads, arraysize(middle_quads)), | 1054 test::Pass(middle_quads, arraysize(middle_quads)), |
930 }; | 1055 }; |
931 | 1056 |
932 RenderPassList middle_pass_list; | 1057 RenderPassList middle_pass_list; |
933 AddPasses(&middle_pass_list, gfx::Rect(SurfaceSize()), middle_passes, | 1058 AddPasses(&middle_pass_list, gfx::Rect(SurfaceSize()), middle_passes, |
934 arraysize(middle_passes)); | 1059 arraysize(middle_passes)); |
935 | 1060 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
978 | 1103 |
979 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1104 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
980 root_pass_list.swap(root_frame_data->render_pass_list); | 1105 root_pass_list.swap(root_frame_data->render_pass_list); |
981 | 1106 |
982 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1107 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
983 root_frame->delegated_frame_data = root_frame_data.Pass(); | 1108 root_frame->delegated_frame_data = root_frame_data.Pass(); |
984 | 1109 |
985 factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(), | 1110 factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(), |
986 SurfaceFactory::DrawCallback()); | 1111 SurfaceFactory::DrawCallback()); |
987 | 1112 |
1113 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1114 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1115 EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1116 | |
988 scoped_ptr<CompositorFrame> aggregated_frame = | 1117 scoped_ptr<CompositorFrame> aggregated_frame = |
989 aggregator_.Aggregate(root_surface_id_); | 1118 aggregator_.Aggregate(root_surface_id_); |
990 | 1119 |
1120 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1121 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1122 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1123 | |
991 ASSERT_TRUE(aggregated_frame); | 1124 ASSERT_TRUE(aggregated_frame); |
992 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1125 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
993 | 1126 |
994 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1127 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
995 | 1128 |
996 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1129 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
997 | 1130 |
998 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1131 ASSERT_EQ(3u, aggregated_pass_list.size()); |
999 | 1132 |
1000 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); | 1133 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1217 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1085 | 1218 |
1086 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 1219 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
1087 child_pass_list.swap(child_frame_data->render_pass_list); | 1220 child_pass_list.swap(child_frame_data->render_pass_list); |
1088 | 1221 |
1089 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1222 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
1090 child_frame->delegated_frame_data = child_frame_data.Pass(); | 1223 child_frame->delegated_frame_data = child_frame_data.Pass(); |
1091 | 1224 |
1092 SurfaceId child_surface_id = allocator_.GenerateId(); | 1225 SurfaceId child_surface_id = allocator_.GenerateId(); |
1093 factory_.Create(child_surface_id); | 1226 factory_.Create(child_surface_id); |
1227 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
1094 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), | 1228 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), |
1095 SurfaceFactory::DrawCallback()); | 1229 SurfaceFactory::DrawCallback()); |
1096 | 1230 |
1097 test::Quad parent_surface_quads[] = { | 1231 test::Quad parent_surface_quads[] = { |
1098 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1232 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1099 test::Pass parent_surface_passes[] = { | 1233 test::Pass parent_surface_passes[] = { |
1100 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), | 1234 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), |
1101 RenderPassId(1, 1))}; | 1235 RenderPassId(1, 1))}; |
1102 | 1236 |
1103 RenderPassList parent_surface_pass_list; | 1237 RenderPassList parent_surface_pass_list; |
1104 AddPasses(&parent_surface_pass_list, | 1238 AddPasses(&parent_surface_pass_list, |
1105 gfx::Rect(SurfaceSize()), | 1239 gfx::Rect(SurfaceSize()), |
1106 parent_surface_passes, | 1240 parent_surface_passes, |
1107 arraysize(parent_surface_passes)); | 1241 arraysize(parent_surface_passes)); |
1108 | 1242 |
1109 // Parent surface is only used to test if the transform is applied correctly | 1243 // Parent surface is only used to test if the transform is applied correctly |
1110 // to the child surface's damage. | 1244 // to the child surface's damage. |
1111 scoped_ptr<DelegatedFrameData> parent_surface_frame_data( | 1245 scoped_ptr<DelegatedFrameData> parent_surface_frame_data( |
1112 new DelegatedFrameData); | 1246 new DelegatedFrameData); |
1113 parent_surface_pass_list.swap(parent_surface_frame_data->render_pass_list); | 1247 parent_surface_pass_list.swap(parent_surface_frame_data->render_pass_list); |
1114 | 1248 |
1115 scoped_ptr<CompositorFrame> parent_surface_frame(new CompositorFrame); | 1249 scoped_ptr<CompositorFrame> parent_surface_frame(new CompositorFrame); |
1116 parent_surface_frame->delegated_frame_data = parent_surface_frame_data.Pass(); | 1250 parent_surface_frame->delegated_frame_data = parent_surface_frame_data.Pass(); |
1117 | 1251 |
1118 SurfaceId parent_surface_id = allocator_.GenerateId(); | 1252 SurfaceId parent_surface_id = allocator_.GenerateId(); |
1119 factory_.Create(parent_surface_id); | 1253 factory_.Create(parent_surface_id); |
1254 Surface* parent_surface = manager_.GetSurfaceForId(parent_surface_id); | |
1120 factory_.SubmitCompositorFrame(parent_surface_id, parent_surface_frame.Pass(), | 1255 factory_.SubmitCompositorFrame(parent_surface_id, parent_surface_frame.Pass(), |
1121 SurfaceFactory::DrawCallback()); | 1256 SurfaceFactory::DrawCallback()); |
1122 | 1257 |
1123 test::Quad root_surface_quads[] = { | 1258 test::Quad root_surface_quads[] = { |
1124 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; | 1259 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; |
1125 test::Quad root_render_pass_quads[] = { | 1260 test::Quad root_render_pass_quads[] = { |
1126 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1261 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
1127 | 1262 |
1128 test::Pass root_passes[] = { | 1263 test::Pass root_passes[] = { |
1129 test::Pass(root_surface_quads, arraysize(root_surface_quads), | 1264 test::Pass(root_surface_quads, arraysize(root_surface_quads), |
(...skipping 15 matching lines...) Expand all Loading... | |
1145 | 1280 |
1146 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1281 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1147 root_pass_list.swap(root_frame_data->render_pass_list); | 1282 root_pass_list.swap(root_frame_data->render_pass_list); |
1148 | 1283 |
1149 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1284 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
1150 root_frame->delegated_frame_data = root_frame_data.Pass(); | 1285 root_frame->delegated_frame_data = root_frame_data.Pass(); |
1151 | 1286 |
1152 factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(), | 1287 factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(), |
1153 SurfaceFactory::DrawCallback()); | 1288 SurfaceFactory::DrawCallback()); |
1154 | 1289 |
1290 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1291 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1292 EXPECT_FALSE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1293 | |
1155 scoped_ptr<CompositorFrame> aggregated_frame = | 1294 scoped_ptr<CompositorFrame> aggregated_frame = |
1156 aggregator_.Aggregate(root_surface_id_); | 1295 aggregator_.Aggregate(root_surface_id_); |
1157 | 1296 |
1297 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1298 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1299 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1300 | |
1158 ASSERT_TRUE(aggregated_frame); | 1301 ASSERT_TRUE(aggregated_frame); |
1159 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1302 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1160 | 1303 |
1161 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1304 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
1162 | 1305 |
1163 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1306 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1164 | 1307 |
1165 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1308 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1166 | 1309 |
1167 // Damage rect for first aggregation should contain entire root surface. | 1310 // Damage rect for first aggregation should contain entire root surface. |
(...skipping 14 matching lines...) Expand all Loading... | |
1182 | 1325 |
1183 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 1326 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
1184 child_pass_list.swap(child_frame_data->render_pass_list); | 1327 child_pass_list.swap(child_frame_data->render_pass_list); |
1185 | 1328 |
1186 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1329 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
1187 child_frame->delegated_frame_data = child_frame_data.Pass(); | 1330 child_frame->delegated_frame_data = child_frame_data.Pass(); |
1188 | 1331 |
1189 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), | 1332 factory_.SubmitCompositorFrame(child_surface_id, child_frame.Pass(), |
1190 SurfaceFactory::DrawCallback()); | 1333 SurfaceFactory::DrawCallback()); |
1191 | 1334 |
1335 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1336 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1337 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1338 | |
1192 scoped_ptr<CompositorFrame> aggregated_frame = | 1339 scoped_ptr<CompositorFrame> aggregated_frame = |
1193 aggregator_.Aggregate(root_surface_id_); | 1340 aggregator_.Aggregate(root_surface_id_); |
1194 | 1341 |
1342 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1343 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1344 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1345 | |
1195 ASSERT_TRUE(aggregated_frame); | 1346 ASSERT_TRUE(aggregated_frame); |
1196 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1347 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1197 | 1348 |
1198 DelegatedFrameData* frame_data = | 1349 DelegatedFrameData* frame_data = |
1199 aggregated_frame->delegated_frame_data.get(); | 1350 aggregated_frame->delegated_frame_data.get(); |
1200 | 1351 |
1201 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1352 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1202 | 1353 |
1203 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1354 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1204 | 1355 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 | 1395 |
1245 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1396 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1246 root_pass_list.swap(root_frame_data->render_pass_list); | 1397 root_pass_list.swap(root_frame_data->render_pass_list); |
1247 | 1398 |
1248 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1399 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
1249 root_frame->delegated_frame_data = root_frame_data.Pass(); | 1400 root_frame->delegated_frame_data = root_frame_data.Pass(); |
1250 | 1401 |
1251 factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(), | 1402 factory_.SubmitCompositorFrame(root_surface_id_, root_frame.Pass(), |
1252 SurfaceFactory::DrawCallback()); | 1403 SurfaceFactory::DrawCallback()); |
1253 | 1404 |
1405 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1406 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1407 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1408 | |
1254 scoped_ptr<CompositorFrame> aggregated_frame = | 1409 scoped_ptr<CompositorFrame> aggregated_frame = |
1255 aggregator_.Aggregate(root_surface_id_); | 1410 aggregator_.Aggregate(root_surface_id_); |
1256 | 1411 |
1412 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1413 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1414 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1415 | |
1257 ASSERT_TRUE(aggregated_frame); | 1416 ASSERT_TRUE(aggregated_frame); |
1258 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1417 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1259 | 1418 |
1260 DelegatedFrameData* frame_data = | 1419 DelegatedFrameData* frame_data = |
1261 aggregated_frame->delegated_frame_data.get(); | 1420 aggregated_frame->delegated_frame_data.get(); |
1262 | 1421 |
1263 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1422 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1264 | 1423 |
1265 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1424 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1266 | 1425 |
1267 // The root surface was enqueued without being aggregated once, so it should | 1426 // The root surface was enqueued without being aggregated once, so it should |
1268 // be treated as completely damaged. | 1427 // be treated as completely damaged. |
1269 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1428 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1270 gfx::Rect(SurfaceSize()))); | 1429 gfx::Rect(SurfaceSize()))); |
1271 } | 1430 } |
1272 | 1431 |
1273 // No Surface changed, so no damage should be given. | 1432 // No Surface changed, so no damage should be given. |
1274 { | 1433 { |
1434 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1435 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1436 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1437 | |
1275 scoped_ptr<CompositorFrame> aggregated_frame = | 1438 scoped_ptr<CompositorFrame> aggregated_frame = |
1276 aggregator_.Aggregate(root_surface_id_); | 1439 aggregator_.Aggregate(root_surface_id_); |
1277 | 1440 |
1441 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1442 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1443 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1444 | |
1278 ASSERT_TRUE(aggregated_frame); | 1445 ASSERT_TRUE(aggregated_frame); |
1279 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1446 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1280 | 1447 |
1281 DelegatedFrameData* frame_data = | 1448 DelegatedFrameData* frame_data = |
1282 aggregated_frame->delegated_frame_data.get(); | 1449 aggregated_frame->delegated_frame_data.get(); |
1283 | 1450 |
1284 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1451 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1285 | 1452 |
1286 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1453 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1287 | 1454 |
1288 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); | 1455 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); |
1289 } | 1456 } |
1290 | 1457 |
1291 // SetFullDamageRectForSurface should cause the entire output to be | 1458 // SetFullDamageRectForSurface should cause the entire output to be |
1292 // marked as damaged. | 1459 // marked as damaged. |
1293 { | 1460 { |
1461 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1462 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1463 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1464 | |
1294 aggregator_.SetFullDamageForSurface(root_surface_id_); | 1465 aggregator_.SetFullDamageForSurface(root_surface_id_); |
1295 scoped_ptr<CompositorFrame> aggregated_frame = | 1466 scoped_ptr<CompositorFrame> aggregated_frame = |
1296 aggregator_.Aggregate(root_surface_id_); | 1467 aggregator_.Aggregate(root_surface_id_); |
1297 | 1468 |
1469 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1470 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1471 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1472 | |
1298 ASSERT_TRUE(aggregated_frame); | 1473 ASSERT_TRUE(aggregated_frame); |
1299 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1474 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1300 | 1475 |
1301 DelegatedFrameData* frame_data = | 1476 DelegatedFrameData* frame_data = |
1302 aggregated_frame->delegated_frame_data.get(); | 1477 aggregated_frame->delegated_frame_data.get(); |
1303 | 1478 |
1304 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1479 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1305 | 1480 |
1306 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1481 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1307 | 1482 |
1308 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1483 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1309 gfx::Rect(SurfaceSize()))); | 1484 gfx::Rect(SurfaceSize()))); |
1310 } | 1485 } |
1311 | 1486 |
1312 factory_.Destroy(child_surface_id); | 1487 factory_.Destroy(child_surface_id); |
1313 } | 1488 } |
1314 | 1489 |
1315 class SurfaceAggregatorPartialSwapTest | 1490 class SurfaceAggregatorPartialSwapTest |
1316 : public SurfaceAggregatorValidSurfaceTest { | 1491 : public SurfaceAggregatorValidSurfaceTest { |
1317 public: | 1492 public: |
1318 SurfaceAggregatorPartialSwapTest() | 1493 SurfaceAggregatorPartialSwapTest() |
1319 : SurfaceAggregatorValidSurfaceTest(true) {} | 1494 : SurfaceAggregatorValidSurfaceTest(true) {} |
1320 }; | 1495 }; |
1321 | 1496 |
1322 // Tests that quads outside the damage rect are ignored. | 1497 // Tests that quads outside the damage rect are ignored. |
1323 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { | 1498 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { |
1324 SurfaceId child_surface_id = allocator_.GenerateId(); | 1499 SurfaceId child_surface_id = allocator_.GenerateId(); |
1325 factory_.Create(child_surface_id); | 1500 factory_.Create(child_surface_id); |
1501 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
1326 // The child surface has two quads, one with a visible rect of 13,13 4x4 and | 1502 // The child surface has two quads, one with a visible rect of 13,13 4x4 and |
1327 // the other other with a visible rect of 10,10 2x2 (relative to root target | 1503 // the other other with a visible rect of 10,10 2x2 (relative to root target |
1328 // space). | 1504 // space). |
1329 { | 1505 { |
1330 RenderPassId child_pass_id = RenderPassId(1, 1); | 1506 RenderPassId child_pass_id = RenderPassId(1, 1); |
1331 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1507 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1332 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1508 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1333 test::Pass child_passes[] = { | 1509 test::Pass child_passes[] = { |
1334 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), | 1510 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), |
1335 test::Pass(child_quads2, arraysize(child_quads2), child_pass_id)}; | 1511 test::Pass(child_quads2, arraysize(child_quads2), child_pass_id)}; |
(...skipping 25 matching lines...) Expand all Loading... | |
1361 arraysize(root_passes)); | 1537 arraysize(root_passes)); |
1362 | 1538 |
1363 RenderPass* root_pass = root_pass_list.at(0u); | 1539 RenderPass* root_pass = root_pass_list.at(0u); |
1364 root_pass->shared_quad_state_list.front() | 1540 root_pass->shared_quad_state_list.front() |
1365 ->quad_to_target_transform.Translate(10, 10); | 1541 ->quad_to_target_transform.Translate(10, 10); |
1366 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); | 1542 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); |
1367 | 1543 |
1368 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1544 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1369 } | 1545 } |
1370 | 1546 |
1547 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1548 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1549 | |
1371 scoped_ptr<CompositorFrame> aggregated_frame = | 1550 scoped_ptr<CompositorFrame> aggregated_frame = |
1372 aggregator_.Aggregate(root_surface_id_); | 1551 aggregator_.Aggregate(root_surface_id_); |
1373 | 1552 |
1553 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1554 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1555 | |
1374 ASSERT_TRUE(aggregated_frame); | 1556 ASSERT_TRUE(aggregated_frame); |
1375 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1557 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1376 | 1558 |
1377 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1559 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
1378 | 1560 |
1379 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1561 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1380 | 1562 |
1381 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1563 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1382 | 1564 |
1383 // Damage rect for first aggregation should contain entire root surface. | 1565 // Damage rect for first aggregation should contain entire root surface. |
(...skipping 12 matching lines...) Expand all Loading... | |
1396 arraysize(root_passes)); | 1578 arraysize(root_passes)); |
1397 | 1579 |
1398 RenderPass* root_pass = root_pass_list.at(0u); | 1580 RenderPass* root_pass = root_pass_list.at(0u); |
1399 root_pass->shared_quad_state_list.front() | 1581 root_pass->shared_quad_state_list.front() |
1400 ->quad_to_target_transform.Translate(10, 10); | 1582 ->quad_to_target_transform.Translate(10, 10); |
1401 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1583 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
1402 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1584 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1403 } | 1585 } |
1404 | 1586 |
1405 { | 1587 { |
1588 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1589 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1590 | |
1406 scoped_ptr<CompositorFrame> aggregated_frame = | 1591 scoped_ptr<CompositorFrame> aggregated_frame = |
1407 aggregator_.Aggregate(root_surface_id_); | 1592 aggregator_.Aggregate(root_surface_id_); |
1408 | 1593 |
1594 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1595 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1596 | |
1409 ASSERT_TRUE(aggregated_frame); | 1597 ASSERT_TRUE(aggregated_frame); |
1410 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1598 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1411 | 1599 |
1412 DelegatedFrameData* frame_data = | 1600 DelegatedFrameData* frame_data = |
1413 aggregated_frame->delegated_frame_data.get(); | 1601 aggregated_frame->delegated_frame_data.get(); |
1414 | 1602 |
1415 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1603 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1416 | 1604 |
1417 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1605 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1418 | 1606 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 | 1639 |
1452 RenderPass* child_root_pass = child_pass_list.at(1u); | 1640 RenderPass* child_root_pass = child_pass_list.at(1u); |
1453 | 1641 |
1454 child_root_pass->copy_requests.push_back( | 1642 child_root_pass->copy_requests.push_back( |
1455 CopyOutputRequest::CreateEmptyRequest()); | 1643 CopyOutputRequest::CreateEmptyRequest()); |
1456 child_root_pass->damage_rect = gfx::Rect(); | 1644 child_root_pass->damage_rect = gfx::Rect(); |
1457 SubmitPassListAsFrame(child_surface_id, &child_pass_list); | 1645 SubmitPassListAsFrame(child_surface_id, &child_pass_list); |
1458 } | 1646 } |
1459 | 1647 |
1460 { | 1648 { |
1649 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1650 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1651 | |
1461 scoped_ptr<CompositorFrame> aggregated_frame = | 1652 scoped_ptr<CompositorFrame> aggregated_frame = |
1462 aggregator_.Aggregate(root_surface_id_); | 1653 aggregator_.Aggregate(root_surface_id_); |
1463 | 1654 |
1655 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1656 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1657 | |
1464 ASSERT_TRUE(aggregated_frame); | 1658 ASSERT_TRUE(aggregated_frame); |
1465 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1659 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1466 | 1660 |
1467 DelegatedFrameData* frame_data = | 1661 DelegatedFrameData* frame_data = |
1468 aggregated_frame->delegated_frame_data.get(); | 1662 aggregated_frame->delegated_frame_data.get(); |
1469 | 1663 |
1470 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1664 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1471 | 1665 |
1472 // Output frame should have no damage, but all quads included. | 1666 // Output frame should have no damage, but all quads included. |
1473 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1667 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1474 | 1668 |
1475 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); | 1669 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); |
1476 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | 1670 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); |
1477 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1671 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
1478 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), | 1672 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), |
1479 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); | 1673 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); |
1480 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), | 1674 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), |
1481 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); | 1675 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); |
1482 } | 1676 } |
1483 | 1677 |
1484 { | 1678 { |
1679 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1680 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1681 | |
1485 scoped_ptr<CompositorFrame> aggregated_frame = | 1682 scoped_ptr<CompositorFrame> aggregated_frame = |
1486 aggregator_.Aggregate(root_surface_id_); | 1683 aggregator_.Aggregate(root_surface_id_); |
1487 | 1684 |
1685 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1686 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1687 | |
1488 ASSERT_TRUE(aggregated_frame); | 1688 ASSERT_TRUE(aggregated_frame); |
1489 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1689 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1490 | 1690 |
1491 DelegatedFrameData* frame_data = | 1691 DelegatedFrameData* frame_data = |
1492 aggregated_frame->delegated_frame_data.get(); | 1692 aggregated_frame->delegated_frame_data.get(); |
1493 | 1693 |
1494 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1694 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1495 // There were no changes since last aggregation, so output should be empty | 1695 // There were no changes since last aggregation, so output should be empty |
1496 // and have no damage. | 1696 // and have no damage. |
1497 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1697 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1498 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1698 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
1499 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1699 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1500 } | 1700 } |
1501 | 1701 |
1502 factory_.Destroy(child_surface_id); | 1702 factory_.Destroy(child_surface_id); |
1503 } | 1703 } |
1504 | 1704 |
1505 class SurfaceAggregatorWithResourcesTest : public testing::Test { | 1705 class SurfaceAggregatorWithResourcesTest : public testing::Test { |
1506 public: | 1706 public: |
1507 void SetUp() override { | 1707 void SetUp() override { |
1508 output_surface_ = FakeOutputSurface::CreateSoftware( | 1708 output_surface_ = FakeOutputSurface::CreateSoftware( |
1509 make_scoped_ptr(new SoftwareOutputDevice)); | 1709 make_scoped_ptr(new SoftwareOutputDevice)); |
1510 output_surface_->BindToClient(&output_surface_client_); | 1710 output_surface_->BindToClient(&output_surface_client_); |
1511 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 1711 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
1512 | 1712 |
1513 resource_provider_ = FakeResourceProvider::Create( | 1713 resource_provider_ = FakeResourceProvider::Create( |
1514 output_surface_.get(), shared_bitmap_manager_.get()); | 1714 output_surface_.get(), shared_bitmap_manager_.get()); |
1515 | 1715 |
1516 aggregator_.reset( | 1716 aggregator_.reset(new SurfaceAggregator(&surface_aggregator_client_, |
1517 new SurfaceAggregator(&manager_, resource_provider_.get(), false)); | 1717 &manager_, resource_provider_.get(), |
1718 false)); | |
1518 } | 1719 } |
1519 | 1720 |
1520 protected: | 1721 protected: |
1521 SurfaceManager manager_; | 1722 SurfaceManager manager_; |
1522 FakeOutputSurfaceClient output_surface_client_; | 1723 FakeOutputSurfaceClient output_surface_client_; |
1523 scoped_ptr<OutputSurface> output_surface_; | 1724 scoped_ptr<OutputSurface> output_surface_; |
1524 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 1725 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
1525 scoped_ptr<ResourceProvider> resource_provider_; | 1726 scoped_ptr<ResourceProvider> resource_provider_; |
1526 scoped_ptr<SurfaceAggregator> aggregator_; | 1727 scoped_ptr<SurfaceAggregator> aggregator_; |
1728 FakeSurfaceAggregatorClient surface_aggregator_client_; | |
1527 }; | 1729 }; |
1528 | 1730 |
1529 class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient { | 1731 class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient { |
1530 public: | 1732 public: |
1531 ResourceTrackingSurfaceFactoryClient() {} | 1733 ResourceTrackingSurfaceFactoryClient() {} |
1532 ~ResourceTrackingSurfaceFactoryClient() override {} | 1734 ~ResourceTrackingSurfaceFactoryClient() override {} |
1533 | 1735 |
1534 void ReturnResources(const ReturnedResourceArray& resources) override { | 1736 void ReturnResources(const ReturnedResourceArray& resources) override { |
1535 returned_resources_ = resources; | 1737 returned_resources_ = resources; |
1536 } | 1738 } |
1537 | 1739 |
1538 ReturnedResourceArray returned_resources() const { | 1740 ReturnedResourceArray returned_resources() const { |
1539 return returned_resources_; | 1741 return returned_resources_; |
1540 } | 1742 } |
1541 | 1743 |
1744 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} | |
1745 | |
1542 private: | 1746 private: |
1543 ReturnedResourceArray returned_resources_; | 1747 ReturnedResourceArray returned_resources_; |
1544 | 1748 |
1545 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient); | 1749 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient); |
1546 }; | 1750 }; |
1547 | 1751 |
1548 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, | 1752 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, |
1549 size_t num_resource_ids, | 1753 size_t num_resource_ids, |
1550 bool valid, | 1754 bool valid, |
1551 SurfaceId child_id, | 1755 SurfaceId child_id, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1591 frame->delegated_frame_data = frame_data.Pass(); | 1795 frame->delegated_frame_data = frame_data.Pass(); |
1592 factory->SubmitCompositorFrame(surface_id, frame.Pass(), | 1796 factory->SubmitCompositorFrame(surface_id, frame.Pass(), |
1593 SurfaceFactory::DrawCallback()); | 1797 SurfaceFactory::DrawCallback()); |
1594 } | 1798 } |
1595 | 1799 |
1596 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1800 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
1597 ResourceTrackingSurfaceFactoryClient client; | 1801 ResourceTrackingSurfaceFactoryClient client; |
1598 SurfaceFactory factory(&manager_, &client); | 1802 SurfaceFactory factory(&manager_, &client); |
1599 SurfaceId surface_id(7u); | 1803 SurfaceId surface_id(7u); |
1600 factory.Create(surface_id); | 1804 factory.Create(surface_id); |
1805 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
1601 | 1806 |
1602 ResourceId ids[] = {11, 12, 13}; | 1807 ResourceId ids[] = {11, 12, 13}; |
1603 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1808 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1604 &factory, surface_id); | 1809 &factory, surface_id); |
1605 | 1810 |
1811 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
1812 | |
1606 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); | 1813 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); |
1607 | 1814 |
1815 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1816 | |
1608 // Nothing should be available to be returned yet. | 1817 // Nothing should be available to be returned yet. |
1609 EXPECT_TRUE(client.returned_resources().empty()); | 1818 EXPECT_TRUE(client.returned_resources().empty()); |
1610 | 1819 |
1611 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1820 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, |
1612 surface_id); | 1821 surface_id); |
1613 | 1822 |
1823 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1824 | |
1614 frame = aggregator_->Aggregate(surface_id); | 1825 frame = aggregator_->Aggregate(surface_id); |
1615 | 1826 |
1827 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1828 | |
1616 ASSERT_EQ(3u, client.returned_resources().size()); | 1829 ASSERT_EQ(3u, client.returned_resources().size()); |
1617 ResourceId returned_ids[3]; | 1830 ResourceId returned_ids[3]; |
1618 for (size_t i = 0; i < 3; ++i) { | 1831 for (size_t i = 0; i < 3; ++i) { |
1619 returned_ids[i] = client.returned_resources()[i].id; | 1832 returned_ids[i] = client.returned_resources()[i].id; |
1620 } | 1833 } |
1621 EXPECT_THAT(returned_ids, | 1834 EXPECT_THAT(returned_ids, |
1622 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1835 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1623 factory.Destroy(surface_id); | 1836 factory.Destroy(surface_id); |
1624 } | 1837 } |
1625 | 1838 |
1626 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 1839 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
1627 ResourceTrackingSurfaceFactoryClient client; | 1840 ResourceTrackingSurfaceFactoryClient client; |
1628 SurfaceFactory factory(&manager_, &client); | 1841 SurfaceFactory factory(&manager_, &client); |
1629 SurfaceId surface_id(7u); | 1842 SurfaceId surface_id(7u); |
1630 factory.Create(surface_id); | 1843 factory.Create(surface_id); |
1844 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
1631 | 1845 |
1632 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 1846 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
1633 scoped_ptr<RenderPass> pass = RenderPass::Create(); | 1847 scoped_ptr<RenderPass> pass = RenderPass::Create(); |
1634 pass->id = RenderPassId(1, 1); | 1848 pass->id = RenderPassId(1, 1); |
1635 TransferableResource resource; | 1849 TransferableResource resource; |
1636 resource.id = 11; | 1850 resource.id = 11; |
1637 // ResourceProvider is software but resource is not, so it should be | 1851 // ResourceProvider is software but resource is not, so it should be |
1638 // ignored. | 1852 // ignored. |
1639 resource.is_software = false; | 1853 resource.is_software = false; |
1640 frame_data->resource_list.push_back(resource); | 1854 frame_data->resource_list.push_back(resource); |
1641 frame_data->render_pass_list.push_back(pass.Pass()); | 1855 frame_data->render_pass_list.push_back(pass.Pass()); |
1642 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 1856 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
1643 frame->delegated_frame_data = frame_data.Pass(); | 1857 frame->delegated_frame_data = frame_data.Pass(); |
1644 factory.SubmitCompositorFrame(surface_id, frame.Pass(), | 1858 factory.SubmitCompositorFrame(surface_id, frame.Pass(), |
1645 SurfaceFactory::DrawCallback()); | 1859 SurfaceFactory::DrawCallback()); |
1646 | 1860 |
1861 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
1862 | |
1647 scoped_ptr<CompositorFrame> returned_frame = | 1863 scoped_ptr<CompositorFrame> returned_frame = |
1648 aggregator_->Aggregate(surface_id); | 1864 aggregator_->Aggregate(surface_id); |
1649 | 1865 |
1866 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1867 | |
1650 // Nothing should be available to be returned yet. | 1868 // Nothing should be available to be returned yet. |
1651 EXPECT_TRUE(client.returned_resources().empty()); | 1869 EXPECT_TRUE(client.returned_resources().empty()); |
1652 | 1870 |
1653 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1871 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
1654 surface_id); | 1872 surface_id); |
1655 ASSERT_EQ(1u, client.returned_resources().size()); | 1873 ASSERT_EQ(1u, client.returned_resources().size()); |
1656 EXPECT_EQ(11u, client.returned_resources()[0].id); | 1874 EXPECT_EQ(11u, client.returned_resources()[0].id); |
1657 | 1875 |
1658 factory.Destroy(surface_id); | 1876 factory.Destroy(surface_id); |
1659 } | 1877 } |
1660 | 1878 |
1661 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1879 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
1662 ResourceTrackingSurfaceFactoryClient client; | 1880 ResourceTrackingSurfaceFactoryClient client; |
1663 SurfaceFactory factory(&manager_, &client); | 1881 SurfaceFactory factory(&manager_, &client); |
1664 SurfaceId surface_id(7u); | 1882 SurfaceId surface1_id(7u); |
1665 factory.Create(surface_id); | 1883 factory.Create(surface1_id); |
1666 SurfaceId surface_id2(8u); | 1884 Surface* surface1 = manager_.GetSurfaceForId(surface1_id); |
1667 factory.Create(surface_id2); | 1885 |
1886 SurfaceId surface2_id(8u); | |
1887 factory.Create(surface2_id); | |
1888 Surface* surface2 = manager_.GetSurfaceForId(surface2_id); | |
1668 | 1889 |
1669 ResourceId ids[] = {11, 12, 13}; | 1890 ResourceId ids[] = {11, 12, 13}; |
1670 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1891 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1671 &factory, surface_id); | 1892 &factory, surface1_id); |
1672 ResourceId ids2[] = {14, 15, 16}; | 1893 ResourceId ids2[] = {14, 15, 16}; |
1673 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), | 1894 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), |
1674 &factory, surface_id2); | 1895 &factory, surface2_id); |
1675 | 1896 |
1676 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); | 1897 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface1)); |
1898 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2)); | |
1899 | |
1900 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface1_id); | |
1901 | |
1902 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface1)); | |
1903 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2)); | |
1677 | 1904 |
1678 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1905 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
1679 surface_id); | 1906 surface1_id); |
1680 | 1907 |
1681 // Nothing should be available to be returned yet. | 1908 // Nothing should be available to be returned yet. |
1682 EXPECT_TRUE(client.returned_resources().empty()); | 1909 EXPECT_TRUE(client.returned_resources().empty()); |
1683 | 1910 |
1684 frame = aggregator_->Aggregate(surface_id2); | 1911 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface1)); |
1912 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2)); | |
1685 | 1913 |
1686 // surface_id wasn't referenced, so its resources should be returned. | 1914 frame = aggregator_->Aggregate(surface2_id); |
1915 | |
1916 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface1)); | |
1917 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface2)); | |
1918 | |
1919 // surface1_id wasn't referenced, so its resources should be returned. | |
1687 ASSERT_EQ(3u, client.returned_resources().size()); | 1920 ASSERT_EQ(3u, client.returned_resources().size()); |
1688 ResourceId returned_ids[3]; | 1921 ResourceId returned_ids[3]; |
1689 for (size_t i = 0; i < 3; ++i) { | 1922 for (size_t i = 0; i < 3; ++i) { |
1690 returned_ids[i] = client.returned_resources()[i].id; | 1923 returned_ids[i] = client.returned_resources()[i].id; |
1691 } | 1924 } |
1692 EXPECT_THAT(returned_ids, | 1925 EXPECT_THAT(returned_ids, |
1693 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1926 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1694 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1927 EXPECT_EQ(3u, resource_provider_->num_resources()); |
1695 factory.Destroy(surface_id); | 1928 factory.Destroy(surface1_id); |
1696 factory.Destroy(surface_id2); | 1929 factory.Destroy(surface2_id); |
1697 } | 1930 } |
1698 | 1931 |
1699 // Ensure that aggregator completely ignores Surfaces that reference invalid | 1932 // Ensure that aggregator completely ignores Surfaces that reference invalid |
1700 // resources. | 1933 // resources. |
1701 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 1934 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
1702 ResourceTrackingSurfaceFactoryClient client; | 1935 ResourceTrackingSurfaceFactoryClient client; |
1703 SurfaceFactory factory(&manager_, &client); | 1936 SurfaceFactory factory(&manager_, &client); |
1704 SurfaceId root_surface_id(7u); | 1937 SurfaceId root_surface_id(7u); |
1705 factory.Create(root_surface_id); | 1938 factory.Create(root_surface_id); |
1939 Surface* root_surface = manager_.GetSurfaceForId(root_surface_id); | |
1706 SurfaceId middle_surface_id(8u); | 1940 SurfaceId middle_surface_id(8u); |
1707 factory.Create(middle_surface_id); | 1941 factory.Create(middle_surface_id); |
1942 Surface* middle_surface = manager_.GetSurfaceForId(middle_surface_id); | |
1708 SurfaceId child_surface_id(9u); | 1943 SurfaceId child_surface_id(9u); |
1709 factory.Create(child_surface_id); | 1944 factory.Create(child_surface_id); |
1945 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
1710 | 1946 |
1711 ResourceId ids[] = {14, 15, 16}; | 1947 ResourceId ids[] = {14, 15, 16}; |
1712 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1948 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1713 &factory, child_surface_id); | 1949 &factory, child_surface_id); |
1714 | 1950 |
1715 ResourceId ids2[] = {17, 18, 19}; | 1951 ResourceId ids2[] = {17, 18, 19}; |
1716 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 1952 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
1717 child_surface_id, &factory, | 1953 child_surface_id, &factory, |
1718 middle_surface_id); | 1954 middle_surface_id); |
1719 | 1955 |
1720 ResourceId ids3[] = {20, 21, 22}; | 1956 ResourceId ids3[] = {20, 21, 22}; |
1721 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 1957 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
1722 middle_surface_id, &factory, | 1958 middle_surface_id, &factory, |
1723 root_surface_id); | 1959 root_surface_id); |
1724 | 1960 |
1961 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface)); | |
1962 EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1963 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1964 | |
1725 scoped_ptr<CompositorFrame> frame; | 1965 scoped_ptr<CompositorFrame> frame; |
1726 frame = aggregator_->Aggregate(root_surface_id); | 1966 frame = aggregator_->Aggregate(root_surface_id); |
1727 | 1967 |
1968 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface)); | |
1969 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1970 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1971 | |
1728 RenderPassList* pass_list = &frame->delegated_frame_data->render_pass_list; | 1972 RenderPassList* pass_list = &frame->delegated_frame_data->render_pass_list; |
1729 ASSERT_EQ(1u, pass_list->size()); | 1973 ASSERT_EQ(1u, pass_list->size()); |
1730 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 1974 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
1731 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 1975 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
1732 | 1976 |
1733 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 1977 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
1734 child_surface_id, &factory, | 1978 child_surface_id, &factory, |
1735 middle_surface_id); | 1979 middle_surface_id); |
1736 | 1980 |
1981 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface)); | |
1982 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1983 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1984 | |
1737 frame = aggregator_->Aggregate(root_surface_id); | 1985 frame = aggregator_->Aggregate(root_surface_id); |
1738 | 1986 |
1987 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface)); | |
1988 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1989 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1990 | |
1739 pass_list = &frame->delegated_frame_data->render_pass_list; | 1991 pass_list = &frame->delegated_frame_data->render_pass_list; |
1740 ASSERT_EQ(1u, pass_list->size()); | 1992 ASSERT_EQ(1u, pass_list->size()); |
1741 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 1993 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
1742 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 1994 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
1743 | 1995 |
1744 factory.Destroy(root_surface_id); | 1996 factory.Destroy(root_surface_id); |
1745 factory.Destroy(child_surface_id); | 1997 factory.Destroy(child_surface_id); |
1746 factory.Destroy(middle_surface_id); | 1998 factory.Destroy(middle_surface_id); |
1747 } | 1999 } |
1748 | 2000 |
1749 } // namespace | 2001 } // namespace |
1750 } // namespace cc | 2002 } // namespace cc |
1751 | 2003 |
OLD | NEW |