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

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

Issue 2757373002: Fixing flakiness of TextureLayerChangeInvisibleMailboxTest (Closed)
Patch Set: Invalidate on DidLose Created 3 years, 8 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 | « no previous file | cc/trees/proxy_impl.h » ('j') | cc/trees/proxy_impl.cc » ('J')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1180
1181 TextureMailbox MakeMailbox(char name) { 1181 TextureMailbox MakeMailbox(char name) {
1182 return TextureMailbox(MailboxFromChar(name), 1182 return TextureMailbox(MailboxFromChar(name),
1183 SyncTokenFromUInt(static_cast<uint32_t>(name)), 1183 SyncTokenFromUInt(static_cast<uint32_t>(name)),
1184 GL_TEXTURE_2D); 1184 GL_TEXTURE_2D);
1185 } 1185 }
1186 1186
1187 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) { 1187 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
1188 EXPECT_TRUE(sync_token.HasData()); 1188 EXPECT_TRUE(sync_token.HasData());
1189 ++mailbox_returned_; 1189 ++mailbox_returned_;
1190 switch (mailbox_returned_) {
1191 case 1:
1192 break;
1193 case 2:
1194 EXPECT_EQ(commit_count_, 5);
1195 EndTest();
1196 break;
1197 default:
1198 NOTREACHED();
1199 }
1200 } 1190 }
1201 1191
1202 void SetupTree() override { 1192 void SetupTree() override {
1203 scoped_refptr<Layer> root = Layer::Create(); 1193 scoped_refptr<Layer> root = Layer::Create();
1204 root->SetBounds(gfx::Size(10, 10)); 1194 root->SetBounds(gfx::Size(10, 10));
1205 root->SetIsDrawable(true); 1195 root->SetIsDrawable(true);
1206 1196
1207 solid_layer_ = SolidColorLayer::Create(); 1197 solid_layer_ = SolidColorLayer::Create();
1208 solid_layer_->SetBounds(gfx::Size(10, 10)); 1198 solid_layer_->SetBounds(gfx::Size(10, 10));
1209 solid_layer_->SetIsDrawable(true); 1199 solid_layer_->SetIsDrawable(true);
1210 solid_layer_->SetBackgroundColor(SK_ColorWHITE); 1200 solid_layer_->SetBackgroundColor(SK_ColorWHITE);
1211 root->AddChild(solid_layer_); 1201 root->AddChild(solid_layer_);
1212 1202
1213 parent_layer_ = Layer::Create(); 1203 parent_layer_ = Layer::Create();
1214 parent_layer_->SetBounds(gfx::Size(10, 10)); 1204 parent_layer_->SetBounds(gfx::Size(10, 10));
1215 parent_layer_->SetIsDrawable(true); 1205 parent_layer_->SetIsDrawable(true);
1216 root->AddChild(parent_layer_); 1206 root->AddChild(parent_layer_);
1217 1207
1218 texture_layer_ = TextureLayer::CreateForMailbox(this); 1208 texture_layer_ = TextureLayer::CreateForMailbox(this);
1219 texture_layer_->SetBounds(gfx::Size(10, 10)); 1209 texture_layer_->SetBounds(gfx::Size(10, 10));
1220 texture_layer_->SetIsDrawable(true); 1210 texture_layer_->SetIsDrawable(true);
1221 parent_layer_->AddChild(texture_layer_); 1211 parent_layer_->AddChild(texture_layer_);
1222 1212
1223 layer_tree_host()->SetRootLayer(root); 1213 layer_tree_host()->SetRootLayer(root);
1224 LayerTreeTest::SetupTree(); 1214 LayerTreeTest::SetupTree();
1225 } 1215 }
1226 1216
1227 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1217 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1228 1218
1229 void DidCommitAndDrawFrame() override { 1219 void DidReceiveCompositorFrameAck() override {
1230 ++commit_count_; 1220 ++commit_count_;
1231 switch (commit_count_) { 1221 switch (commit_count_) {
1232 case 1: 1222 case 1:
1233 // We should have updated the layer, committing the texture. 1223 // We should have updated the layer, committing the texture.
1234 EXPECT_EQ(1, prepare_called_); 1224 EXPECT_EQ(1, prepare_called_);
1235 // Make layer invisible. 1225 // Make layer invisible.
1236 parent_layer_->SetOpacity(0.f); 1226 parent_layer_->SetOpacity(0.f);
1237 break; 1227 break;
1238 case 2: 1228 case 2:
1239 // Layer shouldn't have been updated. 1229 // Layer shouldn't have been updated.
(...skipping 14 matching lines...) Expand all
1254 parent_layer_->SetOpacity(0.9f); 1244 parent_layer_->SetOpacity(0.9f);
1255 break; 1245 break;
1256 case 4: 1246 case 4:
1257 // Layer should have been updated. 1247 // Layer should have been updated.
1258 EXPECT_EQ(2, prepare_called_); 1248 EXPECT_EQ(2, prepare_called_);
1259 // So the old mailbox should have been returned already. 1249 // So the old mailbox should have been returned already.
1260 EXPECT_EQ(1, mailbox_returned_); 1250 EXPECT_EQ(1, mailbox_returned_);
1261 texture_layer_->ClearClient(); 1251 texture_layer_->ClearClient();
1262 break; 1252 break;
1263 case 5: 1253 case 5:
1254 EXPECT_EQ(2, mailbox_returned_);
1255 EndTest();
1264 break; 1256 break;
1265 default: 1257 default:
1266 NOTREACHED(); 1258 NOTREACHED();
1267 break; 1259 break;
1268 } 1260 }
1269 } 1261 }
1270 1262
1271 void AfterTest() override {} 1263 void AfterTest() override {}
1272 1264
1273 private: 1265 private:
1274 scoped_refptr<SolidColorLayer> solid_layer_; 1266 scoped_refptr<SolidColorLayer> solid_layer_;
1275 scoped_refptr<Layer> parent_layer_; 1267 scoped_refptr<Layer> parent_layer_;
1276 scoped_refptr<TextureLayer> texture_layer_; 1268 scoped_refptr<TextureLayer> texture_layer_;
1277 1269
1278 // Used on the main thread. 1270 // Used on the main thread.
1279 bool mailbox_changed_; 1271 bool mailbox_changed_;
1280 TextureMailbox mailbox_; 1272 TextureMailbox mailbox_;
1281 int mailbox_returned_; 1273 int mailbox_returned_;
1282 int prepare_called_; 1274 int prepare_called_;
1283 int commit_count_; 1275 int commit_count_;
1284 }; 1276 };
1285 1277
1286 // Flaky when multi-threaded. crbug.com/702868 1278 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest);
1287 SINGLE_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest);
1288 1279
1289 // Test that TextureLayerImpl::ReleaseResources can be called which releases 1280 // Test that TextureLayerImpl::ReleaseResources can be called which releases
1290 // the mailbox back to TextureLayerClient. 1281 // the mailbox back to TextureLayerClient.
1291 class TextureLayerReleaseResourcesBase 1282 class TextureLayerReleaseResourcesBase
1292 : public LayerTreeTest, 1283 : public LayerTreeTest,
1293 public TextureLayerClient { 1284 public TextureLayerClient {
1294 public: 1285 public:
1295 // TextureLayerClient implementation. 1286 // TextureLayerClient implementation.
1296 bool PrepareTextureMailbox( 1287 bool PrepareTextureMailbox(
1297 TextureMailbox* mailbox, 1288 TextureMailbox* mailbox,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 base::ThreadChecker main_thread_; 1487 base::ThreadChecker main_thread_;
1497 int callback_count_; 1488 int callback_count_;
1498 scoped_refptr<Layer> root_; 1489 scoped_refptr<Layer> root_;
1499 scoped_refptr<TextureLayer> layer_; 1490 scoped_refptr<TextureLayer> layer_;
1500 }; 1491 };
1501 1492
1502 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerWithMailboxImplThreadDeleted); 1493 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerWithMailboxImplThreadDeleted);
1503 1494
1504 } // namespace 1495 } // namespace
1505 } // namespace cc 1496 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/proxy_impl.h » ('j') | cc/trees/proxy_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698