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

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