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

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

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format Created 5 years, 1 month 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_impl_unittest.cc ('k') | cc/layers/video_layer_impl.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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 TextureMailbox mailbox_; 108 TextureMailbox mailbox_;
109 scoped_ptr<SingleReleaseCallback> release_callback_; 109 scoped_ptr<SingleReleaseCallback> release_callback_;
110 bool mailbox_changed_; 110 bool mailbox_changed_;
111 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); 111 DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
112 }; 112 };
113 113
114 class MockMailboxCallback { 114 class MockMailboxCallback {
115 public: 115 public:
116 MOCK_METHOD3(Release, 116 MOCK_METHOD3(Release,
117 void(const gpu::Mailbox& mailbox, 117 void(const gpu::Mailbox& mailbox,
118 uint32 sync_point, 118 const gpu::SyncToken& sync_token,
119 bool lost_resource)); 119 bool lost_resource));
120 MOCK_METHOD3(Release2, 120 MOCK_METHOD3(Release2,
121 void(SharedBitmap* shared_bitmap, 121 void(SharedBitmap* shared_bitmap,
122 uint32 sync_point, 122 const gpu::SyncToken& sync_token,
123 bool lost_resource)); 123 bool lost_resource));
124 MOCK_METHOD4(ReleaseImpl, 124 MOCK_METHOD4(ReleaseImpl,
125 void(const gpu::Mailbox& mailbox, 125 void(const gpu::Mailbox& mailbox,
126 uint32 sync_point, 126 const gpu::SyncToken& sync_token,
127 bool lost_resource, 127 bool lost_resource,
128 BlockingTaskRunner* main_thread_task_runner)); 128 BlockingTaskRunner* main_thread_task_runner));
129 MOCK_METHOD4(ReleaseImpl2, 129 MOCK_METHOD4(ReleaseImpl2,
130 void(SharedBitmap* shared_bitmap, 130 void(SharedBitmap* shared_bitmap,
131 uint32 sync_point, 131 const gpu::SyncToken& sync_token,
132 bool lost_resource, 132 bool lost_resource,
133 BlockingTaskRunner* main_thread_task_runner)); 133 BlockingTaskRunner* main_thread_task_runner));
134 }; 134 };
135 135
136 struct CommonMailboxObjects { 136 struct CommonMailboxObjects {
137 explicit CommonMailboxObjects(SharedBitmapManager* manager) 137 explicit CommonMailboxObjects(SharedBitmapManager* manager)
138 : mailbox_name1_(MailboxFromChar('1')), 138 : mailbox_name1_(MailboxFromChar('1')),
139 mailbox_name2_(MailboxFromChar('2')), 139 mailbox_name2_(MailboxFromChar('2')),
140 sync_point1_(1), 140 sync_token1_(1),
141 sync_point2_(2) { 141 sync_token2_(2) {
142 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release, 142 release_mailbox1_ = base::Bind(&MockMailboxCallback::Release,
143 base::Unretained(&mock_callback_), 143 base::Unretained(&mock_callback_),
144 mailbox_name1_); 144 mailbox_name1_);
145 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, 145 release_mailbox2_ = base::Bind(&MockMailboxCallback::Release,
146 base::Unretained(&mock_callback_), 146 base::Unretained(&mock_callback_),
147 mailbox_name2_); 147 mailbox_name2_);
148 release_mailbox1_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl, 148 release_mailbox1_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
149 base::Unretained(&mock_callback_), 149 base::Unretained(&mock_callback_),
150 mailbox_name1_); 150 mailbox_name1_);
151 release_mailbox2_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl, 151 release_mailbox2_impl_ = base::Bind(&MockMailboxCallback::ReleaseImpl,
152 base::Unretained(&mock_callback_), 152 base::Unretained(&mock_callback_),
153 mailbox_name2_); 153 mailbox_name2_);
154 const uint32 arbitrary_target1 = GL_TEXTURE_2D; 154 const uint32 arbitrary_target1 = GL_TEXTURE_2D;
155 const uint32 arbitrary_target2 = GL_TEXTURE_EXTERNAL_OES; 155 const uint32 arbitrary_target2 = GL_TEXTURE_EXTERNAL_OES;
156 mailbox1_ = TextureMailbox(mailbox_name1_, arbitrary_target1, sync_point1_); 156 mailbox1_ = TextureMailbox(mailbox_name1_, sync_token1_, arbitrary_target1);
157 mailbox2_ = TextureMailbox(mailbox_name2_, arbitrary_target2, sync_point2_); 157 mailbox2_ = TextureMailbox(mailbox_name2_, sync_token2_, arbitrary_target2);
158 gfx::Size size(128, 128); 158 gfx::Size size(128, 128);
159 shared_bitmap_ = manager->AllocateSharedBitmap(size); 159 shared_bitmap_ = manager->AllocateSharedBitmap(size);
160 DCHECK(shared_bitmap_); 160 DCHECK(shared_bitmap_);
161 release_mailbox3_ = 161 release_mailbox3_ =
162 base::Bind(&MockMailboxCallback::Release2, 162 base::Bind(&MockMailboxCallback::Release2,
163 base::Unretained(&mock_callback_), shared_bitmap_.get()); 163 base::Unretained(&mock_callback_), shared_bitmap_.get());
164 release_mailbox3_impl_ = 164 release_mailbox3_impl_ =
165 base::Bind(&MockMailboxCallback::ReleaseImpl2, 165 base::Bind(&MockMailboxCallback::ReleaseImpl2,
166 base::Unretained(&mock_callback_), shared_bitmap_.get()); 166 base::Unretained(&mock_callback_), shared_bitmap_.get());
167 mailbox3_ = TextureMailbox(shared_bitmap_.get(), size); 167 mailbox3_ = TextureMailbox(shared_bitmap_.get(), size);
168 } 168 }
169 169
170 gpu::Mailbox mailbox_name1_; 170 gpu::Mailbox mailbox_name1_;
171 gpu::Mailbox mailbox_name2_; 171 gpu::Mailbox mailbox_name2_;
172 MockMailboxCallback mock_callback_; 172 MockMailboxCallback mock_callback_;
173 ReleaseCallback release_mailbox1_; 173 ReleaseCallback release_mailbox1_;
174 ReleaseCallback release_mailbox2_; 174 ReleaseCallback release_mailbox2_;
175 ReleaseCallback release_mailbox3_; 175 ReleaseCallback release_mailbox3_;
176 ReleaseCallbackImpl release_mailbox1_impl_; 176 ReleaseCallbackImpl release_mailbox1_impl_;
177 ReleaseCallbackImpl release_mailbox2_impl_; 177 ReleaseCallbackImpl release_mailbox2_impl_;
178 ReleaseCallbackImpl release_mailbox3_impl_; 178 ReleaseCallbackImpl release_mailbox3_impl_;
179 TextureMailbox mailbox1_; 179 TextureMailbox mailbox1_;
180 TextureMailbox mailbox2_; 180 TextureMailbox mailbox2_;
181 TextureMailbox mailbox3_; 181 TextureMailbox mailbox3_;
182 uint32 sync_point1_; 182 gpu::SyncToken sync_token1_;
183 uint32 sync_point2_; 183 gpu::SyncToken sync_token2_;
184 scoped_ptr<SharedBitmap> shared_bitmap_; 184 scoped_ptr<SharedBitmap> shared_bitmap_;
185 }; 185 };
186 186
187 class TextureLayerTest : public testing::Test { 187 class TextureLayerTest : public testing::Test {
188 public: 188 public:
189 TextureLayerTest() 189 TextureLayerTest()
190 : fake_client_( 190 : fake_client_(
191 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)), 191 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)),
192 output_surface_(FakeOutputSurface::Create3d()), 192 output_surface_(FakeOutputSurface::Create3d()),
193 host_impl_(&task_runner_provider_, 193 host_impl_(&task_runner_provider_,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 using TextureLayer::TextureMailboxHolder::Create; 245 using TextureLayer::TextureMailboxHolder::Create;
246 246
247 protected: 247 protected:
248 ~TestMailboxHolder() override {} 248 ~TestMailboxHolder() override {}
249 }; 249 };
250 250
251 class TextureLayerWithMailboxTest : public TextureLayerTest { 251 class TextureLayerWithMailboxTest : public TextureLayerTest {
252 protected: 252 protected:
253 void TearDown() override { 253 void TearDown() override {
254 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 254 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
255 EXPECT_CALL(test_data_.mock_callback_, 255 EXPECT_CALL(
256 Release(test_data_.mailbox_name1_, 256 test_data_.mock_callback_,
257 test_data_.sync_point1_, 257 Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false))
258 false)).Times(1); 258 .Times(1);
259 TextureLayerTest::TearDown(); 259 TextureLayerTest::TearDown();
260 } 260 }
261 }; 261 };
262 262
263 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { 263 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) {
264 scoped_refptr<TextureLayer> test_layer = 264 scoped_refptr<TextureLayer> test_layer =
265 TextureLayer::CreateForMailbox(layer_settings_, nullptr); 265 TextureLayer::CreateForMailbox(layer_settings_, nullptr);
266 ASSERT_TRUE(test_layer.get()); 266 ASSERT_TRUE(test_layer.get());
267 267
268 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 268 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
269 layer_tree_host_->SetRootLayer(test_layer); 269 layer_tree_host_->SetRootLayer(test_layer);
270 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 270 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
271 271
272 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 272 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
273 test_layer->SetTextureMailbox( 273 test_layer->SetTextureMailbox(
274 test_data_.mailbox1_, 274 test_data_.mailbox1_,
275 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 275 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
276 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 276 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
277 277
278 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 278 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
279 EXPECT_CALL(test_data_.mock_callback_, 279 EXPECT_CALL(
280 Release(test_data_.mailbox_name1_, 280 test_data_.mock_callback_,
281 test_data_.sync_point1_, 281 Release(test_data_.mailbox_name1_, test_data_.sync_token1_, false))
282 false))
283 .Times(1); 282 .Times(1);
284 test_layer->SetTextureMailbox( 283 test_layer->SetTextureMailbox(
285 test_data_.mailbox2_, 284 test_data_.mailbox2_,
286 SingleReleaseCallback::Create(test_data_.release_mailbox2_)); 285 SingleReleaseCallback::Create(test_data_.release_mailbox2_));
287 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 286 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
288 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 287 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
289 288
290 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 289 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
291 EXPECT_CALL(test_data_.mock_callback_, 290 EXPECT_CALL(
292 Release(test_data_.mailbox_name2_, 291 test_data_.mock_callback_,
293 test_data_.sync_point2_, 292 Release(test_data_.mailbox_name2_, test_data_.sync_token2_, false))
294 false))
295 .Times(1); 293 .Times(1);
296 test_layer->SetTextureMailbox(TextureMailbox(), nullptr); 294 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
297 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 295 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
298 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 296 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
299 297
300 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 298 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
301 test_layer->SetTextureMailbox( 299 test_layer->SetTextureMailbox(
302 test_data_.mailbox3_, 300 test_data_.mailbox3_,
303 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); 301 SingleReleaseCallback::Create(test_data_.release_mailbox3_));
304 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 302 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
305 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 303 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
306 304
307 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 305 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
308 EXPECT_CALL(test_data_.mock_callback_, 306 EXPECT_CALL(test_data_.mock_callback_,
309 Release2(test_data_.shared_bitmap_.get(), 0, false)).Times(1); 307 Release2(test_data_.shared_bitmap_.get(), _, false))
308 .Times(1);
310 test_layer->SetTextureMailbox(TextureMailbox(), nullptr); 309 test_layer->SetTextureMailbox(TextureMailbox(), nullptr);
311 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 310 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
312 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 311 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
313 312
314 // Test destructor. 313 // Test destructor.
315 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 314 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
316 test_layer->SetTextureMailbox( 315 test_layer->SetTextureMailbox(
317 test_data_.mailbox1_, 316 test_data_.mailbox1_,
318 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); 317 SingleReleaseCallback::Create(test_data_.release_mailbox1_));
319 } 318 }
320 319
321 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { 320 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) {
322 scoped_refptr<TextureLayer> test_layer = 321 scoped_refptr<TextureLayer> test_layer =
323 TextureLayer::CreateForMailbox(layer_settings_, nullptr); 322 TextureLayer::CreateForMailbox(layer_settings_, nullptr);
324 ASSERT_TRUE(test_layer.get()); 323 ASSERT_TRUE(test_layer.get());
325 324
326 // These use the same gpu::Mailbox, but different sync points. 325 // These use the same gpu::Mailbox, but different sync points.
327 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); 326 TextureMailbox mailbox1(MailboxFromChar('a'), gpu::SyncToken(1),
328 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); 327 GL_TEXTURE_2D);
328 TextureMailbox mailbox2(MailboxFromChar('a'), gpu::SyncToken(2),
329 GL_TEXTURE_2D);
329 330
330 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); 331 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
331 layer_tree_host_->SetRootLayer(test_layer); 332 layer_tree_host_->SetRootLayer(test_layer);
332 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 333 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
333 334
334 // Set the mailbox the first time. It should cause a commit. 335 // Set the mailbox the first time. It should cause a commit.
335 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); 336 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
336 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1); 337 test_layer->SetTextureMailboxWithoutReleaseCallback(mailbox1);
337 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 338 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
338 339
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 422 scoped_ptr<SingleReleaseCallbackImpl> compositor2;
422 main_thread_.message_loop()->task_runner()->PostTask( 423 main_thread_.message_loop()->task_runner()->PostTask(
423 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 424 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
424 base::Unretained(this), &compositor2)); 425 base::Unretained(this), &compositor2));
425 426
426 Wait(main_thread_); 427 Wait(main_thread_);
427 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 428 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
428 429
429 // The compositors both destroy their impl trees before the main thread layer 430 // The compositors both destroy their impl trees before the main thread layer
430 // is destroyed. 431 // is destroyed.
431 compositor1->Run(100, false, main_thread_task_runner_.get()); 432 compositor1->Run(gpu::SyncToken(100), false, main_thread_task_runner_.get());
432 compositor2->Run(200, false, main_thread_task_runner_.get()); 433 compositor2->Run(gpu::SyncToken(200), false, main_thread_task_runner_.get());
433 434
434 Wait(main_thread_); 435 Wait(main_thread_);
435 436
436 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); 437 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
437 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 438 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
438 439
439 // The main thread ref is the last one, so the mailbox is released back to the 440 // The main thread ref is the last one, so the mailbox is released back to the
440 // embedder, with the last sync point provided by the impl trees. 441 // embedder, with the last sync point provided by the impl trees.
441 EXPECT_CALL(test_data_.mock_callback_, 442 EXPECT_CALL(test_data_.mock_callback_,
442 Release(test_data_.mailbox_name1_, 200, false)).Times(1); 443 Release(test_data_.mailbox_name1_, gpu::SyncToken(200), false))
444 .Times(1);
443 445
444 main_thread_.message_loop()->task_runner()->PostTask( 446 main_thread_.message_loop()->task_runner()->PostTask(
445 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 447 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
446 base::Unretained(this))); 448 base::Unretained(this)));
447 Wait(main_thread_); 449 Wait(main_thread_);
448 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 450 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
449 } 451 }
450 452
451 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { 453 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) {
452 scoped_refptr<TextureLayer> test_layer = 454 scoped_refptr<TextureLayer> test_layer =
(...skipping 17 matching lines...) Expand all
470 // reference to its impl tree. 472 // reference to its impl tree.
471 scoped_ptr<SingleReleaseCallbackImpl> compositor2; 473 scoped_ptr<SingleReleaseCallbackImpl> compositor2;
472 main_thread_.message_loop()->task_runner()->PostTask( 474 main_thread_.message_loop()->task_runner()->PostTask(
473 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef, 475 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateImplRef,
474 base::Unretained(this), &compositor2)); 476 base::Unretained(this), &compositor2));
475 477
476 Wait(main_thread_); 478 Wait(main_thread_);
477 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 479 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
478 480
479 // One compositor destroys their impl tree. 481 // One compositor destroys their impl tree.
480 compositor1->Run(100, false, main_thread_task_runner_.get()); 482 compositor1->Run(gpu::SyncToken(100), false, main_thread_task_runner_.get());
481 483
482 // Then the main thread reference is destroyed. 484 // Then the main thread reference is destroyed.
483 main_thread_.message_loop()->task_runner()->PostTask( 485 main_thread_.message_loop()->task_runner()->PostTask(
484 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 486 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
485 base::Unretained(this))); 487 base::Unretained(this)));
486 488
487 Wait(main_thread_); 489 Wait(main_thread_);
488 490
489 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); 491 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
490 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 492 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
491 493
492 // The second impl reference is destroyed last, causing the mailbox to be 494 // The second impl reference is destroyed last, causing the mailbox to be
493 // released back to the embedder with the last sync point from the impl tree. 495 // released back to the embedder with the last sync point from the impl tree.
494 EXPECT_CALL(test_data_.mock_callback_, 496 EXPECT_CALL(test_data_.mock_callback_,
495 Release(test_data_.mailbox_name1_, 200, true)).Times(1); 497 Release(test_data_.mailbox_name1_, gpu::SyncToken(200), true))
498 .Times(1);
496 499
497 compositor2->Run(200, true, main_thread_task_runner_.get()); 500 compositor2->Run(gpu::SyncToken(200), true, main_thread_task_runner_.get());
498 Wait(main_thread_); 501 Wait(main_thread_);
499 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 502 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
500 } 503 }
501 504
502 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { 505 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) {
503 scoped_refptr<TextureLayer> test_layer = 506 scoped_refptr<TextureLayer> test_layer =
504 TextureLayer::CreateForMailbox(layer_settings_, nullptr); 507 TextureLayer::CreateForMailbox(layer_settings_, nullptr);
505 ASSERT_TRUE(test_layer.get()); 508 ASSERT_TRUE(test_layer.get());
506 509
507 main_thread_.message_loop()->task_runner()->PostTask( 510 main_thread_.message_loop()->task_runner()->PostTask(
(...skipping 18 matching lines...) Expand all
526 529
527 Wait(main_thread_); 530 Wait(main_thread_);
528 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 531 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
529 532
530 // The main thread reference is destroyed first. 533 // The main thread reference is destroyed first.
531 main_thread_.message_loop()->task_runner()->PostTask( 534 main_thread_.message_loop()->task_runner()->PostTask(
532 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 535 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
533 base::Unretained(this))); 536 base::Unretained(this)));
534 537
535 // One compositor destroys their impl tree. 538 // One compositor destroys their impl tree.
536 compositor2->Run(200, false, main_thread_task_runner_.get()); 539 compositor2->Run(gpu::SyncToken(200), false, main_thread_task_runner_.get());
537 540
538 Wait(main_thread_); 541 Wait(main_thread_);
539 542
540 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0); 543 EXPECT_CALL(test_data_.mock_callback_, Release(_, _, _)).Times(0);
541 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 544 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
542 545
543 // The second impl reference is destroyed last, causing the mailbox to be 546 // The second impl reference is destroyed last, causing the mailbox to be
544 // released back to the embedder with the last sync point from the impl tree. 547 // released back to the embedder with the last sync point from the impl tree.
545 EXPECT_CALL(test_data_.mock_callback_, 548 EXPECT_CALL(test_data_.mock_callback_,
546 Release(test_data_.mailbox_name1_, 100, true)).Times(1); 549 Release(test_data_.mailbox_name1_, gpu::SyncToken(100), true))
550 .Times(1);
547 551
548 compositor1->Run(100, true, main_thread_task_runner_.get()); 552 compositor1->Run(gpu::SyncToken(100), true, main_thread_task_runner_.get());
549 Wait(main_thread_); 553 Wait(main_thread_);
550 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 554 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
551 } 555 }
552 556
553 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { 557 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) {
554 scoped_refptr<TextureLayer> test_layer = 558 scoped_refptr<TextureLayer> test_layer =
555 TextureLayer::CreateForMailbox(layer_settings_, nullptr); 559 TextureLayer::CreateForMailbox(layer_settings_, nullptr);
556 ASSERT_TRUE(test_layer.get()); 560 ASSERT_TRUE(test_layer.get());
557 561
558 main_thread_.message_loop()->task_runner()->PostTask( 562 main_thread_.message_loop()->task_runner()->PostTask(
(...skipping 18 matching lines...) Expand all
577 581
578 Wait(main_thread_); 582 Wait(main_thread_);
579 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 583 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
580 584
581 // The main thread reference is destroyed first. 585 // The main thread reference is destroyed first.
582 main_thread_.message_loop()->task_runner()->PostTask( 586 main_thread_.message_loop()->task_runner()->PostTask(
583 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, 587 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef,
584 base::Unretained(this))); 588 base::Unretained(this)));
585 589
586 EXPECT_CALL(test_data_.mock_callback_, 590 EXPECT_CALL(test_data_.mock_callback_,
587 Release(test_data_.mailbox_name1_, 200, true)).Times(1); 591 Release(test_data_.mailbox_name1_, gpu::SyncToken(200), true))
592 .Times(1);
588 593
589 bool manual_reset = false; 594 bool manual_reset = false;
590 bool initially_signaled = false; 595 bool initially_signaled = false;
591 base::WaitableEvent begin_capture(manual_reset, initially_signaled); 596 base::WaitableEvent begin_capture(manual_reset, initially_signaled);
592 base::WaitableEvent wait_for_capture(manual_reset, initially_signaled); 597 base::WaitableEvent wait_for_capture(manual_reset, initially_signaled);
593 base::WaitableEvent stop_capture(manual_reset, initially_signaled); 598 base::WaitableEvent stop_capture(manual_reset, initially_signaled);
594 599
595 // Post a task to start capturing tasks on the main thread. This will block 600 // Post a task to start capturing tasks on the main thread. This will block
596 // the main thread until we signal the |stop_capture| event. 601 // the main thread until we signal the |stop_capture| event.
597 main_thread_.message_loop()->task_runner()->PostTask( 602 main_thread_.message_loop()->task_runner()->PostTask(
598 FROM_HERE, 603 FROM_HERE,
599 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait, 604 base::Bind(&TextureLayerMailboxHolderTest::CapturePostTasksAndWait,
600 base::Unretained(this), &begin_capture, &wait_for_capture, 605 base::Unretained(this), &begin_capture, &wait_for_capture,
601 &stop_capture)); 606 &stop_capture));
602 607
603 // Before the main thread capturing starts, one compositor destroys their 608 // Before the main thread capturing starts, one compositor destroys their
604 // impl reference. Since capturing did not start, this gets post-tasked to 609 // impl reference. Since capturing did not start, this gets post-tasked to
605 // the main thread. 610 // the main thread.
606 compositor1->Run(100, false, main_thread_task_runner_.get()); 611 compositor1->Run(gpu::SyncToken(100), false, main_thread_task_runner_.get());
607 612
608 // Start capturing on the main thread. 613 // Start capturing on the main thread.
609 begin_capture.Signal(); 614 begin_capture.Signal();
610 wait_for_capture.Wait(); 615 wait_for_capture.Wait();
611 616
612 // Meanwhile, the second compositor released its impl reference, but this task 617 // Meanwhile, the second compositor released its impl reference, but this task
613 // gets shortcutted directly to the main thread. This means the reference is 618 // gets shortcutted directly to the main thread. This means the reference is
614 // released before compositor1, whose reference will be released later when 619 // released before compositor1, whose reference will be released later when
615 // the post-task is serviced. But since it was destroyed _on the impl thread_ 620 // the post-task is serviced. But since it was destroyed _on the impl thread_
616 // last, its sync point values should be used. 621 // last, its sync point values should be used.
617 compositor2->Run(200, true, main_thread_task_runner_.get()); 622 compositor2->Run(gpu::SyncToken(200), true, main_thread_task_runner_.get());
618 623
619 stop_capture.Signal(); 624 stop_capture.Signal();
620 Wait(main_thread_); 625 Wait(main_thread_);
621 626
622 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 627 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
623 } 628 }
624 629
625 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { 630 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
626 public: 631 public:
627 TextureLayerImplWithMailboxThreadedCallback() 632 TextureLayerImplWithMailboxThreadedCallback()
628 : callback_count_(0), 633 : callback_count_(0),
629 commit_count_(0) {} 634 commit_count_(0) {}
630 635
631 // Make sure callback is received on main and doesn't block the impl thread. 636 // Make sure callback is received on main and doesn't block the impl thread.
632 void ReleaseCallback(uint32 sync_point, bool lost_resource) { 637 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
633 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 638 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
634 EXPECT_FALSE(lost_resource); 639 EXPECT_FALSE(lost_resource);
635 ++callback_count_; 640 ++callback_count_;
636 } 641 }
637 642
638 void SetMailbox(char mailbox_char) { 643 void SetMailbox(char mailbox_char) {
639 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 644 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
640 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 645 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
641 base::Bind( 646 base::Bind(
642 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, 647 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback,
643 base::Unretained(this))); 648 base::Unretained(this)));
644 layer_->SetTextureMailbox( 649 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
645 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), 650 gpu::SyncToken(), GL_TEXTURE_2D),
646 callback.Pass()); 651 callback.Pass());
647 } 652 }
648 653
649 void BeginTest() override { 654 void BeginTest() override {
650 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 655 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
651 656
652 gfx::Size bounds(100, 100); 657 gfx::Size bounds(100, 100);
653 root_ = Layer::Create(layer_settings()); 658 root_ = Layer::Create(layer_settings());
654 root_->SetBounds(bounds); 659 root_->SetBounds(bounds);
655 660
656 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); 661 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 }; 748 };
744 749
745 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 750 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
746 TextureLayerImplWithMailboxThreadedCallback); 751 TextureLayerImplWithMailboxThreadedCallback);
747 752
748 753
749 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { 754 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest {
750 protected: 755 protected:
751 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} 756 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {}
752 757
753 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} 758 static void ReleaseCallback(const gpu::SyncToken& sync_token,
759 bool lost_resource) {}
754 760
755 void SetMailbox(char mailbox_char) { 761 void SetMailbox(char mailbox_char) {
756 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 762 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
757 base::Bind( 763 base::Bind(
758 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); 764 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback));
759 layer_->SetTextureMailbox( 765 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
760 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), 766 gpu::SyncToken(), GL_TEXTURE_2D),
761 callback.Pass()); 767 callback.Pass());
762 } 768 }
763 769
764 void BeginTest() override { 770 void BeginTest() override {
765 gfx::Size bounds(100, 100); 771 gfx::Size bounds(100, 100);
766 root_ = Layer::Create(layer_settings()); 772 root_ = Layer::Create(layer_settings());
767 root_->SetBounds(bounds); 773 root_->SetBounds(bounds);
768 774
769 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); 775 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr);
770 layer_->SetIsDrawable(true); 776 layer_->SetIsDrawable(true);
771 layer_->SetBounds(bounds); 777 layer_->SetBounds(bounds);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 } 856 }
851 857
852 FakeLayerTreeHostClient fake_client_; 858 FakeLayerTreeHostClient fake_client_;
853 }; 859 };
854 860
855 // Test conditions for results of TextureLayerImpl::WillDraw under 861 // Test conditions for results of TextureLayerImpl::WillDraw under
856 // different configurations of different mailbox, texture_id, and draw_mode. 862 // different configurations of different mailbox, texture_id, and draw_mode.
857 TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { 863 TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) {
858 EXPECT_CALL( 864 EXPECT_CALL(
859 test_data_.mock_callback_, 865 test_data_.mock_callback_,
860 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _)) 866 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
861 .Times(AnyNumber()); 867 .Times(AnyNumber());
862 EXPECT_CALL(test_data_.mock_callback_, 868 EXPECT_CALL(
863 ReleaseImpl2(test_data_.shared_bitmap_.get(), 0, false, _)) 869 test_data_.mock_callback_,
870 ReleaseImpl2(test_data_.shared_bitmap_.get(), gpu::SyncToken(), false, _))
864 .Times(AnyNumber()); 871 .Times(AnyNumber());
865 // Hardware mode. 872 // Hardware mode.
866 { 873 {
867 scoped_ptr<TextureLayerImpl> impl_layer = 874 scoped_ptr<TextureLayerImpl> impl_layer =
868 TextureLayerImpl::Create(host_impl_.active_tree(), 1); 875 TextureLayerImpl::Create(host_impl_.active_tree(), 1);
869 impl_layer->SetTextureMailbox( 876 impl_layer->SetTextureMailbox(
870 test_data_.mailbox1_, 877 test_data_.mailbox1_,
871 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 878 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
872 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); 879 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE));
873 } 880 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 pending_layer->CreateLayerImpl(host_impl_.active_tree())); 944 pending_layer->CreateLayerImpl(host_impl_.active_tree()));
938 ASSERT_TRUE(active_layer); 945 ASSERT_TRUE(active_layer);
939 946
940 pending_layer->SetTextureMailbox( 947 pending_layer->SetTextureMailbox(
941 test_data_.mailbox1_, 948 test_data_.mailbox1_,
942 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 949 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
943 950
944 // Test multiple commits without an activation. 951 // Test multiple commits without an activation.
945 EXPECT_CALL( 952 EXPECT_CALL(
946 test_data_.mock_callback_, 953 test_data_.mock_callback_,
947 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _)) 954 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
948 .Times(1); 955 .Times(1);
949 pending_layer->SetTextureMailbox( 956 pending_layer->SetTextureMailbox(
950 test_data_.mailbox2_, 957 test_data_.mailbox2_,
951 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox2_impl_)); 958 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox2_impl_));
952 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 959 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
953 960
954 // Test callback after activation. 961 // Test callback after activation.
955 pending_layer->PushPropertiesTo(active_layer.get()); 962 pending_layer->PushPropertiesTo(active_layer.get());
956 active_layer->DidBecomeActive(); 963 active_layer->DidBecomeActive();
957 964
(...skipping 13 matching lines...) Expand all
971 EXPECT_CALL(test_data_.mock_callback_, 978 EXPECT_CALL(test_data_.mock_callback_,
972 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1); 979 ReleaseImpl(test_data_.mailbox_name1_, _, false, _)).Times(1);
973 pending_layer->SetTextureMailbox(TextureMailbox(), nullptr); 980 pending_layer->SetTextureMailbox(TextureMailbox(), nullptr);
974 pending_layer->PushPropertiesTo(active_layer.get()); 981 pending_layer->PushPropertiesTo(active_layer.get());
975 active_layer->DidBecomeActive(); 982 active_layer->DidBecomeActive();
976 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 983 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
977 984
978 // Test destructor. 985 // Test destructor.
979 EXPECT_CALL( 986 EXPECT_CALL(
980 test_data_.mock_callback_, 987 test_data_.mock_callback_,
981 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_point1_, false, _)) 988 ReleaseImpl(test_data_.mailbox_name1_, test_data_.sync_token1_, false, _))
982 .Times(1); 989 .Times(1);
983 pending_layer->SetTextureMailbox( 990 pending_layer->SetTextureMailbox(
984 test_data_.mailbox1_, 991 test_data_.mailbox1_,
985 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_)); 992 SingleReleaseCallbackImpl::Create(test_data_.release_mailbox1_impl_));
986 } 993 }
987 994
988 TEST_F(TextureLayerImplWithMailboxTest, 995 TEST_F(TextureLayerImplWithMailboxTest,
989 TestDestructorCallbackOnCreatedResource) { 996 TestDestructorCallbackOnCreatedResource) {
990 scoped_ptr<TextureLayerImpl> impl_layer; 997 scoped_ptr<TextureLayerImpl> impl_layer;
991 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); 998 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 bool PrepareTextureMailbox( 1043 bool PrepareTextureMailbox(
1037 TextureMailbox* texture_mailbox, 1044 TextureMailbox* texture_mailbox,
1038 scoped_ptr<SingleReleaseCallback>* release_callback, 1045 scoped_ptr<SingleReleaseCallback>* release_callback,
1039 bool use_shared_memory) override { 1046 bool use_shared_memory) override {
1040 if (layer_tree_host()->source_frame_number() == 1) { 1047 if (layer_tree_host()->source_frame_number() == 1) {
1041 // Once this has been committed, the mailbox will be released. 1048 // Once this has been committed, the mailbox will be released.
1042 *texture_mailbox = TextureMailbox(); 1049 *texture_mailbox = TextureMailbox();
1043 return true; 1050 return true;
1044 } 1051 }
1045 1052
1046 *texture_mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); 1053 *texture_mailbox =
1054 TextureMailbox(MailboxFromChar('1'), gpu::SyncToken(), GL_TEXTURE_2D);
1047 *release_callback = SingleReleaseCallback::Create( 1055 *release_callback = SingleReleaseCallback::Create(
1048 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, 1056 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased,
1049 base::Unretained(this))); 1057 base::Unretained(this)));
1050 return true; 1058 return true;
1051 } 1059 }
1052 1060
1053 void MailboxReleased(uint32 sync_point, bool lost_resource) { 1061 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
1054 // Source frame number during callback is the same as the source frame 1062 // Source frame number during callback is the same as the source frame
1055 // on which it was released. 1063 // on which it was released.
1056 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); 1064 EXPECT_EQ(1, layer_tree_host()->source_frame_number());
1057 EndTest(); 1065 EndTest();
1058 } 1066 }
1059 1067
1060 void SetupTree() override { 1068 void SetupTree() override {
1061 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 1069 scoped_refptr<Layer> root = Layer::Create(layer_settings());
1062 root->SetBounds(gfx::Size(10, 10)); 1070 root->SetBounds(gfx::Size(10, 10));
1063 root->SetIsDrawable(true); 1071 root->SetIsDrawable(true);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 if (!mailbox_changed_) 1146 if (!mailbox_changed_)
1139 return false; 1147 return false;
1140 *mailbox = mailbox_; 1148 *mailbox = mailbox_;
1141 *release_callback = SingleReleaseCallback::Create( 1149 *release_callback = SingleReleaseCallback::Create(
1142 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, 1150 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased,
1143 base::Unretained(this))); 1151 base::Unretained(this)));
1144 return true; 1152 return true;
1145 } 1153 }
1146 1154
1147 TextureMailbox MakeMailbox(char name) { 1155 TextureMailbox MakeMailbox(char name) {
1148 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); 1156 return TextureMailbox(MailboxFromChar(name), gpu::SyncToken(),
1157 GL_TEXTURE_2D);
1149 } 1158 }
1150 1159
1151 void MailboxReleased(uint32 sync_point, bool lost_resource) { 1160 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
1152 ++mailbox_returned_; 1161 ++mailbox_returned_;
1153 } 1162 }
1154 1163
1155 void SetupTree() override { 1164 void SetupTree() override {
1156 scoped_refptr<Layer> root = Layer::Create(layer_settings()); 1165 scoped_refptr<Layer> root = Layer::Create(layer_settings());
1157 root->SetBounds(gfx::Size(10, 10)); 1166 root->SetBounds(gfx::Size(10, 10));
1158 root->SetIsDrawable(true); 1167 root->SetIsDrawable(true);
1159 1168
1160 solid_layer_ = SolidColorLayer::Create(layer_settings()); 1169 solid_layer_ = SolidColorLayer::Create(layer_settings());
1161 solid_layer_->SetBounds(gfx::Size(10, 10)); 1170 solid_layer_->SetBounds(gfx::Size(10, 10));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 // the mailbox back to TextureLayerClient. 1270 // the mailbox back to TextureLayerClient.
1262 class TextureLayerReleaseResourcesBase 1271 class TextureLayerReleaseResourcesBase
1263 : public LayerTreeTest, 1272 : public LayerTreeTest,
1264 public TextureLayerClient { 1273 public TextureLayerClient {
1265 public: 1274 public:
1266 // TextureLayerClient implementation. 1275 // TextureLayerClient implementation.
1267 bool PrepareTextureMailbox( 1276 bool PrepareTextureMailbox(
1268 TextureMailbox* mailbox, 1277 TextureMailbox* mailbox,
1269 scoped_ptr<SingleReleaseCallback>* release_callback, 1278 scoped_ptr<SingleReleaseCallback>* release_callback,
1270 bool use_shared_memory) override { 1279 bool use_shared_memory) override {
1271 *mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); 1280 *mailbox =
1281 TextureMailbox(MailboxFromChar('1'), gpu::SyncToken(), GL_TEXTURE_2D);
1272 *release_callback = SingleReleaseCallback::Create( 1282 *release_callback = SingleReleaseCallback::Create(
1273 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, 1283 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased,
1274 base::Unretained(this))); 1284 base::Unretained(this)));
1275 return true; 1285 return true;
1276 } 1286 }
1277 1287
1278 void MailboxReleased(unsigned sync_point, bool lost_resource) { 1288 void MailboxReleased(const gpu::SyncToken& sync_token, bool lost_resource) {
1279 mailbox_released_ = true; 1289 mailbox_released_ = true;
1280 } 1290 }
1281 1291
1282 void SetupTree() override { 1292 void SetupTree() override {
1283 LayerTreeTest::SetupTree(); 1293 LayerTreeTest::SetupTree();
1284 1294
1285 scoped_refptr<TextureLayer> texture_layer = 1295 scoped_refptr<TextureLayer> texture_layer =
1286 TextureLayer::CreateForMailbox(layer_settings(), this); 1296 TextureLayer::CreateForMailbox(layer_settings(), this);
1287 texture_layer->SetBounds(gfx::Size(10, 10)); 1297 texture_layer->SetBounds(gfx::Size(10, 10));
1288 texture_layer->SetIsDrawable(true); 1298 texture_layer->SetIsDrawable(true);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 public: 1330 public:
1321 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1331 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1322 host_impl->active_tree()->root_layer()->children()[0]->ReleaseResources(); 1332 host_impl->active_tree()->root_layer()->children()[0]->ReleaseResources();
1323 } 1333 }
1324 }; 1334 };
1325 1335
1326 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate); 1336 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate);
1327 1337
1328 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { 1338 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest {
1329 public: 1339 public:
1330 void ReleaseCallback(uint32 sync_point, bool lost_resource) { 1340 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
1331 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1341 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1332 EXPECT_FALSE(lost_resource); 1342 EXPECT_FALSE(lost_resource);
1333 ++callback_count_; 1343 ++callback_count_;
1334 EndTest(); 1344 EndTest();
1335 } 1345 }
1336 1346
1337 void SetMailbox(char mailbox_char) { 1347 void SetMailbox(char mailbox_char) {
1338 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1348 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1339 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 1349 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
1340 base::Bind( 1350 base::Bind(
1341 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, 1351 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback,
1342 base::Unretained(this))); 1352 base::Unretained(this)));
1343 layer_->SetTextureMailbox( 1353 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
1344 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), 1354 gpu::SyncToken(), GL_TEXTURE_2D),
1345 callback.Pass()); 1355 callback.Pass());
1346 } 1356 }
1347 1357
1348 void SetupTree() override { 1358 void SetupTree() override {
1349 gfx::Size bounds(100, 100); 1359 gfx::Size bounds(100, 100);
1350 root_ = Layer::Create(layer_settings()); 1360 root_ = Layer::Create(layer_settings());
1351 root_->SetBounds(bounds); 1361 root_->SetBounds(bounds);
1352 1362
1353 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); 1363 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr);
1354 layer_->SetIsDrawable(true); 1364 layer_->SetIsDrawable(true);
1355 layer_->SetBounds(bounds); 1365 layer_->SetBounds(bounds);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 int callback_count_; 1399 int callback_count_;
1390 scoped_refptr<Layer> root_; 1400 scoped_refptr<Layer> root_;
1391 scoped_refptr<TextureLayer> layer_; 1401 scoped_refptr<TextureLayer> layer_;
1392 }; 1402 };
1393 1403
1394 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1404 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1395 TextureLayerWithMailboxMainThreadDeleted); 1405 TextureLayerWithMailboxMainThreadDeleted);
1396 1406
1397 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { 1407 class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest {
1398 public: 1408 public:
1399 void ReleaseCallback(uint32 sync_point, bool lost_resource) { 1409 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
1400 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1410 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1401 EXPECT_FALSE(lost_resource); 1411 EXPECT_FALSE(lost_resource);
1402 ++callback_count_; 1412 ++callback_count_;
1403 EndTest(); 1413 EndTest();
1404 } 1414 }
1405 1415
1406 void SetMailbox(char mailbox_char) { 1416 void SetMailbox(char mailbox_char) {
1407 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1417 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1408 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( 1418 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
1409 base::Bind( 1419 base::Bind(
1410 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, 1420 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback,
1411 base::Unretained(this))); 1421 base::Unretained(this)));
1412 layer_->SetTextureMailbox( 1422 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
1413 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), 1423 gpu::SyncToken(), GL_TEXTURE_2D),
1414 callback.Pass()); 1424 callback.Pass());
1415 } 1425 }
1416 1426
1417 void SetupTree() override { 1427 void SetupTree() override {
1418 gfx::Size bounds(100, 100); 1428 gfx::Size bounds(100, 100);
1419 root_ = Layer::Create(layer_settings()); 1429 root_ = Layer::Create(layer_settings());
1420 root_->SetBounds(bounds); 1430 root_->SetBounds(bounds);
1421 1431
1422 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); 1432 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr);
1423 layer_->SetIsDrawable(true); 1433 layer_->SetIsDrawable(true);
1424 layer_->SetBounds(bounds); 1434 layer_->SetBounds(bounds);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 int callback_count_; 1471 int callback_count_;
1462 scoped_refptr<Layer> root_; 1472 scoped_refptr<Layer> root_;
1463 scoped_refptr<TextureLayer> layer_; 1473 scoped_refptr<TextureLayer> layer_;
1464 }; 1474 };
1465 1475
1466 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1476 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1467 TextureLayerWithMailboxImplThreadDeleted); 1477 TextureLayerWithMailboxImplThreadDeleted);
1468 1478
1469 } // namespace 1479 } // namespace
1470 } // namespace cc 1480 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_impl_unittest.cc ('k') | cc/layers/video_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698