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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 371 |
372 protected: | 372 protected: |
373 virtual ~TestMailboxHolder() {} | 373 virtual ~TestMailboxHolder() {} |
374 }; | 374 }; |
375 | 375 |
376 class TextureLayerWithMailboxTest : public TextureLayerTest { | 376 class TextureLayerWithMailboxTest : public TextureLayerTest { |
377 protected: | 377 protected: |
378 virtual void TearDown() { | 378 virtual void TearDown() { |
379 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 379 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
380 EXPECT_CALL(test_data_.mock_callback_, | 380 EXPECT_CALL(test_data_.mock_callback_, |
381 Release(test_data_.mailbox_name1_, | 381 Release(test_data_.mailbox_name1_, 0, false)).Times(1); |
382 test_data_.sync_point1_, | |
383 false)).Times(1); | |
384 TextureLayerTest::TearDown(); | 382 TextureLayerTest::TearDown(); |
385 } | 383 } |
386 | 384 |
387 CommonMailboxObjects test_data_; | 385 CommonMailboxObjects test_data_; |
388 }; | 386 }; |
389 | 387 |
390 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { | 388 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { |
391 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); | 389 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox(NULL); |
392 ASSERT_TRUE(test_layer.get()); | 390 ASSERT_TRUE(test_layer.get()); |
393 | 391 |
394 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 392 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
395 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 393 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
396 layer_tree_host_->SetRootLayer(test_layer); | 394 layer_tree_host_->SetRootLayer(test_layer); |
397 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 395 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
398 | 396 |
399 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 397 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
400 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 398 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
401 test_layer->SetTextureMailbox( | 399 test_layer->SetTextureMailbox( |
402 test_data_.mailbox1_, | 400 test_data_.mailbox1_, |
403 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 401 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
404 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 402 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
405 | 403 |
406 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 404 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
407 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 405 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
408 EXPECT_CALL(test_data_.mock_callback_, | 406 EXPECT_CALL(test_data_.mock_callback_, |
409 Release(test_data_.mailbox_name1_, | 407 Release(test_data_.mailbox_name1_, 0, false)).Times(1); |
410 test_data_.sync_point1_, | |
411 false)) | |
412 .Times(1); | |
413 test_layer->SetTextureMailbox( | 408 test_layer->SetTextureMailbox( |
414 test_data_.mailbox2_, | 409 test_data_.mailbox2_, |
415 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); | 410 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); |
416 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 411 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
417 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 412 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
418 | 413 |
419 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 414 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
420 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 415 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
421 EXPECT_CALL(test_data_.mock_callback_, | 416 EXPECT_CALL(test_data_.mock_callback_, |
422 Release(test_data_.mailbox_name2_, | 417 Release(test_data_.mailbox_name2_, 0, false)).Times(1); |
423 test_data_.sync_point2_, | |
424 false)) | |
425 .Times(1); | |
426 test_layer->SetTextureMailbox(TextureMailbox(), | 418 test_layer->SetTextureMailbox(TextureMailbox(), |
427 scoped_ptr<SingleReleaseCallback>()); | 419 scoped_ptr<SingleReleaseCallback>()); |
428 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 420 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
429 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 421 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
430 | 422 |
431 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); | 423 EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(0); |
432 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 424 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
433 test_layer->SetTextureMailbox( | 425 test_layer->SetTextureMailbox( |
434 test_data_.mailbox3_, | 426 test_data_.mailbox3_, |
435 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); | 427 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 return will_draw; | 1138 return will_draw; |
1147 } | 1139 } |
1148 | 1140 |
1149 CommonMailboxObjects test_data_; | 1141 CommonMailboxObjects test_data_; |
1150 FakeLayerTreeHostClient fake_client_; | 1142 FakeLayerTreeHostClient fake_client_; |
1151 }; | 1143 }; |
1152 | 1144 |
1153 // Test conditions for results of TextureLayerImpl::WillDraw under | 1145 // Test conditions for results of TextureLayerImpl::WillDraw under |
1154 // different configurations of different mailbox, texture_id, and draw_mode. | 1146 // different configurations of different mailbox, texture_id, and draw_mode. |
1155 TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { | 1147 TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { |
| 1148 EXPECT_CALL( |
| 1149 test_data_.mock_callback_, |
| 1150 Release(test_data_.mailbox_name1_, test_data_.sync_point1_, false)) |
| 1151 .Times(0); |
1156 EXPECT_CALL(test_data_.mock_callback_, | 1152 EXPECT_CALL(test_data_.mock_callback_, |
1157 Release(test_data_.mailbox_name1_, | 1153 Release(test_data_.mailbox_name1_, 0, false)).Times(AnyNumber()); |
1158 test_data_.sync_point1_, | |
1159 false)) | |
1160 .Times(AnyNumber()); | |
1161 EXPECT_CALL(test_data_.mock_callback_, | 1154 EXPECT_CALL(test_data_.mock_callback_, |
1162 Release2(test_data_.shared_memory_.get(), 0, false)) | 1155 Release2(test_data_.shared_memory_.get(), 0, false)) |
1163 .Times(AnyNumber()); | 1156 .Times(AnyNumber()); |
1164 // Hardware mode. | 1157 // Hardware mode. |
1165 { | 1158 { |
1166 scoped_ptr<TextureLayerImpl> impl_layer = | 1159 scoped_ptr<TextureLayerImpl> impl_layer = |
1167 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1160 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1168 impl_layer->SetDrawsContent(true); | 1161 impl_layer->SetDrawsContent(true); |
1169 impl_layer->SetTextureMailbox( | 1162 impl_layer->SetTextureMailbox( |
1170 test_data_.mailbox1_, | 1163 test_data_.mailbox1_, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 scoped_ptr<LayerImpl> active_layer( | 1289 scoped_ptr<LayerImpl> active_layer( |
1297 pending_layer->CreateLayerImpl(host_impl_.active_tree())); | 1290 pending_layer->CreateLayerImpl(host_impl_.active_tree())); |
1298 ASSERT_TRUE(active_layer); | 1291 ASSERT_TRUE(active_layer); |
1299 | 1292 |
1300 pending_layer->SetTextureMailbox( | 1293 pending_layer->SetTextureMailbox( |
1301 test_data_.mailbox1_, | 1294 test_data_.mailbox1_, |
1302 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1295 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
1303 | 1296 |
1304 // Test multiple commits without an activation. | 1297 // Test multiple commits without an activation. |
1305 EXPECT_CALL(test_data_.mock_callback_, | 1298 EXPECT_CALL(test_data_.mock_callback_, |
1306 Release(test_data_.mailbox_name1_, | 1299 Release(test_data_.mailbox_name1_, 0, false)).Times(1); |
1307 test_data_.sync_point1_, | |
1308 false)) | |
1309 .Times(1); | |
1310 pending_layer->SetTextureMailbox( | 1300 pending_layer->SetTextureMailbox( |
1311 test_data_.mailbox2_, | 1301 test_data_.mailbox2_, |
1312 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); | 1302 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); |
1313 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1303 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1314 | 1304 |
1315 // Test callback after activation. | 1305 // Test callback after activation. |
1316 pending_layer->PushPropertiesTo(active_layer.get()); | 1306 pending_layer->PushPropertiesTo(active_layer.get()); |
1317 active_layer->DidBecomeActive(); | 1307 active_layer->DidBecomeActive(); |
1318 | 1308 |
1319 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); | 1309 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); |
(...skipping 14 matching lines...) Expand all Loading... |
1334 Release(test_data_.mailbox_name1_, _, false)) | 1324 Release(test_data_.mailbox_name1_, _, false)) |
1335 .Times(1); | 1325 .Times(1); |
1336 pending_layer->SetTextureMailbox(TextureMailbox(), | 1326 pending_layer->SetTextureMailbox(TextureMailbox(), |
1337 scoped_ptr<SingleReleaseCallback>()); | 1327 scoped_ptr<SingleReleaseCallback>()); |
1338 pending_layer->PushPropertiesTo(active_layer.get()); | 1328 pending_layer->PushPropertiesTo(active_layer.get()); |
1339 active_layer->DidBecomeActive(); | 1329 active_layer->DidBecomeActive(); |
1340 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 1330 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
1341 | 1331 |
1342 // Test destructor. | 1332 // Test destructor. |
1343 EXPECT_CALL(test_data_.mock_callback_, | 1333 EXPECT_CALL(test_data_.mock_callback_, |
1344 Release(test_data_.mailbox_name1_, | 1334 Release(test_data_.mailbox_name1_, 0, false)).Times(1); |
1345 test_data_.sync_point1_, | |
1346 false)) | |
1347 .Times(1); | |
1348 pending_layer->SetTextureMailbox( | 1335 pending_layer->SetTextureMailbox( |
1349 test_data_.mailbox1_, | 1336 test_data_.mailbox1_, |
1350 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1337 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
1351 } | 1338 } |
1352 | 1339 |
1353 TEST_F(TextureLayerImplWithMailboxTest, | 1340 TEST_F(TextureLayerImplWithMailboxTest, |
1354 TestDestructorCallbackOnCreatedResource) { | 1341 TestDestructorCallbackOnCreatedResource) { |
1355 scoped_ptr<TextureLayerImpl> impl_layer; | 1342 scoped_ptr<TextureLayerImpl> impl_layer; |
1356 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1343 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
1357 ASSERT_TRUE(impl_layer); | 1344 ASSERT_TRUE(impl_layer); |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2145 int callback_count_; | 2132 int callback_count_; |
2146 scoped_refptr<Layer> root_; | 2133 scoped_refptr<Layer> root_; |
2147 scoped_refptr<TextureLayer> layer_; | 2134 scoped_refptr<TextureLayer> layer_; |
2148 }; | 2135 }; |
2149 | 2136 |
2150 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2137 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
2151 TextureLayerWithMailboxImplThreadDeleted); | 2138 TextureLayerWithMailboxImplThreadDeleted); |
2152 | 2139 |
2153 } // namespace | 2140 } // namespace |
2154 } // namespace cc | 2141 } // namespace cc |
OLD | NEW |