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

Side by Side Diff: content/browser/compositor/buffer_queue_unittest.cc

Issue 1423843003: Make content::BufferQueue use scoped ptrs for AllocatedSurfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@surfaceless_only
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 5 #include <set>
6 6
7 #include "cc/test/test_context_provider.h" 7 #include "cc/test/test_context_provider.h"
8 #include "cc/test/test_web_graphics_context_3d.h" 8 #include "cc/test/test_web_graphics_context_3d.h"
9 #include "content/browser/compositor/buffer_queue.h" 9 #include "content/browser/compositor/buffer_queue.h"
10 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s urface.h" 10 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s urface.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 cc::TestContextProvider::Create(context.Pass()); 87 cc::TestContextProvider::Create(context.Pass());
88 context_provider->BindToCurrentThread(); 88 context_provider->BindToCurrentThread();
89 gpu_memory_buffer_manager_.reset(new StubBrowserGpuMemoryBufferManager); 89 gpu_memory_buffer_manager_.reset(new StubBrowserGpuMemoryBufferManager);
90 mock_output_surface_ = 90 mock_output_surface_ =
91 new MockBufferQueue(context_provider, gpu_memory_buffer_manager_.get(), 91 new MockBufferQueue(context_provider, gpu_memory_buffer_manager_.get(),
92 GL_TEXTURE_2D, GL_RGBA); 92 GL_TEXTURE_2D, GL_RGBA);
93 output_surface_.reset(mock_output_surface_); 93 output_surface_.reset(mock_output_surface_);
94 output_surface_->Initialize(); 94 output_surface_->Initialize();
95 } 95 }
96 96
97 unsigned current_surface() { return output_surface_->current_surface_.image; } 97 unsigned current_surface() {
98 const std::vector<BufferQueue::AllocatedSurface>& available_surfaces() { 98 return output_surface_->current_surface_
99 ? output_surface_->current_surface_->image
100 : 0;
101 }
102 const cc::ScopedPtrVector<BufferQueue::AllocatedSurface>&
103 available_surfaces() {
99 return output_surface_->available_surfaces_; 104 return output_surface_->available_surfaces_;
100 } 105 }
101 const std::deque<BufferQueue::AllocatedSurface>& in_flight_surfaces() { 106 const cc::ScopedPtrDeque<BufferQueue::AllocatedSurface>&
107 in_flight_surfaces() {
102 return output_surface_->in_flight_surfaces_; 108 return output_surface_->in_flight_surfaces_;
103 } 109 }
110 size_t in_flight_surface_count() {
111 return output_surface_->in_flight_surfaces_.size() +
112 output_surface_->deleted_in_flight_surface_count_;
113 }
104 114
105 const BufferQueue::AllocatedSurface& displayed_frame() { 115 const BufferQueue::AllocatedSurface* displayed_frame() {
106 return output_surface_->displayed_surface_; 116 return output_surface_->displayed_surface_.get();
107 } 117 }
108 const BufferQueue::AllocatedSurface& current_frame() { 118 const BufferQueue::AllocatedSurface* current_frame() {
109 return output_surface_->current_surface_; 119 return output_surface_->current_surface_.get();
110 } 120 }
111 const BufferQueue::AllocatedSurface& last_frame() { 121 const BufferQueue::AllocatedSurface* next_frame() {
112 return output_surface_->in_flight_surfaces_.back();
113 }
114 const BufferQueue::AllocatedSurface& next_frame() {
115 return output_surface_->available_surfaces_.back(); 122 return output_surface_->available_surfaces_.back();
116 } 123 }
117 const gfx::Size size() { return output_surface_->size_; } 124 const gfx::Size size() { return output_surface_->size_; }
118 125
119 int CountBuffers() { 126 int CountBuffers() {
120 int n = available_surfaces().size() + in_flight_surfaces().size() + 127 int n = available_surfaces().size() + in_flight_surfaces().size() +
121 (displayed_frame().texture ? 1 : 0); 128 (displayed_frame() ? 1 : 0);
122 if (current_surface()) 129 if (current_surface())
123 n++; 130 n++;
124 return n; 131 return n;
125 } 132 }
126 133
127 // Check that each buffer is unique if present. 134 // Check that each buffer is unique if present.
128 void CheckUnique() { 135 void CheckUnique() {
129 std::set<unsigned> buffers; 136 std::set<unsigned> buffers;
130 EXPECT_TRUE(InsertUnique(&buffers, current_surface())); 137 EXPECT_TRUE(InsertUnique(&buffers, current_surface()));
131 EXPECT_TRUE(InsertUnique(&buffers, displayed_frame().image)); 138 if (displayed_frame())
139 EXPECT_TRUE(InsertUnique(&buffers, displayed_frame()->image));
132 for (size_t i = 0; i < available_surfaces().size(); i++) 140 for (size_t i = 0; i < available_surfaces().size(); i++)
133 EXPECT_TRUE(InsertUnique(&buffers, available_surfaces()[i].image)); 141 EXPECT_TRUE(InsertUnique(&buffers, available_surfaces()[i]->image));
134 for (std::deque<BufferQueue::AllocatedSurface>::const_iterator it = 142 for (size_t i = 0; i < in_flight_surfaces().size(); i++)
135 in_flight_surfaces().begin(); 143 EXPECT_TRUE(InsertUnique(&buffers, in_flight_surfaces()[i]->image));
136 it != in_flight_surfaces().end();
137 ++it)
138 EXPECT_TRUE(InsertUnique(&buffers, it->image));
139 } 144 }
140 145
141 void SwapBuffers() { 146 void SwapBuffers() {
142 output_surface_->SwapBuffers(gfx::Rect(output_surface_->size_)); 147 output_surface_->SwapBuffers(gfx::Rect(output_surface_->size_));
143 } 148 }
144 149
145 void SendDamagedFrame(const gfx::Rect& damage) { 150 void SendDamagedFrame(const gfx::Rect& damage) {
146 // We don't care about the GL-level implementation here, just how it uses 151 // We don't care about the GL-level implementation here, just how it uses
147 // damage rects. 152 // damage rects.
148 output_surface_->BindFramebuffer(); 153 output_surface_->BindFramebuffer();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 CopyBufferDamage(_, _, small_damage, screen_rect)).Times(1); 312 CopyBufferDamage(_, _, small_damage, screen_rect)).Times(1);
308 EXPECT_CALL(*mock_output_surface_, 313 EXPECT_CALL(*mock_output_surface_,
309 CopyBufferDamage(_, _, small_damage, small_damage)).Times(1); 314 CopyBufferDamage(_, _, small_damage, small_damage)).Times(1);
310 EXPECT_CALL(*mock_output_surface_, 315 EXPECT_CALL(*mock_output_surface_,
311 CopyBufferDamage(_, _, large_damage, small_damage)).Times(1); 316 CopyBufferDamage(_, _, large_damage, small_damage)).Times(1);
312 SendFullFrame(); 317 SendFullFrame();
313 SendDamagedFrame(small_damage); 318 SendDamagedFrame(small_damage);
314 SendDamagedFrame(small_damage); 319 SendDamagedFrame(small_damage);
315 SendDamagedFrame(large_damage); 320 SendDamagedFrame(large_damage);
316 // Verify that the damage has propagated. 321 // Verify that the damage has propagated.
317 EXPECT_EQ(next_frame().damage, large_damage); 322 EXPECT_EQ(next_frame()->damage, large_damage);
318 } 323 }
319 324
320 TEST_F(BufferQueueTest, PartialSwapFullFrame) { 325 TEST_F(BufferQueueTest, PartialSwapFullFrame) {
321 output_surface_->Reshape(screen_size, 1.0f); 326 output_surface_->Reshape(screen_size, 1.0f);
322 ASSERT_TRUE(doublebuffering_); 327 ASSERT_TRUE(doublebuffering_);
323 EXPECT_CALL(*mock_output_surface_, 328 EXPECT_CALL(*mock_output_surface_,
324 CopyBufferDamage(_, _, small_damage, screen_rect)).Times(1); 329 CopyBufferDamage(_, _, small_damage, screen_rect)).Times(1);
325 SendFullFrame(); 330 SendFullFrame();
326 SendDamagedFrame(small_damage); 331 SendDamagedFrame(small_damage);
327 SendFullFrame(); 332 SendFullFrame();
328 SendFullFrame(); 333 SendFullFrame();
329 EXPECT_EQ(next_frame().damage, screen_rect); 334 EXPECT_EQ(next_frame()->damage, screen_rect);
330 } 335 }
331 336
332 TEST_F(BufferQueueTest, PartialSwapOverlapping) { 337 TEST_F(BufferQueueTest, PartialSwapOverlapping) {
333 output_surface_->Reshape(screen_size, 1.0f); 338 output_surface_->Reshape(screen_size, 1.0f);
334 ASSERT_TRUE(doublebuffering_); 339 ASSERT_TRUE(doublebuffering_);
335 EXPECT_CALL(*mock_output_surface_, 340 EXPECT_CALL(*mock_output_surface_,
336 CopyBufferDamage(_, _, small_damage, screen_rect)).Times(1); 341 CopyBufferDamage(_, _, small_damage, screen_rect)).Times(1);
337 EXPECT_CALL(*mock_output_surface_, CopyBufferDamage(_, _, overlapping_damage, 342 EXPECT_CALL(*mock_output_surface_, CopyBufferDamage(_, _, overlapping_damage,
338 small_damage)).Times(1); 343 small_damage)).Times(1);
339 344
340 SendFullFrame(); 345 SendFullFrame();
341 SendDamagedFrame(small_damage); 346 SendDamagedFrame(small_damage);
342 SendDamagedFrame(overlapping_damage); 347 SendDamagedFrame(overlapping_damage);
343 EXPECT_EQ(next_frame().damage, overlapping_damage); 348 EXPECT_EQ(next_frame()->damage, overlapping_damage);
344 } 349 }
345 350
346 TEST_F(BufferQueueTest, MultipleBindCalls) { 351 TEST_F(BufferQueueTest, MultipleBindCalls) {
347 // Check that multiple bind calls do not create or change surfaces. 352 // Check that multiple bind calls do not create or change surfaces.
348 output_surface_->BindFramebuffer(); 353 output_surface_->BindFramebuffer();
349 EXPECT_EQ(1, CountBuffers()); 354 EXPECT_EQ(1, CountBuffers());
350 unsigned int fb = current_surface(); 355 unsigned int fb = current_surface();
351 output_surface_->BindFramebuffer(); 356 output_surface_->BindFramebuffer();
352 EXPECT_EQ(1, CountBuffers()); 357 EXPECT_EQ(1, CountBuffers());
353 EXPECT_EQ(fb, current_surface()); 358 EXPECT_EQ(fb, current_surface());
354 } 359 }
355 360
356 TEST_F(BufferQueueTest, CheckDoubleBuffering) { 361 TEST_F(BufferQueueTest, CheckDoubleBuffering) {
357 // Check buffer flow through double buffering path. 362 // Check buffer flow through double buffering path.
358 EXPECT_EQ(0, CountBuffers()); 363 EXPECT_EQ(0, CountBuffers());
359 output_surface_->BindFramebuffer(); 364 output_surface_->BindFramebuffer();
360 EXPECT_EQ(1, CountBuffers()); 365 EXPECT_EQ(1, CountBuffers());
361 EXPECT_NE(0U, current_surface()); 366 EXPECT_NE(0U, current_surface());
362 EXPECT_FALSE(displayed_frame().texture); 367 EXPECT_FALSE(displayed_frame());
363 SwapBuffers(); 368 SwapBuffers();
364 EXPECT_EQ(1U, in_flight_surfaces().size()); 369 EXPECT_EQ(1U, in_flight_surfaces().size());
365 output_surface_->PageFlipComplete(); 370 output_surface_->PageFlipComplete();
366 EXPECT_EQ(0U, in_flight_surfaces().size()); 371 EXPECT_EQ(0U, in_flight_surfaces().size());
367 EXPECT_TRUE(displayed_frame().texture); 372 EXPECT_TRUE(displayed_frame());
368 output_surface_->BindFramebuffer(); 373 output_surface_->BindFramebuffer();
369 EXPECT_EQ(2, CountBuffers()); 374 EXPECT_EQ(2, CountBuffers());
370 CheckUnique(); 375 CheckUnique();
371 EXPECT_NE(0U, current_surface()); 376 EXPECT_NE(0U, current_surface());
372 EXPECT_EQ(0U, in_flight_surfaces().size()); 377 EXPECT_EQ(0U, in_flight_surfaces().size());
373 EXPECT_TRUE(displayed_frame().texture); 378 EXPECT_TRUE(displayed_frame());
374 SwapBuffers(); 379 SwapBuffers();
375 CheckUnique(); 380 CheckUnique();
376 EXPECT_EQ(1U, in_flight_surfaces().size()); 381 EXPECT_EQ(1U, in_flight_surfaces().size());
377 EXPECT_TRUE(displayed_frame().texture); 382 EXPECT_TRUE(displayed_frame());
378 output_surface_->PageFlipComplete(); 383 output_surface_->PageFlipComplete();
379 CheckUnique(); 384 CheckUnique();
380 EXPECT_EQ(0U, in_flight_surfaces().size()); 385 EXPECT_EQ(0U, in_flight_surfaces().size());
381 EXPECT_EQ(1U, available_surfaces().size()); 386 EXPECT_EQ(1U, available_surfaces().size());
382 EXPECT_TRUE(displayed_frame().texture); 387 EXPECT_TRUE(displayed_frame());
383 output_surface_->BindFramebuffer(); 388 output_surface_->BindFramebuffer();
384 EXPECT_EQ(2, CountBuffers()); 389 EXPECT_EQ(2, CountBuffers());
385 CheckUnique(); 390 CheckUnique();
386 EXPECT_TRUE(available_surfaces().empty()); 391 EXPECT_TRUE(available_surfaces().empty());
387 } 392 }
388 393
389 TEST_F(BufferQueueTest, CheckTripleBuffering) { 394 TEST_F(BufferQueueTest, CheckTripleBuffering) {
390 // Check buffer flow through triple buffering path. 395 // Check buffer flow through triple buffering path.
391 396
392 // This bit is the same sequence tested in the doublebuffering case. 397 // This bit is the same sequence tested in the doublebuffering case.
393 output_surface_->BindFramebuffer(); 398 output_surface_->BindFramebuffer();
394 EXPECT_FALSE(displayed_frame().texture); 399 EXPECT_FALSE(displayed_frame());
395 SwapBuffers(); 400 SwapBuffers();
396 output_surface_->PageFlipComplete(); 401 output_surface_->PageFlipComplete();
397 output_surface_->BindFramebuffer(); 402 output_surface_->BindFramebuffer();
398 SwapBuffers(); 403 SwapBuffers();
399 404
400 EXPECT_EQ(2, CountBuffers()); 405 EXPECT_EQ(2, CountBuffers());
401 CheckUnique(); 406 CheckUnique();
402 EXPECT_EQ(1U, in_flight_surfaces().size()); 407 EXPECT_EQ(1U, in_flight_surfaces().size());
403 EXPECT_TRUE(displayed_frame().texture); 408 EXPECT_TRUE(displayed_frame());
404 output_surface_->BindFramebuffer(); 409 output_surface_->BindFramebuffer();
405 EXPECT_EQ(3, CountBuffers()); 410 EXPECT_EQ(3, CountBuffers());
406 CheckUnique(); 411 CheckUnique();
407 EXPECT_NE(0U, current_surface()); 412 EXPECT_NE(0U, current_surface());
408 EXPECT_EQ(1U, in_flight_surfaces().size()); 413 EXPECT_EQ(1U, in_flight_surfaces().size());
409 EXPECT_TRUE(displayed_frame().texture); 414 EXPECT_TRUE(displayed_frame());
410 output_surface_->PageFlipComplete(); 415 output_surface_->PageFlipComplete();
411 EXPECT_EQ(3, CountBuffers()); 416 EXPECT_EQ(3, CountBuffers());
412 CheckUnique(); 417 CheckUnique();
413 EXPECT_NE(0U, current_surface()); 418 EXPECT_NE(0U, current_surface());
414 EXPECT_EQ(0U, in_flight_surfaces().size()); 419 EXPECT_EQ(0U, in_flight_surfaces().size());
415 EXPECT_TRUE(displayed_frame().texture); 420 EXPECT_TRUE(displayed_frame());
416 EXPECT_EQ(1U, available_surfaces().size()); 421 EXPECT_EQ(1U, available_surfaces().size());
417 } 422 }
418 423
419 TEST_F(BufferQueueTest, CheckCorrectBufferOrdering) { 424 TEST_F(BufferQueueTest, CheckCorrectBufferOrdering) {
420 const size_t kSwapCount = 3; 425 const size_t kSwapCount = 3;
421 for (size_t i = 0; i < kSwapCount; ++i) { 426 for (size_t i = 0; i < kSwapCount; ++i) {
422 output_surface_->BindFramebuffer(); 427 output_surface_->BindFramebuffer();
423 SwapBuffers(); 428 SwapBuffers();
424 } 429 }
425 430
426 EXPECT_EQ(kSwapCount, in_flight_surfaces().size()); 431 EXPECT_EQ(kSwapCount, in_flight_surfaces().size());
427 for (size_t i = 0; i < kSwapCount; ++i) { 432 for (size_t i = 0; i < kSwapCount; ++i) {
428 unsigned int next_texture_id = in_flight_surfaces().front().texture; 433 unsigned int next_texture_id = in_flight_surfaces().front()->texture;
429 output_surface_->PageFlipComplete(); 434 output_surface_->PageFlipComplete();
430 EXPECT_EQ(displayed_frame().texture, next_texture_id); 435 EXPECT_EQ(displayed_frame()->texture, next_texture_id);
431 } 436 }
432 } 437 }
433 438
434 TEST_F(BufferQueueTest, ReshapeWithInFlightSurfaces) { 439 TEST_F(BufferQueueTest, ReshapeWithInFlightSurfaces) {
435 const size_t kSwapCount = 3; 440 const size_t kSwapCount = 3;
436 for (size_t i = 0; i < kSwapCount; ++i) { 441 for (size_t i = 0; i < kSwapCount; ++i) {
437 output_surface_->BindFramebuffer(); 442 output_surface_->BindFramebuffer();
438 SwapBuffers(); 443 SwapBuffers();
439 } 444 }
440 445
441 output_surface_->Reshape(gfx::Size(10, 20), 1.0f); 446 output_surface_->Reshape(gfx::Size(10, 20), 1.0f);
442 EXPECT_EQ(3u, in_flight_surfaces().size()); 447 EXPECT_EQ(3u, in_flight_surface_count());
443 448
444 for (size_t i = 0; i < kSwapCount; ++i) { 449 for (size_t i = 0; i < kSwapCount; ++i) {
445 output_surface_->PageFlipComplete(); 450 output_surface_->PageFlipComplete();
446 EXPECT_EQ(0u, displayed_frame().texture); 451 EXPECT_FALSE(displayed_frame());
447 } 452 }
448 453
449 // The dummy surfacess left should be discarded. 454 // The dummy surfacess left should be discarded.
450 EXPECT_EQ(0u, available_surfaces().size()); 455 EXPECT_EQ(0u, available_surfaces().size());
451 } 456 }
452 457
453 TEST_F(BufferQueueTest, SwapAfterReshape) { 458 TEST_F(BufferQueueTest, SwapAfterReshape) {
454 const size_t kSwapCount = 3; 459 const size_t kSwapCount = 3;
455 for (size_t i = 0; i < kSwapCount; ++i) { 460 for (size_t i = 0; i < kSwapCount; ++i) {
456 output_surface_->BindFramebuffer(); 461 output_surface_->BindFramebuffer();
457 SwapBuffers(); 462 SwapBuffers();
458 } 463 }
459 464
460 output_surface_->Reshape(gfx::Size(10, 20), 1.0f); 465 output_surface_->Reshape(gfx::Size(10, 20), 1.0f);
461 466
462 for (size_t i = 0; i < kSwapCount; ++i) { 467 for (size_t i = 0; i < kSwapCount; ++i) {
463 output_surface_->BindFramebuffer(); 468 output_surface_->BindFramebuffer();
464 SwapBuffers(); 469 SwapBuffers();
465 } 470 }
466 471
467 EXPECT_EQ(2 * kSwapCount, in_flight_surfaces().size()); 472 EXPECT_EQ(2 * kSwapCount, in_flight_surface_count());
468 473
469 for (size_t i = 0; i < kSwapCount; ++i) { 474 for (size_t i = 0; i < kSwapCount; ++i) {
470 output_surface_->PageFlipComplete(); 475 output_surface_->PageFlipComplete();
471 EXPECT_EQ(0u, displayed_frame().texture); 476 EXPECT_FALSE(displayed_frame());
472 } 477 }
473 478
474 CheckUnique(); 479 CheckUnique();
475 480
476 for (size_t i = 0; i < kSwapCount; ++i) { 481 for (size_t i = 0; i < kSwapCount; ++i) {
477 unsigned int next_texture_id = in_flight_surfaces().front().texture; 482 unsigned int next_texture_id = in_flight_surfaces().front()->texture;
478 output_surface_->PageFlipComplete(); 483 output_surface_->PageFlipComplete();
479 EXPECT_EQ(displayed_frame().texture, next_texture_id); 484 EXPECT_EQ(displayed_frame()->texture, next_texture_id);
480 EXPECT_NE(0u, displayed_frame().texture); 485 EXPECT_TRUE(displayed_frame());
481 } 486 }
482 } 487 }
483 488
484 TEST_F(BufferQueueMockedContextTest, RecreateBuffers) { 489 TEST_F(BufferQueueMockedContextTest, RecreateBuffers) {
485 // This setup is to easily get one frame in each of: 490 // This setup is to easily get one frame in each of:
486 // - currently bound for drawing. 491 // - currently bound for drawing.
487 // - in flight to GPU. 492 // - in flight to GPU.
488 // - currently displayed. 493 // - currently displayed.
489 // - free frame. 494 // - free frame.
490 // This tests buffers in all states. 495 // This tests buffers in all states.
491 // Bind/swap pushes frames into the in flight list, then the PageFlipComplete 496 // Bind/swap pushes frames into the in flight list, then the PageFlipComplete
492 // calls pull one frame into displayed and another into the free list. 497 // calls pull one frame into displayed and another into the free list.
493 output_surface_->BindFramebuffer(); 498 output_surface_->BindFramebuffer();
494 SwapBuffers(); 499 SwapBuffers();
495 output_surface_->BindFramebuffer(); 500 output_surface_->BindFramebuffer();
496 SwapBuffers(); 501 SwapBuffers();
497 output_surface_->BindFramebuffer(); 502 output_surface_->BindFramebuffer();
498 SwapBuffers(); 503 SwapBuffers();
499 output_surface_->BindFramebuffer(); 504 output_surface_->BindFramebuffer();
500 output_surface_->PageFlipComplete(); 505 output_surface_->PageFlipComplete();
501 output_surface_->PageFlipComplete(); 506 output_surface_->PageFlipComplete();
502 // We should have one buffer in each possible state right now, including one 507 // We should have one buffer in each possible state right now, including one
503 // being drawn to. 508 // being drawn to.
504 ASSERT_EQ(1U, in_flight_surfaces().size()); 509 ASSERT_EQ(1U, in_flight_surfaces().size());
505 ASSERT_EQ(1U, available_surfaces().size()); 510 ASSERT_EQ(1U, available_surfaces().size());
506 EXPECT_TRUE(displayed_frame().texture); 511 EXPECT_TRUE(displayed_frame()->texture);
507 EXPECT_TRUE(current_frame().texture); 512 EXPECT_TRUE(current_frame()->texture);
508 513
509 auto current = current_frame(); 514 auto current = current_frame();
510 auto displayed = displayed_frame(); 515 auto displayed = displayed_frame();
511 auto in_flight = in_flight_surfaces().front(); 516 auto in_flight = in_flight_surfaces().front();
512 auto available = available_surfaces().front(); 517 auto available = available_surfaces().front();
513 518
514 // Expect all 4 images to be destroyed, 3 of the existing textures to be 519 // Expect all 4 images to be destroyed, 3 of the existing textures to be
515 // copied from and 3 new images to be created. 520 // copied from and 3 new images to be created.
516 EXPECT_CALL(*context_, createImageCHROMIUM(_, 0, 0, GL_RGBA)).Times(3); 521 EXPECT_CALL(*context_, createImageCHROMIUM(_, 0, 0, GL_RGBA)).Times(3);
517 Expectation copy1 = 522 Expectation copy1 = EXPECT_CALL(*mock_output_surface_,
518 EXPECT_CALL(*mock_output_surface_, 523 CopyBufferDamage(_, displayed->texture, _, _))
519 CopyBufferDamage(_, displayed.texture, _, _)).Times(1); 524 .Times(1);
520 Expectation copy2 = 525 Expectation copy2 = EXPECT_CALL(*mock_output_surface_,
521 EXPECT_CALL(*mock_output_surface_, 526 CopyBufferDamage(_, current->texture, _, _))
522 CopyBufferDamage(_, current.texture, _, _)).Times(1); 527 .Times(1);
523 Expectation copy3 = 528 Expectation copy3 = EXPECT_CALL(*mock_output_surface_,
524 EXPECT_CALL(*mock_output_surface_, 529 CopyBufferDamage(_, in_flight->texture, _, _))
525 CopyBufferDamage(_, in_flight.texture, _, _)).Times(1); 530 .Times(1);
526 531
527 EXPECT_CALL(*context_, destroyImageCHROMIUM(displayed.image)) 532 EXPECT_CALL(*context_, destroyImageCHROMIUM(displayed->image))
528 .Times(1) 533 .Times(1)
529 .After(copy1); 534 .After(copy1);
530 EXPECT_CALL(*context_, destroyImageCHROMIUM(current.image)) 535 EXPECT_CALL(*context_, destroyImageCHROMIUM(current->image))
531 .Times(1) 536 .Times(1)
532 .After(copy2); 537 .After(copy2);
533 EXPECT_CALL(*context_, destroyImageCHROMIUM(in_flight.image)) 538 EXPECT_CALL(*context_, destroyImageCHROMIUM(in_flight->image))
534 .Times(1) 539 .Times(1)
535 .After(copy3); 540 .After(copy3);
536 EXPECT_CALL(*context_, destroyImageCHROMIUM(available.image)).Times(1); 541 EXPECT_CALL(*context_, destroyImageCHROMIUM(available->image)).Times(1);
537 // After copying, we expect the framebuffer binding to be updated. 542 // After copying, we expect the framebuffer binding to be updated.
538 EXPECT_CALL(*context_, bindFramebuffer(_, _)) 543 EXPECT_CALL(*context_, bindFramebuffer(_, _))
539 .After(copy1) 544 .After(copy1)
540 .After(copy2) 545 .After(copy2)
541 .After(copy3); 546 .After(copy3);
542 EXPECT_CALL(*context_, framebufferTexture2D(_, _, _, _, _)) 547 EXPECT_CALL(*context_, framebufferTexture2D(_, _, _, _, _))
543 .After(copy1) 548 .After(copy1)
544 .After(copy2) 549 .After(copy2)
545 .After(copy3); 550 .After(copy3);
546 551
547 output_surface_->RecreateBuffers(); 552 output_surface_->RecreateBuffers();
548 testing::Mock::VerifyAndClearExpectations(context_); 553 testing::Mock::VerifyAndClearExpectations(context_);
549 testing::Mock::VerifyAndClearExpectations(mock_output_surface_); 554 testing::Mock::VerifyAndClearExpectations(mock_output_surface_);
550 555
551 // All free buffers should be destroyed, the remaining buffers should all 556 // All free buffers should be destroyed, the remaining buffers should all
552 // be replaced but still valid. 557 // be replaced but still valid.
553 EXPECT_EQ(1U, in_flight_surfaces().size()); 558 EXPECT_EQ(1U, in_flight_surface_count());
554 EXPECT_EQ(0U, available_surfaces().size()); 559 EXPECT_EQ(0U, available_surfaces().size());
555 EXPECT_TRUE(displayed_frame().texture); 560 EXPECT_TRUE(displayed_frame()->texture);
556 EXPECT_TRUE(current_frame().texture); 561 EXPECT_TRUE(current_frame()->texture);
557 } 562 }
558 563
559 } // namespace 564 } // namespace
560 } // namespace content 565 } // namespace content
OLDNEW
« content/browser/compositor/buffer_queue.cc ('K') | « content/browser/compositor/buffer_queue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698