| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 325 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 326 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 326 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 327 | 327 |
| 328 // Test destructor. | 328 // Test destructor. |
| 329 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 329 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
| 330 test_layer->SetTextureMailbox( | 330 test_layer->SetTextureMailbox( |
| 331 test_data_.mailbox1_, | 331 test_data_.mailbox1_, |
| 332 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 332 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
| 333 } | 333 } |
| 334 | 334 |
| 335 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { |
| 336 scoped_refptr<TextureLayer> test_layer = |
| 337 TextureLayer::CreateForMailbox(nullptr); |
| 338 ASSERT_TRUE(test_layer.get()); |
| 339 |
| 340 // These use the same gpu::Mailbox, but different sync points. |
| 341 TextureMailbox mailbox1(MailboxFromChar('a'), SyncTokenFromUInt(1), |
| 342 GL_TEXTURE_2D); |
| 343 TextureMailbox mailbox2(MailboxFromChar('a'), SyncTokenFromUInt(2), |
| 344 GL_TEXTURE_2D); |
| 345 |
| 346 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
| 347 layer_tree_host_->SetRootLayer(test_layer); |
| 348 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 349 |
| 350 // Set the mailbox the first time. It should cause a commit. |
| 351 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
| 352 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1); |
| 353 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 354 |
| 355 // Set the mailbox again with a new sync point, as the backing texture has |
| 356 // been updated. It should cause a new commit. |
| 357 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
| 358 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox2); |
| 359 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 360 } |
| 361 |
| 335 class TextureLayerMailboxHolderTest : public TextureLayerTest { | 362 class TextureLayerMailboxHolderTest : public TextureLayerTest { |
| 336 public: | 363 public: |
| 337 TextureLayerMailboxHolderTest() | 364 TextureLayerMailboxHolderTest() |
| 338 : main_thread_("MAIN") { | 365 : main_thread_("MAIN") { |
| 339 main_thread_.Start(); | 366 main_thread_.Start(); |
| 340 main_thread_.message_loop()->task_runner()->PostTask( | 367 main_thread_.message_loop()->task_runner()->PostTask( |
| 341 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain, | 368 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain, |
| 342 base::Unretained(this))); | 369 base::Unretained(this))); |
| 343 Wait(main_thread_); | 370 Wait(main_thread_); |
| 344 } | 371 } |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 int callback_count_; | 1510 int callback_count_; |
| 1484 scoped_refptr<Layer> root_; | 1511 scoped_refptr<Layer> root_; |
| 1485 scoped_refptr<TextureLayer> layer_; | 1512 scoped_refptr<TextureLayer> layer_; |
| 1486 }; | 1513 }; |
| 1487 | 1514 |
| 1488 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1515 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1489 TextureLayerWithMailboxImplThreadDeleted); | 1516 TextureLayerWithMailboxImplThreadDeleted); |
| 1490 | 1517 |
| 1491 } // namespace | 1518 } // namespace |
| 1492 } // namespace cc | 1519 } // namespace cc |
| OLD | NEW |