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 | |
362 class TextureLayerMailboxHolderTest : public TextureLayerTest { | 335 class TextureLayerMailboxHolderTest : public TextureLayerTest { |
363 public: | 336 public: |
364 TextureLayerMailboxHolderTest() | 337 TextureLayerMailboxHolderTest() |
365 : main_thread_("MAIN") { | 338 : main_thread_("MAIN") { |
366 main_thread_.Start(); | 339 main_thread_.Start(); |
367 main_thread_.message_loop()->task_runner()->PostTask( | 340 main_thread_.message_loop()->task_runner()->PostTask( |
368 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain, | 341 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::InitializeOnMain, |
369 base::Unretained(this))); | 342 base::Unretained(this))); |
370 Wait(main_thread_); | 343 Wait(main_thread_); |
371 } | 344 } |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 int callback_count_; | 1483 int callback_count_; |
1511 scoped_refptr<Layer> root_; | 1484 scoped_refptr<Layer> root_; |
1512 scoped_refptr<TextureLayer> layer_; | 1485 scoped_refptr<TextureLayer> layer_; |
1513 }; | 1486 }; |
1514 | 1487 |
1515 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1488 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1516 TextureLayerWithMailboxImplThreadDeleted); | 1489 TextureLayerWithMailboxImplThreadDeleted); |
1517 | 1490 |
1518 } // namespace | 1491 } // namespace |
1519 } // namespace cc | 1492 } // namespace cc |
OLD | NEW |