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

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 1608303002: Removed OLD_SYNC_POINT sync token namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cc_perftests, formatted Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 namespace cc { 51 namespace cc {
52 namespace { 52 namespace {
53 53
54 gpu::Mailbox MailboxFromChar(char value) { 54 gpu::Mailbox MailboxFromChar(char value) {
55 gpu::Mailbox mailbox; 55 gpu::Mailbox mailbox;
56 memset(mailbox.name, value, sizeof(mailbox.name)); 56 memset(mailbox.name, value, sizeof(mailbox.name));
57 return mailbox; 57 return mailbox;
58 } 58 }
59 59
60 gpu::SyncToken SyncTokenFromUInt(uint32_t value) {
61 return gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0, 0x123, value);
62 }
63
60 class MockLayerTreeHost : public LayerTreeHost { 64 class MockLayerTreeHost : public LayerTreeHost {
61 public: 65 public:
62 static scoped_ptr<MockLayerTreeHost> Create( 66 static scoped_ptr<MockLayerTreeHost> Create(
63 FakeLayerTreeHostClient* client, 67 FakeLayerTreeHostClient* client,
64 TaskGraphRunner* task_graph_runner) { 68 TaskGraphRunner* task_graph_runner) {
65 LayerTreeHost::InitParams params; 69 LayerTreeHost::InitParams params;
66 params.client = client; 70 params.client = client;
67 params.task_graph_runner = task_graph_runner; 71 params.task_graph_runner = task_graph_runner;
68 LayerTreeSettings settings; 72 LayerTreeSettings settings;
69 params.settings = &settings; 73 params.settings = &settings;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void(SharedBitmap* shared_bitmap, 138 void(SharedBitmap* shared_bitmap,
135 const gpu::SyncToken& sync_token, 139 const gpu::SyncToken& sync_token,
136 bool lost_resource, 140 bool lost_resource,
137 BlockingTaskRunner* main_thread_task_runner)); 141 BlockingTaskRunner* main_thread_task_runner));
138 }; 142 };
139 143
140 struct CommonMailboxObjects { 144 struct CommonMailboxObjects {
141 explicit CommonMailboxObjects(SharedBitmapManager* manager) 145 explicit CommonMailboxObjects(SharedBitmapManager* manager)
142 : mailbox_name1_(MailboxFromChar('1')), 146 : mailbox_name1_(MailboxFromChar('1')),
143 mailbox_name2_(MailboxFromChar('2')), 147 mailbox_name2_(MailboxFromChar('2')),
144 sync_token1_(1), 148 sync_token1_(gpu::CommandBufferNamespace::GPU_IO, 123, 0x234, 1),
145 sync_token2_(2) { 149 sync_token2_(gpu::CommandBufferNamespace::GPU_IO, 123, 0x234, 2) {
146 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, 150 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release,
147 base::Unretained(&mock_callback_), 151 base::Unretained(&mock_callback_),
148 mailbox_name1_); 152 mailbox_name1_);
149 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, 153 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release,
150 base::Unretained(&mock_callback_), 154 base::Unretained(&mock_callback_),
151 mailbox_name2_); 155 mailbox_name2_);
152 release_mailbox1_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl, 156 release_mailbox1_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
153 base::Unretained(&mock_callback_), 157 base::Unretained(&mock_callback_),
154 mailbox_name1_); 158 mailbox_name1_);
155 release_mailbox2_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl, 159 release_mailbox2_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 test_data_.mailbox1_, 324 test_data_.mailbox1_,
321 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 325 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
322 } 326 }
323 327
324 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { 328 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) {
325 scoped_refptr<TextureLayer> test_layer = 329 scoped_refptr<TextureLayer> test_layer =
326 TextureLayer::CreateForMailbox(layer_settings_, nullptr); 330 TextureLayer::CreateForMailbox(layer_settings_, nullptr);
327 ASSERT_TRUE(test_layer.get()); 331 ASSERT_TRUE(test_layer.get());
328 332
329 // These use the same gpu::Mailbox, but different sync points. 333 // These use the same gpu::Mailbox, but different sync points.
330 TextureMailbox mailbox1(MailboxFromChar('a'), gpu::SyncToken(1), 334 TextureMailbox mailbox1(MailboxFromChar('a'), SyncTokenFromUInt(1),
331 GL_TEXTURE_2D); 335 GL_TEXTURE_2D);
332 TextureMailbox mailbox2(MailboxFromChar('a'), gpu::SyncToken(2), 336 TextureMailbox mailbox2(MailboxFromChar('a'), SyncTokenFromUInt(2),
333 GL_TEXTURE_2D); 337 GL_TEXTURE_2D);
334 338
335 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 339 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
336 layer_tree_host_->SetRootLayer(test_layer); 340 layer_tree_host_->SetRootLayer(test_layer);
337 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 341 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
338 342
339 // Set the mailbox the first time. It should cause a commit. 343 // Set the mailbox the first time. It should cause a commit.
340 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 344 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
341 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1); 345 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1);
342 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 346 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 430 scoped_ptr<SingleReleaseCallbackImpl> compositor2;
427 main_thread_.message_loop()->task_runner()->PostTask( 431 main_thread_.message_loop()->task_runner()->PostTask(
428 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 432 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
429 base::Unretained(this), &compositor2)); 433 base::Unretained(this), &compositor2));
430 434
431 Wait(main_thread_); 435 Wait(main_thread_);
432 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 436 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
433 437
434 // The compositors both destroy their impl trees before the main thread layer 438 // The compositors both destroy their impl trees before the main thread layer
435 // is destroyed. 439 // is destroyed.
436 compositor1->Run(gpu::SyncToken(100), false, main_thread_task_runner_.get()); 440 compositor1->Run(SyncTokenFromUInt(100), false,
437 compositor2->Run(gpu::SyncToken(200), false, main_thread_task_runner_.get()); 441 main_thread_task_runner_.get());
442 compositor2->Run(SyncTokenFromUInt(200), false,
443 main_thread_task_runner_.get());
438 444
439 Wait(main_thread_); 445 Wait(main_thread_);
440 446
441 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); 447 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
442 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 448 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
443 449
444 // The main thread ref is the last one, so the mailbox is released back to the 450 // The main thread ref is the last one, so the mailbox is released back to the
445 // embedder, with the last sync point provided by the impl trees. 451 // embedder, with the last sync point provided by the impl trees.
446 EXPECT_CALL(test_data_.mock_callback_, 452 EXPECT_CALL(test_data_.mock_callback_,
447 Release(test_data_.mailbox_name1_, gpu::SyncToken(200), false)) 453 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), false))
448 .Times(1); 454 .Times(1);
449 455
450 main_thread_.message_loop()->task_runner()->PostTask( 456 main_thread_.message_loop()->task_runner()->PostTask(
451 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 457 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
452 base::Unretained(this))); 458 base::Unretained(this)));
453 Wait(main_thread_); 459 Wait(main_thread_);
454 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 460 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
455 } 461 }
456 462
457 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { 463 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) {
(...skipping 18 matching lines...) Expand all
476 // reference to its impl tree. 482 // reference to its impl tree.
477 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 483 scoped_ptr<SingleReleaseCallbackImpl> compositor2;
478 main_thread_.message_loop()->task_runner()->PostTask( 484 main_thread_.message_loop()->task_runner()->PostTask(
479 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 485 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
480 base::Unretained(this), &compositor2)); 486 base::Unretained(this), &compositor2));
481 487
482 Wait(main_thread_); 488 Wait(main_thread_);
483 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 489 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
484 490
485 // One compositor destroys their impl tree. 491 // One compositor destroys their impl tree.
486 compositor1->Run(gpu::SyncToken(100), false, main_thread_task_runner_.get()); 492 compositor1->Run(SyncTokenFromUInt(100), false,
493 main_thread_task_runner_.get());
487 494
488 // Then the main thread reference is destroyed. 495 // Then the main thread reference is destroyed.
489 main_thread_.message_loop()->task_runner()->PostTask( 496 main_thread_.message_loop()->task_runner()->PostTask(
490 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 497 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
491 base::Unretained(this))); 498 base::Unretained(this)));
492 499
493 Wait(main_thread_); 500 Wait(main_thread_);
494 501
495 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); 502 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
496 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 503 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
497 504
498 // The second impl reference is destroyed last, causing the mailbox to be 505 // The second impl reference is destroyed last, causing the mailbox to be
499 // released back to the embedder with the last sync point from the impl tree. 506 // released back to the embedder with the last sync point from the impl tree.
500 EXPECT_CALL(test_data_.mock_callback_, 507 EXPECT_CALL(test_data_.mock_callback_,
501 Release(test_data_.mailbox_name1_, gpu::SyncToken(200), true)) 508 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true))
502 .Times(1); 509 .Times(1);
503 510
504 compositor2->Run(gpu::SyncToken(200), true, main_thread_task_runner_.get()); 511 compositor2->Run(SyncTokenFromUInt(200), true,
512 main_thread_task_runner_.get());
505 Wait(main_thread_); 513 Wait(main_thread_);
506 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 514 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
507 } 515 }
508 516
509 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { 517 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) {
510 scoped_refptr<TextureLayer> test_layer = 518 scoped_refptr<TextureLayer> test_layer =
511 TextureLayer::CreateForMailbox(layer_settings_, nullptr); 519 TextureLayer::CreateForMailbox(layer_settings_, nullptr);
512 ASSERT_TRUE(test_layer.get()); 520 ASSERT_TRUE(test_layer.get());
513 521
514 main_thread_.message_loop()->task_runner()->PostTask( 522 main_thread_.message_loop()->task_runner()->PostTask(
(...skipping 18 matching lines...) Expand all
533 541
534 Wait(main_thread_); 542 Wait(main_thread_);
535 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 543 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
536 544
537 // The main thread reference is destroyed first. 545 // The main thread reference is destroyed first.
538 main_thread_.message_loop()->task_runner()->PostTask( 546 main_thread_.message_loop()->task_runner()->PostTask(
539 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 547 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
540 base::Unretained(this))); 548 base::Unretained(this)));
541 549
542 // One compositor destroys their impl tree. 550 // One compositor destroys their impl tree.
543 compositor2->Run(gpu::SyncToken(200), false, main_thread_task_runner_.get()); 551 compositor2->Run(SyncTokenFromUInt(200), false,
552 main_thread_task_runner_.get());
544 553
545 Wait(main_thread_); 554 Wait(main_thread_);
546 555
547 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); 556 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
548 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 557 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
549 558
550 // The second impl reference is destroyed last, causing the mailbox to be 559 // The second impl reference is destroyed last, causing the mailbox to be
551 // released back to the embedder with the last sync point from the impl tree. 560 // released back to the embedder with the last sync point from the impl tree.
552 EXPECT_CALL(test_data_.mock_callback_, 561 EXPECT_CALL(test_data_.mock_callback_,
553 Release(test_data_.mailbox_name1_, gpu::SyncToken(100), true)) 562 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(100), true))
554 .Times(1); 563 .Times(1);
555 564
556 compositor1->Run(gpu::SyncToken(100), true, main_thread_task_runner_.get()); 565 compositor1->Run(SyncTokenFromUInt(100), true,
566 main_thread_task_runner_.get());
557 Wait(main_thread_); 567 Wait(main_thread_);
558 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 568 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
559 } 569 }
560 570
561 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { 571 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) {
562 scoped_refptr<TextureLayer> test_layer = 572 scoped_refptr<TextureLayer> test_layer =
563 TextureLayer::CreateForMailbox(layer_settings_, nullptr); 573 TextureLayer::CreateForMailbox(layer_settings_, nullptr);
564 ASSERT_TRUE(test_layer.get()); 574 ASSERT_TRUE(test_layer.get());
565 575
566 main_thread_.message_loop()->task_runner()->PostTask( 576 main_thread_.message_loop()->task_runner()->PostTask(
(...skipping 18 matching lines...) Expand all
585 595
586 Wait(main_thread_); 596 Wait(main_thread_);
587 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 597 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
588 598
589 // The main thread reference is destroyed first. 599 // The main thread reference is destroyed first.
590 main_thread_.message_loop()->task_runner()->PostTask( 600 main_thread_.message_loop()->task_runner()->PostTask(
591 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 601 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
592 base::Unretained(this))); 602 base::Unretained(this)));
593 603
594 EXPECT_CALL(test_data_.mock_callback_, 604 EXPECT_CALL(test_data_.mock_callback_,
595 Release(test_data_.mailbox_name1_, gpu::SyncToken(200), true)) 605 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true))
596 .Times(1); 606 .Times(1);
597 607
598 bool manual_reset = false; 608 bool manual_reset = false;
599 bool initially_signaled = false; 609 bool initially_signaled = false;
600 base::WaitableEvent begin_capture(manual_reset, initially_signaled); 610 base::WaitableEvent begin_capture(manual_reset, initially_signaled);
601 base::WaitableEvent wait_for_capture(manual_reset, initially_signaled); 611 base::WaitableEvent wait_for_capture(manual_reset, initially_signaled);
602 base::WaitableEvent stop_capture(manual_reset, initially_signaled); 612 base::WaitableEvent stop_capture(manual_reset, initially_signaled);
603 613
604 // Post a task to start capturing tasks on the main thread. This will block 614 // Post a task to start capturing tasks on the main thread. This will block
605 // the main thread until we signal the |stop_capture| event. 615 // the main thread until we signal the |stop_capture| event.
606 main_thread_.message_loop()->task_runner()->PostTask( 616 main_thread_.message_loop()->task_runner()->PostTask(
607 FROM_HERE, 617 FROM_HERE,
608 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, 618 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait,
609 base::Unretained(this), &begin_capture, &wait_for_capture, 619 base::Unretained(this), &begin_capture, &wait_for_capture,
610 &stop_capture)); 620 &stop_capture));
611 621
612 // Before the main thread capturing starts, one compositor destroys their 622 // Before the main thread capturing starts, one compositor destroys their
613 // impl reference. Since capturing did not start, this gets post-tasked to 623 // impl reference. Since capturing did not start, this gets post-tasked to
614 // the main thread. 624 // the main thread.
615 compositor1->Run(gpu::SyncToken(100), false, main_thread_task_runner_.get()); 625 compositor1->Run(SyncTokenFromUInt(100), false,
626 main_thread_task_runner_.get());
616 627
617 // Start capturing on the main thread. 628 // Start capturing on the main thread.
618 begin_capture.Signal(); 629 begin_capture.Signal();
619 wait_for_capture.Wait(); 630 wait_for_capture.Wait();
620 631
621 // Meanwhile, the second compositor released its impl reference, but this task 632 // Meanwhile, the second compositor released its impl reference, but this task
622 // gets shortcutted directly to the main thread. This means the reference is 633 // gets shortcutted directly to the main thread. This means the reference is
623 // released before compositor1, whose reference will be released later when 634 // released before compositor1, whose reference will be released later when
624 // the post-task is serviced. But since it was destroyed _on the impl thread_ 635 // the post-task is serviced. But since it was destroyed _on the impl thread_
625 // last, its sync point values should be used. 636 // last, its sync point values should be used.
626 compositor2->Run(gpu::SyncToken(200), true, main_thread_task_runner_.get()); 637 compositor2->Run(SyncTokenFromUInt(200), true,
638 main_thread_task_runner_.get());
627 639
628 stop_capture.Signal(); 640 stop_capture.Signal();
629 Wait(main_thread_); 641 Wait(main_thread_);
630 642
631 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 643 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
632 } 644 }
633 645
634 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { 646 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
635 public: 647 public:
636 TextureLayerImplWithMailboxThreadedCallback() 648 TextureLayerImplWithMailboxThreadedCallback()
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 int callback_count_; 1487 int callback_count_;
1476 scoped_refptr<Layer> root_; 1488 scoped_refptr<Layer> root_;
1477 scoped_refptr<TextureLayer> layer_; 1489 scoped_refptr<TextureLayer> layer_;
1478 }; 1490 };
1479 1491
1480 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1492 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1481 TextureLayerWithMailboxImplThreadDeleted); 1493 TextureLayerWithMailboxImplThreadDeleted);
1482 1494
1483 } // namespace 1495 } // namespace
1484 } // namespace cc 1496 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698