| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 TextureLayerMailboxHolderTest() | 340 TextureLayerMailboxHolderTest() |
| 341 : main_thread_("MAIN") { | 341 : main_thread_("MAIN") { |
| 342 main_thread_.Start(); | 342 main_thread_.Start(); |
| 343 main_thread_.message_loop()->task_runner()->PostTask( | 343 main_thread_.message_loop()->task_runner()->PostTask( |
| 344 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain, | 344 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain, |
| 345 base::Unretained(this))); | 345 base::Unretained(this))); |
| 346 Wait(main_thread_); | 346 Wait(main_thread_); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void Wait(const base::Thread& thread) { | 349 void Wait(const base::Thread& thread) { |
| 350 bool manual_reset = false; | 350 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 351 bool initially_signaled = false; | 351 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 352 base::WaitableEvent event(manual_reset, initially_signaled); | |
| 353 thread.message_loop()->task_runner()->PostTask( | 352 thread.message_loop()->task_runner()->PostTask( |
| 354 FROM_HERE, | 353 FROM_HERE, |
| 355 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); | 354 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); |
| 356 event.Wait(); | 355 event.Wait(); |
| 357 } | 356 } |
| 358 | 357 |
| 359 void CreateMainRef() { | 358 void CreateMainRef() { |
| 360 main_ref_ = TestMailboxHolder::Create( | 359 main_ref_ = TestMailboxHolder::Create( |
| 361 test_data_.mailbox1_, | 360 test_data_.mailbox1_, |
| 362 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 361 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 579 |
| 581 // The main thread reference is destroyed first. | 580 // The main thread reference is destroyed first. |
| 582 main_thread_.message_loop()->task_runner()->PostTask( | 581 main_thread_.message_loop()->task_runner()->PostTask( |
| 583 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 582 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
| 584 base::Unretained(this))); | 583 base::Unretained(this))); |
| 585 | 584 |
| 586 EXPECT_CALL(test_data_.mock_callback_, | 585 EXPECT_CALL(test_data_.mock_callback_, |
| 587 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true)) | 586 Release(test_data_.mailbox_name1_, SyncTokenFromUInt(200), true)) |
| 588 .Times(1); | 587 .Times(1); |
| 589 | 588 |
| 590 bool manual_reset = false; | 589 base::WaitableEvent begin_capture( |
| 591 bool initially_signaled = false; | 590 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 592 base::WaitableEvent begin_capture(manual_reset, initially_signaled); | 591 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 593 base::WaitableEvent wait_for_capture(manual_reset, initially_signaled); | 592 base::WaitableEvent wait_for_capture( |
| 594 base::WaitableEvent stop_capture(manual_reset, initially_signaled); | 593 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 594 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 595 base::WaitableEvent stop_capture( |
| 596 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 597 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 595 | 598 |
| 596 // Post a task to start capturing tasks on the main thread. This will block | 599 // Post a task to start capturing tasks on the main thread. This will block |
| 597 // the main thread until we signal the |stop_capture| event. | 600 // the main thread until we signal the |stop_capture| event. |
| 598 main_thread_.message_loop()->task_runner()->PostTask( | 601 main_thread_.message_loop()->task_runner()->PostTask( |
| 599 FROM_HERE, | 602 FROM_HERE, |
| 600 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, | 603 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, |
| 601 base::Unretained(this), &begin_capture, &wait_for_capture, | 604 base::Unretained(this), &begin_capture, &wait_for_capture, |
| 602 &stop_capture)); | 605 &stop_capture)); |
| 603 | 606 |
| 604 // Before the main thread capturing starts, one compositor destroys their | 607 // Before the main thread capturing starts, one compositor destroys their |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 int callback_count_; | 1489 int callback_count_; |
| 1487 scoped_refptr<Layer> root_; | 1490 scoped_refptr<Layer> root_; |
| 1488 scoped_refptr<TextureLayer> layer_; | 1491 scoped_refptr<TextureLayer> layer_; |
| 1489 }; | 1492 }; |
| 1490 | 1493 |
| 1491 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1494 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1492 TextureLayerWithMailboxImplThreadDeleted); | 1495 TextureLayerWithMailboxImplThreadDeleted); |
| 1493 | 1496 |
| 1494 } // namespace | 1497 } // namespace |
| 1495 } // namespace cc | 1498 } // namespace cc |
| OLD | NEW |