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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 | 44 |
45 gpu::Mailbox MailboxFromChar(char value) { | 45 gpu::Mailbox MailboxFromChar(char value) { |
46 gpu::Mailbox mailbox; | 46 gpu::Mailbox mailbox; |
47 memset(mailbox.name, value, sizeof(mailbox.name)); | 47 memset(mailbox.name, value, sizeof(mailbox.name)); |
48 return mailbox; | 48 return mailbox; |
49 } | 49 } |
50 | 50 |
51 class MockLayerTreeHost : public LayerTreeHost { | 51 class MockLayerTreeHost : public LayerTreeHost { |
52 public: | 52 public: |
53 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) | 53 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) |
54 : LayerTreeHost(client, NULL, LayerTreeSettings()) { | 54 : LayerTreeHost(client, nullptr, LayerTreeSettings()) { |
55 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); | 55 InitializeSingleThreaded(client, base::MessageLoopProxy::current()); |
56 } | 56 } |
57 | 57 |
58 MOCK_METHOD0(SetNeedsCommit, void()); | 58 MOCK_METHOD0(SetNeedsCommit, void()); |
59 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 59 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
60 MOCK_METHOD0(StartRateLimiter, void()); | 60 MOCK_METHOD0(StartRateLimiter, void()); |
61 MOCK_METHOD0(StopRateLimiter, void()); | 61 MOCK_METHOD0(StopRateLimiter, void()); |
62 }; | 62 }; |
63 | 63 |
64 class FakeTextureLayerClient : public TextureLayerClient { | 64 class FakeTextureLayerClient : public TextureLayerClient { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); | 177 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); |
178 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 178 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
179 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); | 179 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); |
180 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 180 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
181 } | 181 } |
182 | 182 |
183 virtual void TearDown() { | 183 virtual void TearDown() { |
184 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 184 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
185 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 185 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
186 | 186 |
187 layer_tree_host_->SetRootLayer(NULL); | 187 layer_tree_host_->SetRootLayer(nullptr); |
188 layer_tree_host_ = nullptr; | 188 layer_tree_host_ = nullptr; |
189 } | 189 } |
190 | 190 |
191 scoped_ptr<MockLayerTreeHost> layer_tree_host_; | 191 scoped_ptr<MockLayerTreeHost> layer_tree_host_; |
192 FakeImplProxy proxy_; | 192 FakeImplProxy proxy_; |
193 FakeLayerTreeHostClient fake_client_; | 193 FakeLayerTreeHostClient fake_client_; |
194 TestSharedBitmapManager shared_bitmap_manager_; | 194 TestSharedBitmapManager shared_bitmap_manager_; |
195 FakeLayerTreeHostImpl host_impl_; | 195 FakeLayerTreeHostImpl host_impl_; |
196 }; | 196 }; |
197 | 197 |
198 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 198 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
199 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 199 scoped_refptr<TextureLayer> test_layer = |
200 TextureLayer::CreateForMailbox(nullptr); | |
reveman
2014/10/10 11:44:19
this formatting looks weird. is this what "cl form
| |
200 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); | 201 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); |
201 | 202 |
202 // Test properties that should call SetNeedsCommit. All properties need to | 203 // Test properties that should call SetNeedsCommit. All properties need to |
203 // be set to new values in order for SetNeedsCommit to be called. | 204 // be set to new values in order for SetNeedsCommit to be called. |
204 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); | 205 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); |
205 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( | 206 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( |
206 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); | 207 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); |
207 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( | 208 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( |
208 0.5f, 0.5f, 0.5f, 0.5f)); | 209 0.5f, 0.5f, 0.5f, 0.5f)); |
209 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); | 210 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); |
210 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); | 211 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); |
211 } | 212 } |
212 | 213 |
213 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { | 214 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { |
214 const gfx::Size layer_bounds(100, 100); | 215 const gfx::Size layer_bounds(100, 100); |
215 const gfx::Rect layer_rect(layer_bounds); | 216 const gfx::Rect layer_rect(layer_bounds); |
216 const Region layer_region(layer_rect); | 217 const Region layer_region(layer_rect); |
217 | 218 |
218 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(NULL); | 219 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(nullptr); |
219 layer->SetBounds(layer_bounds); | 220 layer->SetBounds(layer_bounds); |
220 layer->draw_properties().visible_content_rect = layer_rect; | 221 layer->draw_properties().visible_content_rect = layer_rect; |
221 layer->SetBlendBackgroundColor(true); | 222 layer->SetBlendBackgroundColor(true); |
222 | 223 |
223 // Verify initial conditions. | 224 // Verify initial conditions. |
224 EXPECT_FALSE(layer->contents_opaque()); | 225 EXPECT_FALSE(layer->contents_opaque()); |
225 EXPECT_EQ(0u, layer->background_color()); | 226 EXPECT_EQ(0u, layer->background_color()); |
226 EXPECT_EQ(Region().ToString(), | 227 EXPECT_EQ(Region().ToString(), |
227 layer->VisibleContentOpaqueRegion().ToString()); | 228 layer->VisibleContentOpaqueRegion().ToString()); |
228 | 229 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 layer_tree_host_->SetRootLayer(test_layer); | 277 layer_tree_host_->SetRootLayer(test_layer); |
277 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | 278 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); |
278 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 279 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
279 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); | 280 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); |
280 test_layer->SetNeedsDisplay(); | 281 test_layer->SetNeedsDisplay(); |
281 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 282 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
282 | 283 |
283 // Stop rate limiter when we're removed from the tree. | 284 // Stop rate limiter when we're removed from the tree. |
284 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | 285 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); |
285 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 286 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
286 layer_tree_host_->SetRootLayer(NULL); | 287 layer_tree_host_->SetRootLayer(nullptr); |
287 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 288 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
288 } | 289 } |
289 | 290 |
290 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { | 291 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { |
291 public: | 292 public: |
292 using TextureLayer::TextureMailboxHolder::Create; | 293 using TextureLayer::TextureMailboxHolder::Create; |
293 | 294 |
294 protected: | 295 protected: |
295 virtual ~TestMailboxHolder() {} | 296 virtual ~TestMailboxHolder() {} |
296 }; | 297 }; |
297 | 298 |
298 class TextureLayerWithMailboxTest : public TextureLayerTest { | 299 class TextureLayerWithMailboxTest : public TextureLayerTest { |
299 protected: | 300 protected: |
300 virtual void TearDown() { | 301 virtual void TearDown() { |
301 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 302 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
302 EXPECT_CALL(test_data_.mock_callback_, | 303 EXPECT_CALL(test_data_.mock_callback_, |
303 Release(test_data_.mailbox_name1_, | 304 Release(test_data_.mailbox_name1_, |
304 test_data_.sync_point1_, | 305 test_data_.sync_point1_, |
305 false)).Times(1); | 306 false)).Times(1); |
306 TextureLayerTest::TearDown(); | 307 TextureLayerTest::TearDown(); |
307 } | 308 } |
308 | 309 |
309 CommonMailboxObjects test_data_; | 310 CommonMailboxObjects test_data_; |
310 }; | 311 }; |
311 | 312 |
312 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { | 313 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { |
313 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 314 scoped_refptr<TextureLayer> test_layer = |
315 TextureLayer::CreateForMailbox(nullptr); | |
314 ASSERT_TRUE(test_layer.get()); | 316 ASSERT_TRUE(test_layer.get()); |
315 | 317 |
316 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 318 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
317 layer_tree_host_->SetRootLayer(test_layer); | 319 layer_tree_host_->SetRootLayer(test_layer); |
318 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 320 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
319 | 321 |
320 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 322 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
321 test_layer->SetTextureMailbox( | 323 test_layer->SetTextureMailbox( |
322 test_data_.mailbox1_, | 324 test_data_.mailbox1_, |
323 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 325 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 366 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
365 | 367 |
366 // Test destructor. | 368 // Test destructor. |
367 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 369 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
368 test_layer->SetTextureMailbox( | 370 test_layer->SetTextureMailbox( |
369 test_data_.mailbox1_, | 371 test_data_.mailbox1_, |
370 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 372 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
371 } | 373 } |
372 | 374 |
373 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { | 375 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { |
374 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 376 scoped_refptr<TextureLayer> test_layer = |
377 TextureLayer::CreateForMailbox(nullptr); | |
375 ASSERT_TRUE(test_layer.get()); | 378 ASSERT_TRUE(test_layer.get()); |
376 | 379 |
377 // These use the same gpu::Mailbox, but different sync points. | 380 // These use the same gpu::Mailbox, but different sync points. |
378 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); | 381 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); |
379 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); | 382 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); |
380 | 383 |
381 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 384 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
382 layer_tree_host_->SetRootLayer(test_layer); | 385 layer_tree_host_->SetRootLayer(test_layer); |
383 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 386 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
384 | 387 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 } | 448 } |
446 | 449 |
447 scoped_ptr<TestMailboxHolder::MainThreadReference> | 450 scoped_ptr<TestMailboxHolder::MainThreadReference> |
448 main_ref_; | 451 main_ref_; |
449 base::Thread main_thread_; | 452 base::Thread main_thread_; |
450 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; | 453 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; |
451 CommonMailboxObjects test_data_; | 454 CommonMailboxObjects test_data_; |
452 }; | 455 }; |
453 | 456 |
454 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { | 457 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { |
455 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 458 scoped_refptr<TextureLayer> test_layer = |
459 TextureLayer::CreateForMailbox(nullptr); | |
456 ASSERT_TRUE(test_layer.get()); | 460 ASSERT_TRUE(test_layer.get()); |
457 | 461 |
458 main_thread_.message_loop()->PostTask( | 462 main_thread_.message_loop()->PostTask( |
459 FROM_HERE, | 463 FROM_HERE, |
460 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 464 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
461 base::Unretained(this))); | 465 base::Unretained(this))); |
462 | 466 |
463 Wait(main_thread_); | 467 Wait(main_thread_); |
464 | 468 |
465 // The texture layer is attached to compositor1, and passes a reference to its | 469 // The texture layer is attached to compositor1, and passes a reference to its |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 | 504 |
501 main_thread_.message_loop()->PostTask( | 505 main_thread_.message_loop()->PostTask( |
502 FROM_HERE, | 506 FROM_HERE, |
503 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 507 base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
504 base::Unretained(this))); | 508 base::Unretained(this))); |
505 Wait(main_thread_); | 509 Wait(main_thread_); |
506 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 510 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
507 } | 511 } |
508 | 512 |
509 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { | 513 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { |
510 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 514 scoped_refptr<TextureLayer> test_layer = |
515 TextureLayer::CreateForMailbox(nullptr); | |
511 ASSERT_TRUE(test_layer.get()); | 516 ASSERT_TRUE(test_layer.get()); |
512 | 517 |
513 main_thread_.message_loop()->PostTask( | 518 main_thread_.message_loop()->PostTask( |
514 FROM_HERE, | 519 FROM_HERE, |
515 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 520 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
516 base::Unretained(this))); | 521 base::Unretained(this))); |
517 | 522 |
518 Wait(main_thread_); | 523 Wait(main_thread_); |
519 | 524 |
520 // The texture layer is attached to compositor1, and passes a reference to its | 525 // The texture layer is attached to compositor1, and passes a reference to its |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 // released back to the embedder with the last sync point from the impl tree. | 561 // released back to the embedder with the last sync point from the impl tree. |
557 EXPECT_CALL(test_data_.mock_callback_, | 562 EXPECT_CALL(test_data_.mock_callback_, |
558 Release(test_data_.mailbox_name1_, 200, true)).Times(1); | 563 Release(test_data_.mailbox_name1_, 200, true)).Times(1); |
559 | 564 |
560 compositor2->Run(200, true, main_thread_task_runner_.get()); | 565 compositor2->Run(200, true, main_thread_task_runner_.get()); |
561 Wait(main_thread_); | 566 Wait(main_thread_); |
562 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 567 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
563 } | 568 } |
564 | 569 |
565 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 570 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { |
566 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 571 scoped_refptr<TextureLayer> test_layer = |
572 TextureLayer::CreateForMailbox(nullptr); | |
567 ASSERT_TRUE(test_layer.get()); | 573 ASSERT_TRUE(test_layer.get()); |
568 | 574 |
569 main_thread_.message_loop()->PostTask( | 575 main_thread_.message_loop()->PostTask( |
570 FROM_HERE, | 576 FROM_HERE, |
571 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 577 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
572 base::Unretained(this))); | 578 base::Unretained(this))); |
573 | 579 |
574 Wait(main_thread_); | 580 Wait(main_thread_); |
575 | 581 |
576 // The texture layer is attached to compositor1, and passes a reference to its | 582 // The texture layer is attached to compositor1, and passes a reference to its |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 // released back to the embedder with the last sync point from the impl tree. | 618 // released back to the embedder with the last sync point from the impl tree. |
613 EXPECT_CALL(test_data_.mock_callback_, | 619 EXPECT_CALL(test_data_.mock_callback_, |
614 Release(test_data_.mailbox_name1_, 100, true)).Times(1); | 620 Release(test_data_.mailbox_name1_, 100, true)).Times(1); |
615 | 621 |
616 compositor1->Run(100, true, main_thread_task_runner_.get()); | 622 compositor1->Run(100, true, main_thread_task_runner_.get()); |
617 Wait(main_thread_); | 623 Wait(main_thread_); |
618 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 624 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
619 } | 625 } |
620 | 626 |
621 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 627 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { |
622 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 628 scoped_refptr<TextureLayer> test_layer = |
629 TextureLayer::CreateForMailbox(nullptr); | |
623 ASSERT_TRUE(test_layer.get()); | 630 ASSERT_TRUE(test_layer.get()); |
624 | 631 |
625 main_thread_.message_loop()->PostTask( | 632 main_thread_.message_loop()->PostTask( |
626 FROM_HERE, | 633 FROM_HERE, |
627 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 634 base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
628 base::Unretained(this))); | 635 base::Unretained(this))); |
629 | 636 |
630 Wait(main_thread_); | 637 Wait(main_thread_); |
631 | 638 |
632 // The texture layer is attached to compositor1, and passes a reference to its | 639 // The texture layer is attached to compositor1, and passes a reference to its |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 callback.Pass()); | 728 callback.Pass()); |
722 } | 729 } |
723 | 730 |
724 virtual void BeginTest() override { | 731 virtual void BeginTest() override { |
725 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 732 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
726 | 733 |
727 gfx::Size bounds(100, 100); | 734 gfx::Size bounds(100, 100); |
728 root_ = Layer::Create(); | 735 root_ = Layer::Create(); |
729 root_->SetBounds(bounds); | 736 root_->SetBounds(bounds); |
730 | 737 |
731 layer_ = TextureLayer::CreateForMailbox(NULL); | 738 layer_ = TextureLayer::CreateForMailbox(nullptr); |
732 layer_->SetIsDrawable(true); | 739 layer_->SetIsDrawable(true); |
733 layer_->SetBounds(bounds); | 740 layer_->SetBounds(bounds); |
734 | 741 |
735 root_->AddChild(layer_); | 742 root_->AddChild(layer_); |
736 layer_tree_host()->SetRootLayer(root_); | 743 layer_tree_host()->SetRootLayer(root_); |
737 layer_tree_host()->SetViewportSize(bounds); | 744 layer_tree_host()->SetViewportSize(bounds); |
738 SetMailbox('1'); | 745 SetMailbox('1'); |
739 EXPECT_EQ(0, callback_count_); | 746 EXPECT_EQ(0, callback_count_); |
740 | 747 |
741 // Case #1: change mailbox before the commit. The old mailbox should be | 748 // Case #1: change mailbox before the commit. The old mailbox should be |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 layer_->SetTextureMailbox( | 851 layer_->SetTextureMailbox( |
845 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 852 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
846 callback.Pass()); | 853 callback.Pass()); |
847 } | 854 } |
848 | 855 |
849 virtual void BeginTest() override { | 856 virtual void BeginTest() override { |
850 gfx::Size bounds(100, 100); | 857 gfx::Size bounds(100, 100); |
851 root_ = Layer::Create(); | 858 root_ = Layer::Create(); |
852 root_->SetBounds(bounds); | 859 root_->SetBounds(bounds); |
853 | 860 |
854 layer_ = TextureLayer::CreateForMailbox(NULL); | 861 layer_ = TextureLayer::CreateForMailbox(nullptr); |
855 layer_->SetIsDrawable(true); | 862 layer_->SetIsDrawable(true); |
856 layer_->SetBounds(bounds); | 863 layer_->SetBounds(bounds); |
857 | 864 |
858 root_->AddChild(layer_); | 865 root_->AddChild(layer_); |
859 layer_tree_host()->SetRootLayer(root_); | 866 layer_tree_host()->SetRootLayer(root_); |
860 layer_tree_host()->SetViewportSize(bounds); | 867 layer_tree_host()->SetViewportSize(bounds); |
861 SetMailbox('1'); | 868 SetMailbox('1'); |
862 | 869 |
863 PostSetNeedsCommitToMainThread(); | 870 PostSetNeedsCommitToMainThread(); |
864 } | 871 } |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1407 } | 1414 } |
1408 | 1415 |
1409 private: | 1416 private: |
1410 bool mailbox_released_; | 1417 bool mailbox_released_; |
1411 }; | 1418 }; |
1412 | 1419 |
1413 class TextureLayerReleaseResourcesAfterCommit | 1420 class TextureLayerReleaseResourcesAfterCommit |
1414 : public TextureLayerReleaseResourcesBase { | 1421 : public TextureLayerReleaseResourcesBase { |
1415 public: | 1422 public: |
1416 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1423 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
1417 LayerTreeImpl* tree = NULL; | 1424 LayerTreeImpl* tree = nullptr; |
1418 if (host_impl->settings().impl_side_painting) | 1425 if (host_impl->settings().impl_side_painting) |
1419 tree = host_impl->pending_tree(); | 1426 tree = host_impl->pending_tree(); |
1420 else | 1427 else |
1421 tree = host_impl->active_tree(); | 1428 tree = host_impl->active_tree(); |
1422 tree->root_layer()->children()[0]->ReleaseResources(); | 1429 tree->root_layer()->children()[0]->ReleaseResources(); |
1423 } | 1430 } |
1424 }; | 1431 }; |
1425 | 1432 |
1426 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterCommit); | 1433 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterCommit); |
1427 | 1434 |
(...skipping 25 matching lines...) Expand all Loading... | |
1453 layer_->SetTextureMailbox( | 1460 layer_->SetTextureMailbox( |
1454 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1461 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1455 callback.Pass()); | 1462 callback.Pass()); |
1456 } | 1463 } |
1457 | 1464 |
1458 virtual void SetupTree() override { | 1465 virtual void SetupTree() override { |
1459 gfx::Size bounds(100, 100); | 1466 gfx::Size bounds(100, 100); |
1460 root_ = Layer::Create(); | 1467 root_ = Layer::Create(); |
1461 root_->SetBounds(bounds); | 1468 root_->SetBounds(bounds); |
1462 | 1469 |
1463 layer_ = TextureLayer::CreateForMailbox(NULL); | 1470 layer_ = TextureLayer::CreateForMailbox(nullptr); |
1464 layer_->SetIsDrawable(true); | 1471 layer_->SetIsDrawable(true); |
1465 layer_->SetBounds(bounds); | 1472 layer_->SetBounds(bounds); |
1466 | 1473 |
1467 root_->AddChild(layer_); | 1474 root_->AddChild(layer_); |
1468 layer_tree_host()->SetRootLayer(root_); | 1475 layer_tree_host()->SetRootLayer(root_); |
1469 layer_tree_host()->SetViewportSize(bounds); | 1476 layer_tree_host()->SetViewportSize(bounds); |
1470 } | 1477 } |
1471 | 1478 |
1472 virtual void BeginTest() override { | 1479 virtual void BeginTest() override { |
1473 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1480 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1474 | 1481 |
1475 callback_count_ = 0; | 1482 callback_count_ = 0; |
1476 | 1483 |
1477 // Set the mailbox on the main thread. | 1484 // Set the mailbox on the main thread. |
1478 SetMailbox('1'); | 1485 SetMailbox('1'); |
1479 EXPECT_EQ(0, callback_count_); | 1486 EXPECT_EQ(0, callback_count_); |
1480 | 1487 |
1481 PostSetNeedsCommitToMainThread(); | 1488 PostSetNeedsCommitToMainThread(); |
1482 } | 1489 } |
1483 | 1490 |
1484 virtual void DidCommitAndDrawFrame() override { | 1491 virtual void DidCommitAndDrawFrame() override { |
1485 switch (layer_tree_host()->source_frame_number()) { | 1492 switch (layer_tree_host()->source_frame_number()) { |
1486 case 1: | 1493 case 1: |
1487 // Delete the TextureLayer on the main thread while the mailbox is in | 1494 // Delete the TextureLayer on the main thread while the mailbox is in |
1488 // the impl tree. | 1495 // the impl tree. |
1489 layer_->RemoveFromParent(); | 1496 layer_->RemoveFromParent(); |
1490 layer_ = NULL; | 1497 layer_ = nullptr; |
1491 break; | 1498 break; |
1492 } | 1499 } |
1493 } | 1500 } |
1494 | 1501 |
1495 virtual void AfterTest() override { | 1502 virtual void AfterTest() override { |
1496 EXPECT_EQ(1, callback_count_); | 1503 EXPECT_EQ(1, callback_count_); |
1497 } | 1504 } |
1498 | 1505 |
1499 private: | 1506 private: |
1500 base::ThreadChecker main_thread_; | 1507 base::ThreadChecker main_thread_; |
(...skipping 23 matching lines...) Expand all Loading... | |
1524 layer_->SetTextureMailbox( | 1531 layer_->SetTextureMailbox( |
1525 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1532 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1526 callback.Pass()); | 1533 callback.Pass()); |
1527 } | 1534 } |
1528 | 1535 |
1529 virtual void SetupTree() override { | 1536 virtual void SetupTree() override { |
1530 gfx::Size bounds(100, 100); | 1537 gfx::Size bounds(100, 100); |
1531 root_ = Layer::Create(); | 1538 root_ = Layer::Create(); |
1532 root_->SetBounds(bounds); | 1539 root_->SetBounds(bounds); |
1533 | 1540 |
1534 layer_ = TextureLayer::CreateForMailbox(NULL); | 1541 layer_ = TextureLayer::CreateForMailbox(nullptr); |
1535 layer_->SetIsDrawable(true); | 1542 layer_->SetIsDrawable(true); |
1536 layer_->SetBounds(bounds); | 1543 layer_->SetBounds(bounds); |
1537 | 1544 |
1538 root_->AddChild(layer_); | 1545 root_->AddChild(layer_); |
1539 layer_tree_host()->SetRootLayer(root_); | 1546 layer_tree_host()->SetRootLayer(root_); |
1540 layer_tree_host()->SetViewportSize(bounds); | 1547 layer_tree_host()->SetViewportSize(bounds); |
1541 } | 1548 } |
1542 | 1549 |
1543 virtual void BeginTest() override { | 1550 virtual void BeginTest() override { |
1544 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1551 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1545 | 1552 |
1546 callback_count_ = 0; | 1553 callback_count_ = 0; |
1547 | 1554 |
1548 // Set the mailbox on the main thread. | 1555 // Set the mailbox on the main thread. |
1549 SetMailbox('1'); | 1556 SetMailbox('1'); |
1550 EXPECT_EQ(0, callback_count_); | 1557 EXPECT_EQ(0, callback_count_); |
1551 | 1558 |
1552 PostSetNeedsCommitToMainThread(); | 1559 PostSetNeedsCommitToMainThread(); |
1553 } | 1560 } |
1554 | 1561 |
1555 virtual void DidCommitAndDrawFrame() override { | 1562 virtual void DidCommitAndDrawFrame() override { |
1556 switch (layer_tree_host()->source_frame_number()) { | 1563 switch (layer_tree_host()->source_frame_number()) { |
1557 case 1: | 1564 case 1: |
1558 // Remove the TextureLayer on the main thread while the mailbox is in | 1565 // Remove the TextureLayer on the main thread while the mailbox is in |
1559 // the impl tree, but don't delete the TextureLayer until after the impl | 1566 // the impl tree, but don't delete the TextureLayer until after the impl |
1560 // tree side is deleted. | 1567 // tree side is deleted. |
1561 layer_->RemoveFromParent(); | 1568 layer_->RemoveFromParent(); |
1562 break; | 1569 break; |
1563 case 2: | 1570 case 2: |
1564 layer_ = NULL; | 1571 layer_ = nullptr; |
1565 break; | 1572 break; |
1566 } | 1573 } |
1567 } | 1574 } |
1568 | 1575 |
1569 virtual void AfterTest() override { | 1576 virtual void AfterTest() override { |
1570 EXPECT_EQ(1, callback_count_); | 1577 EXPECT_EQ(1, callback_count_); |
1571 } | 1578 } |
1572 | 1579 |
1573 private: | 1580 private: |
1574 base::ThreadChecker main_thread_; | 1581 base::ThreadChecker main_thread_; |
1575 int callback_count_; | 1582 int callback_count_; |
1576 scoped_refptr<Layer> root_; | 1583 scoped_refptr<Layer> root_; |
1577 scoped_refptr<TextureLayer> layer_; | 1584 scoped_refptr<TextureLayer> layer_; |
1578 }; | 1585 }; |
1579 | 1586 |
1580 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1587 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1581 TextureLayerWithMailboxImplThreadDeleted); | 1588 TextureLayerWithMailboxImplThreadDeleted); |
1582 | 1589 |
1583 } // namespace | 1590 } // namespace |
1584 } // namespace cc | 1591 } // namespace cc |
OLD | NEW |