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

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