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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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 | « cc/layers/texture_layer_impl.cc ('k') | cc/layers/ui_resource_layer.h » ('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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h"
17 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
18 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
19 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
20 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
21 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
22 #include "base/time/time.h" 23 #include "base/time/time.h"
23 #include "cc/layers/solid_color_layer.h" 24 #include "cc/layers/solid_color_layer.h"
24 #include "cc/layers/texture_layer_client.h" 25 #include "cc/layers/texture_layer_client.h"
25 #include "cc/layers/texture_layer_impl.h" 26 #include "cc/layers/texture_layer_impl.h"
26 #include "cc/output/compositor_frame_ack.h" 27 #include "cc/output/compositor_frame_ack.h"
(...skipping 30 matching lines...) Expand all
57 return mailbox; 58 return mailbox;
58 } 59 }
59 60
60 gpu::SyncToken SyncTokenFromUInt(uint32_t value) { 61 gpu::SyncToken SyncTokenFromUInt(uint32_t value) {
61 return gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0, 62 return gpu::SyncToken(gpu::CommandBufferNamespace::GPU_IO, 0,
62 gpu::CommandBufferId::FromUnsafeValue(0x123), value); 63 gpu::CommandBufferId::FromUnsafeValue(0x123), value);
63 } 64 }
64 65
65 class MockLayerTreeHost : public LayerTreeHost { 66 class MockLayerTreeHost : public LayerTreeHost {
66 public: 67 public:
67 static scoped_ptr<MockLayerTreeHost> Create( 68 static std::unique_ptr<MockLayerTreeHost> Create(
68 FakeLayerTreeHostClient* client, 69 FakeLayerTreeHostClient* client,
69 TaskGraphRunner* task_graph_runner) { 70 TaskGraphRunner* task_graph_runner) {
70 LayerTreeHost::InitParams params; 71 LayerTreeHost::InitParams params;
71 params.client = client; 72 params.client = client;
72 params.task_graph_runner = task_graph_runner; 73 params.task_graph_runner = task_graph_runner;
73 LayerTreeSettings settings; 74 LayerTreeSettings settings;
74 params.settings = &settings; 75 params.settings = &settings;
75 return make_scoped_ptr(new MockLayerTreeHost(client, &params)); 76 return base::WrapUnique(new MockLayerTreeHost(client, &params));
76 } 77 }
77 78
78 MOCK_METHOD0(SetNeedsCommit, void()); 79 MOCK_METHOD0(SetNeedsCommit, void());
79 MOCK_METHOD0(SetNeedsUpdateLayers, void()); 80 MOCK_METHOD0(SetNeedsUpdateLayers, void());
80 MOCK_METHOD0(StartRateLimiter, void()); 81 MOCK_METHOD0(StartRateLimiter, void());
81 MOCK_METHOD0(StopRateLimiter, void()); 82 MOCK_METHOD0(StopRateLimiter, void());
82 83
83 private: 84 private:
84 MockLayerTreeHost(FakeLayerTreeHostClient* client, 85 MockLayerTreeHost(FakeLayerTreeHostClient* client,
85 LayerTreeHost::InitParams* params) 86 LayerTreeHost::InitParams* params)
86 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) { 87 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) {
87 InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(), 88 InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(),
88 nullptr); 89 nullptr);
89 } 90 }
90 }; 91 };
91 92
92 class FakeTextureLayerClient : public TextureLayerClient { 93 class FakeTextureLayerClient : public TextureLayerClient {
93 public: 94 public:
94 FakeTextureLayerClient() : mailbox_changed_(true) {} 95 FakeTextureLayerClient() : mailbox_changed_(true) {}
95 96
96 bool PrepareTextureMailbox( 97 bool PrepareTextureMailbox(
97 TextureMailbox* mailbox, 98 TextureMailbox* mailbox,
98 scoped_ptr<SingleReleaseCallback>* release_callback, 99 std::unique_ptr<SingleReleaseCallback>* release_callback,
99 bool use_shared_memory) override { 100 bool use_shared_memory) override {
100 if (!mailbox_changed_) 101 if (!mailbox_changed_)
101 return false; 102 return false;
102 103
103 *mailbox = mailbox_; 104 *mailbox = mailbox_;
104 *release_callback = std::move(release_callback_); 105 *release_callback = std::move(release_callback_);
105 mailbox_changed_ = false; 106 mailbox_changed_ = false;
106 return true; 107 return true;
107 } 108 }
108 109
109 void set_mailbox(const TextureMailbox& mailbox, 110 void set_mailbox(const TextureMailbox& mailbox,
110 scoped_ptr<SingleReleaseCallback> release_callback) { 111 std::unique_ptr<SingleReleaseCallback> release_callback) {
111 mailbox_ = mailbox; 112 mailbox_ = mailbox;
112 release_callback_ = std::move(release_callback); 113 release_callback_ = std::move(release_callback);
113 mailbox_changed_ = true; 114 mailbox_changed_ = true;
114 } 115 }
115 116
116 private: 117 private:
117 TextureMailbox mailbox_; 118 TextureMailbox mailbox_;
118 scoped_ptr<SingleReleaseCallback> release_callback_; 119 std::unique_ptr<SingleReleaseCallback> release_callback_;
119 bool mailbox_changed_; 120 bool mailbox_changed_;
120 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); 121 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
121 }; 122 };
122 123
123 class MockMailboxCallback { 124 class MockMailboxCallback {
124 public: 125 public:
125 MOCK_METHOD3(Release, 126 MOCK_METHOD3(Release,
126 void(const gpu::Mailbox& mailbox, 127 void(const gpu::Mailbox& mailbox,
127 const gpu::SyncToken& sync_token, 128 const gpu::SyncToken& sync_token,
128 bool lost_resource)); 129 bool lost_resource));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ReleaseCallback release_mailbox2_; 190 ReleaseCallback release_mailbox2_;
190 ReleaseCallback release_mailbox3_; 191 ReleaseCallback release_mailbox3_;
191 ReleaseCallbackImpl release_mailbox1_impl_; 192 ReleaseCallbackImpl release_mailbox1_impl_;
192 ReleaseCallbackImpl release_mailbox2_impl_; 193 ReleaseCallbackImpl release_mailbox2_impl_;
193 ReleaseCallbackImpl release_mailbox3_impl_; 194 ReleaseCallbackImpl release_mailbox3_impl_;
194 TextureMailbox mailbox1_; 195 TextureMailbox mailbox1_;
195 TextureMailbox mailbox2_; 196 TextureMailbox mailbox2_;
196 TextureMailbox mailbox3_; 197 TextureMailbox mailbox3_;
197 gpu::SyncToken sync_token1_; 198 gpu::SyncToken sync_token1_;
198 gpu::SyncToken sync_token2_; 199 gpu::SyncToken sync_token2_;
199 scoped_ptr<SharedBitmap> shared_bitmap_; 200 std::unique_ptr<SharedBitmap> shared_bitmap_;
200 }; 201 };
201 202
202 class TextureLayerTest : public testing::Test { 203 class TextureLayerTest : public testing::Test {
203 public: 204 public:
204 TextureLayerTest() 205 TextureLayerTest()
205 : fake_client_( 206 : fake_client_(
206 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), 207 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)),
207 output_surface_(FakeOutputSurface::Create3d()), 208 output_surface_(FakeOutputSurface::Create3d()),
208 host_impl_(&task_runner_provider_, 209 host_impl_(&task_runner_provider_,
209 &shared_bitmap_manager_, 210 &shared_bitmap_manager_,
(...skipping 10 matching lines...) Expand all
220 } 221 }
221 222
222 void TearDown() override { 223 void TearDown() override {
223 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 224 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
224 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 225 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
225 226
226 layer_tree_host_->SetRootLayer(nullptr); 227 layer_tree_host_->SetRootLayer(nullptr);
227 layer_tree_host_ = nullptr; 228 layer_tree_host_ = nullptr;
228 } 229 }
229 230
230 scoped_ptr<MockLayerTreeHost> layer_tree_host_; 231 std::unique_ptr<MockLayerTreeHost> layer_tree_host_;
231 FakeImplTaskRunnerProvider task_runner_provider_; 232 FakeImplTaskRunnerProvider task_runner_provider_;
232 FakeLayerTreeHostClient fake_client_; 233 FakeLayerTreeHostClient fake_client_;
233 TestSharedBitmapManager shared_bitmap_manager_; 234 TestSharedBitmapManager shared_bitmap_manager_;
234 TestTaskGraphRunner task_graph_runner_; 235 TestTaskGraphRunner task_graph_runner_;
235 scoped_ptr<OutputSurface> output_surface_; 236 std::unique_ptr<OutputSurface> output_surface_;
236 FakeLayerTreeHostImpl host_impl_; 237 FakeLayerTreeHostImpl host_impl_;
237 CommonMailboxObjects test_data_; 238 CommonMailboxObjects test_data_;
238 }; 239 };
239 240
240 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { 241 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) {
241 scoped_refptr<TextureLayer> test_layer = 242 scoped_refptr<TextureLayer> test_layer =
242 TextureLayer::CreateForMailbox(nullptr); 243 TextureLayer::CreateForMailbox(nullptr);
243 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); 244 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer));
244 245
245 // Test properties that should call SetNeedsCommit. All properties need to 246 // Test properties that should call SetNeedsCommit. All properties need to
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 381 }
381 382
382 void CreateMainRef() { 383 void CreateMainRef() {
383 main_ref_ = TestMailboxHolder::Create( 384 main_ref_ = TestMailboxHolder::Create(
384 test_data_.mailbox1_, 385 test_data_.mailbox1_,
385 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 386 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
386 } 387 }
387 388
388 void ReleaseMainRef() { main_ref_ = nullptr; } 389 void ReleaseMainRef() { main_ref_ = nullptr; }
389 390
390 void CreateImplRef(scoped_ptr<SingleReleaseCallbackImpl>* impl_ref) { 391 void CreateImplRef(std::unique_ptr<SingleReleaseCallbackImpl>* impl_ref) {
391 *impl_ref = main_ref_->holder()->GetCallbackForImplThread(); 392 *impl_ref = main_ref_->holder()->GetCallbackForImplThread();
392 } 393 }
393 394
394 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture, 395 void CapturePostTasksAndWait(base::WaitableEvent* begin_capture,
395 base::WaitableEvent* wait_for_capture, 396 base::WaitableEvent* wait_for_capture,
396 base::WaitableEvent* stop_capture) { 397 base::WaitableEvent* stop_capture) {
397 begin_capture->Wait(); 398 begin_capture->Wait();
398 BlockingTaskRunner::CapturePostTasks capture( 399 BlockingTaskRunner::CapturePostTasks capture(
399 main_thread_task_runner_.get()); 400 main_thread_task_runner_.get());
400 wait_for_capture->Signal(); 401 wait_for_capture->Signal();
401 stop_capture->Wait(); 402 stop_capture->Wait();
402 } 403 }
403 404
404 protected: 405 protected:
405 void InitializeOnMain() { 406 void InitializeOnMain() {
406 main_thread_task_runner_ = 407 main_thread_task_runner_ =
407 BlockingTaskRunner::Create(main_thread_.task_runner()); 408 BlockingTaskRunner::Create(main_thread_.task_runner());
408 } 409 }
409 410
410 scoped_ptr<TestMailboxHolder::MainThreadReference> 411 std::unique_ptr<TestMailboxHolder::MainThreadReference> main_ref_;
411 main_ref_;
412 base::Thread main_thread_; 412 base::Thread main_thread_;
413 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; 413 std::unique_ptr<BlockingTaskRunner> main_thread_task_runner_;
414 }; 414 };
415 415
416 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { 416 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) {
417 scoped_refptr<TextureLayer> test_layer = 417 scoped_refptr<TextureLayer> test_layer =
418 TextureLayer::CreateForMailbox(nullptr); 418 TextureLayer::CreateForMailbox(nullptr);
419 ASSERT_TRUE(test_layer.get()); 419 ASSERT_TRUE(test_layer.get());
420 420
421 main_thread_.message_loop()->task_runner()->PostTask( 421 main_thread_.message_loop()->task_runner()->PostTask(
422 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, 422 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
423 base::Unretained(this))); 423 base::Unretained(this)));
424 424
425 Wait(main_thread_); 425 Wait(main_thread_);
426 426
427 // The texture layer is attached to compositor1, and passes a reference to its 427 // The texture layer is attached to compositor1, and passes a reference to its
428 // impl tree. 428 // impl tree.
429 scoped_ptr<SingleReleaseCallbackImpl> compositor1; 429 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
430 main_thread_.message_loop()->task_runner()->PostTask( 430 main_thread_.message_loop()->task_runner()->PostTask(
431 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 431 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
432 base::Unretained(this), &compositor1)); 432 base::Unretained(this), &compositor1));
433 433
434 // Then the texture layer is removed and attached to compositor2, and passes a 434 // Then the texture layer is removed and attached to compositor2, and passes a
435 // reference to its impl tree. 435 // reference to its impl tree.
436 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 436 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
437 main_thread_.message_loop()->task_runner()->PostTask( 437 main_thread_.message_loop()->task_runner()->PostTask(
438 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 438 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
439 base::Unretained(this), &compositor2)); 439 base::Unretained(this), &compositor2));
440 440
441 Wait(main_thread_); 441 Wait(main_thread_);
442 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 442 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
443 443
444 // The compositors both destroy their impl trees before the main thread layer 444 // The compositors both destroy their impl trees before the main thread layer
445 // is destroyed. 445 // is destroyed.
446 compositor1->Run(SyncTokenFromUInt(100), false, 446 compositor1->Run(SyncTokenFromUInt(100), false,
(...skipping 25 matching lines...) Expand all
472 ASSERT_TRUE(test_layer.get()); 472 ASSERT_TRUE(test_layer.get());
473 473
474 main_thread_.message_loop()->task_runner()->PostTask( 474 main_thread_.message_loop()->task_runner()->PostTask(
475 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, 475 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
476 base::Unretained(this))); 476 base::Unretained(this)));
477 477
478 Wait(main_thread_); 478 Wait(main_thread_);
479 479
480 // The texture layer is attached to compositor1, and passes a reference to its 480 // The texture layer is attached to compositor1, and passes a reference to its
481 // impl tree. 481 // impl tree.
482 scoped_ptr<SingleReleaseCallbackImpl> compositor1; 482 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
483 main_thread_.message_loop()->task_runner()->PostTask( 483 main_thread_.message_loop()->task_runner()->PostTask(
484 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 484 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
485 base::Unretained(this), &compositor1)); 485 base::Unretained(this), &compositor1));
486 486
487 // Then the texture layer is removed and attached to compositor2, and passes a 487 // Then the texture layer is removed and attached to compositor2, and passes a
488 // reference to its impl tree. 488 // reference to its impl tree.
489 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 489 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
490 main_thread_.message_loop()->task_runner()->PostTask( 490 main_thread_.message_loop()->task_runner()->PostTask(
491 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 491 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
492 base::Unretained(this), &compositor2)); 492 base::Unretained(this), &compositor2));
493 493
494 Wait(main_thread_); 494 Wait(main_thread_);
495 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 495 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
496 496
497 // One compositor destroys their impl tree. 497 // One compositor destroys their impl tree.
498 compositor1->Run(SyncTokenFromUInt(100), false, 498 compositor1->Run(SyncTokenFromUInt(100), false,
499 main_thread_task_runner_.get()); 499 main_thread_task_runner_.get());
(...skipping 26 matching lines...) Expand all
526 ASSERT_TRUE(test_layer.get()); 526 ASSERT_TRUE(test_layer.get());
527 527
528 main_thread_.message_loop()->task_runner()->PostTask( 528 main_thread_.message_loop()->task_runner()->PostTask(
529 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, 529 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
530 base::Unretained(this))); 530 base::Unretained(this)));
531 531
532 Wait(main_thread_); 532 Wait(main_thread_);
533 533
534 // The texture layer is attached to compositor1, and passes a reference to its 534 // The texture layer is attached to compositor1, and passes a reference to its
535 // impl tree. 535 // impl tree.
536 scoped_ptr<SingleReleaseCallbackImpl> compositor1; 536 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
537 main_thread_.message_loop()->task_runner()->PostTask( 537 main_thread_.message_loop()->task_runner()->PostTask(
538 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 538 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
539 base::Unretained(this), &compositor1)); 539 base::Unretained(this), &compositor1));
540 540
541 // Then the texture layer is removed and attached to compositor2, and passes a 541 // Then the texture layer is removed and attached to compositor2, and passes a
542 // reference to its impl tree. 542 // reference to its impl tree.
543 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 543 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
544 main_thread_.message_loop()->task_runner()->PostTask( 544 main_thread_.message_loop()->task_runner()->PostTask(
545 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 545 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
546 base::Unretained(this), &compositor2)); 546 base::Unretained(this), &compositor2));
547 547
548 Wait(main_thread_); 548 Wait(main_thread_);
549 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 549 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
550 550
551 // The main thread reference is destroyed first. 551 // The main thread reference is destroyed first.
552 main_thread_.message_loop()->task_runner()->PostTask( 552 main_thread_.message_loop()->task_runner()->PostTask(
553 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 553 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
(...skipping 26 matching lines...) Expand all
580 ASSERT_TRUE(test_layer.get()); 580 ASSERT_TRUE(test_layer.get());
581 581
582 main_thread_.message_loop()->task_runner()->PostTask( 582 main_thread_.message_loop()->task_runner()->PostTask(
583 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, 583 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef,
584 base::Unretained(this))); 584 base::Unretained(this)));
585 585
586 Wait(main_thread_); 586 Wait(main_thread_);
587 587
588 // The texture layer is attached to compositor1, and passes a reference to its 588 // The texture layer is attached to compositor1, and passes a reference to its
589 // impl tree. 589 // impl tree.
590 scoped_ptr<SingleReleaseCallbackImpl> compositor1; 590 std::unique_ptr<SingleReleaseCallbackImpl> compositor1;
591 main_thread_.message_loop()->task_runner()->PostTask( 591 main_thread_.message_loop()->task_runner()->PostTask(
592 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 592 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
593 base::Unretained(this), &compositor1)); 593 base::Unretained(this), &compositor1));
594 594
595 // Then the texture layer is removed and attached to compositor2, and passes a 595 // Then the texture layer is removed and attached to compositor2, and passes a
596 // reference to its impl tree. 596 // reference to its impl tree.
597 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 597 std::unique_ptr<SingleReleaseCallbackImpl> compositor2;
598 main_thread_.message_loop()->task_runner()->PostTask( 598 main_thread_.message_loop()->task_runner()->PostTask(
599 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 599 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
600 base::Unretained(this), &compositor2)); 600 base::Unretained(this), &compositor2));
601 601
602 Wait(main_thread_); 602 Wait(main_thread_);
603 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 603 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
604 604
605 // The main thread reference is destroyed first. 605 // The main thread reference is destroyed first.
606 main_thread_.message_loop()->task_runner()->PostTask( 606 main_thread_.message_loop()->task_runner()->PostTask(
607 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 607 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 657
658 // Make sure callback is received on main and doesn't block the impl thread. 658 // Make sure callback is received on main and doesn't block the impl thread.
659 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) { 659 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
660 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 660 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
661 EXPECT_FALSE(lost_resource); 661 EXPECT_FALSE(lost_resource);
662 ++callback_count_; 662 ++callback_count_;
663 } 663 }
664 664
665 void SetMailbox(char mailbox_char) { 665 void SetMailbox(char mailbox_char) {
666 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 666 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
667 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 667 std::unique_ptr<SingleReleaseCallback> callback =
668 base::Bind( 668 SingleReleaseCallback::Create(base::Bind(
669 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, 669 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback,
670 base::Unretained(this))); 670 base::Unretained(this)));
671 layer_->SetTextureMailbox( 671 layer_->SetTextureMailbox(
672 TextureMailbox(MailboxFromChar(mailbox_char), 672 TextureMailbox(MailboxFromChar(mailbox_char),
673 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), 673 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
674 GL_TEXTURE_2D), 674 GL_TEXTURE_2D),
675 std::move(callback)); 675 std::move(callback));
676 } 676 }
677 677
678 void BeginTest() override { 678 void BeginTest() override {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 protected: 779 protected:
780 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} 780 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {}
781 781
782 static void ReleaseCallback(const gpu::SyncToken& original_sync_token, 782 static void ReleaseCallback(const gpu::SyncToken& original_sync_token,
783 const gpu::SyncToken& release_sync_token, 783 const gpu::SyncToken& release_sync_token,
784 bool lost_resource) {} 784 bool lost_resource) {}
785 785
786 void SetMailbox(char mailbox_char) { 786 void SetMailbox(char mailbox_char) {
787 const gpu::SyncToken sync_token = 787 const gpu::SyncToken sync_token =
788 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)); 788 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char));
789 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 789 std::unique_ptr<SingleReleaseCallback> callback =
790 base::Bind(&TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback, 790 SingleReleaseCallback::Create(base::Bind(
791 sync_token)); 791 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback,
792 sync_token));
792 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char), 793 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
793 sync_token, GL_TEXTURE_2D), 794 sync_token, GL_TEXTURE_2D),
794 std::move(callback)); 795 std::move(callback));
795 } 796 }
796 797
797 void BeginTest() override { 798 void BeginTest() override {
798 gfx::Size bounds(100, 100); 799 gfx::Size bounds(100, 100);
799 root_ = Layer::Create(); 800 root_ = Layer::Create();
800 root_->SetBounds(bounds); 801 root_->SetBounds(bounds);
801 802
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 EXPECT_CALL( 892 EXPECT_CALL(
892 test_data_.mock_callback_, 893 test_data_.mock_callback_,
893 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _)) 894 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
894 .Times(AnyNumber()); 895 .Times(AnyNumber());
895 EXPECT_CALL( 896 EXPECT_CALL(
896 test_data_.mock_callback_, 897 test_data_.mock_callback_,
897 ReleaseImpl2(test_data_.shared_bitmap_.get(), gpu::SyncToken(), false, _)) 898 ReleaseImpl2(test_data_.shared_bitmap_.get(), gpu::SyncToken(), false, _))
898 .Times(AnyNumber()); 899 .Times(AnyNumber());
899 // Hardware mode. 900 // Hardware mode.
900 { 901 {
901 scoped_ptr<TextureLayerImpl> impl_layer = 902 std::unique_ptr<TextureLayerImpl> impl_layer =
902 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 903 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
903 impl_layer->SetTextureMailbox( 904 impl_layer->SetTextureMailbox(
904 test_data_.mailbox1_, 905 test_data_.mailbox1_,
905 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 906 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
906 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 907 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
907 } 908 }
908 909
909 { 910 {
910 scoped_ptr<TextureLayerImpl> impl_layer = 911 std::unique_ptr<TextureLayerImpl> impl_layer =
911 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 912 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
912 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr); 913 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
913 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 914 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
914 } 915 }
915 916
916 { 917 {
917 // Software resource. 918 // Software resource.
918 scoped_ptr<TextureLayerImpl> impl_layer = 919 std::unique_ptr<TextureLayerImpl> impl_layer =
919 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 920 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
920 impl_layer->SetTextureMailbox( 921 impl_layer->SetTextureMailbox(
921 test_data_.mailbox3_, 922 test_data_.mailbox3_,
922 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_)); 923 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
923 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 924 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
924 } 925 }
925 926
926 // Software mode. 927 // Software mode.
927 { 928 {
928 scoped_ptr<TextureLayerImpl> impl_layer = 929 std::unique_ptr<TextureLayerImpl> impl_layer =
929 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 930 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
930 impl_layer->SetTextureMailbox( 931 impl_layer->SetTextureMailbox(
931 test_data_.mailbox1_, 932 test_data_.mailbox1_,
932 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 933 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
933 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 934 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
934 } 935 }
935 936
936 { 937 {
937 scoped_ptr<TextureLayerImpl> impl_layer = 938 std::unique_ptr<TextureLayerImpl> impl_layer =
938 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 939 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
939 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr); 940 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
940 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 941 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
941 } 942 }
942 943
943 { 944 {
944 // Software resource. 945 // Software resource.
945 scoped_ptr<TextureLayerImpl> impl_layer = 946 std::unique_ptr<TextureLayerImpl> impl_layer =
946 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 947 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
947 impl_layer->SetTextureMailbox( 948 impl_layer->SetTextureMailbox(
948 test_data_.mailbox3_, 949 test_data_.mailbox3_,
949 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_)); 950 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
950 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 951 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
951 } 952 }
952 953
953 // Resourceless software mode. 954 // Resourceless software mode.
954 { 955 {
955 scoped_ptr<TextureLayerImpl> impl_layer = 956 std::unique_ptr<TextureLayerImpl> impl_layer =
956 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 957 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
957 impl_layer->SetTextureMailbox( 958 impl_layer->SetTextureMailbox(
958 test_data_.mailbox1_, 959 test_data_.mailbox1_,
959 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 960 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
960 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); 961 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE));
961 } 962 }
962 } 963 }
963 964
964 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { 965 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) {
965 host_impl_.CreatePendingTree(); 966 host_impl_.CreatePendingTree();
966 scoped_ptr<TextureLayerImpl> pending_layer; 967 std::unique_ptr<TextureLayerImpl> pending_layer;
967 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1); 968 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1);
968 ASSERT_TRUE(pending_layer); 969 ASSERT_TRUE(pending_layer);
969 970
970 scoped_ptr<LayerImpl> active_layer( 971 std::unique_ptr<LayerImpl> active_layer(
971 pending_layer->CreateLayerImpl(host_impl_.active_tree())); 972 pending_layer->CreateLayerImpl(host_impl_.active_tree()));
972 ASSERT_TRUE(active_layer); 973 ASSERT_TRUE(active_layer);
973 974
974 pending_layer->SetTextureMailbox( 975 pending_layer->SetTextureMailbox(
975 test_data_.mailbox1_, 976 test_data_.mailbox1_,
976 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 977 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
977 978
978 // Test multiple commits without an activation. 979 // Test multiple commits without an activation.
979 EXPECT_CALL( 980 EXPECT_CALL(
980 test_data_.mock_callback_, 981 test_data_.mock_callback_,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 test_data_.mock_callback_, 1015 test_data_.mock_callback_,
1015 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _)) 1016 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
1016 .Times(1); 1017 .Times(1);
1017 pending_layer->SetTextureMailbox( 1018 pending_layer->SetTextureMailbox(
1018 test_data_.mailbox1_, 1019 test_data_.mailbox1_,
1019 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 1020 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
1020 } 1021 }
1021 1022
1022 TEST_F(TextureLayerImplWithMailboxTest, 1023 TEST_F(TextureLayerImplWithMailboxTest,
1023 TestDestructorCallbackOnCreatedResource) { 1024 TestDestructorCallbackOnCreatedResource) {
1024 scoped_ptr<TextureLayerImpl> impl_layer; 1025 std::unique_ptr<TextureLayerImpl> impl_layer;
1025 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); 1026 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1026 ASSERT_TRUE(impl_layer); 1027 ASSERT_TRUE(impl_layer);
1027 1028
1028 EXPECT_CALL(test_data_.mock_callback_, 1029 EXPECT_CALL(test_data_.mock_callback_,
1029 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1); 1030 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
1030 impl_layer->SetTextureMailbox( 1031 impl_layer->SetTextureMailbox(
1031 test_data_.mailbox1_, 1032 test_data_.mailbox1_,
1032 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 1033 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
1033 impl_layer->DidBecomeActive(); 1034 impl_layer->DidBecomeActive();
1034 EXPECT_TRUE(impl_layer->WillDraw( 1035 EXPECT_TRUE(impl_layer->WillDraw(
(...skipping 27 matching lines...) Expand all
1062 1063
1063 // Checks that TextureLayer::Update does not cause an extra commit when setting 1064 // Checks that TextureLayer::Update does not cause an extra commit when setting
1064 // the texture mailbox. 1065 // the texture mailbox.
1065 class TextureLayerNoExtraCommitForMailboxTest 1066 class TextureLayerNoExtraCommitForMailboxTest
1066 : public LayerTreeTest, 1067 : public LayerTreeTest,
1067 public TextureLayerClient { 1068 public TextureLayerClient {
1068 public: 1069 public:
1069 // TextureLayerClient implementation. 1070 // TextureLayerClient implementation.
1070 bool PrepareTextureMailbox( 1071 bool PrepareTextureMailbox(
1071 TextureMailbox* texture_mailbox, 1072 TextureMailbox* texture_mailbox,
1072 scoped_ptr<SingleReleaseCallback>* release_callback, 1073 std::unique_ptr<SingleReleaseCallback>* release_callback,
1073 bool use_shared_memory) override { 1074 bool use_shared_memory) override {
1074 if (layer_tree_host()->source_frame_number() == 1) { 1075 if (layer_tree_host()->source_frame_number() == 1) {
1075 // Once this has been committed, the mailbox will be released. 1076 // Once this has been committed, the mailbox will be released.
1076 *texture_mailbox = TextureMailbox(); 1077 *texture_mailbox = TextureMailbox();
1077 return true; 1078 return true;
1078 } 1079 }
1079 1080
1080 *texture_mailbox = TextureMailbox(MailboxFromChar('1'), 1081 *texture_mailbox = TextureMailbox(MailboxFromChar('1'),
1081 SyncTokenFromUInt(0x123), GL_TEXTURE_2D); 1082 SyncTokenFromUInt(0x123), GL_TEXTURE_2D);
1082 *release_callback = SingleReleaseCallback::Create( 1083 *release_callback = SingleReleaseCallback::Create(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 : mailbox_changed_(true), 1162 : mailbox_changed_(true),
1162 mailbox_returned_(0), 1163 mailbox_returned_(0),
1163 prepare_called_(0), 1164 prepare_called_(0),
1164 commit_count_(0) { 1165 commit_count_(0) {
1165 mailbox_ = MakeMailbox('1'); 1166 mailbox_ = MakeMailbox('1');
1166 } 1167 }
1167 1168
1168 // TextureLayerClient implementation. 1169 // TextureLayerClient implementation.
1169 bool PrepareTextureMailbox( 1170 bool PrepareTextureMailbox(
1170 TextureMailbox* mailbox, 1171 TextureMailbox* mailbox,
1171 scoped_ptr<SingleReleaseCallback>* release_callback, 1172 std::unique_ptr<SingleReleaseCallback>* release_callback,
1172 bool use_shared_memory) override { 1173 bool use_shared_memory) override {
1173 ++prepare_called_; 1174 ++prepare_called_;
1174 if (!mailbox_changed_) 1175 if (!mailbox_changed_)
1175 return false; 1176 return false;
1176 *mailbox = mailbox_; 1177 *mailbox = mailbox_;
1177 *release_callback = SingleReleaseCallback::Create( 1178 *release_callback = SingleReleaseCallback::Create(
1178 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, 1179 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased,
1179 base::Unretained(this))); 1180 base::Unretained(this)));
1180 return true; 1181 return true;
1181 } 1182 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1299
1299 // Test that TextureLayerImpl::ReleaseResources can be called which releases 1300 // Test that TextureLayerImpl::ReleaseResources can be called which releases
1300 // the mailbox back to TextureLayerClient. 1301 // the mailbox back to TextureLayerClient.
1301 class TextureLayerReleaseResourcesBase 1302 class TextureLayerReleaseResourcesBase
1302 : public LayerTreeTest, 1303 : public LayerTreeTest,
1303 public TextureLayerClient { 1304 public TextureLayerClient {
1304 public: 1305 public:
1305 // TextureLayerClient implementation. 1306 // TextureLayerClient implementation.
1306 bool PrepareTextureMailbox( 1307 bool PrepareTextureMailbox(
1307 TextureMailbox* mailbox, 1308 TextureMailbox* mailbox,
1308 scoped_ptr<SingleReleaseCallback>* release_callback, 1309 std::unique_ptr<SingleReleaseCallback>* release_callback,
1309 bool use_shared_memory) override { 1310 bool use_shared_memory) override {
1310 *mailbox = TextureMailbox(MailboxFromChar('1'), SyncTokenFromUInt(1), 1311 *mailbox = TextureMailbox(MailboxFromChar('1'), SyncTokenFromUInt(1),
1311 GL_TEXTURE_2D); 1312 GL_TEXTURE_2D);
1312 *release_callback = SingleReleaseCallback::Create( 1313 *release_callback = SingleReleaseCallback::Create(
1313 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, 1314 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased,
1314 base::Unretained(this))); 1315 base::Unretained(this)));
1315 return true; 1316 return true;
1316 } 1317 }
1317 1318
1318 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { 1319 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 public: 1370 public:
1370 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) { 1371 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
1371 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1372 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1372 EXPECT_FALSE(lost_resource); 1373 EXPECT_FALSE(lost_resource);
1373 ++callback_count_; 1374 ++callback_count_;
1374 EndTest(); 1375 EndTest();
1375 } 1376 }
1376 1377
1377 void SetMailbox(char mailbox_char) { 1378 void SetMailbox(char mailbox_char) {
1378 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1379 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1379 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 1380 std::unique_ptr<SingleReleaseCallback> callback =
1380 base::Bind( 1381 SingleReleaseCallback::Create(base::Bind(
1381 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, 1382 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback,
1382 base::Unretained(this))); 1383 base::Unretained(this)));
1383 layer_->SetTextureMailbox( 1384 layer_->SetTextureMailbox(
1384 TextureMailbox(MailboxFromChar(mailbox_char), 1385 TextureMailbox(MailboxFromChar(mailbox_char),
1385 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), 1386 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
1386 GL_TEXTURE_2D), 1387 GL_TEXTURE_2D),
1387 std::move(callback)); 1388 std::move(callback));
1388 } 1389 }
1389 1390
1390 void SetupTree() override { 1391 void SetupTree() override {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 public: 1441 public:
1441 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) { 1442 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
1442 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1443 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1443 EXPECT_FALSE(lost_resource); 1444 EXPECT_FALSE(lost_resource);
1444 ++callback_count_; 1445 ++callback_count_;
1445 EndTest(); 1446 EndTest();
1446 } 1447 }
1447 1448
1448 void SetMailbox(char mailbox_char) { 1449 void SetMailbox(char mailbox_char) {
1449 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1450 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1450 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 1451 std::unique_ptr<SingleReleaseCallback> callback =
1451 base::Bind( 1452 SingleReleaseCallback::Create(base::Bind(
1452 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, 1453 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback,
1453 base::Unretained(this))); 1454 base::Unretained(this)));
1454 layer_->SetTextureMailbox( 1455 layer_->SetTextureMailbox(
1455 TextureMailbox(MailboxFromChar(mailbox_char), 1456 TextureMailbox(MailboxFromChar(mailbox_char),
1456 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), 1457 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
1457 GL_TEXTURE_2D), 1458 GL_TEXTURE_2D),
1458 std::move(callback)); 1459 std::move(callback));
1459 } 1460 }
1460 1461
1461 void SetupTree() override { 1462 void SetupTree() override {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 int callback_count_; 1506 int callback_count_;
1506 scoped_refptr<Layer> root_; 1507 scoped_refptr<Layer> root_;
1507 scoped_refptr<TextureLayer> layer_; 1508 scoped_refptr<TextureLayer> layer_;
1508 }; 1509 };
1509 1510
1510 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1511 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1511 TextureLayerWithMailboxImplThreadDeleted); 1512 TextureLayerWithMailboxImplThreadDeleted);
1512 1513
1513 } // namespace 1514 } // namespace
1514 } // namespace cc 1515 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_impl.cc ('k') | cc/layers/ui_resource_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698