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