Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 657103003: cc: Change scoped_ptr<T>() to nullptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); 336 SingleReleaseCallback::Create(test_data_.release_mailbox2_));
337 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 337 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
338 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 338 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
339 339
340 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 340 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
341 EXPECT_CALL(test_data_.mock_callback_, 341 EXPECT_CALL(test_data_.mock_callback_,
342 Release(test_data_.mailbox_name2_, 342 Release(test_data_.mailbox_name2_,
343 test_data_.sync_point2_, 343 test_data_.sync_point2_,
344 false)) 344 false))
345 .Times(1); 345 .Times(1);
346 test_layer->SetTextureMailbox(TextureMailbox(), 346 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
347 scoped_ptr<SingleReleaseCallback>());
348 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 347 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
349 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 348 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
350 349
351 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 350 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
352 test_layer->SetTextureMailbox( 351 test_layer->SetTextureMailbox(
353 test_data_.mailbox3_, 352 test_data_.mailbox3_,
354 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); 353 SingleReleaseCallback::Create(test_data_.release_mailbox3_));
355 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 354 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
356 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 355 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
357 356
358 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 357 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
359 EXPECT_CALL(test_data_.mock_callback_, 358 EXPECT_CALL(test_data_.mock_callback_,
360 Release2(test_data_.shared_memory_.get(), 359 Release2(test_data_.shared_memory_.get(),
361 0, false)) 360 0, false))
362 .Times(1); 361 .Times(1);
363 test_layer->SetTextureMailbox(TextureMailbox(), 362 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
364 scoped_ptr<SingleReleaseCallback>());
365 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 363 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
366 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 364 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
367 365
368 // Test destructor. 366 // Test destructor.
369 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 367 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
370 test_layer->SetTextureMailbox( 368 test_layer->SetTextureMailbox(
371 test_data_.mailbox1_, 369 test_data_.mailbox1_,
372 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 370 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
373 } 371 }
374 372
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 EXPECT_EQ(2, callback_count_); 764 EXPECT_EQ(2, callback_count_);
767 // Case #3: change mailbox when the layer doesn't draw. The old 765 // Case #3: change mailbox when the layer doesn't draw. The old
768 // mailbox should be released during the next commit. 766 // mailbox should be released during the next commit.
769 layer_->SetBounds(gfx::Size()); 767 layer_->SetBounds(gfx::Size());
770 SetMailbox('4'); 768 SetMailbox('4');
771 break; 769 break;
772 case 3: 770 case 3:
773 EXPECT_EQ(3, callback_count_); 771 EXPECT_EQ(3, callback_count_);
774 // Case #4: release mailbox that was committed but never drawn. The 772 // Case #4: release mailbox that was committed but never drawn. The
775 // old mailbox should be released during the next commit. 773 // old mailbox should be released during the next commit.
776 layer_->SetTextureMailbox(TextureMailbox(), 774 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
777 scoped_ptr<SingleReleaseCallback>());
778 break; 775 break;
779 case 4: 776 case 4:
780 if (layer_tree_host()->settings().impl_side_painting) { 777 if (layer_tree_host()->settings().impl_side_painting) {
781 // With impl painting, the texture mailbox will still be on the impl 778 // With impl painting, the texture mailbox will still be on the impl
782 // thread when the commit finishes, because the layer is not drawble 779 // thread when the commit finishes, because the layer is not drawble
783 // when it has no texture mailbox, and thus does not block the commit 780 // when it has no texture mailbox, and thus does not block the commit
784 // on activation. So, we wait for activation. 781 // on activation. So, we wait for activation.
785 // TODO(danakj): fix this. crbug.com/277953 782 // TODO(danakj): fix this. crbug.com/277953
786 layer_tree_host()->SetNeedsCommit(); 783 layer_tree_host()->SetNeedsCommit();
787 break; 784 break;
(...skipping 18 matching lines...) Expand all
806 // block the commit on activation anymore. So, we wait for activation. 803 // block the commit on activation anymore. So, we wait for activation.
807 // TODO(danakj): fix this. crbug.com/277953 804 // TODO(danakj): fix this. crbug.com/277953
808 layer_tree_host()->SetNeedsCommit(); 805 layer_tree_host()->SetNeedsCommit();
809 break; 806 break;
810 } else { 807 } else {
811 ++commit_count_; 808 ++commit_count_;
812 } 809 }
813 case 8: 810 case 8:
814 EXPECT_EQ(4, callback_count_); 811 EXPECT_EQ(4, callback_count_);
815 // Resetting the mailbox will call the callback now. 812 // Resetting the mailbox will call the callback now.
816 layer_->SetTextureMailbox(TextureMailbox(), 813 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
817 scoped_ptr<SingleReleaseCallback>());
818 EXPECT_EQ(5, callback_count_); 814 EXPECT_EQ(5, callback_count_);
819 EndTest(); 815 EndTest();
820 break; 816 break;
821 default: 817 default:
822 NOTREACHED(); 818 NOTREACHED();
823 break; 819 break;
824 } 820 }
825 } 821 }
826 822
827 virtual void AfterTest() override {} 823 virtual void AfterTest() override {}
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 964 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
969 impl_layer->SetTextureMailbox( 965 impl_layer->SetTextureMailbox(
970 test_data_.mailbox1_, 966 test_data_.mailbox1_,
971 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 967 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
972 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 968 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
973 } 969 }
974 970
975 { 971 {
976 scoped_ptr<TextureLayerImpl> impl_layer = 972 scoped_ptr<TextureLayerImpl> impl_layer =
977 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 973 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
978 impl_layer->SetTextureMailbox(TextureMailbox(), 974 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
979 scoped_ptr<SingleReleaseCallbackImpl>());
980 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 975 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
981 } 976 }
982 977
983 { 978 {
984 // Software resource. 979 // Software resource.
985 scoped_ptr<TextureLayerImpl> impl_layer = 980 scoped_ptr<TextureLayerImpl> impl_layer =
986 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 981 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
987 impl_layer->SetTextureMailbox( 982 impl_layer->SetTextureMailbox(
988 test_data_.mailbox3_, 983 test_data_.mailbox3_,
989 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_)); 984 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
990 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 985 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
991 } 986 }
992 987
993 // Software mode. 988 // Software mode.
994 { 989 {
995 scoped_ptr<TextureLayerImpl> impl_layer = 990 scoped_ptr<TextureLayerImpl> impl_layer =
996 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 991 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
997 impl_layer->SetTextureMailbox( 992 impl_layer->SetTextureMailbox(
998 test_data_.mailbox1_, 993 test_data_.mailbox1_,
999 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 994 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
1000 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 995 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
1001 } 996 }
1002 997
1003 { 998 {
1004 scoped_ptr<TextureLayerImpl> impl_layer = 999 scoped_ptr<TextureLayerImpl> impl_layer =
1005 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 1000 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1006 impl_layer->SetTextureMailbox(TextureMailbox(), 1001 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
1007 scoped_ptr<SingleReleaseCallbackImpl>());
1008 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); 1002 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE));
1009 } 1003 }
1010 1004
1011 { 1005 {
1012 // Software resource. 1006 // Software resource.
1013 scoped_ptr<TextureLayerImpl> impl_layer = 1007 scoped_ptr<TextureLayerImpl> impl_layer =
1014 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 1008 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1015 impl_layer->SetTextureMailbox( 1009 impl_layer->SetTextureMailbox(
1016 test_data_.mailbox3_, 1010 test_data_.mailbox3_,
1017 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_)); 1011 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox3_impl_));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 1059
1066 EXPECT_CALL(test_data_.mock_callback_, 1060 EXPECT_CALL(test_data_.mock_callback_,
1067 ReleaseImpl(test_data_.mailbox_name2_, _, false, _)).Times(1); 1061 ReleaseImpl(test_data_.mailbox_name2_, _, false, _)).Times(1);
1068 pending_layer->PushPropertiesTo(active_layer.get()); 1062 pending_layer->PushPropertiesTo(active_layer.get());
1069 active_layer->DidBecomeActive(); 1063 active_layer->DidBecomeActive();
1070 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 1064 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
1071 1065
1072 // Test resetting the mailbox. 1066 // Test resetting the mailbox.
1073 EXPECT_CALL(test_data_.mock_callback_, 1067 EXPECT_CALL(test_data_.mock_callback_,
1074 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1); 1068 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
1075 pending_layer->SetTextureMailbox(TextureMailbox(), 1069 pending_layer->SetTextureMailbox(TextureMailbox(), nullptr);
1076 scoped_ptr<SingleReleaseCallbackImpl>());
1077 pending_layer->PushPropertiesTo(active_layer.get()); 1070 pending_layer->PushPropertiesTo(active_layer.get());
1078 active_layer->DidBecomeActive(); 1071 active_layer->DidBecomeActive();
1079 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 1072 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
1080 1073
1081 // Test destructor. 1074 // Test destructor.
1082 EXPECT_CALL( 1075 EXPECT_CALL(
1083 test_data_.mock_callback_, 1076 test_data_.mock_callback_,
1084 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _)) 1077 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _))
1085 .Times(1); 1078 .Times(1);
1086 pending_layer->SetTextureMailbox( 1079 pending_layer->SetTextureMailbox(
1087 test_data_.mailbox1_, 1080 test_data_.mailbox1_,
1088 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 1081 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
1089 } 1082 }
1090 1083
1091 TEST_F(TextureLayerImplWithMailboxTest, 1084 TEST_F(TextureLayerImplWithMailboxTest,
1092 TestDestructorCallbackOnCreatedResource) { 1085 TestDestructorCallbackOnCreatedResource) {
1093 scoped_ptr<TextureLayerImpl> impl_layer; 1086 scoped_ptr<TextureLayerImpl> impl_layer;
1094 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); 1087 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1);
1095 ASSERT_TRUE(impl_layer); 1088 ASSERT_TRUE(impl_layer);
1096 1089
1097 EXPECT_CALL(test_data_.mock_callback_, 1090 EXPECT_CALL(test_data_.mock_callback_,
1098 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1); 1091 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
1099 impl_layer->SetTextureMailbox( 1092 impl_layer->SetTextureMailbox(
1100 test_data_.mailbox1_, 1093 test_data_.mailbox1_,
1101 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 1094 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
1102 impl_layer->DidBecomeActive(); 1095 impl_layer->DidBecomeActive();
1103 EXPECT_TRUE(impl_layer->WillDraw( 1096 EXPECT_TRUE(impl_layer->WillDraw(
1104 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); 1097 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
1105 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); 1098 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider());
1106 impl_layer->SetTextureMailbox(TextureMailbox(), 1099 impl_layer->SetTextureMailbox(TextureMailbox(), nullptr);
1107 scoped_ptr<SingleReleaseCallbackImpl>());
1108 } 1100 }
1109 1101
1110 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { 1102 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) {
1111 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); 1103 ResourceProvider* provider = host_impl_.active_tree()->resource_provider();
1112 ResourceProvider::ResourceId id = provider->CreateResourceFromTextureMailbox( 1104 ResourceProvider::ResourceId id = provider->CreateResourceFromTextureMailbox(
1113 test_data_.mailbox1_, 1105 test_data_.mailbox1_,
1114 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 1106 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
1115 provider->AllocateForTesting(id); 1107 provider->AllocateForTesting(id);
1116 1108
1117 // Transfer some resources to the parent. 1109 // Transfer some resources to the parent.
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 int callback_count_; 1574 int callback_count_;
1583 scoped_refptr<Layer> root_; 1575 scoped_refptr<Layer> root_;
1584 scoped_refptr<TextureLayer> layer_; 1576 scoped_refptr<TextureLayer> layer_;
1585 }; 1577 };
1586 1578
1587 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1579 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1588 TextureLayerWithMailboxImplThreadDeleted); 1580 TextureLayerWithMailboxImplThreadDeleted);
1589 1581
1590 } // namespace 1582 } // namespace
1591 } // namespace cc 1583 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698