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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 virtual unsigned PrepareTexture() OVERRIDE { | 245 virtual unsigned PrepareTexture() OVERRIDE { |
246 return 0; | 246 return 0; |
247 } | 247 } |
248 | 248 |
249 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 249 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
250 return context_.get(); | 250 return context_.get(); |
251 } | 251 } |
252 | 252 |
253 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, | 253 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, |
| 254 ScopedReleaseCallback* release_callback, |
254 bool use_shared_memory) OVERRIDE { | 255 bool use_shared_memory) OVERRIDE { |
255 *mailbox = TextureMailbox(); | 256 *mailbox = TextureMailbox(); |
| 257 *release_callback = ScopedReleaseCallback(); |
256 return true; | 258 return true; |
257 } | 259 } |
258 | 260 |
259 private: | 261 private: |
260 scoped_ptr<TestWebGraphicsContext3D> context_; | 262 scoped_ptr<TestWebGraphicsContext3D> context_; |
261 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); | 263 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); |
262 }; | 264 }; |
263 | 265 |
264 TEST_F(TextureLayerTest, RateLimiter) { | 266 TEST_F(TextureLayerTest, RateLimiter) { |
265 FakeTextureLayerClient client; | 267 FakeTextureLayerClient client; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 sync_point2_(2), | 330 sync_point2_(2), |
329 shared_memory_(new base::SharedMemory) { | 331 shared_memory_(new base::SharedMemory) { |
330 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, | 332 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, |
331 base::Unretained(&mock_callback_), | 333 base::Unretained(&mock_callback_), |
332 mailbox_name1_); | 334 mailbox_name1_); |
333 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, | 335 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, |
334 base::Unretained(&mock_callback_), | 336 base::Unretained(&mock_callback_), |
335 mailbox_name2_); | 337 mailbox_name2_); |
336 gpu::Mailbox m1; | 338 gpu::Mailbox m1; |
337 m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); | 339 m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); |
338 mailbox1_ = TextureMailbox(m1, release_mailbox1_, sync_point1_); | 340 mailbox1_ = TextureMailbox(m1, sync_point1_); |
339 gpu::Mailbox m2; | 341 gpu::Mailbox m2; |
340 m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); | 342 m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); |
341 mailbox2_ = TextureMailbox(m2, release_mailbox2_, sync_point2_); | 343 mailbox2_ = TextureMailbox(m2, sync_point2_); |
342 | 344 |
343 gfx::Size size(128, 128); | 345 gfx::Size size(128, 128); |
344 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); | 346 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); |
345 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, | 347 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, |
346 base::Unretained(&mock_callback_), | 348 base::Unretained(&mock_callback_), |
347 shared_memory_.get()); | 349 shared_memory_.get()); |
348 mailbox3_ = TextureMailbox(shared_memory_.get(), size, release_mailbox3_); | 350 mailbox3_ = TextureMailbox(shared_memory_.get(), size); |
349 } | 351 } |
350 | 352 |
351 std::string mailbox_name1_; | 353 std::string mailbox_name1_; |
352 std::string mailbox_name2_; | 354 std::string mailbox_name2_; |
353 MockMailboxCallback mock_callback_; | 355 MockMailboxCallback mock_callback_; |
354 TextureMailbox::ReleaseCallback release_mailbox1_; | 356 ReleaseCallback release_mailbox1_; |
355 TextureMailbox::ReleaseCallback release_mailbox2_; | 357 ReleaseCallback release_mailbox2_; |
356 TextureMailbox::ReleaseCallback release_mailbox3_; | 358 ReleaseCallback release_mailbox3_; |
357 TextureMailbox mailbox1_; | 359 TextureMailbox mailbox1_; |
358 TextureMailbox mailbox2_; | 360 TextureMailbox mailbox2_; |
359 TextureMailbox mailbox3_; | 361 TextureMailbox mailbox3_; |
360 unsigned sync_point1_; | 362 unsigned sync_point1_; |
361 unsigned sync_point2_; | 363 unsigned sync_point2_; |
362 scoped_ptr<base::SharedMemory> shared_memory_; | 364 scoped_ptr<base::SharedMemory> shared_memory_; |
363 }; | 365 }; |
364 | 366 |
365 class TestMailboxHolder : public TextureLayer::MailboxHolder { | 367 class TestMailboxHolder : public TextureLayer::MailboxHolder { |
366 public: | 368 public: |
(...skipping 21 matching lines...) Expand all Loading... |
388 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 390 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
389 ASSERT_TRUE(test_layer.get()); | 391 ASSERT_TRUE(test_layer.get()); |
390 | 392 |
391 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 393 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
392 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 394 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
393 layer_tree_host_->SetRootLayer(test_layer); | 395 layer_tree_host_->SetRootLayer(test_layer); |
394 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 396 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
395 | 397 |
396 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 398 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
397 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 399 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
398 test_layer->SetTextureMailbox(test_data_.mailbox1_); | 400 test_layer->SetTextureMailbox( |
| 401 test_data_.mailbox1_, |
| 402 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
399 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 403 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
400 | 404 |
401 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 405 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
402 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 406 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
403 EXPECT_CALL(test_data_.mock_callback_, | 407 EXPECT_CALL(test_data_.mock_callback_, |
404 Release(test_data_.mailbox_name1_, | 408 Release(test_data_.mailbox_name1_, |
405 test_data_.sync_point1_, | 409 test_data_.sync_point1_, |
406 false)) | 410 false)) |
407 .Times(1); | 411 .Times(1); |
408 test_layer->SetTextureMailbox(test_data_.mailbox2_); | 412 test_layer->SetTextureMailbox( |
| 413 test_data_.mailbox2_, |
| 414 ScopedReleaseCallback(test_data_.release_mailbox2_)); |
409 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 415 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
410 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 416 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
411 | 417 |
412 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 418 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
413 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 419 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
414 EXPECT_CALL(test_data_.mock_callback_, | 420 EXPECT_CALL(test_data_.mock_callback_, |
415 Release(test_data_.mailbox_name2_, | 421 Release(test_data_.mailbox_name2_, |
416 test_data_.sync_point2_, | 422 test_data_.sync_point2_, |
417 false)) | 423 false)) |
418 .Times(1); | 424 .Times(1); |
419 test_layer->SetTextureMailbox(TextureMailbox()); | 425 test_layer->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
420 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 426 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
421 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 427 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
422 | 428 |
423 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 429 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
424 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 430 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
425 test_layer->SetTextureMailbox(test_data_.mailbox3_); | 431 test_layer->SetTextureMailbox( |
| 432 test_data_.mailbox3_, |
| 433 ScopedReleaseCallback(test_data_.release_mailbox3_)); |
426 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 434 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
427 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 435 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
428 | 436 |
429 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 437 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
430 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 438 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
431 EXPECT_CALL(test_data_.mock_callback_, | 439 EXPECT_CALL(test_data_.mock_callback_, |
432 Release2(test_data_.shared_memory_.get(), | 440 Release2(test_data_.shared_memory_.get(), |
433 0, false)) | 441 0, false)) |
434 .Times(1); | 442 .Times(1); |
435 test_layer->SetTextureMailbox(TextureMailbox()); | 443 test_layer->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
436 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 444 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
437 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 445 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
438 | 446 |
439 // Test destructor. | 447 // Test destructor. |
440 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 448 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
441 test_layer->SetTextureMailbox(test_data_.mailbox1_); | 449 test_layer->SetTextureMailbox( |
| 450 test_data_.mailbox1_, |
| 451 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
442 } | 452 } |
443 | 453 |
444 class TextureLayerMailboxHolderTest : public TextureLayerTest { | 454 class TextureLayerMailboxHolderTest : public TextureLayerTest { |
445 public: | 455 public: |
446 TextureLayerMailboxHolderTest() | 456 TextureLayerMailboxHolderTest() |
447 : main_thread_("MAIN") { | 457 : main_thread_("MAIN") { |
448 main_thread_.Start(); | 458 main_thread_.Start(); |
449 } | 459 } |
450 | 460 |
451 void Wait(const base::Thread& thread) { | 461 void Wait(const base::Thread& thread) { |
452 bool manual_reset = false; | 462 bool manual_reset = false; |
453 bool initially_signaled = false; | 463 bool initially_signaled = false; |
454 base::WaitableEvent event(manual_reset, initially_signaled); | 464 base::WaitableEvent event(manual_reset, initially_signaled); |
455 thread.message_loop()->PostTask( | 465 thread.message_loop()->PostTask( |
456 FROM_HERE, | 466 FROM_HERE, |
457 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); | 467 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); |
458 event.Wait(); | 468 event.Wait(); |
459 } | 469 } |
460 | 470 |
461 void CreateMainRef() { | 471 void CreateMainRef() { |
462 main_ref_ = TestMailboxHolder::Create( | 472 main_ref_ = TestMailboxHolder::Create( |
463 test_data_.mailbox1_).Pass(); | 473 test_data_.mailbox1_, |
| 474 ScopedReleaseCallback(test_data_.release_mailbox1_)).Pass(); |
464 } | 475 } |
465 | 476 |
466 void ReleaseMainRef() { | 477 void ReleaseMainRef() { |
467 main_ref_.reset(); | 478 main_ref_.reset(); |
468 } | 479 } |
469 | 480 |
470 void CreateImplRef(TextureMailbox::ReleaseCallback* impl_ref) { | 481 void CreateImplRef(ScopedReleaseCallback* impl_ref) { |
471 *impl_ref = main_ref_->holder()->GetCallbackForImplThread(); | 482 *impl_ref = main_ref_->holder()->GetCallbackForImplThread(); |
472 } | 483 } |
473 | 484 |
474 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture, | 485 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture, |
475 base::WaitableEvent* wait_for_capture, | 486 base::WaitableEvent* wait_for_capture, |
476 base::WaitableEvent* stop_capture) { | 487 base::WaitableEvent* stop_capture) { |
477 begin_capture->Wait(); | 488 begin_capture->Wait(); |
478 BlockingTaskRunner::CapturePostTasks capture; | 489 BlockingTaskRunner::CapturePostTasks capture; |
479 wait_for_capture->Signal(); | 490 wait_for_capture->Signal(); |
480 stop_capture->Wait(); | 491 stop_capture->Wait(); |
(...skipping 12 matching lines...) Expand all Loading... |
493 | 504 |
494 main_thread_.message_loop()->PostTask( | 505 main_thread_.message_loop()->PostTask( |
495 FROM_HERE, | 506 FROM_HERE, |
496 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 507 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
497 base::Unretained(this))); | 508 base::Unretained(this))); |
498 | 509 |
499 Wait(main_thread_); | 510 Wait(main_thread_); |
500 | 511 |
501 // The texture layer is attached to compositor1, and passes a reference to its | 512 // The texture layer is attached to compositor1, and passes a reference to its |
502 // impl tree. | 513 // impl tree. |
503 TextureMailbox::ReleaseCallback compositor1; | 514 ScopedReleaseCallback compositor1; |
504 main_thread_.message_loop()->PostTask( | 515 main_thread_.message_loop()->PostTask( |
505 FROM_HERE, | 516 FROM_HERE, |
506 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 517 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
507 base::Unretained(this), | 518 base::Unretained(this), |
508 &compositor1)); | 519 &compositor1)); |
509 | 520 |
510 // Then the texture layer is removed and attached to compositor2, and passes a | 521 // Then the texture layer is removed and attached to compositor2, and passes a |
511 // reference to its impl tree. | 522 // reference to its impl tree. |
512 TextureMailbox::ReleaseCallback compositor2; | 523 ScopedReleaseCallback compositor2; |
513 main_thread_.message_loop()->PostTask( | 524 main_thread_.message_loop()->PostTask( |
514 FROM_HERE, | 525 FROM_HERE, |
515 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 526 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
516 base::Unretained(this), | 527 base::Unretained(this), |
517 &compositor2)); | 528 &compositor2)); |
518 | 529 |
519 Wait(main_thread_); | 530 Wait(main_thread_); |
520 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 531 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
521 | 532 |
522 // The compositors both destroy their impl trees before the main thread layer | 533 // The compositors both destroy their impl trees before the main thread layer |
523 // is destroyed. | 534 // is destroyed. |
524 compositor1.Run(100, false); | 535 compositor1.RunAndReset(100, false); |
525 compositor2.Run(200, false); | 536 compositor2.RunAndReset(200, false); |
526 | 537 |
527 Wait(main_thread_); | 538 Wait(main_thread_); |
528 | 539 |
529 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 540 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
530 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 541 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
531 | 542 |
532 // The main thread ref is the last one, so the mailbox is released back to the | 543 // The main thread ref is the last one, so the mailbox is released back to the |
533 // embedder, with the last sync point provided by the impl trees. | 544 // embedder, with the last sync point provided by the impl trees. |
534 EXPECT_CALL(test_data_.mock_callback_, | 545 EXPECT_CALL(test_data_.mock_callback_, |
535 Release(test_data_.mailbox_name1_, 200, false)).Times(1); | 546 Release(test_data_.mailbox_name1_, 200, false)).Times(1); |
(...skipping 12 matching lines...) Expand all Loading... |
548 | 559 |
549 main_thread_.message_loop()->PostTask( | 560 main_thread_.message_loop()->PostTask( |
550 FROM_HERE, | 561 FROM_HERE, |
551 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 562 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
552 base::Unretained(this))); | 563 base::Unretained(this))); |
553 | 564 |
554 Wait(main_thread_); | 565 Wait(main_thread_); |
555 | 566 |
556 // The texture layer is attached to compositor1, and passes a reference to its | 567 // The texture layer is attached to compositor1, and passes a reference to its |
557 // impl tree. | 568 // impl tree. |
558 TextureMailbox::ReleaseCallback compositor1; | 569 ScopedReleaseCallback compositor1; |
559 main_thread_.message_loop()->PostTask( | 570 main_thread_.message_loop()->PostTask( |
560 FROM_HERE, | 571 FROM_HERE, |
561 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 572 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
562 base::Unretained(this), | 573 base::Unretained(this), |
563 &compositor1)); | 574 &compositor1)); |
564 | 575 |
565 // Then the texture layer is removed and attached to compositor2, and passes a | 576 // Then the texture layer is removed and attached to compositor2, and passes a |
566 // reference to its impl tree. | 577 // reference to its impl tree. |
567 TextureMailbox::ReleaseCallback compositor2; | 578 ScopedReleaseCallback compositor2; |
568 main_thread_.message_loop()->PostTask( | 579 main_thread_.message_loop()->PostTask( |
569 FROM_HERE, | 580 FROM_HERE, |
570 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 581 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
571 base::Unretained(this), | 582 base::Unretained(this), |
572 &compositor2)); | 583 &compositor2)); |
573 | 584 |
574 Wait(main_thread_); | 585 Wait(main_thread_); |
575 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 586 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
576 | 587 |
577 // One compositor destroys their impl tree. | 588 // One compositor destroys their impl tree. |
578 compositor1.Run(100, false); | 589 compositor1.RunAndReset(100, false); |
579 | 590 |
580 // Then the main thread reference is destroyed. | 591 // Then the main thread reference is destroyed. |
581 main_thread_.message_loop()->PostTask( | 592 main_thread_.message_loop()->PostTask( |
582 FROM_HERE, | 593 FROM_HERE, |
583 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 594 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
584 base::Unretained(this))); | 595 base::Unretained(this))); |
585 | 596 |
586 Wait(main_thread_); | 597 Wait(main_thread_); |
587 | 598 |
588 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 599 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
589 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 600 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
590 | 601 |
591 // The second impl reference is destroyed last, causing the mailbox to be | 602 // The second impl reference is destroyed last, causing the mailbox to be |
592 // released back to the embedder with the last sync point from the impl tree. | 603 // released back to the embedder with the last sync point from the impl tree. |
593 EXPECT_CALL(test_data_.mock_callback_, | 604 EXPECT_CALL(test_data_.mock_callback_, |
594 Release(test_data_.mailbox_name1_, 200, true)).Times(1); | 605 Release(test_data_.mailbox_name1_, 200, true)).Times(1); |
595 | 606 |
596 compositor2.Run(200, true); | 607 compositor2.RunAndReset(200, true); |
597 Wait(main_thread_); | 608 Wait(main_thread_); |
598 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 609 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
599 } | 610 } |
600 | 611 |
601 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 612 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { |
602 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 613 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
603 ASSERT_TRUE(test_layer.get()); | 614 ASSERT_TRUE(test_layer.get()); |
604 | 615 |
605 main_thread_.message_loop()->PostTask( | 616 main_thread_.message_loop()->PostTask( |
606 FROM_HERE, | 617 FROM_HERE, |
607 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 618 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
608 base::Unretained(this))); | 619 base::Unretained(this))); |
609 | 620 |
610 Wait(main_thread_); | 621 Wait(main_thread_); |
611 | 622 |
612 // The texture layer is attached to compositor1, and passes a reference to its | 623 // The texture layer is attached to compositor1, and passes a reference to its |
613 // impl tree. | 624 // impl tree. |
614 TextureMailbox::ReleaseCallback compositor1; | 625 ScopedReleaseCallback compositor1; |
615 main_thread_.message_loop()->PostTask( | 626 main_thread_.message_loop()->PostTask( |
616 FROM_HERE, | 627 FROM_HERE, |
617 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 628 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
618 base::Unretained(this), | 629 base::Unretained(this), |
619 &compositor1)); | 630 &compositor1)); |
620 | 631 |
621 // Then the texture layer is removed and attached to compositor2, and passes a | 632 // Then the texture layer is removed and attached to compositor2, and passes a |
622 // reference to its impl tree. | 633 // reference to its impl tree. |
623 TextureMailbox::ReleaseCallback compositor2; | 634 ScopedReleaseCallback compositor2; |
624 main_thread_.message_loop()->PostTask( | 635 main_thread_.message_loop()->PostTask( |
625 FROM_HERE, | 636 FROM_HERE, |
626 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 637 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
627 base::Unretained(this), | 638 base::Unretained(this), |
628 &compositor2)); | 639 &compositor2)); |
629 | 640 |
630 Wait(main_thread_); | 641 Wait(main_thread_); |
631 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 642 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
632 | 643 |
633 // The main thread reference is destroyed first. | 644 // The main thread reference is destroyed first. |
634 main_thread_.message_loop()->PostTask( | 645 main_thread_.message_loop()->PostTask( |
635 FROM_HERE, | 646 FROM_HERE, |
636 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 647 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
637 base::Unretained(this))); | 648 base::Unretained(this))); |
638 | 649 |
639 // One compositor destroys their impl tree. | 650 // One compositor destroys their impl tree. |
640 compositor2.Run(200, false); | 651 compositor2.RunAndReset(200, false); |
641 | 652 |
642 Wait(main_thread_); | 653 Wait(main_thread_); |
643 | 654 |
644 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 655 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
645 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 656 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
646 | 657 |
647 // The second impl reference is destroyed last, causing the mailbox to be | 658 // The second impl reference is destroyed last, causing the mailbox to be |
648 // released back to the embedder with the last sync point from the impl tree. | 659 // released back to the embedder with the last sync point from the impl tree. |
649 EXPECT_CALL(test_data_.mock_callback_, | 660 EXPECT_CALL(test_data_.mock_callback_, |
650 Release(test_data_.mailbox_name1_, 100, true)).Times(1); | 661 Release(test_data_.mailbox_name1_, 100, true)).Times(1); |
651 | 662 |
652 compositor1.Run(100, true); | 663 compositor1.RunAndReset(100, true); |
653 Wait(main_thread_); | 664 Wait(main_thread_); |
654 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 665 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
655 } | 666 } |
656 | 667 |
657 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 668 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { |
658 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 669 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
659 ASSERT_TRUE(test_layer.get()); | 670 ASSERT_TRUE(test_layer.get()); |
660 | 671 |
661 main_thread_.message_loop()->PostTask( | 672 main_thread_.message_loop()->PostTask( |
662 FROM_HERE, | 673 FROM_HERE, |
663 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 674 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
664 base::Unretained(this))); | 675 base::Unretained(this))); |
665 | 676 |
666 Wait(main_thread_); | 677 Wait(main_thread_); |
667 | 678 |
668 // The texture layer is attached to compositor1, and passes a reference to its | 679 // The texture layer is attached to compositor1, and passes a reference to its |
669 // impl tree. | 680 // impl tree. |
670 TextureMailbox::ReleaseCallback compositor1; | 681 ScopedReleaseCallback compositor1; |
671 main_thread_.message_loop()->PostTask( | 682 main_thread_.message_loop()->PostTask( |
672 FROM_HERE, | 683 FROM_HERE, |
673 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 684 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
674 base::Unretained(this), | 685 base::Unretained(this), |
675 &compositor1)); | 686 &compositor1)); |
676 | 687 |
677 // Then the texture layer is removed and attached to compositor2, and passes a | 688 // Then the texture layer is removed and attached to compositor2, and passes a |
678 // reference to its impl tree. | 689 // reference to its impl tree. |
679 TextureMailbox::ReleaseCallback compositor2; | 690 ScopedReleaseCallback compositor2; |
680 main_thread_.message_loop()->PostTask( | 691 main_thread_.message_loop()->PostTask( |
681 FROM_HERE, | 692 FROM_HERE, |
682 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 693 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
683 base::Unretained(this), | 694 base::Unretained(this), |
684 &compositor2)); | 695 &compositor2)); |
685 | 696 |
686 Wait(main_thread_); | 697 Wait(main_thread_); |
687 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 698 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
688 | 699 |
689 // The main thread reference is destroyed first. | 700 // The main thread reference is destroyed first. |
(...skipping 17 matching lines...) Expand all Loading... |
707 FROM_HERE, | 718 FROM_HERE, |
708 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, | 719 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, |
709 base::Unretained(this), | 720 base::Unretained(this), |
710 &begin_capture, | 721 &begin_capture, |
711 &wait_for_capture, | 722 &wait_for_capture, |
712 &stop_capture)); | 723 &stop_capture)); |
713 | 724 |
714 // Before the main thread capturing starts, one compositor destroys their | 725 // Before the main thread capturing starts, one compositor destroys their |
715 // impl reference. Since capturing did not start, this gets post-tasked to | 726 // impl reference. Since capturing did not start, this gets post-tasked to |
716 // the main thread. | 727 // the main thread. |
717 compositor1.Run(100, false); | 728 compositor1.RunAndReset(100, false); |
718 | 729 |
719 // Start capturing on the main thread. | 730 // Start capturing on the main thread. |
720 begin_capture.Signal(); | 731 begin_capture.Signal(); |
721 wait_for_capture.Wait(); | 732 wait_for_capture.Wait(); |
722 | 733 |
723 // Meanwhile, the second compositor released its impl reference, but this task | 734 // Meanwhile, the second compositor released its impl reference, but this task |
724 // gets shortcutted directly to the main thread. This means the reference is | 735 // gets shortcutted directly to the main thread. This means the reference is |
725 // released before compositor1, whose reference will be released later when | 736 // released before compositor1, whose reference will be released later when |
726 // the post-task is serviced. But since it was destroyed _on the impl thread_ | 737 // the post-task is serviced. But since it was destroyed _on the impl thread_ |
727 // last, its sync point values should be used. | 738 // last, its sync point values should be used. |
728 compositor2.Run(200, true); | 739 compositor2.RunAndReset(200, true); |
729 | 740 |
730 stop_capture.Signal(); | 741 stop_capture.Signal(); |
731 Wait(main_thread_); | 742 Wait(main_thread_); |
732 | 743 |
733 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 744 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
734 } | 745 } |
735 | 746 |
736 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { | 747 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { |
737 public: | 748 public: |
738 TextureLayerImplWithMailboxThreadedCallback() | 749 TextureLayerImplWithMailboxThreadedCallback() |
739 : callback_count_(0), | 750 : callback_count_(0), |
740 commit_count_(0) {} | 751 commit_count_(0) {} |
741 | 752 |
742 // Make sure callback is received on main and doesn't block the impl thread. | 753 // Make sure callback is received on main and doesn't block the impl thread. |
743 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 754 void ReleaseCallback(unsigned sync_point, bool lost_resource) { |
744 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 755 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
745 EXPECT_FALSE(lost_resource); | 756 EXPECT_FALSE(lost_resource); |
746 ++callback_count_; | 757 ++callback_count_; |
747 } | 758 } |
748 | 759 |
749 void SetMailbox(char mailbox_char) { | 760 void SetMailbox(char mailbox_char) { |
750 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 761 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
751 TextureMailbox mailbox( | 762 TextureMailbox mailbox(std::string(64, mailbox_char)); |
752 std::string(64, mailbox_char), | 763 ScopedReleaseCallback callback(base::Bind( |
753 base::Bind( | 764 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, |
754 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, | 765 base::Unretained(this))); |
755 base::Unretained(this))); | 766 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
756 layer_->SetTextureMailbox(mailbox); | |
757 } | 767 } |
758 | 768 |
759 virtual void BeginTest() OVERRIDE { | 769 virtual void BeginTest() OVERRIDE { |
760 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 770 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
761 | 771 |
762 gfx::Size bounds(100, 100); | 772 gfx::Size bounds(100, 100); |
763 root_ = Layer::Create(); | 773 root_ = Layer::Create(); |
764 root_->SetAnchorPoint(gfx::PointF()); | 774 root_->SetAnchorPoint(gfx::PointF()); |
765 root_->SetBounds(bounds); | 775 root_->SetBounds(bounds); |
766 | 776 |
(...skipping 29 matching lines...) Expand all Loading... |
796 EXPECT_EQ(2, callback_count_); | 806 EXPECT_EQ(2, callback_count_); |
797 // Case #3: change mailbox when the layer doesn't draw. The old | 807 // Case #3: change mailbox when the layer doesn't draw. The old |
798 // mailbox should be released during the next commit. | 808 // mailbox should be released during the next commit. |
799 layer_->SetBounds(gfx::Size()); | 809 layer_->SetBounds(gfx::Size()); |
800 SetMailbox('4'); | 810 SetMailbox('4'); |
801 break; | 811 break; |
802 case 3: | 812 case 3: |
803 EXPECT_EQ(3, callback_count_); | 813 EXPECT_EQ(3, callback_count_); |
804 // Case #4: release mailbox that was committed but never drawn. The | 814 // Case #4: release mailbox that was committed but never drawn. The |
805 // old mailbox should be released during the next commit. | 815 // old mailbox should be released during the next commit. |
806 layer_->SetTextureMailbox(TextureMailbox()); | 816 layer_->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
807 break; | 817 break; |
808 case 4: | 818 case 4: |
809 if (layer_tree_host()->settings().impl_side_painting) { | 819 if (layer_tree_host()->settings().impl_side_painting) { |
810 // With impl painting, the texture mailbox will still be on the impl | 820 // With impl painting, the texture mailbox will still be on the impl |
811 // thread when the commit finishes, because the layer is not drawble | 821 // thread when the commit finishes, because the layer is not drawble |
812 // when it has no texture mailbox, and thus does not block the commit | 822 // when it has no texture mailbox, and thus does not block the commit |
813 // on activation. So, we wait for activation. | 823 // on activation. So, we wait for activation. |
814 // TODO(danakj): fix this. crbug.com/277953 | 824 // TODO(danakj): fix this. crbug.com/277953 |
815 layer_tree_host()->SetNeedsCommit(); | 825 layer_tree_host()->SetNeedsCommit(); |
816 break; | 826 break; |
(...skipping 18 matching lines...) Expand all Loading... |
835 // block the commit on activation anymore. So, we wait for activation. | 845 // block the commit on activation anymore. So, we wait for activation. |
836 // TODO(danakj): fix this. crbug.com/277953 | 846 // TODO(danakj): fix this. crbug.com/277953 |
837 layer_tree_host()->SetNeedsCommit(); | 847 layer_tree_host()->SetNeedsCommit(); |
838 break; | 848 break; |
839 } else { | 849 } else { |
840 ++commit_count_; | 850 ++commit_count_; |
841 } | 851 } |
842 case 8: | 852 case 8: |
843 EXPECT_EQ(4, callback_count_); | 853 EXPECT_EQ(4, callback_count_); |
844 // Resetting the mailbox will call the callback now. | 854 // Resetting the mailbox will call the callback now. |
845 layer_->SetTextureMailbox(TextureMailbox()); | 855 layer_->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
846 EXPECT_EQ(5, callback_count_); | 856 EXPECT_EQ(5, callback_count_); |
847 EndTest(); | 857 EndTest(); |
848 break; | 858 break; |
849 default: | 859 default: |
850 NOTREACHED(); | 860 NOTREACHED(); |
851 break; | 861 break; |
852 } | 862 } |
853 } | 863 } |
854 | 864 |
855 virtual void AfterTest() OVERRIDE {} | 865 virtual void AfterTest() OVERRIDE {} |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 907 |
898 // TextureLayerClient implementation. | 908 // TextureLayerClient implementation. |
899 virtual unsigned PrepareTexture() OVERRIDE { | 909 virtual unsigned PrepareTexture() OVERRIDE { |
900 return OffscreenContextProviderForMainThread() | 910 return OffscreenContextProviderForMainThread() |
901 ->Context3d()->createTexture(); | 911 ->Context3d()->createTexture(); |
902 } | 912 } |
903 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 913 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
904 return OffscreenContextProviderForMainThread()->Context3d(); | 914 return OffscreenContextProviderForMainThread()->Context3d(); |
905 } | 915 } |
906 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, | 916 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, |
| 917 ScopedReleaseCallback* release_callback, |
907 bool use_shared_memory) OVERRIDE { | 918 bool use_shared_memory) OVERRIDE { |
908 return false; | 919 return false; |
909 } | 920 } |
910 | 921 |
911 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 922 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
912 // Slow down activation so the main thread DidCommit() will run if | 923 // Slow down activation so the main thread DidCommit() will run if |
913 // not blocked. | 924 // not blocked. |
914 wait_thread_.message_loop()->PostDelayedTask( | 925 wait_thread_.message_loop()->PostDelayedTask( |
915 FROM_HERE, | 926 FROM_HERE, |
916 base::Bind(&base::WaitableEvent::Signal, | 927 base::Bind(&base::WaitableEvent::Signal, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 protected: | 1002 protected: |
992 TextureLayerMailboxIsActivatedDuringCommit() | 1003 TextureLayerMailboxIsActivatedDuringCommit() |
993 : wait_thread_("WAIT"), | 1004 : wait_thread_("WAIT"), |
994 wait_event_(false, false) { | 1005 wait_event_(false, false) { |
995 wait_thread_.Start(); | 1006 wait_thread_.Start(); |
996 } | 1007 } |
997 | 1008 |
998 static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} | 1009 static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} |
999 | 1010 |
1000 void SetMailbox(char mailbox_char) { | 1011 void SetMailbox(char mailbox_char) { |
1001 TextureMailbox mailbox( | 1012 TextureMailbox mailbox(std::string(64, mailbox_char)); |
1002 std::string(64, mailbox_char), | 1013 ScopedReleaseCallback callback(base::Bind( |
1003 base::Bind( | 1014 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
1004 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 1015 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
1005 layer_->SetTextureMailbox(mailbox); | |
1006 } | 1016 } |
1007 | 1017 |
1008 virtual void BeginTest() OVERRIDE { | 1018 virtual void BeginTest() OVERRIDE { |
1009 activate_count_ = 0; | 1019 activate_count_ = 0; |
1010 | 1020 |
1011 gfx::Size bounds(100, 100); | 1021 gfx::Size bounds(100, 100); |
1012 root_ = Layer::Create(); | 1022 root_ = Layer::Create(); |
1013 root_->SetAnchorPoint(gfx::PointF()); | 1023 root_->SetAnchorPoint(gfx::PointF()); |
1014 root_->SetBounds(bounds); | 1024 root_->SetBounds(bounds); |
1015 | 1025 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 test_data_.sync_point1_, | 1146 test_data_.sync_point1_, |
1137 false)) | 1147 false)) |
1138 .Times(AnyNumber()); | 1148 .Times(AnyNumber()); |
1139 EXPECT_CALL(test_data_.mock_callback_, | 1149 EXPECT_CALL(test_data_.mock_callback_, |
1140 Release2(test_data_.shared_memory_.get(), 0, false)) | 1150 Release2(test_data_.shared_memory_.get(), 0, false)) |
1141 .Times(AnyNumber()); | 1151 .Times(AnyNumber()); |
1142 // Hardware mode. | 1152 // Hardware mode. |
1143 { | 1153 { |
1144 scoped_ptr<TextureLayerImpl> impl_layer = | 1154 scoped_ptr<TextureLayerImpl> impl_layer = |
1145 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1155 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1146 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1156 impl_layer->SetTextureMailbox( |
| 1157 test_data_.mailbox1_, |
| 1158 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1147 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1159 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1148 } | 1160 } |
1149 | 1161 |
1150 { | 1162 { |
1151 scoped_ptr<TextureLayerImpl> impl_layer = | 1163 scoped_ptr<TextureLayerImpl> impl_layer = |
1152 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1164 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1153 impl_layer->SetTextureMailbox(TextureMailbox()); | 1165 impl_layer->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
1154 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1166 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1155 } | 1167 } |
1156 | 1168 |
1157 { | 1169 { |
1158 // Software resource. | 1170 // Software resource. |
1159 scoped_ptr<TextureLayerImpl> impl_layer = | 1171 scoped_ptr<TextureLayerImpl> impl_layer = |
1160 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1172 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1161 impl_layer->SetTextureMailbox(test_data_.mailbox3_); | 1173 impl_layer->SetTextureMailbox( |
| 1174 test_data_.mailbox3_, |
| 1175 ScopedReleaseCallback(test_data_.release_mailbox3_)); |
1162 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1176 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1163 } | 1177 } |
1164 | 1178 |
1165 { | 1179 { |
1166 scoped_ptr<TextureLayerImpl> impl_layer = | 1180 scoped_ptr<TextureLayerImpl> impl_layer = |
1167 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1181 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1168 ContextProvider* context_provider = | 1182 ContextProvider* context_provider = |
1169 host_impl_.output_surface()->context_provider(); | 1183 host_impl_.output_surface()->context_provider(); |
1170 unsigned texture = | 1184 unsigned texture = |
1171 context_provider->Context3d()->createTexture(); | 1185 context_provider->Context3d()->createTexture(); |
1172 impl_layer->set_texture_id(texture); | 1186 impl_layer->set_texture_id(texture); |
1173 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1187 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1174 } | 1188 } |
1175 | 1189 |
1176 { | 1190 { |
1177 scoped_ptr<TextureLayerImpl> impl_layer = | 1191 scoped_ptr<TextureLayerImpl> impl_layer = |
1178 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1192 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1179 impl_layer->set_texture_id(0); | 1193 impl_layer->set_texture_id(0); |
1180 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1194 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1181 } | 1195 } |
1182 | 1196 |
1183 // Software mode. | 1197 // Software mode. |
1184 { | 1198 { |
1185 scoped_ptr<TextureLayerImpl> impl_layer = | 1199 scoped_ptr<TextureLayerImpl> impl_layer = |
1186 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1200 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1187 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1201 impl_layer->SetTextureMailbox( |
| 1202 test_data_.mailbox1_, |
| 1203 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1188 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1204 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1189 } | 1205 } |
1190 | 1206 |
1191 { | 1207 { |
1192 scoped_ptr<TextureLayerImpl> impl_layer = | 1208 scoped_ptr<TextureLayerImpl> impl_layer = |
1193 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1209 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1194 impl_layer->SetTextureMailbox(TextureMailbox()); | 1210 impl_layer->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
1195 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1211 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1196 } | 1212 } |
1197 | 1213 |
1198 { | 1214 { |
1199 // Software resource. | 1215 // Software resource. |
1200 scoped_ptr<TextureLayerImpl> impl_layer = | 1216 scoped_ptr<TextureLayerImpl> impl_layer = |
1201 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1217 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1202 impl_layer->SetTextureMailbox(test_data_.mailbox3_); | 1218 impl_layer->SetTextureMailbox( |
| 1219 test_data_.mailbox3_, |
| 1220 ScopedReleaseCallback(test_data_.release_mailbox3_)); |
1203 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1221 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1204 } | 1222 } |
1205 | 1223 |
1206 { | 1224 { |
1207 scoped_ptr<TextureLayerImpl> impl_layer = | 1225 scoped_ptr<TextureLayerImpl> impl_layer = |
1208 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1226 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1209 ContextProvider* context_provider = | 1227 ContextProvider* context_provider = |
1210 host_impl_.output_surface()->context_provider(); | 1228 host_impl_.output_surface()->context_provider(); |
1211 unsigned texture = | 1229 unsigned texture = |
1212 context_provider->Context3d()->createTexture(); | 1230 context_provider->Context3d()->createTexture(); |
1213 impl_layer->set_texture_id(texture); | 1231 impl_layer->set_texture_id(texture); |
1214 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1232 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1215 } | 1233 } |
1216 | 1234 |
1217 { | 1235 { |
1218 scoped_ptr<TextureLayerImpl> impl_layer = | 1236 scoped_ptr<TextureLayerImpl> impl_layer = |
1219 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1237 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1220 impl_layer->set_texture_id(0); | 1238 impl_layer->set_texture_id(0); |
1221 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1239 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1222 } | 1240 } |
1223 | 1241 |
1224 // Resourceless software mode. | 1242 // Resourceless software mode. |
1225 { | 1243 { |
1226 scoped_ptr<TextureLayerImpl> impl_layer = | 1244 scoped_ptr<TextureLayerImpl> impl_layer = |
1227 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1245 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1228 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1246 impl_layer->SetTextureMailbox( |
| 1247 test_data_.mailbox1_, |
| 1248 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1229 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 1249 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
1230 } | 1250 } |
1231 | 1251 |
1232 { | 1252 { |
1233 scoped_ptr<TextureLayerImpl> impl_layer = | 1253 scoped_ptr<TextureLayerImpl> impl_layer = |
1234 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1254 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1235 ContextProvider* context_provider = | 1255 ContextProvider* context_provider = |
1236 host_impl_.output_surface()->context_provider(); | 1256 host_impl_.output_surface()->context_provider(); |
1237 unsigned texture = | 1257 unsigned texture = |
1238 context_provider->Context3d()->createTexture(); | 1258 context_provider->Context3d()->createTexture(); |
1239 impl_layer->set_texture_id(texture); | 1259 impl_layer->set_texture_id(texture); |
1240 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 1260 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
1241 } | 1261 } |
1242 } | 1262 } |
1243 | 1263 |
1244 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { | 1264 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { |
1245 host_impl_.CreatePendingTree(); | 1265 host_impl_.CreatePendingTree(); |
1246 scoped_ptr<TextureLayerImpl> pending_layer; | 1266 scoped_ptr<TextureLayerImpl> pending_layer; |
1247 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); | 1267 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); |
1248 ASSERT_TRUE(pending_layer); | 1268 ASSERT_TRUE(pending_layer); |
1249 | 1269 |
1250 scoped_ptr<LayerImpl> active_layer( | 1270 scoped_ptr<LayerImpl> active_layer( |
1251 pending_layer->CreateLayerImpl(host_impl_.active_tree())); | 1271 pending_layer->CreateLayerImpl(host_impl_.active_tree())); |
1252 ASSERT_TRUE(active_layer); | 1272 ASSERT_TRUE(active_layer); |
1253 | 1273 |
1254 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 1274 pending_layer->SetTextureMailbox( |
| 1275 test_data_.mailbox1_, |
| 1276 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1255 | 1277 |
1256 // Test multiple commits without an activation. | 1278 // Test multiple commits without an activation. |
1257 EXPECT_CALL(test_data_.mock_callback_, | 1279 EXPECT_CALL(test_data_.mock_callback_, |
1258 Release(test_data_.mailbox_name1_, | 1280 Release(test_data_.mailbox_name1_, |
1259 test_data_.sync_point1_, | 1281 test_data_.sync_point1_, |
1260 false)) | 1282 false)) |
1261 .Times(1); | 1283 .Times(1); |
1262 pending_layer->SetTextureMailbox(test_data_.mailbox2_); | 1284 pending_layer->SetTextureMailbox( |
| 1285 test_data_.mailbox2_, |
| 1286 ScopedReleaseCallback(test_data_.release_mailbox2_)); |
1263 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1287 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1264 | 1288 |
1265 // Test callback after activation. | 1289 // Test callback after activation. |
1266 pending_layer->PushPropertiesTo(active_layer.get()); | 1290 pending_layer->PushPropertiesTo(active_layer.get()); |
1267 active_layer->DidBecomeActive(); | 1291 active_layer->DidBecomeActive(); |
1268 | 1292 |
1269 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 1293 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
1270 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 1294 pending_layer->SetTextureMailbox( |
| 1295 test_data_.mailbox1_, |
| 1296 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1271 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1297 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1272 | 1298 |
1273 EXPECT_CALL(test_data_.mock_callback_, | 1299 EXPECT_CALL(test_data_.mock_callback_, |
1274 Release(test_data_.mailbox_name2_, _, false)) | 1300 Release(test_data_.mailbox_name2_, _, false)) |
1275 .Times(1); | 1301 .Times(1); |
1276 pending_layer->PushPropertiesTo(active_layer.get()); | 1302 pending_layer->PushPropertiesTo(active_layer.get()); |
1277 active_layer->DidBecomeActive(); | 1303 active_layer->DidBecomeActive(); |
1278 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1304 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1279 | 1305 |
1280 // Test resetting the mailbox. | 1306 // Test resetting the mailbox. |
1281 EXPECT_CALL(test_data_.mock_callback_, | 1307 EXPECT_CALL(test_data_.mock_callback_, |
1282 Release(test_data_.mailbox_name1_, _, false)) | 1308 Release(test_data_.mailbox_name1_, _, false)) |
1283 .Times(1); | 1309 .Times(1); |
1284 pending_layer->SetTextureMailbox(TextureMailbox()); | 1310 pending_layer->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
1285 pending_layer->PushPropertiesTo(active_layer.get()); | 1311 pending_layer->PushPropertiesTo(active_layer.get()); |
1286 active_layer->DidBecomeActive(); | 1312 active_layer->DidBecomeActive(); |
1287 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1313 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1288 | 1314 |
1289 // Test destructor. | 1315 // Test destructor. |
1290 EXPECT_CALL(test_data_.mock_callback_, | 1316 EXPECT_CALL(test_data_.mock_callback_, |
1291 Release(test_data_.mailbox_name1_, | 1317 Release(test_data_.mailbox_name1_, |
1292 test_data_.sync_point1_, | 1318 test_data_.sync_point1_, |
1293 false)) | 1319 false)) |
1294 .Times(1); | 1320 .Times(1); |
1295 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 1321 pending_layer->SetTextureMailbox( |
| 1322 test_data_.mailbox1_, |
| 1323 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1296 } | 1324 } |
1297 | 1325 |
1298 TEST_F(TextureLayerImplWithMailboxTest, | 1326 TEST_F(TextureLayerImplWithMailboxTest, |
1299 TestDestructorCallbackOnCreatedResource) { | 1327 TestDestructorCallbackOnCreatedResource) { |
1300 scoped_ptr<TextureLayerImpl> impl_layer; | 1328 scoped_ptr<TextureLayerImpl> impl_layer; |
1301 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1329 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1302 ASSERT_TRUE(impl_layer); | 1330 ASSERT_TRUE(impl_layer); |
1303 | 1331 |
1304 EXPECT_CALL(test_data_.mock_callback_, | 1332 EXPECT_CALL(test_data_.mock_callback_, |
1305 Release(test_data_.mailbox_name1_, _, false)) | 1333 Release(test_data_.mailbox_name1_, _, false)) |
1306 .Times(1); | 1334 .Times(1); |
1307 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1335 impl_layer->SetTextureMailbox( |
| 1336 test_data_.mailbox1_, |
| 1337 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1308 impl_layer->DidBecomeActive(); | 1338 impl_layer->DidBecomeActive(); |
1309 EXPECT_TRUE(impl_layer->WillDraw( | 1339 EXPECT_TRUE(impl_layer->WillDraw( |
1310 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); | 1340 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); |
1311 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); | 1341 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); |
1312 impl_layer->SetTextureMailbox(TextureMailbox()); | 1342 impl_layer->SetTextureMailbox(TextureMailbox(), ScopedReleaseCallback()); |
1313 } | 1343 } |
1314 | 1344 |
1315 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { | 1345 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { |
1316 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); | 1346 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); |
1317 ResourceProvider::ResourceId id = | 1347 ResourceProvider::ResourceId id = |
1318 provider->CreateResourceFromTextureMailbox(test_data_.mailbox1_); | 1348 provider->CreateResourceFromTextureMailbox( |
| 1349 test_data_.mailbox1_, |
| 1350 ScopedReleaseCallback(test_data_.release_mailbox1_)); |
1319 provider->AllocateForTesting(id); | 1351 provider->AllocateForTesting(id); |
1320 | 1352 |
1321 // Transfer some resources to the parent. | 1353 // Transfer some resources to the parent. |
1322 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1354 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1323 resource_ids_to_transfer.push_back(id); | 1355 resource_ids_to_transfer.push_back(id); |
1324 TransferableResourceArray list; | 1356 TransferableResourceArray list; |
1325 provider->PrepareSendToParent(resource_ids_to_transfer, &list); | 1357 provider->PrepareSendToParent(resource_ids_to_transfer, &list); |
1326 EXPECT_TRUE(provider->InUseByConsumer(id)); | 1358 EXPECT_TRUE(provider->InUseByConsumer(id)); |
1327 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 1359 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
1328 provider->DeleteResource(id); | 1360 provider->DeleteResource(id); |
(...skipping 30 matching lines...) Expand all Loading... |
1359 | 1391 |
1360 virtual unsigned PrepareTexture() OVERRIDE { | 1392 virtual unsigned PrepareTexture() OVERRIDE { |
1361 return texture_; | 1393 return texture_; |
1362 } | 1394 } |
1363 | 1395 |
1364 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 1396 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
1365 return context_; | 1397 return context_; |
1366 } | 1398 } |
1367 | 1399 |
1368 virtual bool PrepareTextureMailbox( | 1400 virtual bool PrepareTextureMailbox( |
1369 cc::TextureMailbox* mailbox, bool use_shared_memory) OVERRIDE { | 1401 TextureMailbox* mailbox, |
| 1402 ScopedReleaseCallback* release_callback, |
| 1403 bool use_shared_memory) OVERRIDE { |
1370 return false; | 1404 return false; |
1371 } | 1405 } |
1372 | 1406 |
1373 virtual void SetupTree() OVERRIDE { | 1407 virtual void SetupTree() OVERRIDE { |
1374 scoped_refptr<Layer> root = Layer::Create(); | 1408 scoped_refptr<Layer> root = Layer::Create(); |
1375 root->SetBounds(gfx::Size(10, 10)); | 1409 root->SetBounds(gfx::Size(10, 10)); |
1376 root->SetAnchorPoint(gfx::PointF()); | 1410 root->SetAnchorPoint(gfx::PointF()); |
1377 root->SetIsDrawable(true); | 1411 root->SetIsDrawable(true); |
1378 | 1412 |
1379 texture_layer_ = TextureLayer::Create(this); | 1413 texture_layer_ = TextureLayer::Create(this); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 GL_INNOCENT_CONTEXT_RESET_ARB); | 1509 GL_INNOCENT_CONTEXT_RESET_ARB); |
1476 } | 1510 } |
1477 return texture_; | 1511 return texture_; |
1478 } | 1512 } |
1479 | 1513 |
1480 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 1514 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
1481 return texture_context_.get(); | 1515 return texture_context_.get(); |
1482 } | 1516 } |
1483 | 1517 |
1484 virtual bool PrepareTextureMailbox( | 1518 virtual bool PrepareTextureMailbox( |
1485 cc::TextureMailbox* mailbox, bool use_shared_memory) OVERRIDE { | 1519 TextureMailbox* mailbox, |
| 1520 ScopedReleaseCallback* release_callback, |
| 1521 bool use_shared_memory) OVERRIDE { |
1486 return false; | 1522 return false; |
1487 } | 1523 } |
1488 | 1524 |
1489 virtual void SetupTree() OVERRIDE { | 1525 virtual void SetupTree() OVERRIDE { |
1490 scoped_refptr<Layer> root = Layer::Create(); | 1526 scoped_refptr<Layer> root = Layer::Create(); |
1491 root->SetBounds(gfx::Size(10, 10)); | 1527 root->SetBounds(gfx::Size(10, 10)); |
1492 root->SetIsDrawable(true); | 1528 root->SetIsDrawable(true); |
1493 | 1529 |
1494 texture_layer_ = TextureLayer::Create(this); | 1530 texture_layer_ = TextureLayer::Create(this); |
1495 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1531 texture_layer_->SetBounds(gfx::Size(10, 10)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 public: | 1572 public: |
1537 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 1573 void ReleaseCallback(unsigned sync_point, bool lost_resource) { |
1538 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1574 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1539 EXPECT_FALSE(lost_resource); | 1575 EXPECT_FALSE(lost_resource); |
1540 ++callback_count_; | 1576 ++callback_count_; |
1541 EndTest(); | 1577 EndTest(); |
1542 } | 1578 } |
1543 | 1579 |
1544 void SetMailbox(char mailbox_char) { | 1580 void SetMailbox(char mailbox_char) { |
1545 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1581 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1546 TextureMailbox mailbox( | 1582 TextureMailbox mailbox(std::string(64, mailbox_char)); |
1547 std::string(64, mailbox_char), | 1583 ScopedReleaseCallback callback(base::Bind( |
1548 base::Bind( | 1584 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
1549 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 1585 base::Unretained(this))); |
1550 base::Unretained(this))); | 1586 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
1551 layer_->SetTextureMailbox(mailbox); | |
1552 } | 1587 } |
1553 | 1588 |
1554 virtual void SetupTree() OVERRIDE { | 1589 virtual void SetupTree() OVERRIDE { |
1555 gfx::Size bounds(100, 100); | 1590 gfx::Size bounds(100, 100); |
1556 root_ = Layer::Create(); | 1591 root_ = Layer::Create(); |
1557 root_->SetAnchorPoint(gfx::PointF()); | 1592 root_->SetAnchorPoint(gfx::PointF()); |
1558 root_->SetBounds(bounds); | 1593 root_->SetBounds(bounds); |
1559 | 1594 |
1560 layer_ = TextureLayer::CreateForMailbox(NULL); | 1595 layer_ = TextureLayer::CreateForMailbox(NULL); |
1561 layer_->SetIsDrawable(true); | 1596 layer_->SetIsDrawable(true); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 public: | 1643 public: |
1609 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 1644 void ReleaseCallback(unsigned sync_point, bool lost_resource) { |
1610 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1645 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1611 EXPECT_FALSE(lost_resource); | 1646 EXPECT_FALSE(lost_resource); |
1612 ++callback_count_; | 1647 ++callback_count_; |
1613 EndTest(); | 1648 EndTest(); |
1614 } | 1649 } |
1615 | 1650 |
1616 void SetMailbox(char mailbox_char) { | 1651 void SetMailbox(char mailbox_char) { |
1617 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1652 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1618 TextureMailbox mailbox( | 1653 TextureMailbox mailbox(std::string(64, mailbox_char)); |
1619 std::string(64, mailbox_char), | 1654 ScopedReleaseCallback callback(base::Bind( |
1620 base::Bind( | 1655 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
1621 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 1656 base::Unretained(this))); |
1622 base::Unretained(this))); | 1657 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
1623 layer_->SetTextureMailbox(mailbox); | |
1624 } | 1658 } |
1625 | 1659 |
1626 virtual void SetupTree() OVERRIDE { | 1660 virtual void SetupTree() OVERRIDE { |
1627 gfx::Size bounds(100, 100); | 1661 gfx::Size bounds(100, 100); |
1628 root_ = Layer::Create(); | 1662 root_ = Layer::Create(); |
1629 root_->SetAnchorPoint(gfx::PointF()); | 1663 root_->SetAnchorPoint(gfx::PointF()); |
1630 root_->SetBounds(bounds); | 1664 root_->SetBounds(bounds); |
1631 | 1665 |
1632 layer_ = TextureLayer::CreateForMailbox(NULL); | 1666 layer_ = TextureLayer::CreateForMailbox(NULL); |
1633 layer_->SetIsDrawable(true); | 1667 layer_->SetIsDrawable(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 int callback_count_; | 1708 int callback_count_; |
1675 scoped_refptr<Layer> root_; | 1709 scoped_refptr<Layer> root_; |
1676 scoped_refptr<TextureLayer> layer_; | 1710 scoped_refptr<TextureLayer> layer_; |
1677 }; | 1711 }; |
1678 | 1712 |
1679 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1713 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1680 TextureLayerWithMailboxImplThreadDeleted); | 1714 TextureLayerWithMailboxImplThreadDeleted); |
1681 | 1715 |
1682 } // namespace | 1716 } // namespace |
1683 } // namespace cc | 1717 } // namespace cc |
OLD | NEW |