| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 228   } | 228   } | 
| 229 | 229 | 
| 230   scoped_ptr<MockLayerTreeHost> layer_tree_host_; | 230   scoped_ptr<MockLayerTreeHost> layer_tree_host_; | 
| 231   FakeImplTaskRunnerProvider task_runner_provider_; | 231   FakeImplTaskRunnerProvider task_runner_provider_; | 
| 232   FakeLayerTreeHostClient fake_client_; | 232   FakeLayerTreeHostClient fake_client_; | 
| 233   TestSharedBitmapManager shared_bitmap_manager_; | 233   TestSharedBitmapManager shared_bitmap_manager_; | 
| 234   TestTaskGraphRunner task_graph_runner_; | 234   TestTaskGraphRunner task_graph_runner_; | 
| 235   scoped_ptr<OutputSurface> output_surface_; | 235   scoped_ptr<OutputSurface> output_surface_; | 
| 236   FakeLayerTreeHostImpl host_impl_; | 236   FakeLayerTreeHostImpl host_impl_; | 
| 237   CommonMailboxObjects test_data_; | 237   CommonMailboxObjects test_data_; | 
| 238   LayerSettings layer_settings_; |  | 
| 239 }; | 238 }; | 
| 240 | 239 | 
| 241 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 240 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 
| 242   scoped_refptr<TextureLayer> test_layer = | 241   scoped_refptr<TextureLayer> test_layer = | 
| 243       TextureLayer::CreateForMailbox(layer_settings_, nullptr); | 242       TextureLayer::CreateForMailbox(nullptr); | 
| 244   EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); | 243   EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); | 
| 245 | 244 | 
| 246   // Test properties that should call SetNeedsCommit.  All properties need to | 245   // Test properties that should call SetNeedsCommit.  All properties need to | 
| 247   // be set to new values in order for SetNeedsCommit to be called. | 246   // be set to new values in order for SetNeedsCommit to be called. | 
| 248   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); | 247   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); | 
| 249   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); | 248   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); | 
| 250   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( | 249   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( | 
| 251       gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); | 250       gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); | 
| 252   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( | 251   EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( | 
| 253       0.5f, 0.5f, 0.5f, 0.5f)); | 252       0.5f, 0.5f, 0.5f, 0.5f)); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 270     EXPECT_CALL( | 269     EXPECT_CALL( | 
| 271         test_data_.mock_callback_, | 270         test_data_.mock_callback_, | 
| 272         Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false)) | 271         Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false)) | 
| 273         .Times(1); | 272         .Times(1); | 
| 274     TextureLayerTest::TearDown(); | 273     TextureLayerTest::TearDown(); | 
| 275   } | 274   } | 
| 276 }; | 275 }; | 
| 277 | 276 | 
| 278 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { | 277 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { | 
| 279   scoped_refptr<TextureLayer> test_layer = | 278   scoped_refptr<TextureLayer> test_layer = | 
| 280       TextureLayer::CreateForMailbox(layer_settings_, nullptr); | 279       TextureLayer::CreateForMailbox(nullptr); | 
| 281   ASSERT_TRUE(test_layer.get()); | 280   ASSERT_TRUE(test_layer.get()); | 
| 282 | 281 | 
| 283   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 282   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 
| 284   layer_tree_host_->SetRootLayer(test_layer); | 283   layer_tree_host_->SetRootLayer(test_layer); | 
| 285   Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 284   Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 
| 286 | 285 | 
| 287   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 286   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 
| 288   test_layer->SetTextureMailbox( | 287   test_layer->SetTextureMailbox( | 
| 289       test_data_.mailbox1_, | 288       test_data_.mailbox1_, | 
| 290       SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 289       SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 327 | 326 | 
| 328   // Test destructor. | 327   // Test destructor. | 
| 329   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 328   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 
| 330   test_layer->SetTextureMailbox( | 329   test_layer->SetTextureMailbox( | 
| 331       test_data_.mailbox1_, | 330       test_data_.mailbox1_, | 
| 332       SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 331       SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 
| 333 } | 332 } | 
| 334 | 333 | 
| 335 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { | 334 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { | 
| 336   scoped_refptr<TextureLayer> test_layer = | 335   scoped_refptr<TextureLayer> test_layer = | 
| 337       TextureLayer::CreateForMailbox(layer_settings_, nullptr); | 336       TextureLayer::CreateForMailbox(nullptr); | 
| 338   ASSERT_TRUE(test_layer.get()); | 337   ASSERT_TRUE(test_layer.get()); | 
| 339 | 338 | 
| 340   // These use the same gpu::Mailbox, but different sync points. | 339   // These use the same gpu::Mailbox, but different sync points. | 
| 341   TextureMailbox mailbox1(MailboxFromChar('a'), SyncTokenFromUInt(1), | 340   TextureMailbox mailbox1(MailboxFromChar('a'), SyncTokenFromUInt(1), | 
| 342                           GL_TEXTURE_2D); | 341                           GL_TEXTURE_2D); | 
| 343   TextureMailbox mailbox2(MailboxFromChar('a'), SyncTokenFromUInt(2), | 342   TextureMailbox mailbox2(MailboxFromChar('a'), SyncTokenFromUInt(2), | 
| 344                           GL_TEXTURE_2D); | 343                           GL_TEXTURE_2D); | 
| 345 | 344 | 
| 346   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 345   EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 
| 347   layer_tree_host_->SetRootLayer(test_layer); | 346   layer_tree_host_->SetRootLayer(test_layer); | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 409   } | 408   } | 
| 410 | 409 | 
| 411   scoped_ptr<TestMailboxHolder::MainThreadReference> | 410   scoped_ptr<TestMailboxHolder::MainThreadReference> | 
| 412       main_ref_; | 411       main_ref_; | 
| 413   base::Thread main_thread_; | 412   base::Thread main_thread_; | 
| 414   scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; | 413   scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; | 
| 415 }; | 414 }; | 
| 416 | 415 | 
| 417 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { | 416 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { | 
| 418   scoped_refptr<TextureLayer> test_layer = | 417   scoped_refptr<TextureLayer> test_layer = | 
| 419       TextureLayer::CreateForMailbox(layer_settings_, nullptr); | 418       TextureLayer::CreateForMailbox(nullptr); | 
| 420   ASSERT_TRUE(test_layer.get()); | 419   ASSERT_TRUE(test_layer.get()); | 
| 421 | 420 | 
| 422   main_thread_.message_loop()->task_runner()->PostTask( | 421   main_thread_.message_loop()->task_runner()->PostTask( | 
| 423       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 422       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 
| 424                             base::Unretained(this))); | 423                             base::Unretained(this))); | 
| 425 | 424 | 
| 426   Wait(main_thread_); | 425   Wait(main_thread_); | 
| 427 | 426 | 
| 428   // 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 | 
| 429   // impl tree. | 428   // impl tree. | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 462 | 461 | 
| 463   main_thread_.message_loop()->task_runner()->PostTask( | 462   main_thread_.message_loop()->task_runner()->PostTask( | 
| 464       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 463       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 
| 465                             base::Unretained(this))); | 464                             base::Unretained(this))); | 
| 466   Wait(main_thread_); | 465   Wait(main_thread_); | 
| 467   Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 466   Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 
| 468 } | 467 } | 
| 469 | 468 | 
| 470 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { | 469 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { | 
| 471   scoped_refptr<TextureLayer> test_layer = | 470   scoped_refptr<TextureLayer> test_layer = | 
| 472       TextureLayer::CreateForMailbox(layer_settings_, nullptr); | 471       TextureLayer::CreateForMailbox(nullptr); | 
| 473   ASSERT_TRUE(test_layer.get()); | 472   ASSERT_TRUE(test_layer.get()); | 
| 474 | 473 | 
| 475   main_thread_.message_loop()->task_runner()->PostTask( | 474   main_thread_.message_loop()->task_runner()->PostTask( | 
| 476       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 475       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 
| 477                             base::Unretained(this))); | 476                             base::Unretained(this))); | 
| 478 | 477 | 
| 479   Wait(main_thread_); | 478   Wait(main_thread_); | 
| 480 | 479 | 
| 481   // 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 | 
| 482   // impl tree. | 481   // impl tree. | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 516       .Times(1); | 515       .Times(1); | 
| 517 | 516 | 
| 518   compositor2->Run(SyncTokenFromUInt(200), true, | 517   compositor2->Run(SyncTokenFromUInt(200), true, | 
| 519                    main_thread_task_runner_.get()); | 518                    main_thread_task_runner_.get()); | 
| 520   Wait(main_thread_); | 519   Wait(main_thread_); | 
| 521   Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 520   Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 
| 522 } | 521 } | 
| 523 | 522 | 
| 524 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 523 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 
| 525   scoped_refptr<TextureLayer> test_layer = | 524   scoped_refptr<TextureLayer> test_layer = | 
| 526       TextureLayer::CreateForMailbox(layer_settings_, nullptr); | 525       TextureLayer::CreateForMailbox(nullptr); | 
| 527   ASSERT_TRUE(test_layer.get()); | 526   ASSERT_TRUE(test_layer.get()); | 
| 528 | 527 | 
| 529   main_thread_.message_loop()->task_runner()->PostTask( | 528   main_thread_.message_loop()->task_runner()->PostTask( | 
| 530       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 529       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 
| 531                             base::Unretained(this))); | 530                             base::Unretained(this))); | 
| 532 | 531 | 
| 533   Wait(main_thread_); | 532   Wait(main_thread_); | 
| 534 | 533 | 
| 535   // 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 | 
| 536   // impl tree. | 535   // impl tree. | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 570       .Times(1); | 569       .Times(1); | 
| 571 | 570 | 
| 572   compositor1->Run(SyncTokenFromUInt(100), true, | 571   compositor1->Run(SyncTokenFromUInt(100), true, | 
| 573                    main_thread_task_runner_.get()); | 572                    main_thread_task_runner_.get()); | 
| 574   Wait(main_thread_); | 573   Wait(main_thread_); | 
| 575   Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 574   Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 
| 576 } | 575 } | 
| 577 | 576 | 
| 578 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 577 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 
| 579   scoped_refptr<TextureLayer> test_layer = | 578   scoped_refptr<TextureLayer> test_layer = | 
| 580       TextureLayer::CreateForMailbox(layer_settings_, nullptr); | 579       TextureLayer::CreateForMailbox(nullptr); | 
| 581   ASSERT_TRUE(test_layer.get()); | 580   ASSERT_TRUE(test_layer.get()); | 
| 582 | 581 | 
| 583   main_thread_.message_loop()->task_runner()->PostTask( | 582   main_thread_.message_loop()->task_runner()->PostTask( | 
| 584       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 583       FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 
| 585                             base::Unretained(this))); | 584                             base::Unretained(this))); | 
| 586 | 585 | 
| 587   Wait(main_thread_); | 586   Wait(main_thread_); | 
| 588 | 587 | 
| 589   // 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 | 
| 590   // impl tree. | 589   // impl tree. | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 673         TextureMailbox(MailboxFromChar(mailbox_char), | 672         TextureMailbox(MailboxFromChar(mailbox_char), | 
| 674                        SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), | 673                        SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), | 
| 675                        GL_TEXTURE_2D), | 674                        GL_TEXTURE_2D), | 
| 676         std::move(callback)); | 675         std::move(callback)); | 
| 677   } | 676   } | 
| 678 | 677 | 
| 679   void BeginTest() override { | 678   void BeginTest() override { | 
| 680     EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 679     EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 
| 681 | 680 | 
| 682     gfx::Size bounds(100, 100); | 681     gfx::Size bounds(100, 100); | 
| 683     root_ = Layer::Create(layer_settings()); | 682     root_ = Layer::Create(); | 
| 684     root_->SetBounds(bounds); | 683     root_->SetBounds(bounds); | 
| 685 | 684 | 
| 686     layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); | 685     layer_ = TextureLayer::CreateForMailbox(nullptr); | 
| 687     layer_->SetIsDrawable(true); | 686     layer_->SetIsDrawable(true); | 
| 688     layer_->SetBounds(bounds); | 687     layer_->SetBounds(bounds); | 
| 689 | 688 | 
| 690     root_->AddChild(layer_); | 689     root_->AddChild(layer_); | 
| 691     layer_tree_host()->SetRootLayer(root_); | 690     layer_tree_host()->SetRootLayer(root_); | 
| 692     layer_tree_host()->SetViewportSize(bounds); | 691     layer_tree_host()->SetViewportSize(bounds); | 
| 693     SetMailbox('1'); | 692     SetMailbox('1'); | 
| 694     EXPECT_EQ(0, callback_count_); | 693     EXPECT_EQ(0, callback_count_); | 
| 695 | 694 | 
| 696     // Case #1: change mailbox before the commit. The old mailbox should be | 695     // Case #1: change mailbox before the commit. The old mailbox should be | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 790     scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 789     scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 
| 791         base::Bind(&TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback, | 790         base::Bind(&TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback, | 
| 792                    sync_token)); | 791                    sync_token)); | 
| 793     layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char), | 792     layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char), | 
| 794                                              sync_token, GL_TEXTURE_2D), | 793                                              sync_token, GL_TEXTURE_2D), | 
| 795                               std::move(callback)); | 794                               std::move(callback)); | 
| 796   } | 795   } | 
| 797 | 796 | 
| 798   void BeginTest() override { | 797   void BeginTest() override { | 
| 799     gfx::Size bounds(100, 100); | 798     gfx::Size bounds(100, 100); | 
| 800     root_ = Layer::Create(layer_settings()); | 799     root_ = Layer::Create(); | 
| 801     root_->SetBounds(bounds); | 800     root_->SetBounds(bounds); | 
| 802 | 801 | 
| 803     layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); | 802     layer_ = TextureLayer::CreateForMailbox(nullptr); | 
| 804     layer_->SetIsDrawable(true); | 803     layer_->SetIsDrawable(true); | 
| 805     layer_->SetBounds(bounds); | 804     layer_->SetBounds(bounds); | 
| 806 | 805 | 
| 807     root_->AddChild(layer_); | 806     root_->AddChild(layer_); | 
| 808     layer_tree_host()->SetRootLayer(root_); | 807     layer_tree_host()->SetRootLayer(root_); | 
| 809     layer_tree_host()->SetViewportSize(bounds); | 808     layer_tree_host()->SetViewportSize(bounds); | 
| 810     SetMailbox('1'); | 809     SetMailbox('1'); | 
| 811 | 810 | 
| 812     PostSetNeedsCommitToMainThread(); | 811     PostSetNeedsCommitToMainThread(); | 
| 813   } | 812   } | 
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1088 | 1087 | 
| 1089   void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { | 1088   void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { | 
| 1090     // Source frame number during callback is the same as the source frame | 1089     // Source frame number during callback is the same as the source frame | 
| 1091     // on which it was released. | 1090     // on which it was released. | 
| 1092     EXPECT_EQ(1, layer_tree_host()->source_frame_number()); | 1091     EXPECT_EQ(1, layer_tree_host()->source_frame_number()); | 
| 1093     EXPECT_TRUE(sync_token.HasData()); | 1092     EXPECT_TRUE(sync_token.HasData()); | 
| 1094     EndTest(); | 1093     EndTest(); | 
| 1095   } | 1094   } | 
| 1096 | 1095 | 
| 1097   void SetupTree() override { | 1096   void SetupTree() override { | 
| 1098     scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 1097     scoped_refptr<Layer> root = Layer::Create(); | 
| 1099     root->SetBounds(gfx::Size(10, 10)); | 1098     root->SetBounds(gfx::Size(10, 10)); | 
| 1100     root->SetIsDrawable(true); | 1099     root->SetIsDrawable(true); | 
| 1101 | 1100 | 
| 1102     texture_layer_ = TextureLayer::CreateForMailbox(layer_settings(), this); | 1101     texture_layer_ = TextureLayer::CreateForMailbox(this); | 
| 1103     texture_layer_->SetBounds(gfx::Size(10, 10)); | 1102     texture_layer_->SetBounds(gfx::Size(10, 10)); | 
| 1104     texture_layer_->SetIsDrawable(true); | 1103     texture_layer_->SetIsDrawable(true); | 
| 1105     root->AddChild(texture_layer_); | 1104     root->AddChild(texture_layer_); | 
| 1106 | 1105 | 
| 1107     layer_tree_host()->SetRootLayer(root); | 1106     layer_tree_host()->SetRootLayer(root); | 
| 1108     LayerTreeTest::SetupTree(); | 1107     LayerTreeTest::SetupTree(); | 
| 1109   } | 1108   } | 
| 1110 | 1109 | 
| 1111   void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1110   void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 
| 1112 | 1111 | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1186                           SyncTokenFromUInt(static_cast<uint32_t>(name)), | 1185                           SyncTokenFromUInt(static_cast<uint32_t>(name)), | 
| 1187                           GL_TEXTURE_2D); | 1186                           GL_TEXTURE_2D); | 
| 1188   } | 1187   } | 
| 1189 | 1188 | 
| 1190   void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { | 1189   void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { | 
| 1191     EXPECT_TRUE(sync_token.HasData()); | 1190     EXPECT_TRUE(sync_token.HasData()); | 
| 1192     ++mailbox_returned_; | 1191     ++mailbox_returned_; | 
| 1193   } | 1192   } | 
| 1194 | 1193 | 
| 1195   void SetupTree() override { | 1194   void SetupTree() override { | 
| 1196     scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 1195     scoped_refptr<Layer> root = Layer::Create(); | 
| 1197     root->SetBounds(gfx::Size(10, 10)); | 1196     root->SetBounds(gfx::Size(10, 10)); | 
| 1198     root->SetIsDrawable(true); | 1197     root->SetIsDrawable(true); | 
| 1199 | 1198 | 
| 1200     solid_layer_ = SolidColorLayer::Create(layer_settings()); | 1199     solid_layer_ = SolidColorLayer::Create(); | 
| 1201     solid_layer_->SetBounds(gfx::Size(10, 10)); | 1200     solid_layer_->SetBounds(gfx::Size(10, 10)); | 
| 1202     solid_layer_->SetIsDrawable(true); | 1201     solid_layer_->SetIsDrawable(true); | 
| 1203     solid_layer_->SetBackgroundColor(SK_ColorWHITE); | 1202     solid_layer_->SetBackgroundColor(SK_ColorWHITE); | 
| 1204     root->AddChild(solid_layer_); | 1203     root->AddChild(solid_layer_); | 
| 1205 | 1204 | 
| 1206     parent_layer_ = Layer::Create(layer_settings()); | 1205     parent_layer_ = Layer::Create(); | 
| 1207     parent_layer_->SetBounds(gfx::Size(10, 10)); | 1206     parent_layer_->SetBounds(gfx::Size(10, 10)); | 
| 1208     parent_layer_->SetIsDrawable(true); | 1207     parent_layer_->SetIsDrawable(true); | 
| 1209     root->AddChild(parent_layer_); | 1208     root->AddChild(parent_layer_); | 
| 1210 | 1209 | 
| 1211     texture_layer_ = TextureLayer::CreateForMailbox(layer_settings(), this); | 1210     texture_layer_ = TextureLayer::CreateForMailbox(this); | 
| 1212     texture_layer_->SetBounds(gfx::Size(10, 10)); | 1211     texture_layer_->SetBounds(gfx::Size(10, 10)); | 
| 1213     texture_layer_->SetIsDrawable(true); | 1212     texture_layer_->SetIsDrawable(true); | 
| 1214     parent_layer_->AddChild(texture_layer_); | 1213     parent_layer_->AddChild(texture_layer_); | 
| 1215 | 1214 | 
| 1216     layer_tree_host()->SetRootLayer(root); | 1215     layer_tree_host()->SetRootLayer(root); | 
| 1217     LayerTreeTest::SetupTree(); | 1216     LayerTreeTest::SetupTree(); | 
| 1218   } | 1217   } | 
| 1219 | 1218 | 
| 1220   void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1219   void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 
| 1221 | 1220 | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1317   } | 1316   } | 
| 1318 | 1317 | 
| 1319   void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { | 1318   void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { | 
| 1320     mailbox_released_ = true; | 1319     mailbox_released_ = true; | 
| 1321   } | 1320   } | 
| 1322 | 1321 | 
| 1323   void SetupTree() override { | 1322   void SetupTree() override { | 
| 1324     LayerTreeTest::SetupTree(); | 1323     LayerTreeTest::SetupTree(); | 
| 1325 | 1324 | 
| 1326     scoped_refptr<TextureLayer> texture_layer = | 1325     scoped_refptr<TextureLayer> texture_layer = | 
| 1327         TextureLayer::CreateForMailbox(layer_settings(), this); | 1326         TextureLayer::CreateForMailbox(this); | 
| 1328     texture_layer->SetBounds(gfx::Size(10, 10)); | 1327     texture_layer->SetBounds(gfx::Size(10, 10)); | 
| 1329     texture_layer->SetIsDrawable(true); | 1328     texture_layer->SetIsDrawable(true); | 
| 1330 | 1329 | 
| 1331     layer_tree_host()->root_layer()->AddChild(texture_layer); | 1330     layer_tree_host()->root_layer()->AddChild(texture_layer); | 
| 1332   } | 1331   } | 
| 1333 | 1332 | 
| 1334   void BeginTest() override { | 1333   void BeginTest() override { | 
| 1335     mailbox_released_ = false; | 1334     mailbox_released_ = false; | 
| 1336     PostSetNeedsCommitToMainThread(); | 1335     PostSetNeedsCommitToMainThread(); | 
| 1337   } | 1336   } | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1383             base::Unretained(this))); | 1382             base::Unretained(this))); | 
| 1384     layer_->SetTextureMailbox( | 1383     layer_->SetTextureMailbox( | 
| 1385         TextureMailbox(MailboxFromChar(mailbox_char), | 1384         TextureMailbox(MailboxFromChar(mailbox_char), | 
| 1386                        SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), | 1385                        SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), | 
| 1387                        GL_TEXTURE_2D), | 1386                        GL_TEXTURE_2D), | 
| 1388         std::move(callback)); | 1387         std::move(callback)); | 
| 1389   } | 1388   } | 
| 1390 | 1389 | 
| 1391   void SetupTree() override { | 1390   void SetupTree() override { | 
| 1392     gfx::Size bounds(100, 100); | 1391     gfx::Size bounds(100, 100); | 
| 1393     root_ = Layer::Create(layer_settings()); | 1392     root_ = Layer::Create(); | 
| 1394     root_->SetBounds(bounds); | 1393     root_->SetBounds(bounds); | 
| 1395 | 1394 | 
| 1396     layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); | 1395     layer_ = TextureLayer::CreateForMailbox(nullptr); | 
| 1397     layer_->SetIsDrawable(true); | 1396     layer_->SetIsDrawable(true); | 
| 1398     layer_->SetBounds(bounds); | 1397     layer_->SetBounds(bounds); | 
| 1399 | 1398 | 
| 1400     root_->AddChild(layer_); | 1399     root_->AddChild(layer_); | 
| 1401     layer_tree_host()->SetRootLayer(root_); | 1400     layer_tree_host()->SetRootLayer(root_); | 
| 1402     layer_tree_host()->SetViewportSize(bounds); | 1401     layer_tree_host()->SetViewportSize(bounds); | 
| 1403   } | 1402   } | 
| 1404 | 1403 | 
| 1405   void BeginTest() override { | 1404   void BeginTest() override { | 
| 1406     EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1405     EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1454             base::Unretained(this))); | 1453             base::Unretained(this))); | 
| 1455     layer_->SetTextureMailbox( | 1454     layer_->SetTextureMailbox( | 
| 1456         TextureMailbox(MailboxFromChar(mailbox_char), | 1455         TextureMailbox(MailboxFromChar(mailbox_char), | 
| 1457                        SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), | 1456                        SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), | 
| 1458                        GL_TEXTURE_2D), | 1457                        GL_TEXTURE_2D), | 
| 1459         std::move(callback)); | 1458         std::move(callback)); | 
| 1460   } | 1459   } | 
| 1461 | 1460 | 
| 1462   void SetupTree() override { | 1461   void SetupTree() override { | 
| 1463     gfx::Size bounds(100, 100); | 1462     gfx::Size bounds(100, 100); | 
| 1464     root_ = Layer::Create(layer_settings()); | 1463     root_ = Layer::Create(); | 
| 1465     root_->SetBounds(bounds); | 1464     root_->SetBounds(bounds); | 
| 1466 | 1465 | 
| 1467     layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); | 1466     layer_ = TextureLayer::CreateForMailbox(nullptr); | 
| 1468     layer_->SetIsDrawable(true); | 1467     layer_->SetIsDrawable(true); | 
| 1469     layer_->SetBounds(bounds); | 1468     layer_->SetBounds(bounds); | 
| 1470 | 1469 | 
| 1471     root_->AddChild(layer_); | 1470     root_->AddChild(layer_); | 
| 1472     layer_tree_host()->SetRootLayer(root_); | 1471     layer_tree_host()->SetRootLayer(root_); | 
| 1473     layer_tree_host()->SetViewportSize(bounds); | 1472     layer_tree_host()->SetViewportSize(bounds); | 
| 1474   } | 1473   } | 
| 1475 | 1474 | 
| 1476   void BeginTest() override { | 1475   void BeginTest() override { | 
| 1477     EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1476     EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 1506   int callback_count_; | 1505   int callback_count_; | 
| 1507   scoped_refptr<Layer> root_; | 1506   scoped_refptr<Layer> root_; | 
| 1508   scoped_refptr<TextureLayer> layer_; | 1507   scoped_refptr<TextureLayer> layer_; | 
| 1509 }; | 1508 }; | 
| 1510 | 1509 | 
| 1511 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1510 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 
| 1512     TextureLayerWithMailboxImplThreadDeleted); | 1511     TextureLayerWithMailboxImplThreadDeleted); | 
| 1513 | 1512 | 
| 1514 }  // namespace | 1513 }  // namespace | 
| 1515 }  // namespace cc | 1514 }  // namespace cc | 
| OLD | NEW | 
|---|