| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 switch (commit_count_) { | 316 switch (commit_count_) { |
| 317 case 1: | 317 case 1: |
| 318 // Case #2: change mailbox after the commit (and draw), where the | 318 // Case #2: change mailbox after the commit (and draw), where the |
| 319 // layer draws. The old mailbox should be released during the next | 319 // layer draws. The old mailbox should be released during the next |
| 320 // commit. | 320 // commit. |
| 321 SetMailbox('3'); | 321 SetMailbox('3'); |
| 322 EXPECT_EQ(1, callback_count_); | 322 EXPECT_EQ(1, callback_count_); |
| 323 break; | 323 break; |
| 324 case 2: | 324 case 2: |
| 325 // Old mailbox was released, task was posted, but won't execute | 325 // Old mailbox was released, task was posted, but won't execute |
| 326 // until this didCommit returns. | 326 // until this DidCommit returns. |
| 327 // TODO(piman): fix this. | 327 // TODO(piman): fix this. |
| 328 EXPECT_EQ(1, callback_count_); | 328 EXPECT_EQ(1, callback_count_); |
| 329 layer_tree_host()->SetNeedsCommit(); | 329 layer_tree_host()->SetNeedsCommit(); |
| 330 break; | 330 break; |
| 331 case 3: | 331 case 3: |
| 332 EXPECT_EQ(2, callback_count_); | 332 EXPECT_EQ(2, callback_count_); |
| 333 // Case #3: change mailbox when the layer doesn't draw. The old | 333 // Case #3: change mailbox when the layer doesn't draw. The old |
| 334 // mailbox should be released during the next commit. | 334 // mailbox should be released during the next commit. |
| 335 layer_->SetBounds(gfx::Size()); | 335 layer_->SetBounds(gfx::Size()); |
| 336 SetMailbox('4'); | 336 SetMailbox('4'); |
| 337 break; | 337 break; |
| 338 case 4: | 338 case 4: |
| 339 // Old mailbox was released, task was posted, but won't execute | 339 // Old mailbox was released, task was posted, but won't execute |
| 340 // until this didCommit returns. | 340 // until this DidCommit returns. |
| 341 // TODO(piman): fix this. | 341 // TODO(piman): fix this. |
| 342 EXPECT_EQ(2, callback_count_); | 342 EXPECT_EQ(2, callback_count_); |
| 343 layer_tree_host()->SetNeedsCommit(); | 343 layer_tree_host()->SetNeedsCommit(); |
| 344 break; | 344 break; |
| 345 case 5: | 345 case 5: |
| 346 EXPECT_EQ(3, callback_count_); | 346 EXPECT_EQ(3, callback_count_); |
| 347 // Case #4: release mailbox that was committed but never drawn. The | 347 // Case #4: release mailbox that was committed but never drawn. The |
| 348 // old mailbox should be released during the next commit. | 348 // old mailbox should be released during the next commit. |
| 349 layer_->SetTextureMailbox(TextureMailbox()); | 349 layer_->SetTextureMailbox(TextureMailbox()); |
| 350 break; | 350 break; |
| 351 case 6: | 351 case 6: |
| 352 // Old mailbox was released, task was posted, but won't execute | 352 // Old mailbox was released, task was posted, but won't execute |
| 353 // until this didCommit returns. | 353 // until this DidCommit returns. |
| 354 // TODO(piman): fix this. | 354 // TODO(piman): fix this. |
| 355 EXPECT_EQ(3, callback_count_); | 355 EXPECT_EQ(3, callback_count_); |
| 356 layer_tree_host()->SetNeedsCommit(); | 356 layer_tree_host()->SetNeedsCommit(); |
| 357 break; | 357 break; |
| 358 case 7: | 358 case 7: |
| 359 EXPECT_EQ(4, callback_count_); | 359 EXPECT_EQ(4, callback_count_); |
| 360 EndTest(); | 360 EndTest(); |
| 361 break; | 361 break; |
| 362 default: | 362 default: |
| 363 NOTREACHED(); | 363 NOTREACHED(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 391 CommonMailboxObjects test_data_; | 391 CommonMailboxObjects test_data_; |
| 392 FakeLayerTreeHostClient fake_client_; | 392 FakeLayerTreeHostClient fake_client_; |
| 393 }; | 393 }; |
| 394 | 394 |
| 395 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { | 395 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { |
| 396 host_impl_.CreatePendingTree(); | 396 host_impl_.CreatePendingTree(); |
| 397 scoped_ptr<TextureLayerImpl> pending_layer; | 397 scoped_ptr<TextureLayerImpl> pending_layer; |
| 398 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); | 398 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); |
| 399 ASSERT_TRUE(pending_layer); | 399 ASSERT_TRUE(pending_layer); |
| 400 | 400 |
| 401 scoped_ptr<LayerImpl> activeLayer( | 401 scoped_ptr<LayerImpl> active_layer( |
| 402 pending_layer->CreateLayerImpl(host_impl_.active_tree())); | 402 pending_layer->CreateLayerImpl(host_impl_.active_tree())); |
| 403 ASSERT_TRUE(activeLayer); | 403 ASSERT_TRUE(active_layer); |
| 404 | 404 |
| 405 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 405 pending_layer->SetTextureMailbox(test_data_.mailbox1_); |
| 406 | 406 |
| 407 // Test multiple commits without an activation. | 407 // Test multiple commits without an activation. |
| 408 EXPECT_CALL(test_data_.mock_callback_, | 408 EXPECT_CALL(test_data_.mock_callback_, |
| 409 Release(test_data_.mailbox_name1_, test_data_.sync_point1_)) | 409 Release(test_data_.mailbox_name1_, test_data_.sync_point1_)) |
| 410 .Times(1); | 410 .Times(1); |
| 411 pending_layer->SetTextureMailbox(test_data_.mailbox2_); | 411 pending_layer->SetTextureMailbox(test_data_.mailbox2_); |
| 412 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 412 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 413 | 413 |
| 414 // Test callback after activation. | 414 // Test callback after activation. |
| 415 pending_layer->PushPropertiesTo(activeLayer.get()); | 415 pending_layer->PushPropertiesTo(active_layer.get()); |
| 416 activeLayer->DidBecomeActive(); | 416 active_layer->DidBecomeActive(); |
| 417 | 417 |
| 418 EXPECT_CALL(test_data_.mock_callback_, Release(_, _)).Times(0); | 418 EXPECT_CALL(test_data_.mock_callback_, Release(_, _)).Times(0); |
| 419 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 419 pending_layer->SetTextureMailbox(test_data_.mailbox1_); |
| 420 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 420 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 421 | 421 |
| 422 EXPECT_CALL(test_data_.mock_callback_, Release(test_data_.mailbox_name2_, _)) | 422 EXPECT_CALL(test_data_.mock_callback_, Release(test_data_.mailbox_name2_, _)) |
| 423 .Times(1); | 423 .Times(1); |
| 424 pending_layer->PushPropertiesTo(activeLayer.get()); | 424 pending_layer->PushPropertiesTo(active_layer.get()); |
| 425 activeLayer->DidBecomeActive(); | 425 active_layer->DidBecomeActive(); |
| 426 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 426 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 427 | 427 |
| 428 // Test resetting the mailbox. | 428 // Test resetting the mailbox. |
| 429 EXPECT_CALL(test_data_.mock_callback_, Release(test_data_.mailbox_name1_, _)) | 429 EXPECT_CALL(test_data_.mock_callback_, Release(test_data_.mailbox_name1_, _)) |
| 430 .Times(1); | 430 .Times(1); |
| 431 pending_layer->SetTextureMailbox(TextureMailbox()); | 431 pending_layer->SetTextureMailbox(TextureMailbox()); |
| 432 pending_layer->PushPropertiesTo(activeLayer.get()); | 432 pending_layer->PushPropertiesTo(active_layer.get()); |
| 433 activeLayer->DidBecomeActive(); | 433 active_layer->DidBecomeActive(); |
| 434 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 434 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 435 | 435 |
| 436 // Test destructor. | 436 // Test destructor. |
| 437 EXPECT_CALL(test_data_.mock_callback_, | 437 EXPECT_CALL(test_data_.mock_callback_, |
| 438 Release(test_data_.mailbox_name1_, test_data_.sync_point1_)) | 438 Release(test_data_.mailbox_name1_, test_data_.sync_point1_)) |
| 439 .Times(1); | 439 .Times(1); |
| 440 pending_layer->SetTextureMailbox(test_data_.mailbox1_); | 440 pending_layer->SetTextureMailbox(test_data_.mailbox1_); |
| 441 } | 441 } |
| 442 | 442 |
| 443 TEST_F(TextureLayerImplWithMailboxTest, | 443 TEST_F(TextureLayerImplWithMailboxTest, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 469 EXPECT_CALL(test_data_.mock_callback_, Release(_, _)).Times(0); | 469 EXPECT_CALL(test_data_.mock_callback_, Release(_, _)).Times(0); |
| 470 provider->DeleteResource(id); | 470 provider->DeleteResource(id); |
| 471 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 471 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
| 472 EXPECT_CALL(test_data_.mock_callback_, Release(test_data_.mailbox_name1_, _)) | 472 EXPECT_CALL(test_data_.mock_callback_, Release(test_data_.mailbox_name1_, _)) |
| 473 .Times(1); | 473 .Times(1); |
| 474 provider->ReceiveFromParent(list); | 474 provider->ReceiveFromParent(list); |
| 475 } | 475 } |
| 476 | 476 |
| 477 } // namespace | 477 } // namespace |
| 478 } // namespace cc | 478 } // namespace cc |
| OLD | NEW |