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