OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/texture_layer.h" | 5 #include "cc/layers/texture_layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 class MockMailboxCallback { | 95 class MockMailboxCallback { |
96 public: | 96 public: |
97 MOCK_METHOD3(Release, | 97 MOCK_METHOD3(Release, |
98 void(const gpu::Mailbox& mailbox, | 98 void(const gpu::Mailbox& mailbox, |
99 uint32 sync_point, | 99 uint32 sync_point, |
100 bool lost_resource)); | 100 bool lost_resource)); |
101 MOCK_METHOD3(Release2, | 101 MOCK_METHOD3(Release2, |
102 void(base::SharedMemory* shared_memory, | 102 void(base::SharedMemory* shared_memory, |
103 uint32 sync_point, | 103 uint32 sync_point, |
104 bool lost_resource)); | 104 bool lost_resource)); |
| 105 MOCK_METHOD4(ReleaseImpl, |
| 106 void(const gpu::Mailbox& mailbox, |
| 107 uint32 sync_point, |
| 108 bool lost_resource, |
| 109 BlockingTaskRunner* main_thread_task_runner)); |
| 110 MOCK_METHOD4(ReleaseImpl2, |
| 111 void(base::SharedMemory* shared_memory, |
| 112 uint32 sync_point, |
| 113 bool lost_resource, |
| 114 BlockingTaskRunner* main_thread_task_runner)); |
105 }; | 115 }; |
106 | 116 |
107 struct CommonMailboxObjects { | 117 struct CommonMailboxObjects { |
108 CommonMailboxObjects() | 118 CommonMailboxObjects() |
109 : mailbox_name1_(MailboxFromChar('1')), | 119 : mailbox_name1_(MailboxFromChar('1')), |
110 mailbox_name2_(MailboxFromChar('2')), | 120 mailbox_name2_(MailboxFromChar('2')), |
111 sync_point1_(1), | 121 sync_point1_(1), |
112 sync_point2_(2), | 122 sync_point2_(2), |
113 shared_memory_(new base::SharedMemory) { | 123 shared_memory_(new base::SharedMemory) { |
114 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, | 124 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, |
115 base::Unretained(&mock_callback_), | 125 base::Unretained(&mock_callback_), |
116 mailbox_name1_); | 126 mailbox_name1_); |
117 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, | 127 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, |
118 base::Unretained(&mock_callback_), | 128 base::Unretained(&mock_callback_), |
119 mailbox_name2_); | 129 mailbox_name2_); |
| 130 release_mailbox1_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl, |
| 131 base::Unretained(&mock_callback_), |
| 132 mailbox_name1_); |
| 133 release_mailbox2_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl, |
| 134 base::Unretained(&mock_callback_), |
| 135 mailbox_name2_); |
120 const uint32 arbitrary_target1 = GL_TEXTURE_2D; | 136 const uint32 arbitrary_target1 = GL_TEXTURE_2D; |
121 const uint32 arbitrary_target2 = GL_TEXTURE_EXTERNAL_OES; | 137 const uint32 arbitrary_target2 = GL_TEXTURE_EXTERNAL_OES; |
122 mailbox1_ = TextureMailbox(mailbox_name1_, arbitrary_target1, sync_point1_); | 138 mailbox1_ = TextureMailbox(mailbox_name1_, arbitrary_target1, sync_point1_); |
123 mailbox2_ = TextureMailbox(mailbox_name2_, arbitrary_target2, sync_point2_); | 139 mailbox2_ = TextureMailbox(mailbox_name2_, arbitrary_target2, sync_point2_); |
124 gfx::Size size(128, 128); | 140 gfx::Size size(128, 128); |
125 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); | 141 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); |
126 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, | 142 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, |
127 base::Unretained(&mock_callback_), | 143 base::Unretained(&mock_callback_), |
128 shared_memory_.get()); | 144 shared_memory_.get()); |
| 145 release_mailbox3_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl2, |
| 146 base::Unretained(&mock_callback_), |
| 147 shared_memory_.get()); |
129 mailbox3_ = TextureMailbox(shared_memory_.get(), size); | 148 mailbox3_ = TextureMailbox(shared_memory_.get(), size); |
130 } | 149 } |
131 | 150 |
132 gpu::Mailbox mailbox_name1_; | 151 gpu::Mailbox mailbox_name1_; |
133 gpu::Mailbox mailbox_name2_; | 152 gpu::Mailbox mailbox_name2_; |
134 MockMailboxCallback mock_callback_; | 153 MockMailboxCallback mock_callback_; |
135 ReleaseCallback release_mailbox1_; | 154 ReleaseCallback release_mailbox1_; |
136 ReleaseCallback release_mailbox2_; | 155 ReleaseCallback release_mailbox2_; |
137 ReleaseCallback release_mailbox3_; | 156 ReleaseCallback release_mailbox3_; |
| 157 ReleaseCallbackImpl release_mailbox1_impl_; |
| 158 ReleaseCallbackImpl release_mailbox2_impl_; |
| 159 ReleaseCallbackImpl release_mailbox3_impl_; |
138 TextureMailbox mailbox1_; | 160 TextureMailbox mailbox1_; |
139 TextureMailbox mailbox2_; | 161 TextureMailbox mailbox2_; |
140 TextureMailbox mailbox3_; | 162 TextureMailbox mailbox3_; |
141 uint32 sync_point1_; | 163 uint32 sync_point1_; |
142 uint32 sync_point2_; | 164 uint32 sync_point2_; |
143 scoped_ptr<base::SharedMemory> shared_memory_; | 165 scoped_ptr<base::SharedMemory> shared_memory_; |
144 }; | 166 }; |
145 | 167 |
146 class TextureLayerTest : public testing::Test { | 168 class TextureLayerTest : public testing::Test { |
147 public: | 169 public: |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 392 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
371 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox2); | 393 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox2); |
372 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 394 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
373 } | 395 } |
374 | 396 |
375 class TextureLayerMailboxHolderTest : public TextureLayerTest { | 397 class TextureLayerMailboxHolderTest : public TextureLayerTest { |
376 public: | 398 public: |
377 TextureLayerMailboxHolderTest() | 399 TextureLayerMailboxHolderTest() |
378 : main_thread_("MAIN") { | 400 : main_thread_("MAIN") { |
379 main_thread_.Start(); | 401 main_thread_.Start(); |
| 402 main_thread_.message_loop()->PostTask( |
| 403 FROM_HERE, |
| 404 base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain, |
| 405 base::Unretained(this))); |
| 406 Wait(main_thread_); |
380 } | 407 } |
381 | 408 |
382 void Wait(const base::Thread& thread) { | 409 void Wait(const base::Thread& thread) { |
383 bool manual_reset = false; | 410 bool manual_reset = false; |
384 bool initially_signaled = false; | 411 bool initially_signaled = false; |
385 base::WaitableEvent event(manual_reset, initially_signaled); | 412 base::WaitableEvent event(manual_reset, initially_signaled); |
386 thread.message_loop()->PostTask( | 413 thread.message_loop()->PostTask( |
387 FROM_HERE, | 414 FROM_HERE, |
388 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); | 415 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); |
389 event.Wait(); | 416 event.Wait(); |
390 } | 417 } |
391 | 418 |
392 void CreateMainRef() { | 419 void CreateMainRef() { |
393 main_ref_ = TestMailboxHolder::Create( | 420 main_ref_ = TestMailboxHolder::Create( |
394 test_data_.mailbox1_, | 421 test_data_.mailbox1_, |
395 SingleReleaseCallback::Create(test_data_.release_mailbox1_)).Pass(); | 422 SingleReleaseCallback::Create(test_data_.release_mailbox1_)).Pass(); |
396 } | 423 } |
397 | 424 |
398 void ReleaseMainRef() { | 425 void ReleaseMainRef() { |
399 main_ref_.reset(); | 426 main_ref_.reset(); |
400 } | 427 } |
401 | 428 |
402 void CreateImplRef(scoped_ptr<SingleReleaseCallback>* impl_ref) { | 429 void CreateImplRef(scoped_ptr<SingleReleaseCallbackImpl>* impl_ref) { |
403 *impl_ref = main_ref_->holder()->GetCallbackForImplThread(); | 430 *impl_ref = main_ref_->holder()->GetCallbackForImplThread(); |
404 } | 431 } |
405 | 432 |
406 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture, | 433 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture, |
407 base::WaitableEvent* wait_for_capture, | 434 base::WaitableEvent* wait_for_capture, |
408 base::WaitableEvent* stop_capture) { | 435 base::WaitableEvent* stop_capture) { |
409 begin_capture->Wait(); | 436 begin_capture->Wait(); |
410 BlockingTaskRunner::CapturePostTasks capture; | 437 BlockingTaskRunner::CapturePostTasks capture( |
| 438 main_thread_task_runner_.get()); |
411 wait_for_capture->Signal(); | 439 wait_for_capture->Signal(); |
412 stop_capture->Wait(); | 440 stop_capture->Wait(); |
413 } | 441 } |
414 | 442 |
415 protected: | 443 protected: |
| 444 void InitializeOnMain() { |
| 445 main_thread_task_runner_ = |
| 446 BlockingTaskRunner::Create(main_thread_.message_loop_proxy()); |
| 447 } |
| 448 |
416 scoped_ptr<TestMailboxHolder::MainThreadReference> | 449 scoped_ptr<TestMailboxHolder::MainThreadReference> |
417 main_ref_; | 450 main_ref_; |
418 base::Thread main_thread_; | 451 base::Thread main_thread_; |
| 452 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; |
419 CommonMailboxObjects test_data_; | 453 CommonMailboxObjects test_data_; |
420 }; | 454 }; |
421 | 455 |
422 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { | 456 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { |
423 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 457 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
424 ASSERT_TRUE(test_layer.get()); | 458 ASSERT_TRUE(test_layer.get()); |
425 | 459 |
426 main_thread_.message_loop()->PostTask( | 460 main_thread_.message_loop()->PostTask( |
427 FROM_HERE, | 461 FROM_HERE, |
428 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 462 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
429 base::Unretained(this))); | 463 base::Unretained(this))); |
430 | 464 |
431 Wait(main_thread_); | 465 Wait(main_thread_); |
432 | 466 |
433 // The texture layer is attached to compositor1, and passes a reference to its | 467 // The texture layer is attached to compositor1, and passes a reference to its |
434 // impl tree. | 468 // impl tree. |
435 scoped_ptr<SingleReleaseCallback> compositor1; | 469 scoped_ptr<SingleReleaseCallbackImpl> compositor1; |
436 main_thread_.message_loop()->PostTask( | 470 main_thread_.message_loop()->PostTask( |
437 FROM_HERE, | 471 FROM_HERE, |
438 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 472 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
439 base::Unretained(this), | 473 base::Unretained(this), |
440 &compositor1)); | 474 &compositor1)); |
441 | 475 |
442 // Then the texture layer is removed and attached to compositor2, and passes a | 476 // Then the texture layer is removed and attached to compositor2, and passes a |
443 // reference to its impl tree. | 477 // reference to its impl tree. |
444 scoped_ptr<SingleReleaseCallback> compositor2; | 478 scoped_ptr<SingleReleaseCallbackImpl> compositor2; |
445 main_thread_.message_loop()->PostTask( | 479 main_thread_.message_loop()->PostTask( |
446 FROM_HERE, | 480 FROM_HERE, |
447 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 481 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
448 base::Unretained(this), | 482 base::Unretained(this), |
449 &compositor2)); | 483 &compositor2)); |
450 | 484 |
451 Wait(main_thread_); | 485 Wait(main_thread_); |
452 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 486 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
453 | 487 |
454 // The compositors both destroy their impl trees before the main thread layer | 488 // The compositors both destroy their impl trees before the main thread layer |
455 // is destroyed. | 489 // is destroyed. |
456 compositor1->Run(100, false); | 490 compositor1->Run(100, false, main_thread_task_runner_.get()); |
457 compositor2->Run(200, false); | 491 compositor2->Run(200, false, main_thread_task_runner_.get()); |
458 | 492 |
459 Wait(main_thread_); | 493 Wait(main_thread_); |
460 | 494 |
461 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 495 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
462 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 496 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
463 | 497 |
464 // The main thread ref is the last one, so the mailbox is released back to the | 498 // The main thread ref is the last one, so the mailbox is released back to the |
465 // embedder, with the last sync point provided by the impl trees. | 499 // embedder, with the last sync point provided by the impl trees. |
466 EXPECT_CALL(test_data_.mock_callback_, | 500 EXPECT_CALL(test_data_.mock_callback_, |
467 Release(test_data_.mailbox_name1_, 200, false)).Times(1); | 501 Release(test_data_.mailbox_name1_, 200, false)).Times(1); |
(...skipping 12 matching lines...) Expand all Loading... |
480 | 514 |
481 main_thread_.message_loop()->PostTask( | 515 main_thread_.message_loop()->PostTask( |
482 FROM_HERE, | 516 FROM_HERE, |
483 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 517 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
484 base::Unretained(this))); | 518 base::Unretained(this))); |
485 | 519 |
486 Wait(main_thread_); | 520 Wait(main_thread_); |
487 | 521 |
488 // The texture layer is attached to compositor1, and passes a reference to its | 522 // The texture layer is attached to compositor1, and passes a reference to its |
489 // impl tree. | 523 // impl tree. |
490 scoped_ptr<SingleReleaseCallback> compositor1; | 524 scoped_ptr<SingleReleaseCallbackImpl> compositor1; |
491 main_thread_.message_loop()->PostTask( | 525 main_thread_.message_loop()->PostTask( |
492 FROM_HERE, | 526 FROM_HERE, |
493 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 527 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
494 base::Unretained(this), | 528 base::Unretained(this), |
495 &compositor1)); | 529 &compositor1)); |
496 | 530 |
497 // Then the texture layer is removed and attached to compositor2, and passes a | 531 // Then the texture layer is removed and attached to compositor2, and passes a |
498 // reference to its impl tree. | 532 // reference to its impl tree. |
499 scoped_ptr<SingleReleaseCallback> compositor2; | 533 scoped_ptr<SingleReleaseCallbackImpl> compositor2; |
500 main_thread_.message_loop()->PostTask( | 534 main_thread_.message_loop()->PostTask( |
501 FROM_HERE, | 535 FROM_HERE, |
502 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 536 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
503 base::Unretained(this), | 537 base::Unretained(this), |
504 &compositor2)); | 538 &compositor2)); |
505 | 539 |
506 Wait(main_thread_); | 540 Wait(main_thread_); |
507 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 541 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
508 | 542 |
509 // One compositor destroys their impl tree. | 543 // One compositor destroys their impl tree. |
510 compositor1->Run(100, false); | 544 compositor1->Run(100, false, main_thread_task_runner_.get()); |
511 | 545 |
512 // Then the main thread reference is destroyed. | 546 // Then the main thread reference is destroyed. |
513 main_thread_.message_loop()->PostTask( | 547 main_thread_.message_loop()->PostTask( |
514 FROM_HERE, | 548 FROM_HERE, |
515 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 549 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
516 base::Unretained(this))); | 550 base::Unretained(this))); |
517 | 551 |
518 Wait(main_thread_); | 552 Wait(main_thread_); |
519 | 553 |
520 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 554 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
521 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 555 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
522 | 556 |
523 // The second impl reference is destroyed last, causing the mailbox to be | 557 // The second impl reference is destroyed last, causing the mailbox to be |
524 // released back to the embedder with the last sync point from the impl tree. | 558 // released back to the embedder with the last sync point from the impl tree. |
525 EXPECT_CALL(test_data_.mock_callback_, | 559 EXPECT_CALL(test_data_.mock_callback_, |
526 Release(test_data_.mailbox_name1_, 200, true)).Times(1); | 560 Release(test_data_.mailbox_name1_, 200, true)).Times(1); |
527 | 561 |
528 compositor2->Run(200, true); | 562 compositor2->Run(200, true, main_thread_task_runner_.get()); |
529 Wait(main_thread_); | 563 Wait(main_thread_); |
530 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 564 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
531 } | 565 } |
532 | 566 |
533 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 567 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { |
534 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 568 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
535 ASSERT_TRUE(test_layer.get()); | 569 ASSERT_TRUE(test_layer.get()); |
536 | 570 |
537 main_thread_.message_loop()->PostTask( | 571 main_thread_.message_loop()->PostTask( |
538 FROM_HERE, | 572 FROM_HERE, |
539 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 573 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
540 base::Unretained(this))); | 574 base::Unretained(this))); |
541 | 575 |
542 Wait(main_thread_); | 576 Wait(main_thread_); |
543 | 577 |
544 // The texture layer is attached to compositor1, and passes a reference to its | 578 // The texture layer is attached to compositor1, and passes a reference to its |
545 // impl tree. | 579 // impl tree. |
546 scoped_ptr<SingleReleaseCallback> compositor1; | 580 scoped_ptr<SingleReleaseCallbackImpl> compositor1; |
547 main_thread_.message_loop()->PostTask( | 581 main_thread_.message_loop()->PostTask( |
548 FROM_HERE, | 582 FROM_HERE, |
549 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 583 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
550 base::Unretained(this), | 584 base::Unretained(this), |
551 &compositor1)); | 585 &compositor1)); |
552 | 586 |
553 // Then the texture layer is removed and attached to compositor2, and passes a | 587 // Then the texture layer is removed and attached to compositor2, and passes a |
554 // reference to its impl tree. | 588 // reference to its impl tree. |
555 scoped_ptr<SingleReleaseCallback> compositor2; | 589 scoped_ptr<SingleReleaseCallbackImpl> compositor2; |
556 main_thread_.message_loop()->PostTask( | 590 main_thread_.message_loop()->PostTask( |
557 FROM_HERE, | 591 FROM_HERE, |
558 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 592 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
559 base::Unretained(this), | 593 base::Unretained(this), |
560 &compositor2)); | 594 &compositor2)); |
561 | 595 |
562 Wait(main_thread_); | 596 Wait(main_thread_); |
563 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 597 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
564 | 598 |
565 // The main thread reference is destroyed first. | 599 // The main thread reference is destroyed first. |
566 main_thread_.message_loop()->PostTask( | 600 main_thread_.message_loop()->PostTask( |
567 FROM_HERE, | 601 FROM_HERE, |
568 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 602 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
569 base::Unretained(this))); | 603 base::Unretained(this))); |
570 | 604 |
571 // One compositor destroys their impl tree. | 605 // One compositor destroys their impl tree. |
572 compositor2->Run(200, false); | 606 compositor2->Run(200, false, main_thread_task_runner_.get()); |
573 | 607 |
574 Wait(main_thread_); | 608 Wait(main_thread_); |
575 | 609 |
576 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 610 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
577 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 611 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
578 | 612 |
579 // The second impl reference is destroyed last, causing the mailbox to be | 613 // The second impl reference is destroyed last, causing the mailbox to be |
580 // released back to the embedder with the last sync point from the impl tree. | 614 // released back to the embedder with the last sync point from the impl tree. |
581 EXPECT_CALL(test_data_.mock_callback_, | 615 EXPECT_CALL(test_data_.mock_callback_, |
582 Release(test_data_.mailbox_name1_, 100, true)).Times(1); | 616 Release(test_data_.mailbox_name1_, 100, true)).Times(1); |
583 | 617 |
584 compositor1->Run(100, true); | 618 compositor1->Run(100, true, main_thread_task_runner_.get()); |
585 Wait(main_thread_); | 619 Wait(main_thread_); |
586 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 620 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
587 } | 621 } |
588 | 622 |
589 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 623 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { |
590 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 624 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
591 ASSERT_TRUE(test_layer.get()); | 625 ASSERT_TRUE(test_layer.get()); |
592 | 626 |
593 main_thread_.message_loop()->PostTask( | 627 main_thread_.message_loop()->PostTask( |
594 FROM_HERE, | 628 FROM_HERE, |
595 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 629 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
596 base::Unretained(this))); | 630 base::Unretained(this))); |
597 | 631 |
598 Wait(main_thread_); | 632 Wait(main_thread_); |
599 | 633 |
600 // The texture layer is attached to compositor1, and passes a reference to its | 634 // The texture layer is attached to compositor1, and passes a reference to its |
601 // impl tree. | 635 // impl tree. |
602 scoped_ptr<SingleReleaseCallback> compositor1; | 636 scoped_ptr<SingleReleaseCallbackImpl> compositor1; |
603 main_thread_.message_loop()->PostTask( | 637 main_thread_.message_loop()->PostTask( |
604 FROM_HERE, | 638 FROM_HERE, |
605 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 639 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
606 base::Unretained(this), | 640 base::Unretained(this), |
607 &compositor1)); | 641 &compositor1)); |
608 | 642 |
609 // Then the texture layer is removed and attached to compositor2, and passes a | 643 // Then the texture layer is removed and attached to compositor2, and passes a |
610 // reference to its impl tree. | 644 // reference to its impl tree. |
611 scoped_ptr<SingleReleaseCallback> compositor2; | 645 scoped_ptr<SingleReleaseCallbackImpl> compositor2; |
612 main_thread_.message_loop()->PostTask( | 646 main_thread_.message_loop()->PostTask( |
613 FROM_HERE, | 647 FROM_HERE, |
614 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 648 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
615 base::Unretained(this), | 649 base::Unretained(this), |
616 &compositor2)); | 650 &compositor2)); |
617 | 651 |
618 Wait(main_thread_); | 652 Wait(main_thread_); |
619 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 653 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
620 | 654 |
621 // The main thread reference is destroyed first. | 655 // The main thread reference is destroyed first. |
(...skipping 17 matching lines...) Expand all Loading... |
639 FROM_HERE, | 673 FROM_HERE, |
640 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, | 674 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, |
641 base::Unretained(this), | 675 base::Unretained(this), |
642 &begin_capture, | 676 &begin_capture, |
643 &wait_for_capture, | 677 &wait_for_capture, |
644 &stop_capture)); | 678 &stop_capture)); |
645 | 679 |
646 // Before the main thread capturing starts, one compositor destroys their | 680 // Before the main thread capturing starts, one compositor destroys their |
647 // impl reference. Since capturing did not start, this gets post-tasked to | 681 // impl reference. Since capturing did not start, this gets post-tasked to |
648 // the main thread. | 682 // the main thread. |
649 compositor1->Run(100, false); | 683 compositor1->Run(100, false, main_thread_task_runner_.get()); |
650 | 684 |
651 // Start capturing on the main thread. | 685 // Start capturing on the main thread. |
652 begin_capture.Signal(); | 686 begin_capture.Signal(); |
653 wait_for_capture.Wait(); | 687 wait_for_capture.Wait(); |
654 | 688 |
655 // Meanwhile, the second compositor released its impl reference, but this task | 689 // Meanwhile, the second compositor released its impl reference, but this task |
656 // gets shortcutted directly to the main thread. This means the reference is | 690 // gets shortcutted directly to the main thread. This means the reference is |
657 // released before compositor1, whose reference will be released later when | 691 // released before compositor1, whose reference will be released later when |
658 // the post-task is serviced. But since it was destroyed _on the impl thread_ | 692 // the post-task is serviced. But since it was destroyed _on the impl thread_ |
659 // last, its sync point values should be used. | 693 // last, its sync point values should be used. |
660 compositor2->Run(200, true); | 694 compositor2->Run(200, true, main_thread_task_runner_.get()); |
661 | 695 |
662 stop_capture.Signal(); | 696 stop_capture.Signal(); |
663 Wait(main_thread_); | 697 Wait(main_thread_); |
664 | 698 |
665 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 699 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
666 } | 700 } |
667 | 701 |
668 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { | 702 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { |
669 public: | 703 public: |
670 TextureLayerImplWithMailboxThreadedCallback() | 704 TextureLayerImplWithMailboxThreadedCallback() |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 return will_draw; | 944 return will_draw; |
911 } | 945 } |
912 | 946 |
913 CommonMailboxObjects test_data_; | 947 CommonMailboxObjects test_data_; |
914 FakeLayerTreeHostClient fake_client_; | 948 FakeLayerTreeHostClient fake_client_; |
915 }; | 949 }; |
916 | 950 |
917 // Test conditions for results of TextureLayerImpl::WillDraw under | 951 // Test conditions for results of TextureLayerImpl::WillDraw under |
918 // different configurations of different mailbox, texture_id, and draw_mode. | 952 // different configurations of different mailbox, texture_id, and draw_mode. |
919 TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { | 953 TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { |
920 EXPECT_CALL(test_data_.mock_callback_, | 954 EXPECT_CALL( |
921 Release(test_data_.mailbox_name1_, | 955 test_data_.mock_callback_, |
922 test_data_.sync_point1_, | 956 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _)) |
923 false)) | |
924 .Times(AnyNumber()); | 957 .Times(AnyNumber()); |
925 EXPECT_CALL(test_data_.mock_callback_, | 958 EXPECT_CALL(test_data_.mock_callback_, |
926 Release2(test_data_.shared_memory_.get(), 0, false)) | 959 ReleaseImpl2(test_data_.shared_memory_.get(), 0, false, _)) |
927 .Times(AnyNumber()); | 960 .Times(AnyNumber()); |
928 // Hardware mode. | 961 // Hardware mode. |
929 { | 962 { |
930 scoped_ptr<TextureLayerImpl> impl_layer = | 963 scoped_ptr<TextureLayerImpl> impl_layer = |
931 TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 964 TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
932 impl_layer->SetTextureMailbox( | 965 impl_layer->SetTextureMailbox( |
933 test_data_.mailbox1_, | 966 test_data_.mailbox1_, |
934 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 967 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
935 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 968 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
936 } | 969 } |
937 | 970 |
938 { | 971 { |
939 scoped_ptr<TextureLayerImpl> impl_layer = | 972 scoped_ptr<TextureLayerImpl> impl_layer = |
940 TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 973 TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
941 impl_layer->SetTextureMailbox(TextureMailbox(), | 974 impl_layer->SetTextureMailbox(TextureMailbox(), |
942 scoped_ptr<SingleReleaseCallback>()); | 975 scoped_ptr<SingleReleaseCallbackImpl>()); |
943 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 976 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
944 } | 977 } |
945 | 978 |
946 { | 979 { |
947 // Software resource. | 980 // Software resource. |
948 scoped_ptr<TextureLayerImpl> impl_layer = | 981 scoped_ptr<TextureLayerImpl> impl_layer = |
949 TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 982 TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
950 impl_layer->SetTextureMailbox( | 983 impl_layer->SetTextureMailbox( |
951 test_data_.mailbox3_, | 984 test_data_.mailbox3_, |
952 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); | 985 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_)); |
953 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 986 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
954 } | 987 } |
955 | 988 |
956 // Software mode. | 989 // Software mode. |
957 { | 990 { |
958 scoped_ptr<TextureLayerImpl> impl_layer = | 991 scoped_ptr<TextureLayerImpl> impl_layer = |
959 TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 992 TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
960 impl_layer->SetTextureMailbox( | 993 impl_layer->SetTextureMailbox( |
961 test_data_.mailbox1_, | 994 test_data_.mailbox1_, |
962 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 995 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
963 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 996 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
964 } | 997 } |
965 | 998 |
966 { | 999 { |
967 scoped_ptr<TextureLayerImpl> impl_layer = | 1000 scoped_ptr<TextureLayerImpl> impl_layer = |
968 TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 1001 TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
969 impl_layer->SetTextureMailbox(TextureMailbox(), | 1002 impl_layer->SetTextureMailbox(TextureMailbox(), |
970 scoped_ptr<SingleReleaseCallback>()); | 1003 scoped_ptr<SingleReleaseCallbackImpl>()); |
971 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1004 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
972 } | 1005 } |
973 | 1006 |
974 { | 1007 { |
975 // Software resource. | 1008 // Software resource. |
976 scoped_ptr<TextureLayerImpl> impl_layer = | 1009 scoped_ptr<TextureLayerImpl> impl_layer = |
977 TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 1010 TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
978 impl_layer->SetTextureMailbox( | 1011 impl_layer->SetTextureMailbox( |
979 test_data_.mailbox3_, | 1012 test_data_.mailbox3_, |
980 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); | 1013 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_)); |
981 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1014 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
982 } | 1015 } |
983 | 1016 |
984 // Resourceless software mode. | 1017 // Resourceless software mode. |
985 { | 1018 { |
986 scoped_ptr<TextureLayerImpl> impl_layer = | 1019 scoped_ptr<TextureLayerImpl> impl_layer = |
987 TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 1020 TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
988 impl_layer->SetTextureMailbox( | 1021 impl_layer->SetTextureMailbox( |
989 test_data_.mailbox1_, | 1022 test_data_.mailbox1_, |
990 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1023 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
991 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 1024 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
992 } | 1025 } |
993 } | 1026 } |
994 | 1027 |
995 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { | 1028 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { |
996 host_impl_.CreatePendingTree(); | 1029 host_impl_.CreatePendingTree(); |
997 scoped_ptr<TextureLayerImpl> pending_layer; | 1030 scoped_ptr<TextureLayerImpl> pending_layer; |
998 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1); | 1031 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1); |
999 ASSERT_TRUE(pending_layer); | 1032 ASSERT_TRUE(pending_layer); |
1000 | 1033 |
1001 scoped_ptr<LayerImpl> active_layer( | 1034 scoped_ptr<LayerImpl> active_layer( |
1002 pending_layer->CreateLayerImpl(host_impl_.active_tree())); | 1035 pending_layer->CreateLayerImpl(host_impl_.active_tree())); |
1003 ASSERT_TRUE(active_layer); | 1036 ASSERT_TRUE(active_layer); |
1004 | 1037 |
1005 pending_layer->SetTextureMailbox( | 1038 pending_layer->SetTextureMailbox( |
1006 test_data_.mailbox1_, | 1039 test_data_.mailbox1_, |
1007 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1040 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
1008 | 1041 |
1009 // Test multiple commits without an activation. | 1042 // Test multiple commits without an activation. |
1010 EXPECT_CALL(test_data_.mock_callback_, | 1043 EXPECT_CALL( |
1011 Release(test_data_.mailbox_name1_, | 1044 test_data_.mock_callback_, |
1012 test_data_.sync_point1_, | 1045 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _)) |
1013 false)) | |
1014 .Times(1); | 1046 .Times(1); |
1015 pending_layer->SetTextureMailbox( | 1047 pending_layer->SetTextureMailbox( |
1016 test_data_.mailbox2_, | 1048 test_data_.mailbox2_, |
1017 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); | 1049 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox2_impl_)); |
1018 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1050 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1019 | 1051 |
1020 // Test callback after activation. | 1052 // Test callback after activation. |
1021 pending_layer->PushPropertiesTo(active_layer.get()); | 1053 pending_layer->PushPropertiesTo(active_layer.get()); |
1022 active_layer->DidBecomeActive(); | 1054 active_layer->DidBecomeActive(); |
1023 | 1055 |
1024 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 1056 EXPECT_CALL(test_data_.mock_callback_, ReleaseImpl(_, _, _, _)).Times(0); |
1025 pending_layer->SetTextureMailbox( | 1057 pending_layer->SetTextureMailbox( |
1026 test_data_.mailbox1_, | 1058 test_data_.mailbox1_, |
1027 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1059 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
1028 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1060 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1029 | 1061 |
1030 EXPECT_CALL(test_data_.mock_callback_, | 1062 EXPECT_CALL(test_data_.mock_callback_, |
1031 Release(test_data_.mailbox_name2_, _, false)) | 1063 ReleaseImpl(test_data_.mailbox_name2_, _, false, _)).Times(1); |
1032 .Times(1); | |
1033 pending_layer->PushPropertiesTo(active_layer.get()); | 1064 pending_layer->PushPropertiesTo(active_layer.get()); |
1034 active_layer->DidBecomeActive(); | 1065 active_layer->DidBecomeActive(); |
1035 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1066 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1036 | 1067 |
1037 // Test resetting the mailbox. | 1068 // Test resetting the mailbox. |
1038 EXPECT_CALL(test_data_.mock_callback_, | 1069 EXPECT_CALL(test_data_.mock_callback_, |
1039 Release(test_data_.mailbox_name1_, _, false)) | 1070 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1); |
1040 .Times(1); | |
1041 pending_layer->SetTextureMailbox(TextureMailbox(), | 1071 pending_layer->SetTextureMailbox(TextureMailbox(), |
1042 scoped_ptr<SingleReleaseCallback>()); | 1072 scoped_ptr<SingleReleaseCallbackImpl>()); |
1043 pending_layer->PushPropertiesTo(active_layer.get()); | 1073 pending_layer->PushPropertiesTo(active_layer.get()); |
1044 active_layer->DidBecomeActive(); | 1074 active_layer->DidBecomeActive(); |
1045 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1075 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1046 | 1076 |
1047 // Test destructor. | 1077 // Test destructor. |
1048 EXPECT_CALL(test_data_.mock_callback_, | 1078 EXPECT_CALL( |
1049 Release(test_data_.mailbox_name1_, | 1079 test_data_.mock_callback_, |
1050 test_data_.sync_point1_, | 1080 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _)) |
1051 false)) | |
1052 .Times(1); | 1081 .Times(1); |
1053 pending_layer->SetTextureMailbox( | 1082 pending_layer->SetTextureMailbox( |
1054 test_data_.mailbox1_, | 1083 test_data_.mailbox1_, |
1055 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1084 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
1056 } | 1085 } |
1057 | 1086 |
1058 TEST_F(TextureLayerImplWithMailboxTest, | 1087 TEST_F(TextureLayerImplWithMailboxTest, |
1059 TestDestructorCallbackOnCreatedResource) { | 1088 TestDestructorCallbackOnCreatedResource) { |
1060 scoped_ptr<TextureLayerImpl> impl_layer; | 1089 scoped_ptr<TextureLayerImpl> impl_layer; |
1061 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); | 1090 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); |
1062 ASSERT_TRUE(impl_layer); | 1091 ASSERT_TRUE(impl_layer); |
1063 | 1092 |
1064 EXPECT_CALL(test_data_.mock_callback_, | 1093 EXPECT_CALL(test_data_.mock_callback_, |
1065 Release(test_data_.mailbox_name1_, _, false)) | 1094 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1); |
1066 .Times(1); | |
1067 impl_layer->SetTextureMailbox( | 1095 impl_layer->SetTextureMailbox( |
1068 test_data_.mailbox1_, | 1096 test_data_.mailbox1_, |
1069 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1097 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
1070 impl_layer->DidBecomeActive(); | 1098 impl_layer->DidBecomeActive(); |
1071 EXPECT_TRUE(impl_layer->WillDraw( | 1099 EXPECT_TRUE(impl_layer->WillDraw( |
1072 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); | 1100 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); |
1073 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); | 1101 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); |
1074 impl_layer->SetTextureMailbox(TextureMailbox(), | 1102 impl_layer->SetTextureMailbox(TextureMailbox(), |
1075 scoped_ptr<SingleReleaseCallback>()); | 1103 scoped_ptr<SingleReleaseCallbackImpl>()); |
1076 } | 1104 } |
1077 | 1105 |
1078 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { | 1106 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { |
1079 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); | 1107 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); |
1080 ResourceProvider::ResourceId id = | 1108 ResourceProvider::ResourceId id = provider->CreateResourceFromTextureMailbox( |
1081 provider->CreateResourceFromTextureMailbox( | 1109 test_data_.mailbox1_, |
1082 test_data_.mailbox1_, | 1110 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); |
1083 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1084 provider->AllocateForTesting(id); | 1111 provider->AllocateForTesting(id); |
1085 | 1112 |
1086 // Transfer some resources to the parent. | 1113 // Transfer some resources to the parent. |
1087 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1114 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1088 resource_ids_to_transfer.push_back(id); | 1115 resource_ids_to_transfer.push_back(id); |
1089 TransferableResourceArray list; | 1116 TransferableResourceArray list; |
1090 provider->PrepareSendToParent(resource_ids_to_transfer, &list); | 1117 provider->PrepareSendToParent(resource_ids_to_transfer, &list); |
1091 EXPECT_TRUE(provider->InUseByConsumer(id)); | 1118 EXPECT_TRUE(provider->InUseByConsumer(id)); |
1092 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 1119 EXPECT_CALL(test_data_.mock_callback_, ReleaseImpl(_, _, _, _)).Times(0); |
1093 provider->DeleteResource(id); | 1120 provider->DeleteResource(id); |
1094 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1121 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1095 EXPECT_CALL(test_data_.mock_callback_, | 1122 EXPECT_CALL(test_data_.mock_callback_, |
1096 Release(test_data_.mailbox_name1_, _, false)) | 1123 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1); |
1097 .Times(1); | |
1098 ReturnedResourceArray returned; | 1124 ReturnedResourceArray returned; |
1099 TransferableResource::ReturnResources(list, &returned); | 1125 TransferableResource::ReturnResources(list, &returned); |
1100 provider->ReceiveReturnsFromParent(returned); | 1126 provider->ReceiveReturnsFromParent(returned); |
1101 } | 1127 } |
1102 | 1128 |
1103 // Checks that TextureLayer::Update does not cause an extra commit when setting | 1129 // Checks that TextureLayer::Update does not cause an extra commit when setting |
1104 // the texture mailbox. | 1130 // the texture mailbox. |
1105 class TextureLayerNoExtraCommitForMailboxTest | 1131 class TextureLayerNoExtraCommitForMailboxTest |
1106 : public LayerTreeTest, | 1132 : public LayerTreeTest, |
1107 public TextureLayerClient { | 1133 public TextureLayerClient { |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 int callback_count_; | 1578 int callback_count_; |
1553 scoped_refptr<Layer> root_; | 1579 scoped_refptr<Layer> root_; |
1554 scoped_refptr<TextureLayer> layer_; | 1580 scoped_refptr<TextureLayer> layer_; |
1555 }; | 1581 }; |
1556 | 1582 |
1557 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1583 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1558 TextureLayerWithMailboxImplThreadDeleted); | 1584 TextureLayerWithMailboxImplThreadDeleted); |
1559 | 1585 |
1560 } // namespace | 1586 } // namespace |
1561 } // namespace cc | 1587 } // namespace cc |
OLD | NEW |