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

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

Issue 2151433004: cc: Make LayerTreeHostImpl::SwapBuffers not virtual. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removedidswap
Patch Set: novirtualswapbuffers: . Created 4 years, 5 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 1059
1060 *texture_mailbox = TextureMailbox(MailboxFromChar('1'), 1060 *texture_mailbox = TextureMailbox(MailboxFromChar('1'),
1061 SyncTokenFromUInt(0x123), GL_TEXTURE_2D); 1061 SyncTokenFromUInt(0x123), GL_TEXTURE_2D);
1062 *release_callback = SingleReleaseCallback::Create( 1062 *release_callback = SingleReleaseCallback::Create(
1063 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, 1063 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased,
1064 base::Unretained(this))); 1064 base::Unretained(this)));
1065 return true; 1065 return true;
1066 } 1066 }
1067 1067
1068 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { 1068 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
1069 // Source frame number during callback is the same as the source frame
danakj 2016/07/13 21:50:17 Resources are now returned asynchronously from any
1070 // on which it was released.
1071 EXPECT_EQ(1, layer_tree_host()->source_frame_number());
1072 EXPECT_TRUE(sync_token.HasData()); 1069 EXPECT_TRUE(sync_token.HasData());
1073 EndTest(); 1070 EndTest();
1074 } 1071 }
1075 1072
1076 void SetupTree() override { 1073 void SetupTree() override {
1077 scoped_refptr<Layer> root = Layer::Create(); 1074 scoped_refptr<Layer> root = Layer::Create();
1078 root->SetBounds(gfx::Size(10, 10)); 1075 root->SetBounds(gfx::Size(10, 10));
1079 root->SetIsDrawable(true); 1076 root->SetIsDrawable(true);
1080 1077
1081 texture_layer_ = TextureLayer::CreateForMailbox(this); 1078 texture_layer_ = TextureLayer::CreateForMailbox(this);
(...skipping 16 matching lines...) Expand all
1098 texture_layer_->SetNeedsDisplay(); 1095 texture_layer_->SetNeedsDisplay();
1099 break; 1096 break;
1100 case 2: 1097 case 2:
1101 break; 1098 break;
1102 default: 1099 default:
1103 NOTREACHED(); 1100 NOTREACHED();
1104 break; 1101 break;
1105 } 1102 }
1106 } 1103 }
1107 1104
1108 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1109 ASSERT_TRUE(result);
1110 DelegatedFrameData* delegated_frame_data =
1111 output_surface()->last_sent_frame()->delegated_frame_data.get();
1112 if (!delegated_frame_data)
1113 return;
1114
1115 // Return all resources immediately.
danakj 2016/07/13 21:50:17 This moved into FakeOutputSurface to happen automa
1116 TransferableResourceArray resources_to_return =
1117 output_surface()->resources_held_by_parent();
1118
1119 CompositorFrameAck ack;
1120 for (size_t i = 0; i < resources_to_return.size(); ++i)
1121 output_surface()->ReturnResource(resources_to_return[i].id, &ack);
1122 host_impl->ReclaimResources(&ack);
1123 }
1124
1125 void AfterTest() override {} 1105 void AfterTest() override {}
1126 1106
1127 private: 1107 private:
1128 scoped_refptr<TextureLayer> texture_layer_; 1108 scoped_refptr<TextureLayer> texture_layer_;
1129 }; 1109 };
1130 1110
1131 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest); 1111 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(
1112 TextureLayerNoExtraCommitForMailboxTest);
1132 1113
1133 // Checks that changing a mailbox in the client for a TextureLayer that's 1114 // Checks that changing a mailbox in the client for a TextureLayer that's
1134 // invisible correctly works and uses the new mailbox as soon as the layer 1115 // invisible correctly works and uses the new mailbox as soon as the layer
1135 // becomes visible (and returns the old one). 1116 // becomes visible (and returns the old one).
1136 class TextureLayerChangeInvisibleMailboxTest 1117 class TextureLayerChangeInvisibleMailboxTest
1137 : public LayerTreeTest, 1118 : public LayerTreeTest,
1138 public TextureLayerClient { 1119 public TextureLayerClient {
1139 public: 1120 public:
1140 TextureLayerChangeInvisibleMailboxTest() 1121 TextureLayerChangeInvisibleMailboxTest()
1141 : mailbox_changed_(true), 1122 : mailbox_changed_(true),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 case 5: 1216 case 5:
1236 EXPECT_EQ(2, mailbox_returned_); 1217 EXPECT_EQ(2, mailbox_returned_);
1237 EndTest(); 1218 EndTest();
1238 break; 1219 break;
1239 default: 1220 default:
1240 NOTREACHED(); 1221 NOTREACHED();
1241 break; 1222 break;
1242 } 1223 }
1243 } 1224 }
1244 1225
1245 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1246 ASSERT_TRUE(result);
1247 DelegatedFrameData* delegated_frame_data =
1248 output_surface()->last_sent_frame()->delegated_frame_data.get();
1249 if (!delegated_frame_data)
1250 return;
1251
1252 // Return all resources immediately.
1253 TransferableResourceArray resources_to_return =
1254 output_surface()->resources_held_by_parent();
1255
1256 CompositorFrameAck ack;
1257 for (size_t i = 0; i < resources_to_return.size(); ++i)
1258 output_surface()->ReturnResource(resources_to_return[i].id, &ack);
1259 host_impl->ReclaimResources(&ack);
1260 }
1261
1262 void AfterTest() override {} 1226 void AfterTest() override {}
1263 1227
1264 private: 1228 private:
1265 scoped_refptr<SolidColorLayer> solid_layer_; 1229 scoped_refptr<SolidColorLayer> solid_layer_;
1266 scoped_refptr<Layer> parent_layer_; 1230 scoped_refptr<Layer> parent_layer_;
1267 scoped_refptr<TextureLayer> texture_layer_; 1231 scoped_refptr<TextureLayer> texture_layer_;
1268 1232
1269 // Used on the main thread. 1233 // Used on the main thread.
1270 bool mailbox_changed_; 1234 bool mailbox_changed_;
1271 TextureMailbox mailbox_; 1235 TextureMailbox mailbox_;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 int callback_count_; 1453 int callback_count_;
1490 scoped_refptr<Layer> root_; 1454 scoped_refptr<Layer> root_;
1491 scoped_refptr<TextureLayer> layer_; 1455 scoped_refptr<TextureLayer> layer_;
1492 }; 1456 };
1493 1457
1494 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1458 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1495 TextureLayerWithMailboxImplThreadDeleted); 1459 TextureLayerWithMailboxImplThreadDeleted);
1496 1460
1497 } // namespace 1461 } // namespace
1498 } // namespace cc 1462 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698