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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 FakeTextureLayerClient() : context_(TestWebGraphicsContext3D::Create()) {} | 248 FakeTextureLayerClient() : context_(TestWebGraphicsContext3D::Create()) {} |
249 | 249 |
250 virtual unsigned PrepareTexture() OVERRIDE { | 250 virtual unsigned PrepareTexture() OVERRIDE { |
251 return 0; | 251 return 0; |
252 } | 252 } |
253 | 253 |
254 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 254 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
255 return context_.get(); | 255 return context_.get(); |
256 } | 256 } |
257 | 257 |
258 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, | 258 virtual bool PrepareTextureMailbox( |
259 bool use_shared_memory) OVERRIDE { | 259 TextureMailbox* mailbox, |
260 scoped_ptr<ScopedReleaseCallback>* release_callback, | |
261 bool use_shared_memory) OVERRIDE { | |
260 *mailbox = TextureMailbox(); | 262 *mailbox = TextureMailbox(); |
263 *release_callback = scoped_ptr<ScopedReleaseCallback>(); | |
261 return true; | 264 return true; |
262 } | 265 } |
263 | 266 |
264 private: | 267 private: |
265 scoped_ptr<TestWebGraphicsContext3D> context_; | 268 scoped_ptr<TestWebGraphicsContext3D> context_; |
266 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); | 269 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); |
267 }; | 270 }; |
268 | 271 |
269 TEST_F(TextureLayerTest, RateLimiter) { | 272 TEST_F(TextureLayerTest, RateLimiter) { |
270 FakeTextureLayerClient client; | 273 FakeTextureLayerClient client; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 sync_point2_(2), | 336 sync_point2_(2), |
334 shared_memory_(new base::SharedMemory) { | 337 shared_memory_(new base::SharedMemory) { |
335 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, | 338 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, |
336 base::Unretained(&mock_callback_), | 339 base::Unretained(&mock_callback_), |
337 mailbox_name1_); | 340 mailbox_name1_); |
338 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, | 341 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, |
339 base::Unretained(&mock_callback_), | 342 base::Unretained(&mock_callback_), |
340 mailbox_name2_); | 343 mailbox_name2_); |
341 gpu::Mailbox m1; | 344 gpu::Mailbox m1; |
342 m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); | 345 m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); |
343 mailbox1_ = TextureMailbox(m1, release_mailbox1_, sync_point1_); | 346 mailbox1_ = TextureMailbox(m1, sync_point1_); |
344 gpu::Mailbox m2; | 347 gpu::Mailbox m2; |
345 m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); | 348 m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); |
346 mailbox2_ = TextureMailbox(m2, release_mailbox2_, sync_point2_); | 349 mailbox2_ = TextureMailbox(m2, sync_point2_); |
347 | 350 |
348 gfx::Size size(128, 128); | 351 gfx::Size size(128, 128); |
349 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); | 352 EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); |
350 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, | 353 release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, |
351 base::Unretained(&mock_callback_), | 354 base::Unretained(&mock_callback_), |
352 shared_memory_.get()); | 355 shared_memory_.get()); |
353 mailbox3_ = TextureMailbox(shared_memory_.get(), size, release_mailbox3_); | 356 mailbox3_ = TextureMailbox(shared_memory_.get(), size); |
354 } | 357 } |
355 | 358 |
356 std::string mailbox_name1_; | 359 std::string mailbox_name1_; |
357 std::string mailbox_name2_; | 360 std::string mailbox_name2_; |
358 MockMailboxCallback mock_callback_; | 361 MockMailboxCallback mock_callback_; |
359 TextureMailbox::ReleaseCallback release_mailbox1_; | 362 ReleaseCallback release_mailbox1_; |
360 TextureMailbox::ReleaseCallback release_mailbox2_; | 363 ReleaseCallback release_mailbox2_; |
361 TextureMailbox::ReleaseCallback release_mailbox3_; | 364 ReleaseCallback release_mailbox3_; |
362 TextureMailbox mailbox1_; | 365 TextureMailbox mailbox1_; |
363 TextureMailbox mailbox2_; | 366 TextureMailbox mailbox2_; |
364 TextureMailbox mailbox3_; | 367 TextureMailbox mailbox3_; |
365 unsigned sync_point1_; | 368 unsigned sync_point1_; |
366 unsigned sync_point2_; | 369 unsigned sync_point2_; |
367 scoped_ptr<base::SharedMemory> shared_memory_; | 370 scoped_ptr<base::SharedMemory> shared_memory_; |
368 }; | 371 }; |
369 | 372 |
370 class TestMailboxHolder : public TextureLayer::MailboxHolder { | 373 class TestMailboxHolder : public TextureLayer::MailboxHolder { |
371 public: | 374 public: |
(...skipping 21 matching lines...) Expand all Loading... | |
393 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 396 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
394 ASSERT_TRUE(test_layer.get()); | 397 ASSERT_TRUE(test_layer.get()); |
395 | 398 |
396 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 399 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
397 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 400 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
398 layer_tree_host_->SetRootLayer(test_layer); | 401 layer_tree_host_->SetRootLayer(test_layer); |
399 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 402 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
400 | 403 |
401 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 404 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
402 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 405 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
403 test_layer->SetTextureMailbox(test_data_.mailbox1_); | 406 test_layer->SetTextureMailbox( |
407 test_data_.mailbox1_, | |
408 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
404 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 409 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
405 | 410 |
406 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 411 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
407 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 412 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
408 EXPECT_CALL(test_data_.mock_callback_, | 413 EXPECT_CALL(test_data_.mock_callback_, |
409 Release(test_data_.mailbox_name1_, | 414 Release(test_data_.mailbox_name1_, |
410 test_data_.sync_point1_, | 415 test_data_.sync_point1_, |
411 false)) | 416 false)) |
412 .Times(1); | 417 .Times(1); |
413 test_layer->SetTextureMailbox(test_data_.mailbox2_); | 418 test_layer->SetTextureMailbox( |
419 test_data_.mailbox2_, | |
420 ScopedReleaseCallback::Create(test_data_.release_mailbox2_)); | |
414 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 421 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
415 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 422 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
416 | 423 |
417 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 424 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
418 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 425 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
419 EXPECT_CALL(test_data_.mock_callback_, | 426 EXPECT_CALL(test_data_.mock_callback_, |
420 Release(test_data_.mailbox_name2_, | 427 Release(test_data_.mailbox_name2_, |
421 test_data_.sync_point2_, | 428 test_data_.sync_point2_, |
422 false)) | 429 false)) |
423 .Times(1); | 430 .Times(1); |
424 test_layer->SetTextureMailbox(TextureMailbox()); | 431 test_layer->SetTextureMailbox(TextureMailbox(), |
432 scoped_ptr<ScopedReleaseCallback>()); | |
425 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 433 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
426 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 434 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
427 | 435 |
428 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 436 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
429 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 437 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
430 test_layer->SetTextureMailbox(test_data_.mailbox3_); | 438 test_layer->SetTextureMailbox( |
439 test_data_.mailbox3_, | |
440 ScopedReleaseCallback::Create(test_data_.release_mailbox3_)); | |
431 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 441 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
432 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 442 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
433 | 443 |
434 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 444 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
435 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 445 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
436 EXPECT_CALL(test_data_.mock_callback_, | 446 EXPECT_CALL(test_data_.mock_callback_, |
437 Release2(test_data_.shared_memory_.get(), | 447 Release2(test_data_.shared_memory_.get(), |
438 0, false)) | 448 0, false)) |
439 .Times(1); | 449 .Times(1); |
440 test_layer->SetTextureMailbox(TextureMailbox()); | 450 test_layer->SetTextureMailbox(TextureMailbox(), |
451 scoped_ptr<ScopedReleaseCallback>()); | |
441 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 452 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
442 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 453 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
443 | 454 |
444 // Test destructor. | 455 // Test destructor. |
445 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 456 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
446 test_layer->SetTextureMailbox(test_data_.mailbox1_); | 457 test_layer->SetTextureMailbox( |
458 test_data_.mailbox1_, | |
459 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
447 } | 460 } |
448 | 461 |
449 class TextureLayerMailboxHolderTest : public TextureLayerTest { | 462 class TextureLayerMailboxHolderTest : public TextureLayerTest { |
450 public: | 463 public: |
451 TextureLayerMailboxHolderTest() | 464 TextureLayerMailboxHolderTest() |
452 : main_thread_("MAIN") { | 465 : main_thread_("MAIN") { |
453 main_thread_.Start(); | 466 main_thread_.Start(); |
454 } | 467 } |
455 | 468 |
456 void Wait(const base::Thread& thread) { | 469 void Wait(const base::Thread& thread) { |
457 bool manual_reset = false; | 470 bool manual_reset = false; |
458 bool initially_signaled = false; | 471 bool initially_signaled = false; |
459 base::WaitableEvent event(manual_reset, initially_signaled); | 472 base::WaitableEvent event(manual_reset, initially_signaled); |
460 thread.message_loop()->PostTask( | 473 thread.message_loop()->PostTask( |
461 FROM_HERE, | 474 FROM_HERE, |
462 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); | 475 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); |
463 event.Wait(); | 476 event.Wait(); |
464 } | 477 } |
465 | 478 |
466 void CreateMainRef() { | 479 void CreateMainRef() { |
467 main_ref_ = TestMailboxHolder::Create( | 480 main_ref_ = TestMailboxHolder::Create( |
468 test_data_.mailbox1_).Pass(); | 481 test_data_.mailbox1_, |
482 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)).Pass(); | |
469 } | 483 } |
470 | 484 |
471 void ReleaseMainRef() { | 485 void ReleaseMainRef() { |
472 main_ref_.reset(); | 486 main_ref_.reset(); |
473 } | 487 } |
474 | 488 |
475 void CreateImplRef(TextureMailbox::ReleaseCallback* impl_ref) { | 489 void CreateImplRef(scoped_ptr<ScopedReleaseCallback>* impl_ref) { |
476 *impl_ref = main_ref_->holder()->GetCallbackForImplThread(); | 490 *impl_ref = main_ref_->holder()->GetCallbackForImplThread(); |
477 } | 491 } |
478 | 492 |
479 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture, | 493 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture, |
480 base::WaitableEvent* wait_for_capture, | 494 base::WaitableEvent* wait_for_capture, |
481 base::WaitableEvent* stop_capture) { | 495 base::WaitableEvent* stop_capture) { |
482 begin_capture->Wait(); | 496 begin_capture->Wait(); |
483 BlockingTaskRunner::CapturePostTasks capture; | 497 BlockingTaskRunner::CapturePostTasks capture; |
484 wait_for_capture->Signal(); | 498 wait_for_capture->Signal(); |
485 stop_capture->Wait(); | 499 stop_capture->Wait(); |
(...skipping 12 matching lines...) Expand all Loading... | |
498 | 512 |
499 main_thread_.message_loop()->PostTask( | 513 main_thread_.message_loop()->PostTask( |
500 FROM_HERE, | 514 FROM_HERE, |
501 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 515 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
502 base::Unretained(this))); | 516 base::Unretained(this))); |
503 | 517 |
504 Wait(main_thread_); | 518 Wait(main_thread_); |
505 | 519 |
506 // The texture layer is attached to compositor1, and passes a reference to its | 520 // The texture layer is attached to compositor1, and passes a reference to its |
507 // impl tree. | 521 // impl tree. |
508 TextureMailbox::ReleaseCallback compositor1; | 522 scoped_ptr<ScopedReleaseCallback> compositor1; |
509 main_thread_.message_loop()->PostTask( | 523 main_thread_.message_loop()->PostTask( |
510 FROM_HERE, | 524 FROM_HERE, |
511 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 525 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
512 base::Unretained(this), | 526 base::Unretained(this), |
513 &compositor1)); | 527 &compositor1)); |
514 | 528 |
515 // Then the texture layer is removed and attached to compositor2, and passes a | 529 // Then the texture layer is removed and attached to compositor2, and passes a |
516 // reference to its impl tree. | 530 // reference to its impl tree. |
517 TextureMailbox::ReleaseCallback compositor2; | 531 scoped_ptr<ScopedReleaseCallback> compositor2; |
518 main_thread_.message_loop()->PostTask( | 532 main_thread_.message_loop()->PostTask( |
519 FROM_HERE, | 533 FROM_HERE, |
520 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 534 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
521 base::Unretained(this), | 535 base::Unretained(this), |
522 &compositor2)); | 536 &compositor2)); |
523 | 537 |
524 Wait(main_thread_); | 538 Wait(main_thread_); |
525 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 539 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
526 | 540 |
527 // The compositors both destroy their impl trees before the main thread layer | 541 // The compositors both destroy their impl trees before the main thread layer |
528 // is destroyed. | 542 // is destroyed. |
529 compositor1.Run(100, false); | 543 compositor1->Run(100, false); |
530 compositor2.Run(200, false); | 544 compositor2->Run(200, false); |
531 | 545 |
532 Wait(main_thread_); | 546 Wait(main_thread_); |
533 | 547 |
534 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 548 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
535 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 549 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
536 | 550 |
537 // The main thread ref is the last one, so the mailbox is released back to the | 551 // The main thread ref is the last one, so the mailbox is released back to the |
538 // embedder, with the last sync point provided by the impl trees. | 552 // embedder, with the last sync point provided by the impl trees. |
539 EXPECT_CALL(test_data_.mock_callback_, | 553 EXPECT_CALL(test_data_.mock_callback_, |
540 Release(test_data_.mailbox_name1_, 200, false)).Times(1); | 554 Release(test_data_.mailbox_name1_, 200, false)).Times(1); |
(...skipping 12 matching lines...) Expand all Loading... | |
553 | 567 |
554 main_thread_.message_loop()->PostTask( | 568 main_thread_.message_loop()->PostTask( |
555 FROM_HERE, | 569 FROM_HERE, |
556 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 570 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
557 base::Unretained(this))); | 571 base::Unretained(this))); |
558 | 572 |
559 Wait(main_thread_); | 573 Wait(main_thread_); |
560 | 574 |
561 // The texture layer is attached to compositor1, and passes a reference to its | 575 // The texture layer is attached to compositor1, and passes a reference to its |
562 // impl tree. | 576 // impl tree. |
563 TextureMailbox::ReleaseCallback compositor1; | 577 scoped_ptr<ScopedReleaseCallback> compositor1; |
564 main_thread_.message_loop()->PostTask( | 578 main_thread_.message_loop()->PostTask( |
565 FROM_HERE, | 579 FROM_HERE, |
566 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 580 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
567 base::Unretained(this), | 581 base::Unretained(this), |
568 &compositor1)); | 582 &compositor1)); |
569 | 583 |
570 // Then the texture layer is removed and attached to compositor2, and passes a | 584 // Then the texture layer is removed and attached to compositor2, and passes a |
571 // reference to its impl tree. | 585 // reference to its impl tree. |
572 TextureMailbox::ReleaseCallback compositor2; | 586 scoped_ptr<ScopedReleaseCallback> compositor2; |
573 main_thread_.message_loop()->PostTask( | 587 main_thread_.message_loop()->PostTask( |
574 FROM_HERE, | 588 FROM_HERE, |
575 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 589 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
576 base::Unretained(this), | 590 base::Unretained(this), |
577 &compositor2)); | 591 &compositor2)); |
578 | 592 |
579 Wait(main_thread_); | 593 Wait(main_thread_); |
580 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 594 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
581 | 595 |
582 // One compositor destroys their impl tree. | 596 // One compositor destroys their impl tree. |
583 compositor1.Run(100, false); | 597 compositor1->Run(100, false); |
584 | 598 |
585 // Then the main thread reference is destroyed. | 599 // Then the main thread reference is destroyed. |
586 main_thread_.message_loop()->PostTask( | 600 main_thread_.message_loop()->PostTask( |
587 FROM_HERE, | 601 FROM_HERE, |
588 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 602 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
589 base::Unretained(this))); | 603 base::Unretained(this))); |
590 | 604 |
591 Wait(main_thread_); | 605 Wait(main_thread_); |
592 | 606 |
593 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 607 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
594 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 608 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
595 | 609 |
596 // The second impl reference is destroyed last, causing the mailbox to be | 610 // The second impl reference is destroyed last, causing the mailbox to be |
597 // released back to the embedder with the last sync point from the impl tree. | 611 // released back to the embedder with the last sync point from the impl tree. |
598 EXPECT_CALL(test_data_.mock_callback_, | 612 EXPECT_CALL(test_data_.mock_callback_, |
599 Release(test_data_.mailbox_name1_, 200, true)).Times(1); | 613 Release(test_data_.mailbox_name1_, 200, true)).Times(1); |
600 | 614 |
601 compositor2.Run(200, true); | 615 compositor2->Run(200, true); |
602 Wait(main_thread_); | 616 Wait(main_thread_); |
603 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 617 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
604 } | 618 } |
605 | 619 |
606 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 620 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { |
607 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 621 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
608 ASSERT_TRUE(test_layer.get()); | 622 ASSERT_TRUE(test_layer.get()); |
609 | 623 |
610 main_thread_.message_loop()->PostTask( | 624 main_thread_.message_loop()->PostTask( |
611 FROM_HERE, | 625 FROM_HERE, |
612 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 626 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
613 base::Unretained(this))); | 627 base::Unretained(this))); |
614 | 628 |
615 Wait(main_thread_); | 629 Wait(main_thread_); |
616 | 630 |
617 // The texture layer is attached to compositor1, and passes a reference to its | 631 // The texture layer is attached to compositor1, and passes a reference to its |
618 // impl tree. | 632 // impl tree. |
619 TextureMailbox::ReleaseCallback compositor1; | 633 scoped_ptr<ScopedReleaseCallback> compositor1; |
620 main_thread_.message_loop()->PostTask( | 634 main_thread_.message_loop()->PostTask( |
621 FROM_HERE, | 635 FROM_HERE, |
622 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 636 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
623 base::Unretained(this), | 637 base::Unretained(this), |
624 &compositor1)); | 638 &compositor1)); |
625 | 639 |
626 // Then the texture layer is removed and attached to compositor2, and passes a | 640 // Then the texture layer is removed and attached to compositor2, and passes a |
627 // reference to its impl tree. | 641 // reference to its impl tree. |
628 TextureMailbox::ReleaseCallback compositor2; | 642 scoped_ptr<ScopedReleaseCallback> compositor2; |
629 main_thread_.message_loop()->PostTask( | 643 main_thread_.message_loop()->PostTask( |
630 FROM_HERE, | 644 FROM_HERE, |
631 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 645 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
632 base::Unretained(this), | 646 base::Unretained(this), |
633 &compositor2)); | 647 &compositor2)); |
634 | 648 |
635 Wait(main_thread_); | 649 Wait(main_thread_); |
636 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 650 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
637 | 651 |
638 // The main thread reference is destroyed first. | 652 // The main thread reference is destroyed first. |
639 main_thread_.message_loop()->PostTask( | 653 main_thread_.message_loop()->PostTask( |
640 FROM_HERE, | 654 FROM_HERE, |
641 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 655 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
642 base::Unretained(this))); | 656 base::Unretained(this))); |
643 | 657 |
644 // One compositor destroys their impl tree. | 658 // One compositor destroys their impl tree. |
645 compositor2.Run(200, false); | 659 compositor2->Run(200, false); |
646 | 660 |
647 Wait(main_thread_); | 661 Wait(main_thread_); |
648 | 662 |
649 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 663 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
650 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 664 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
651 | 665 |
652 // The second impl reference is destroyed last, causing the mailbox to be | 666 // The second impl reference is destroyed last, causing the mailbox to be |
653 // released back to the embedder with the last sync point from the impl tree. | 667 // released back to the embedder with the last sync point from the impl tree. |
654 EXPECT_CALL(test_data_.mock_callback_, | 668 EXPECT_CALL(test_data_.mock_callback_, |
655 Release(test_data_.mailbox_name1_, 100, true)).Times(1); | 669 Release(test_data_.mailbox_name1_, 100, true)).Times(1); |
656 | 670 |
657 compositor1.Run(100, true); | 671 compositor1->Run(100, true); |
658 Wait(main_thread_); | 672 Wait(main_thread_); |
659 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 673 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
660 } | 674 } |
661 | 675 |
662 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 676 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { |
663 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 677 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
664 ASSERT_TRUE(test_layer.get()); | 678 ASSERT_TRUE(test_layer.get()); |
665 | 679 |
666 main_thread_.message_loop()->PostTask( | 680 main_thread_.message_loop()->PostTask( |
667 FROM_HERE, | 681 FROM_HERE, |
668 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 682 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
669 base::Unretained(this))); | 683 base::Unretained(this))); |
670 | 684 |
671 Wait(main_thread_); | 685 Wait(main_thread_); |
672 | 686 |
673 // The texture layer is attached to compositor1, and passes a reference to its | 687 // The texture layer is attached to compositor1, and passes a reference to its |
674 // impl tree. | 688 // impl tree. |
675 TextureMailbox::ReleaseCallback compositor1; | 689 scoped_ptr<ScopedReleaseCallback> compositor1; |
676 main_thread_.message_loop()->PostTask( | 690 main_thread_.message_loop()->PostTask( |
677 FROM_HERE, | 691 FROM_HERE, |
678 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 692 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
679 base::Unretained(this), | 693 base::Unretained(this), |
680 &compositor1)); | 694 &compositor1)); |
681 | 695 |
682 // Then the texture layer is removed and attached to compositor2, and passes a | 696 // Then the texture layer is removed and attached to compositor2, and passes a |
683 // reference to its impl tree. | 697 // reference to its impl tree. |
684 TextureMailbox::ReleaseCallback compositor2; | 698 scoped_ptr<ScopedReleaseCallback> compositor2; |
685 main_thread_.message_loop()->PostTask( | 699 main_thread_.message_loop()->PostTask( |
686 FROM_HERE, | 700 FROM_HERE, |
687 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, | 701 base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, |
688 base::Unretained(this), | 702 base::Unretained(this), |
689 &compositor2)); | 703 &compositor2)); |
690 | 704 |
691 Wait(main_thread_); | 705 Wait(main_thread_); |
692 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 706 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
693 | 707 |
694 // The main thread reference is destroyed first. | 708 // The main thread reference is destroyed first. |
(...skipping 17 matching lines...) Expand all Loading... | |
712 FROM_HERE, | 726 FROM_HERE, |
713 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, | 727 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, |
714 base::Unretained(this), | 728 base::Unretained(this), |
715 &begin_capture, | 729 &begin_capture, |
716 &wait_for_capture, | 730 &wait_for_capture, |
717 &stop_capture)); | 731 &stop_capture)); |
718 | 732 |
719 // Before the main thread capturing starts, one compositor destroys their | 733 // Before the main thread capturing starts, one compositor destroys their |
720 // impl reference. Since capturing did not start, this gets post-tasked to | 734 // impl reference. Since capturing did not start, this gets post-tasked to |
721 // the main thread. | 735 // the main thread. |
722 compositor1.Run(100, false); | 736 compositor1->Run(100, false); |
723 | 737 |
724 // Start capturing on the main thread. | 738 // Start capturing on the main thread. |
725 begin_capture.Signal(); | 739 begin_capture.Signal(); |
726 wait_for_capture.Wait(); | 740 wait_for_capture.Wait(); |
727 | 741 |
728 // Meanwhile, the second compositor released its impl reference, but this task | 742 // Meanwhile, the second compositor released its impl reference, but this task |
729 // gets shortcutted directly to the main thread. This means the reference is | 743 // gets shortcutted directly to the main thread. This means the reference is |
730 // released before compositor1, whose reference will be released later when | 744 // released before compositor1, whose reference will be released later when |
731 // the post-task is serviced. But since it was destroyed _on the impl thread_ | 745 // the post-task is serviced. But since it was destroyed _on the impl thread_ |
732 // last, its sync point values should be used. | 746 // last, its sync point values should be used. |
733 compositor2.Run(200, true); | 747 compositor2->Run(200, true); |
734 | 748 |
735 stop_capture.Signal(); | 749 stop_capture.Signal(); |
736 Wait(main_thread_); | 750 Wait(main_thread_); |
737 | 751 |
738 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 752 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
739 } | 753 } |
740 | 754 |
741 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { | 755 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { |
742 public: | 756 public: |
743 TextureLayerImplWithMailboxThreadedCallback() | 757 TextureLayerImplWithMailboxThreadedCallback() |
744 : callback_count_(0), | 758 : callback_count_(0), |
745 commit_count_(0) {} | 759 commit_count_(0) {} |
746 | 760 |
747 // Make sure callback is received on main and doesn't block the impl thread. | 761 // Make sure callback is received on main and doesn't block the impl thread. |
748 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 762 void ReleaseCallback(unsigned sync_point, bool lost_resource) { |
749 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 763 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
750 EXPECT_FALSE(lost_resource); | 764 EXPECT_FALSE(lost_resource); |
751 ++callback_count_; | 765 ++callback_count_; |
752 } | 766 } |
753 | 767 |
754 void SetMailbox(char mailbox_char) { | 768 void SetMailbox(char mailbox_char) { |
755 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 769 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
756 TextureMailbox mailbox( | 770 TextureMailbox mailbox(std::string(64, mailbox_char)); |
757 std::string(64, mailbox_char), | 771 scoped_ptr<ScopedReleaseCallback> callback = ScopedReleaseCallback::Create( |
758 base::Bind( | 772 base::Bind( |
759 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, | 773 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, |
760 base::Unretained(this))); | 774 base::Unretained(this))); |
761 layer_->SetTextureMailbox(mailbox); | 775 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
762 } | 776 } |
763 | 777 |
764 virtual void BeginTest() OVERRIDE { | 778 virtual void BeginTest() OVERRIDE { |
765 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 779 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
766 | 780 |
767 gfx::Size bounds(100, 100); | 781 gfx::Size bounds(100, 100); |
768 root_ = Layer::Create(); | 782 root_ = Layer::Create(); |
769 root_->SetAnchorPoint(gfx::PointF()); | 783 root_->SetAnchorPoint(gfx::PointF()); |
770 root_->SetBounds(bounds); | 784 root_->SetBounds(bounds); |
771 | 785 |
(...skipping 29 matching lines...) Expand all Loading... | |
801 EXPECT_EQ(2, callback_count_); | 815 EXPECT_EQ(2, callback_count_); |
802 // Case #3: change mailbox when the layer doesn't draw. The old | 816 // Case #3: change mailbox when the layer doesn't draw. The old |
803 // mailbox should be released during the next commit. | 817 // mailbox should be released during the next commit. |
804 layer_->SetBounds(gfx::Size()); | 818 layer_->SetBounds(gfx::Size()); |
805 SetMailbox('4'); | 819 SetMailbox('4'); |
806 break; | 820 break; |
807 case 3: | 821 case 3: |
808 EXPECT_EQ(3, callback_count_); | 822 EXPECT_EQ(3, callback_count_); |
809 // Case #4: release mailbox that was committed but never drawn. The | 823 // Case #4: release mailbox that was committed but never drawn. The |
810 // old mailbox should be released during the next commit. | 824 // old mailbox should be released during the next commit. |
811 layer_->SetTextureMailbox(TextureMailbox()); | 825 layer_->SetTextureMailbox(TextureMailbox(), |
826 scoped_ptr<ScopedReleaseCallback>()); | |
812 break; | 827 break; |
813 case 4: | 828 case 4: |
814 if (layer_tree_host()->settings().impl_side_painting) { | 829 if (layer_tree_host()->settings().impl_side_painting) { |
815 // With impl painting, the texture mailbox will still be on the impl | 830 // With impl painting, the texture mailbox will still be on the impl |
816 // thread when the commit finishes, because the layer is not drawble | 831 // thread when the commit finishes, because the layer is not drawble |
817 // when it has no texture mailbox, and thus does not block the commit | 832 // when it has no texture mailbox, and thus does not block the commit |
818 // on activation. So, we wait for activation. | 833 // on activation. So, we wait for activation. |
819 // TODO(danakj): fix this. crbug.com/277953 | 834 // TODO(danakj): fix this. crbug.com/277953 |
820 layer_tree_host()->SetNeedsCommit(); | 835 layer_tree_host()->SetNeedsCommit(); |
821 break; | 836 break; |
(...skipping 18 matching lines...) Expand all Loading... | |
840 // block the commit on activation anymore. So, we wait for activation. | 855 // block the commit on activation anymore. So, we wait for activation. |
841 // TODO(danakj): fix this. crbug.com/277953 | 856 // TODO(danakj): fix this. crbug.com/277953 |
842 layer_tree_host()->SetNeedsCommit(); | 857 layer_tree_host()->SetNeedsCommit(); |
843 break; | 858 break; |
844 } else { | 859 } else { |
845 ++commit_count_; | 860 ++commit_count_; |
846 } | 861 } |
847 case 8: | 862 case 8: |
848 EXPECT_EQ(4, callback_count_); | 863 EXPECT_EQ(4, callback_count_); |
849 // Resetting the mailbox will call the callback now. | 864 // Resetting the mailbox will call the callback now. |
850 layer_->SetTextureMailbox(TextureMailbox()); | 865 layer_->SetTextureMailbox(TextureMailbox(), |
866 scoped_ptr<ScopedReleaseCallback>()); | |
851 EXPECT_EQ(5, callback_count_); | 867 EXPECT_EQ(5, callback_count_); |
852 EndTest(); | 868 EndTest(); |
853 break; | 869 break; |
854 default: | 870 default: |
855 NOTREACHED(); | 871 NOTREACHED(); |
856 break; | 872 break; |
857 } | 873 } |
858 } | 874 } |
859 | 875 |
860 virtual void AfterTest() OVERRIDE {} | 876 virtual void AfterTest() OVERRIDE {} |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 } | 917 } |
902 | 918 |
903 // TextureLayerClient implementation. | 919 // TextureLayerClient implementation. |
904 virtual unsigned PrepareTexture() OVERRIDE { | 920 virtual unsigned PrepareTexture() OVERRIDE { |
905 return OffscreenContextProviderForMainThread() | 921 return OffscreenContextProviderForMainThread() |
906 ->Context3d()->createTexture(); | 922 ->Context3d()->createTexture(); |
907 } | 923 } |
908 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 924 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
909 return OffscreenContextProviderForMainThread()->Context3d(); | 925 return OffscreenContextProviderForMainThread()->Context3d(); |
910 } | 926 } |
911 virtual bool PrepareTextureMailbox(TextureMailbox* mailbox, | 927 virtual bool PrepareTextureMailbox( |
912 bool use_shared_memory) OVERRIDE { | 928 TextureMailbox* mailbox, |
929 scoped_ptr<ScopedReleaseCallback>* release_callback, | |
930 bool use_shared_memory) OVERRIDE { | |
913 return false; | 931 return false; |
914 } | 932 } |
915 | 933 |
916 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 934 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
917 // Slow down activation so the main thread DidCommit() will run if | 935 // Slow down activation so the main thread DidCommit() will run if |
918 // not blocked. | 936 // not blocked. |
919 wait_thread_.message_loop()->PostDelayedTask( | 937 wait_thread_.message_loop()->PostDelayedTask( |
920 FROM_HERE, | 938 FROM_HERE, |
921 base::Bind(&base::WaitableEvent::Signal, | 939 base::Bind(&base::WaitableEvent::Signal, |
922 base::Unretained(&wait_event_)), | 940 base::Unretained(&wait_event_)), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
996 protected: | 1014 protected: |
997 TextureLayerMailboxIsActivatedDuringCommit() | 1015 TextureLayerMailboxIsActivatedDuringCommit() |
998 : wait_thread_("WAIT"), | 1016 : wait_thread_("WAIT"), |
999 wait_event_(false, false) { | 1017 wait_event_(false, false) { |
1000 wait_thread_.Start(); | 1018 wait_thread_.Start(); |
1001 } | 1019 } |
1002 | 1020 |
1003 static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} | 1021 static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} |
1004 | 1022 |
1005 void SetMailbox(char mailbox_char) { | 1023 void SetMailbox(char mailbox_char) { |
1006 TextureMailbox mailbox( | 1024 TextureMailbox mailbox(std::string(64, mailbox_char)); |
1007 std::string(64, mailbox_char), | 1025 scoped_ptr<ScopedReleaseCallback> callback = ScopedReleaseCallback::Create( |
1008 base::Bind( | 1026 base::Bind( |
1009 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 1027 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
1010 layer_->SetTextureMailbox(mailbox); | 1028 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
1011 } | 1029 } |
1012 | 1030 |
1013 virtual void BeginTest() OVERRIDE { | 1031 virtual void BeginTest() OVERRIDE { |
1014 activate_count_ = 0; | 1032 activate_count_ = 0; |
1015 | 1033 |
1016 gfx::Size bounds(100, 100); | 1034 gfx::Size bounds(100, 100); |
1017 root_ = Layer::Create(); | 1035 root_ = Layer::Create(); |
1018 root_->SetAnchorPoint(gfx::PointF()); | 1036 root_->SetAnchorPoint(gfx::PointF()); |
1019 root_->SetBounds(bounds); | 1037 root_->SetBounds(bounds); |
1020 | 1038 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1141 test_data_.sync_point1_, | 1159 test_data_.sync_point1_, |
1142 false)) | 1160 false)) |
1143 .Times(AnyNumber()); | 1161 .Times(AnyNumber()); |
1144 EXPECT_CALL(test_data_.mock_callback_, | 1162 EXPECT_CALL(test_data_.mock_callback_, |
1145 Release2(test_data_.shared_memory_.get(), 0, false)) | 1163 Release2(test_data_.shared_memory_.get(), 0, false)) |
1146 .Times(AnyNumber()); | 1164 .Times(AnyNumber()); |
1147 // Hardware mode. | 1165 // Hardware mode. |
1148 { | 1166 { |
1149 scoped_ptr<TextureLayerImpl> impl_layer = | 1167 scoped_ptr<TextureLayerImpl> impl_layer = |
1150 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1168 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1151 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1169 impl_layer->SetTextureMailbox( |
1170 test_data_.mailbox1_, | |
1171 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1152 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1172 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1153 } | 1173 } |
1154 | 1174 |
1155 { | 1175 { |
1156 scoped_ptr<TextureLayerImpl> impl_layer = | 1176 scoped_ptr<TextureLayerImpl> impl_layer = |
1157 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1177 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1158 impl_layer->SetTextureMailbox(TextureMailbox()); | 1178 impl_layer->SetTextureMailbox(TextureMailbox(), |
1179 scoped_ptr<ScopedReleaseCallback>()); | |
1159 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1180 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1160 } | 1181 } |
1161 | 1182 |
1162 { | 1183 { |
1163 // Software resource. | 1184 // Software resource. |
1164 scoped_ptr<TextureLayerImpl> impl_layer = | 1185 scoped_ptr<TextureLayerImpl> impl_layer = |
1165 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1186 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1166 impl_layer->SetTextureMailbox(test_data_.mailbox3_); | 1187 impl_layer->SetTextureMailbox( |
1188 test_data_.mailbox3_, | |
1189 ScopedReleaseCallback::Create(test_data_.release_mailbox3_)); | |
1167 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1190 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1168 } | 1191 } |
1169 | 1192 |
1170 { | 1193 { |
1171 scoped_ptr<TextureLayerImpl> impl_layer = | 1194 scoped_ptr<TextureLayerImpl> impl_layer = |
1172 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1195 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1173 ContextProvider* context_provider = | 1196 ContextProvider* context_provider = |
1174 host_impl_.output_surface()->context_provider(); | 1197 host_impl_.output_surface()->context_provider(); |
1175 unsigned texture = | 1198 unsigned texture = |
1176 context_provider->Context3d()->createTexture(); | 1199 context_provider->Context3d()->createTexture(); |
1177 impl_layer->set_texture_id(texture); | 1200 impl_layer->set_texture_id(texture); |
1178 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1201 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1179 } | 1202 } |
1180 | 1203 |
1181 { | 1204 { |
1182 scoped_ptr<TextureLayerImpl> impl_layer = | 1205 scoped_ptr<TextureLayerImpl> impl_layer = |
1183 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1206 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1184 impl_layer->set_texture_id(0); | 1207 impl_layer->set_texture_id(0); |
1185 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1208 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
1186 } | 1209 } |
1187 | 1210 |
1188 // Software mode. | 1211 // Software mode. |
1189 { | 1212 { |
1190 scoped_ptr<TextureLayerImpl> impl_layer = | 1213 scoped_ptr<TextureLayerImpl> impl_layer = |
1191 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1214 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1192 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1215 impl_layer->SetTextureMailbox( |
1216 test_data_.mailbox1_, | |
1217 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1193 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1218 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1194 } | 1219 } |
1195 | 1220 |
1196 { | 1221 { |
1197 scoped_ptr<TextureLayerImpl> impl_layer = | 1222 scoped_ptr<TextureLayerImpl> impl_layer = |
1198 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1223 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1199 impl_layer->SetTextureMailbox(TextureMailbox()); | 1224 impl_layer->SetTextureMailbox(TextureMailbox(), |
1225 scoped_ptr<ScopedReleaseCallback>()); | |
1200 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1226 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1201 } | 1227 } |
1202 | 1228 |
1203 { | 1229 { |
1204 // Software resource. | 1230 // Software resource. |
1205 scoped_ptr<TextureLayerImpl> impl_layer = | 1231 scoped_ptr<TextureLayerImpl> impl_layer = |
1206 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1232 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1207 impl_layer->SetTextureMailbox(test_data_.mailbox3_); | 1233 impl_layer->SetTextureMailbox( |
1234 test_data_.mailbox3_, | |
1235 ScopedReleaseCallback::Create(test_data_.release_mailbox3_)); | |
1208 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1236 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1209 } | 1237 } |
1210 | 1238 |
1211 { | 1239 { |
1212 scoped_ptr<TextureLayerImpl> impl_layer = | 1240 scoped_ptr<TextureLayerImpl> impl_layer = |
1213 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1241 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1214 ContextProvider* context_provider = | 1242 ContextProvider* context_provider = |
1215 host_impl_.output_surface()->context_provider(); | 1243 host_impl_.output_surface()->context_provider(); |
1216 unsigned texture = | 1244 unsigned texture = |
1217 context_provider->Context3d()->createTexture(); | 1245 context_provider->Context3d()->createTexture(); |
1218 impl_layer->set_texture_id(texture); | 1246 impl_layer->set_texture_id(texture); |
1219 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1247 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1220 } | 1248 } |
1221 | 1249 |
1222 { | 1250 { |
1223 scoped_ptr<TextureLayerImpl> impl_layer = | 1251 scoped_ptr<TextureLayerImpl> impl_layer = |
1224 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1252 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1225 impl_layer->set_texture_id(0); | 1253 impl_layer->set_texture_id(0); |
1226 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1254 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
1227 } | 1255 } |
1228 | 1256 |
1229 // Resourceless software mode. | 1257 // Resourceless software mode. |
1230 { | 1258 { |
1231 scoped_ptr<TextureLayerImpl> impl_layer = | 1259 scoped_ptr<TextureLayerImpl> impl_layer = |
1232 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1260 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1233 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1261 impl_layer->SetTextureMailbox( |
1262 test_data_.mailbox1_, | |
1263 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1234 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 1264 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
1235 } | 1265 } |
1236 | 1266 |
1237 { | 1267 { |
1238 scoped_ptr<TextureLayerImpl> impl_layer = | 1268 scoped_ptr<TextureLayerImpl> impl_layer = |
1239 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1269 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
1240 ContextProvider* context_provider = | 1270 ContextProvider* context_provider = |
1241 host_impl_.output_surface()->context_provider(); | 1271 host_impl_.output_surface()->context_provider(); |
1242 unsigned texture = | 1272 unsigned texture = |
1243 context_provider->Context3d()->createTexture(); | 1273 context_provider->Context3d()->createTexture(); |
1244 impl_layer->set_texture_id(texture); | 1274 impl_layer->set_texture_id(texture); |
1245 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 1275 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
1246 } | 1276 } |
1247 } | 1277 } |
1248 | 1278 |
1249 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { | 1279 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { |
1250 host_impl_.CreatePendingTree(); | 1280 host_impl_.CreatePendingTree(); |
1251 scoped_ptr<TextureLayerImpl> pending_layer; | 1281 scoped_ptr<TextureLayerImpl> pending_layer; |
1252 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); | 1282 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); |
1253 ASSERT_TRUE(pending_layer); | 1283 ASSERT_TRUE(pending_layer); |
1254 | 1284 |
1255 scoped_ptr<LayerImpl> active_layer( | 1285 scoped_ptr<LayerImpl> active_layer( |
1256 pending_layer->CreateLayerImpl(host_impl_.active_tree())); | 1286 pending_layer->CreateLayerImpl(host_impl_.active_tree())); |
1257 ASSERT_TRUE(active_layer); | 1287 ASSERT_TRUE(active_layer); |
1258 | 1288 |
1259 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 1289 pending_layer->SetTextureMailbox( |
1290 test_data_.mailbox1_, | |
1291 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1260 | 1292 |
1261 // Test multiple commits without an activation. | 1293 // Test multiple commits without an activation. |
1262 EXPECT_CALL(test_data_.mock_callback_, | 1294 EXPECT_CALL(test_data_.mock_callback_, |
1263 Release(test_data_.mailbox_name1_, | 1295 Release(test_data_.mailbox_name1_, |
1264 test_data_.sync_point1_, | 1296 test_data_.sync_point1_, |
1265 false)) | 1297 false)) |
1266 .Times(1); | 1298 .Times(1); |
1267 pending_layer->SetTextureMailbox(test_data_.mailbox2_); | 1299 pending_layer->SetTextureMailbox( |
1300 test_data_.mailbox2_, | |
1301 ScopedReleaseCallback::Create(test_data_.release_mailbox2_)); | |
1268 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1302 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1269 | 1303 |
1270 // Test callback after activation. | 1304 // Test callback after activation. |
1271 pending_layer->PushPropertiesTo(active_layer.get()); | 1305 pending_layer->PushPropertiesTo(active_layer.get()); |
1272 active_layer->DidBecomeActive(); | 1306 active_layer->DidBecomeActive(); |
1273 | 1307 |
1274 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 1308 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
1275 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 1309 pending_layer->SetTextureMailbox( |
1310 test_data_.mailbox1_, | |
1311 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1276 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1312 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1277 | 1313 |
1278 EXPECT_CALL(test_data_.mock_callback_, | 1314 EXPECT_CALL(test_data_.mock_callback_, |
1279 Release(test_data_.mailbox_name2_, _, false)) | 1315 Release(test_data_.mailbox_name2_, _, false)) |
1280 .Times(1); | 1316 .Times(1); |
1281 pending_layer->PushPropertiesTo(active_layer.get()); | 1317 pending_layer->PushPropertiesTo(active_layer.get()); |
1282 active_layer->DidBecomeActive(); | 1318 active_layer->DidBecomeActive(); |
1283 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1319 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1284 | 1320 |
1285 // Test resetting the mailbox. | 1321 // Test resetting the mailbox. |
1286 EXPECT_CALL(test_data_.mock_callback_, | 1322 EXPECT_CALL(test_data_.mock_callback_, |
1287 Release(test_data_.mailbox_name1_, _, false)) | 1323 Release(test_data_.mailbox_name1_, _, false)) |
1288 .Times(1); | 1324 .Times(1); |
1289 pending_layer->SetTextureMailbox(TextureMailbox()); | 1325 pending_layer->SetTextureMailbox(TextureMailbox(), |
1326 scoped_ptr<ScopedReleaseCallback>()); | |
1290 pending_layer->PushPropertiesTo(active_layer.get()); | 1327 pending_layer->PushPropertiesTo(active_layer.get()); |
1291 active_layer->DidBecomeActive(); | 1328 active_layer->DidBecomeActive(); |
1292 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1329 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1293 | 1330 |
1294 // Test destructor. | 1331 // Test destructor. |
1295 EXPECT_CALL(test_data_.mock_callback_, | 1332 EXPECT_CALL(test_data_.mock_callback_, |
1296 Release(test_data_.mailbox_name1_, | 1333 Release(test_data_.mailbox_name1_, |
1297 test_data_.sync_point1_, | 1334 test_data_.sync_point1_, |
1298 false)) | 1335 false)) |
1299 .Times(1); | 1336 .Times(1); |
1300 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 1337 pending_layer->SetTextureMailbox( |
1338 test_data_.mailbox1_, | |
1339 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1301 } | 1340 } |
1302 | 1341 |
1303 TEST_F(TextureLayerImplWithMailboxTest, | 1342 TEST_F(TextureLayerImplWithMailboxTest, |
1304 TestDestructorCallbackOnCreatedResource) { | 1343 TestDestructorCallbackOnCreatedResource) { |
1305 scoped_ptr<TextureLayerImpl> impl_layer; | 1344 scoped_ptr<TextureLayerImpl> impl_layer; |
1306 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1345 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1307 ASSERT_TRUE(impl_layer); | 1346 ASSERT_TRUE(impl_layer); |
1308 | 1347 |
1309 EXPECT_CALL(test_data_.mock_callback_, | 1348 EXPECT_CALL(test_data_.mock_callback_, |
1310 Release(test_data_.mailbox_name1_, _, false)) | 1349 Release(test_data_.mailbox_name1_, _, false)) |
1311 .Times(1); | 1350 .Times(1); |
1312 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 1351 impl_layer->SetTextureMailbox( |
1352 test_data_.mailbox1_, | |
1353 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1313 impl_layer->DidBecomeActive(); | 1354 impl_layer->DidBecomeActive(); |
1314 EXPECT_TRUE(impl_layer->WillDraw( | 1355 EXPECT_TRUE(impl_layer->WillDraw( |
1315 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); | 1356 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); |
1316 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); | 1357 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); |
1317 impl_layer->SetTextureMailbox(TextureMailbox()); | 1358 impl_layer->SetTextureMailbox(TextureMailbox(), |
1359 scoped_ptr<ScopedReleaseCallback>()); | |
1318 } | 1360 } |
1319 | 1361 |
1320 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { | 1362 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { |
1321 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); | 1363 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); |
1322 ResourceProvider::ResourceId id = | 1364 ResourceProvider::ResourceId id = |
1323 provider->CreateResourceFromTextureMailbox(test_data_.mailbox1_); | 1365 provider->CreateResourceFromTextureMailbox( |
1366 test_data_.mailbox1_, | |
1367 ScopedReleaseCallback::Create(test_data_.release_mailbox1_)); | |
1324 provider->AllocateForTesting(id); | 1368 provider->AllocateForTesting(id); |
1325 | 1369 |
1326 // Transfer some resources to the parent. | 1370 // Transfer some resources to the parent. |
1327 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1371 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
1328 resource_ids_to_transfer.push_back(id); | 1372 resource_ids_to_transfer.push_back(id); |
1329 TransferableResourceArray list; | 1373 TransferableResourceArray list; |
1330 provider->PrepareSendToParent(resource_ids_to_transfer, &list); | 1374 provider->PrepareSendToParent(resource_ids_to_transfer, &list); |
1331 EXPECT_TRUE(provider->InUseByConsumer(id)); | 1375 EXPECT_TRUE(provider->InUseByConsumer(id)); |
1332 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 1376 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
1333 provider->DeleteResource(id); | 1377 provider->DeleteResource(id); |
(...skipping 30 matching lines...) Expand all Loading... | |
1364 | 1408 |
1365 virtual unsigned PrepareTexture() OVERRIDE { | 1409 virtual unsigned PrepareTexture() OVERRIDE { |
1366 return texture_; | 1410 return texture_; |
1367 } | 1411 } |
1368 | 1412 |
1369 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 1413 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
1370 return context_; | 1414 return context_; |
1371 } | 1415 } |
1372 | 1416 |
1373 virtual bool PrepareTextureMailbox( | 1417 virtual bool PrepareTextureMailbox( |
1374 cc::TextureMailbox* mailbox, bool use_shared_memory) OVERRIDE { | 1418 TextureMailbox* mailbox, |
1419 scoped_ptr<ScopedReleaseCallback>* release_callback, | |
1420 bool use_shared_memory) OVERRIDE { | |
1375 return false; | 1421 return false; |
1376 } | 1422 } |
1377 | 1423 |
1378 virtual void SetupTree() OVERRIDE { | 1424 virtual void SetupTree() OVERRIDE { |
1379 scoped_refptr<Layer> root = Layer::Create(); | 1425 scoped_refptr<Layer> root = Layer::Create(); |
1380 root->SetBounds(gfx::Size(10, 10)); | 1426 root->SetBounds(gfx::Size(10, 10)); |
1381 root->SetAnchorPoint(gfx::PointF()); | 1427 root->SetAnchorPoint(gfx::PointF()); |
1382 root->SetIsDrawable(true); | 1428 root->SetIsDrawable(true); |
1383 | 1429 |
1384 texture_layer_ = TextureLayer::Create(this); | 1430 texture_layer_ = TextureLayer::Create(this); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1480 return texture_; | 1526 return texture_; |
1481 } | 1527 } |
1482 | 1528 |
1483 // TextureLayerClient implementation. | 1529 // TextureLayerClient implementation. |
1484 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 1530 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
1485 return client_context_.get(); | 1531 return client_context_.get(); |
1486 } | 1532 } |
1487 | 1533 |
1488 // TextureLayerClient implementation. | 1534 // TextureLayerClient implementation. |
1489 virtual bool PrepareTextureMailbox( | 1535 virtual bool PrepareTextureMailbox( |
1490 cc::TextureMailbox* mailbox, bool use_shared_memory) OVERRIDE { | 1536 cc::TextureMailbox* mailbox, bool use_shared_memory) OVERRIDE { |
piman
2013/09/14 01:51:33
post-rebase, you need to fix this one, and the oth
danakj
2013/09/16 16:42:21
Done.
| |
1491 return false; | 1537 return false; |
1492 } | 1538 } |
1493 | 1539 |
1494 virtual void SetupTree() OVERRIDE { | 1540 virtual void SetupTree() OVERRIDE { |
1495 scoped_refptr<Layer> root = Layer::Create(); | 1541 scoped_refptr<Layer> root = Layer::Create(); |
1496 root->SetBounds(gfx::Size(10, 10)); | 1542 root->SetBounds(gfx::Size(10, 10)); |
1497 root->SetAnchorPoint(gfx::PointF()); | 1543 root->SetAnchorPoint(gfx::PointF()); |
1498 root->SetIsDrawable(true); | 1544 root->SetIsDrawable(true); |
1499 | 1545 |
1500 solid_layer_ = SolidColorLayer::Create(); | 1546 solid_layer_ = SolidColorLayer::Create(); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1812 GL_INNOCENT_CONTEXT_RESET_ARB); | 1858 GL_INNOCENT_CONTEXT_RESET_ARB); |
1813 } | 1859 } |
1814 return texture_; | 1860 return texture_; |
1815 } | 1861 } |
1816 | 1862 |
1817 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 1863 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
1818 return texture_context_.get(); | 1864 return texture_context_.get(); |
1819 } | 1865 } |
1820 | 1866 |
1821 virtual bool PrepareTextureMailbox( | 1867 virtual bool PrepareTextureMailbox( |
1822 cc::TextureMailbox* mailbox, bool use_shared_memory) OVERRIDE { | 1868 TextureMailbox* mailbox, |
1869 scoped_ptr<ScopedReleaseCallback>* release_callback, | |
1870 bool use_shared_memory) OVERRIDE { | |
1823 return false; | 1871 return false; |
1824 } | 1872 } |
1825 | 1873 |
1826 virtual void SetupTree() OVERRIDE { | 1874 virtual void SetupTree() OVERRIDE { |
1827 scoped_refptr<Layer> root = Layer::Create(); | 1875 scoped_refptr<Layer> root = Layer::Create(); |
1828 root->SetBounds(gfx::Size(10, 10)); | 1876 root->SetBounds(gfx::Size(10, 10)); |
1829 root->SetIsDrawable(true); | 1877 root->SetIsDrawable(true); |
1830 | 1878 |
1831 texture_layer_ = TextureLayer::Create(this); | 1879 texture_layer_ = TextureLayer::Create(this); |
1832 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1880 texture_layer_->SetBounds(gfx::Size(10, 10)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1873 public: | 1921 public: |
1874 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 1922 void ReleaseCallback(unsigned sync_point, bool lost_resource) { |
1875 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1923 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1876 EXPECT_FALSE(lost_resource); | 1924 EXPECT_FALSE(lost_resource); |
1877 ++callback_count_; | 1925 ++callback_count_; |
1878 EndTest(); | 1926 EndTest(); |
1879 } | 1927 } |
1880 | 1928 |
1881 void SetMailbox(char mailbox_char) { | 1929 void SetMailbox(char mailbox_char) { |
1882 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1930 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1883 TextureMailbox mailbox( | 1931 TextureMailbox mailbox(std::string(64, mailbox_char)); |
1884 std::string(64, mailbox_char), | 1932 scoped_ptr<ScopedReleaseCallback> callback = ScopedReleaseCallback::Create( |
1885 base::Bind( | 1933 base::Bind( |
1886 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 1934 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
1887 base::Unretained(this))); | 1935 base::Unretained(this))); |
1888 layer_->SetTextureMailbox(mailbox); | 1936 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
1889 } | 1937 } |
1890 | 1938 |
1891 virtual void SetupTree() OVERRIDE { | 1939 virtual void SetupTree() OVERRIDE { |
1892 gfx::Size bounds(100, 100); | 1940 gfx::Size bounds(100, 100); |
1893 root_ = Layer::Create(); | 1941 root_ = Layer::Create(); |
1894 root_->SetAnchorPoint(gfx::PointF()); | 1942 root_->SetAnchorPoint(gfx::PointF()); |
1895 root_->SetBounds(bounds); | 1943 root_->SetBounds(bounds); |
1896 | 1944 |
1897 layer_ = TextureLayer::CreateForMailbox(NULL); | 1945 layer_ = TextureLayer::CreateForMailbox(NULL); |
1898 layer_->SetIsDrawable(true); | 1946 layer_->SetIsDrawable(true); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1945 public: | 1993 public: |
1946 void ReleaseCallback(unsigned sync_point, bool lost_resource) { | 1994 void ReleaseCallback(unsigned sync_point, bool lost_resource) { |
1947 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1995 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1948 EXPECT_FALSE(lost_resource); | 1996 EXPECT_FALSE(lost_resource); |
1949 ++callback_count_; | 1997 ++callback_count_; |
1950 EndTest(); | 1998 EndTest(); |
1951 } | 1999 } |
1952 | 2000 |
1953 void SetMailbox(char mailbox_char) { | 2001 void SetMailbox(char mailbox_char) { |
1954 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 2002 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1955 TextureMailbox mailbox( | 2003 TextureMailbox mailbox(std::string(64, mailbox_char)); |
1956 std::string(64, mailbox_char), | 2004 scoped_ptr<ScopedReleaseCallback> callback = ScopedReleaseCallback::Create( |
1957 base::Bind( | 2005 base::Bind( |
1958 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 2006 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
1959 base::Unretained(this))); | 2007 base::Unretained(this))); |
1960 layer_->SetTextureMailbox(mailbox); | 2008 layer_->SetTextureMailbox(mailbox, callback.Pass()); |
1961 } | 2009 } |
1962 | 2010 |
1963 virtual void SetupTree() OVERRIDE { | 2011 virtual void SetupTree() OVERRIDE { |
1964 gfx::Size bounds(100, 100); | 2012 gfx::Size bounds(100, 100); |
1965 root_ = Layer::Create(); | 2013 root_ = Layer::Create(); |
1966 root_->SetAnchorPoint(gfx::PointF()); | 2014 root_->SetAnchorPoint(gfx::PointF()); |
1967 root_->SetBounds(bounds); | 2015 root_->SetBounds(bounds); |
1968 | 2016 |
1969 layer_ = TextureLayer::CreateForMailbox(NULL); | 2017 layer_ = TextureLayer::CreateForMailbox(NULL); |
1970 layer_->SetIsDrawable(true); | 2018 layer_->SetIsDrawable(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2011 int callback_count_; | 2059 int callback_count_; |
2012 scoped_refptr<Layer> root_; | 2060 scoped_refptr<Layer> root_; |
2013 scoped_refptr<TextureLayer> layer_; | 2061 scoped_refptr<TextureLayer> layer_; |
2014 }; | 2062 }; |
2015 | 2063 |
2016 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2064 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
2017 TextureLayerWithMailboxImplThreadDeleted); | 2065 TextureLayerWithMailboxImplThreadDeleted); |
2018 | 2066 |
2019 } // namespace | 2067 } // namespace |
2020 } // namespace cc | 2068 } // namespace cc |
OLD | NEW |