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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 layer_tree_host_ = nullptr; | 204 layer_tree_host_ = nullptr; |
205 } | 205 } |
206 | 206 |
207 scoped_ptr<MockLayerTreeHost> layer_tree_host_; | 207 scoped_ptr<MockLayerTreeHost> layer_tree_host_; |
208 FakeImplProxy proxy_; | 208 FakeImplProxy proxy_; |
209 FakeLayerTreeHostClient fake_client_; | 209 FakeLayerTreeHostClient fake_client_; |
210 TestSharedBitmapManager shared_bitmap_manager_; | 210 TestSharedBitmapManager shared_bitmap_manager_; |
211 TestTaskGraphRunner task_graph_runner_; | 211 TestTaskGraphRunner task_graph_runner_; |
212 FakeLayerTreeHostImpl host_impl_; | 212 FakeLayerTreeHostImpl host_impl_; |
213 CommonMailboxObjects test_data_; | 213 CommonMailboxObjects test_data_; |
| 214 LayerSettings layer_settings_; |
214 }; | 215 }; |
215 | 216 |
216 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 217 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
217 scoped_refptr<TextureLayer> test_layer = | 218 scoped_refptr<TextureLayer> test_layer = |
218 TextureLayer::CreateForMailbox(nullptr); | 219 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
219 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); | 220 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); |
220 | 221 |
221 // Test properties that should call SetNeedsCommit. All properties need to | 222 // Test properties that should call SetNeedsCommit. All properties need to |
222 // be set to new values in order for SetNeedsCommit to be called. | 223 // be set to new values in order for SetNeedsCommit to be called. |
223 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); | 224 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); |
224 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); | 225 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); |
225 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( | 226 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( |
226 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); | 227 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); |
227 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( | 228 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( |
228 0.5f, 0.5f, 0.5f, 0.5f)); | 229 0.5f, 0.5f, 0.5f, 0.5f)); |
229 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); | 230 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); |
230 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); | 231 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); |
231 } | 232 } |
232 | 233 |
233 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { | 234 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { |
234 const gfx::Size layer_bounds(100, 100); | 235 const gfx::Size layer_bounds(100, 100); |
235 const gfx::Rect layer_rect(layer_bounds); | 236 const gfx::Rect layer_rect(layer_bounds); |
236 const Region layer_region(layer_rect); | 237 const Region layer_region(layer_rect); |
237 | 238 |
238 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(nullptr); | 239 scoped_refptr<TextureLayer> layer = |
| 240 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
239 layer->SetBounds(layer_bounds); | 241 layer->SetBounds(layer_bounds); |
240 layer->draw_properties().visible_content_rect = layer_rect; | 242 layer->draw_properties().visible_content_rect = layer_rect; |
241 layer->SetBlendBackgroundColor(true); | 243 layer->SetBlendBackgroundColor(true); |
242 | 244 |
243 // Verify initial conditions. | 245 // Verify initial conditions. |
244 EXPECT_FALSE(layer->contents_opaque()); | 246 EXPECT_FALSE(layer->contents_opaque()); |
245 EXPECT_EQ(0u, layer->background_color()); | 247 EXPECT_EQ(0u, layer->background_color()); |
246 EXPECT_EQ(Region().ToString(), | 248 EXPECT_EQ(Region().ToString(), |
247 layer->VisibleContentOpaqueRegion().ToString()); | 249 layer->VisibleContentOpaqueRegion().ToString()); |
248 | 250 |
249 // Opaque background. | 251 // Opaque background. |
250 layer->SetBackgroundColor(SK_ColorWHITE); | 252 layer->SetBackgroundColor(SK_ColorWHITE); |
251 EXPECT_EQ(layer_region.ToString(), | 253 EXPECT_EQ(layer_region.ToString(), |
252 layer->VisibleContentOpaqueRegion().ToString()); | 254 layer->VisibleContentOpaqueRegion().ToString()); |
253 | 255 |
254 // Transparent background. | 256 // Transparent background. |
255 layer->SetBackgroundColor(SkColorSetARGB(100, 255, 255, 255)); | 257 layer->SetBackgroundColor(SkColorSetARGB(100, 255, 255, 255)); |
256 EXPECT_EQ(Region().ToString(), | 258 EXPECT_EQ(Region().ToString(), |
257 layer->VisibleContentOpaqueRegion().ToString()); | 259 layer->VisibleContentOpaqueRegion().ToString()); |
258 } | 260 } |
259 | 261 |
260 TEST_F(TextureLayerTest, RateLimiter) { | 262 TEST_F(TextureLayerTest, RateLimiter) { |
261 FakeTextureLayerClient client; | 263 FakeTextureLayerClient client; |
262 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox( | 264 scoped_refptr<TextureLayer> test_layer = |
263 &client); | 265 TextureLayer::CreateForMailbox(layer_settings_, &client); |
264 test_layer->SetIsDrawable(true); | 266 test_layer->SetIsDrawable(true); |
265 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 267 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
266 layer_tree_host_->SetRootLayer(test_layer); | 268 layer_tree_host_->SetRootLayer(test_layer); |
267 | 269 |
268 // Don't rate limit until we invalidate. | 270 // Don't rate limit until we invalidate. |
269 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | 271 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); |
270 test_layer->SetRateLimitContext(true); | 272 test_layer->SetRateLimitContext(true); |
271 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 273 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
272 | 274 |
273 // Do rate limit after we invalidate. | 275 // Do rate limit after we invalidate. |
274 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); | 276 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); |
275 test_layer->SetNeedsDisplay(); | 277 test_layer->SetNeedsDisplay(); |
276 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 278 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
277 | 279 |
278 // Stop rate limiter when we don't want it any more. | 280 // Stop rate limiter when we don't want it any more. |
279 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | 281 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); |
280 test_layer->SetRateLimitContext(false); | 282 test_layer->SetRateLimitContext(false); |
281 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 283 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
282 | 284 |
283 // Or we clear the client. | 285 // Or we clear the client. |
284 test_layer->SetRateLimitContext(true); | 286 test_layer->SetRateLimitContext(true); |
285 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | 287 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); |
286 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 288 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
287 test_layer->ClearClient(); | 289 test_layer->ClearClient(); |
288 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 290 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
289 | 291 |
290 // Reset to a layer with a client, that started the rate limiter. | 292 // Reset to a layer with a client, that started the rate limiter. |
291 test_layer = TextureLayer::CreateForMailbox( | 293 test_layer = TextureLayer::CreateForMailbox(layer_settings_, &client); |
292 &client); | |
293 test_layer->SetIsDrawable(true); | 294 test_layer->SetIsDrawable(true); |
294 test_layer->SetRateLimitContext(true); | 295 test_layer->SetRateLimitContext(true); |
295 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 296 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
296 layer_tree_host_->SetRootLayer(test_layer); | 297 layer_tree_host_->SetRootLayer(test_layer); |
297 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | 298 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); |
298 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 299 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
299 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); | 300 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); |
300 test_layer->SetNeedsDisplay(); | 301 test_layer->SetNeedsDisplay(); |
301 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 302 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
302 | 303 |
(...skipping 19 matching lines...) Expand all Loading... |
322 EXPECT_CALL(test_data_.mock_callback_, | 323 EXPECT_CALL(test_data_.mock_callback_, |
323 Release(test_data_.mailbox_name1_, | 324 Release(test_data_.mailbox_name1_, |
324 test_data_.sync_point1_, | 325 test_data_.sync_point1_, |
325 false)).Times(1); | 326 false)).Times(1); |
326 TextureLayerTest::TearDown(); | 327 TextureLayerTest::TearDown(); |
327 } | 328 } |
328 }; | 329 }; |
329 | 330 |
330 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { | 331 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { |
331 scoped_refptr<TextureLayer> test_layer = | 332 scoped_refptr<TextureLayer> test_layer = |
332 TextureLayer::CreateForMailbox(nullptr); | 333 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
333 ASSERT_TRUE(test_layer.get()); | 334 ASSERT_TRUE(test_layer.get()); |
334 | 335 |
335 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 336 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
336 layer_tree_host_->SetRootLayer(test_layer); | 337 layer_tree_host_->SetRootLayer(test_layer); |
337 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 338 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
338 | 339 |
339 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 340 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
340 test_layer->SetTextureMailbox( | 341 test_layer->SetTextureMailbox( |
341 test_data_.mailbox1_, | 342 test_data_.mailbox1_, |
342 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 343 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 381 |
381 // Test destructor. | 382 // Test destructor. |
382 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 383 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
383 test_layer->SetTextureMailbox( | 384 test_layer->SetTextureMailbox( |
384 test_data_.mailbox1_, | 385 test_data_.mailbox1_, |
385 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 386 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
386 } | 387 } |
387 | 388 |
388 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { | 389 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { |
389 scoped_refptr<TextureLayer> test_layer = | 390 scoped_refptr<TextureLayer> test_layer = |
390 TextureLayer::CreateForMailbox(nullptr); | 391 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
391 ASSERT_TRUE(test_layer.get()); | 392 ASSERT_TRUE(test_layer.get()); |
392 | 393 |
393 // These use the same gpu::Mailbox, but different sync points. | 394 // These use the same gpu::Mailbox, but different sync points. |
394 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); | 395 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); |
395 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); | 396 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); |
396 | 397 |
397 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 398 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
398 layer_tree_host_->SetRootLayer(test_layer); | 399 layer_tree_host_->SetRootLayer(test_layer); |
399 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 400 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
400 | 401 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 461 } |
461 | 462 |
462 scoped_ptr<TestMailboxHolder::MainThreadReference> | 463 scoped_ptr<TestMailboxHolder::MainThreadReference> |
463 main_ref_; | 464 main_ref_; |
464 base::Thread main_thread_; | 465 base::Thread main_thread_; |
465 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; | 466 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; |
466 }; | 467 }; |
467 | 468 |
468 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { | 469 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { |
469 scoped_refptr<TextureLayer> test_layer = | 470 scoped_refptr<TextureLayer> test_layer = |
470 TextureLayer::CreateForMailbox(nullptr); | 471 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
471 ASSERT_TRUE(test_layer.get()); | 472 ASSERT_TRUE(test_layer.get()); |
472 | 473 |
473 main_thread_.message_loop()->task_runner()->PostTask( | 474 main_thread_.message_loop()->task_runner()->PostTask( |
474 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 475 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
475 base::Unretained(this))); | 476 base::Unretained(this))); |
476 | 477 |
477 Wait(main_thread_); | 478 Wait(main_thread_); |
478 | 479 |
479 // The texture layer is attached to compositor1, and passes a reference to its | 480 // The texture layer is attached to compositor1, and passes a reference to its |
480 // impl tree. | 481 // impl tree. |
(...skipping 29 matching lines...) Expand all Loading... |
510 | 511 |
511 main_thread_.message_loop()->task_runner()->PostTask( | 512 main_thread_.message_loop()->task_runner()->PostTask( |
512 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 513 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
513 base::Unretained(this))); | 514 base::Unretained(this))); |
514 Wait(main_thread_); | 515 Wait(main_thread_); |
515 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 516 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
516 } | 517 } |
517 | 518 |
518 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { | 519 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { |
519 scoped_refptr<TextureLayer> test_layer = | 520 scoped_refptr<TextureLayer> test_layer = |
520 TextureLayer::CreateForMailbox(nullptr); | 521 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
521 ASSERT_TRUE(test_layer.get()); | 522 ASSERT_TRUE(test_layer.get()); |
522 | 523 |
523 main_thread_.message_loop()->task_runner()->PostTask( | 524 main_thread_.message_loop()->task_runner()->PostTask( |
524 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 525 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
525 base::Unretained(this))); | 526 base::Unretained(this))); |
526 | 527 |
527 Wait(main_thread_); | 528 Wait(main_thread_); |
528 | 529 |
529 // The texture layer is attached to compositor1, and passes a reference to its | 530 // The texture layer is attached to compositor1, and passes a reference to its |
530 // impl tree. | 531 // impl tree. |
(...skipping 30 matching lines...) Expand all Loading... |
561 EXPECT_CALL(test_data_.mock_callback_, | 562 EXPECT_CALL(test_data_.mock_callback_, |
562 Release(test_data_.mailbox_name1_, 200, true)).Times(1); | 563 Release(test_data_.mailbox_name1_, 200, true)).Times(1); |
563 | 564 |
564 compositor2->Run(200, true, main_thread_task_runner_.get()); | 565 compositor2->Run(200, true, main_thread_task_runner_.get()); |
565 Wait(main_thread_); | 566 Wait(main_thread_); |
566 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 567 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
567 } | 568 } |
568 | 569 |
569 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 570 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { |
570 scoped_refptr<TextureLayer> test_layer = | 571 scoped_refptr<TextureLayer> test_layer = |
571 TextureLayer::CreateForMailbox(nullptr); | 572 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
572 ASSERT_TRUE(test_layer.get()); | 573 ASSERT_TRUE(test_layer.get()); |
573 | 574 |
574 main_thread_.message_loop()->task_runner()->PostTask( | 575 main_thread_.message_loop()->task_runner()->PostTask( |
575 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 576 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
576 base::Unretained(this))); | 577 base::Unretained(this))); |
577 | 578 |
578 Wait(main_thread_); | 579 Wait(main_thread_); |
579 | 580 |
580 // The texture layer is attached to compositor1, and passes a reference to its | 581 // The texture layer is attached to compositor1, and passes a reference to its |
581 // impl tree. | 582 // impl tree. |
(...skipping 30 matching lines...) Expand all Loading... |
612 EXPECT_CALL(test_data_.mock_callback_, | 613 EXPECT_CALL(test_data_.mock_callback_, |
613 Release(test_data_.mailbox_name1_, 100, true)).Times(1); | 614 Release(test_data_.mailbox_name1_, 100, true)).Times(1); |
614 | 615 |
615 compositor1->Run(100, true, main_thread_task_runner_.get()); | 616 compositor1->Run(100, true, main_thread_task_runner_.get()); |
616 Wait(main_thread_); | 617 Wait(main_thread_); |
617 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 618 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
618 } | 619 } |
619 | 620 |
620 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 621 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { |
621 scoped_refptr<TextureLayer> test_layer = | 622 scoped_refptr<TextureLayer> test_layer = |
622 TextureLayer::CreateForMailbox(nullptr); | 623 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
623 ASSERT_TRUE(test_layer.get()); | 624 ASSERT_TRUE(test_layer.get()); |
624 | 625 |
625 main_thread_.message_loop()->task_runner()->PostTask( | 626 main_thread_.message_loop()->task_runner()->PostTask( |
626 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 627 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
627 base::Unretained(this))); | 628 base::Unretained(this))); |
628 | 629 |
629 Wait(main_thread_); | 630 Wait(main_thread_); |
630 | 631 |
631 // The texture layer is attached to compositor1, and passes a reference to its | 632 // The texture layer is attached to compositor1, and passes a reference to its |
632 // impl tree. | 633 // impl tree. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 base::Unretained(this))); | 711 base::Unretained(this))); |
711 layer_->SetTextureMailbox( | 712 layer_->SetTextureMailbox( |
712 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 713 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
713 callback.Pass()); | 714 callback.Pass()); |
714 } | 715 } |
715 | 716 |
716 void BeginTest() override { | 717 void BeginTest() override { |
717 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 718 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
718 | 719 |
719 gfx::Size bounds(100, 100); | 720 gfx::Size bounds(100, 100); |
720 root_ = Layer::Create(); | 721 root_ = Layer::Create(layer_settings()); |
721 root_->SetBounds(bounds); | 722 root_->SetBounds(bounds); |
722 | 723 |
723 layer_ = TextureLayer::CreateForMailbox(nullptr); | 724 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
724 layer_->SetIsDrawable(true); | 725 layer_->SetIsDrawable(true); |
725 layer_->SetBounds(bounds); | 726 layer_->SetBounds(bounds); |
726 | 727 |
727 root_->AddChild(layer_); | 728 root_->AddChild(layer_); |
728 layer_tree_host()->SetRootLayer(root_); | 729 layer_tree_host()->SetRootLayer(root_); |
729 layer_tree_host()->SetViewportSize(bounds); | 730 layer_tree_host()->SetViewportSize(bounds); |
730 SetMailbox('1'); | 731 SetMailbox('1'); |
731 EXPECT_EQ(0, callback_count_); | 732 EXPECT_EQ(0, callback_count_); |
732 | 733 |
733 // Case #1: change mailbox before the commit. The old mailbox should be | 734 // Case #1: change mailbox before the commit. The old mailbox should be |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 832 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
832 base::Bind( | 833 base::Bind( |
833 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 834 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
834 layer_->SetTextureMailbox( | 835 layer_->SetTextureMailbox( |
835 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 836 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
836 callback.Pass()); | 837 callback.Pass()); |
837 } | 838 } |
838 | 839 |
839 void BeginTest() override { | 840 void BeginTest() override { |
840 gfx::Size bounds(100, 100); | 841 gfx::Size bounds(100, 100); |
841 root_ = Layer::Create(); | 842 root_ = Layer::Create(layer_settings()); |
842 root_->SetBounds(bounds); | 843 root_->SetBounds(bounds); |
843 | 844 |
844 layer_ = TextureLayer::CreateForMailbox(nullptr); | 845 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
845 layer_->SetIsDrawable(true); | 846 layer_->SetIsDrawable(true); |
846 layer_->SetBounds(bounds); | 847 layer_->SetBounds(bounds); |
847 | 848 |
848 root_->AddChild(layer_); | 849 root_->AddChild(layer_); |
849 layer_tree_host()->SetRootLayer(root_); | 850 layer_tree_host()->SetRootLayer(root_); |
850 layer_tree_host()->SetViewportSize(bounds); | 851 layer_tree_host()->SetViewportSize(bounds); |
851 SetMailbox('1'); | 852 SetMailbox('1'); |
852 | 853 |
853 PostSetNeedsCommitToMainThread(); | 854 PostSetNeedsCommitToMainThread(); |
854 } | 855 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 } | 1133 } |
1133 | 1134 |
1134 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1135 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1135 // Source frame number during callback is the same as the source frame | 1136 // Source frame number during callback is the same as the source frame |
1136 // on which it was released. | 1137 // on which it was released. |
1137 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); | 1138 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); |
1138 EndTest(); | 1139 EndTest(); |
1139 } | 1140 } |
1140 | 1141 |
1141 void SetupTree() override { | 1142 void SetupTree() override { |
1142 scoped_refptr<Layer> root = Layer::Create(); | 1143 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
1143 root->SetBounds(gfx::Size(10, 10)); | 1144 root->SetBounds(gfx::Size(10, 10)); |
1144 root->SetIsDrawable(true); | 1145 root->SetIsDrawable(true); |
1145 | 1146 |
1146 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1147 texture_layer_ = TextureLayer::CreateForMailbox(layer_settings(), this); |
1147 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1148 texture_layer_->SetBounds(gfx::Size(10, 10)); |
1148 texture_layer_->SetIsDrawable(true); | 1149 texture_layer_->SetIsDrawable(true); |
1149 root->AddChild(texture_layer_); | 1150 root->AddChild(texture_layer_); |
1150 | 1151 |
1151 layer_tree_host()->SetRootLayer(root); | 1152 layer_tree_host()->SetRootLayer(root); |
1152 LayerTreeTest::SetupTree(); | 1153 LayerTreeTest::SetupTree(); |
1153 } | 1154 } |
1154 | 1155 |
1155 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1156 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1156 | 1157 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 | 1228 |
1228 TextureMailbox MakeMailbox(char name) { | 1229 TextureMailbox MakeMailbox(char name) { |
1229 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); | 1230 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); |
1230 } | 1231 } |
1231 | 1232 |
1232 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1233 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1233 ++mailbox_returned_; | 1234 ++mailbox_returned_; |
1234 } | 1235 } |
1235 | 1236 |
1236 void SetupTree() override { | 1237 void SetupTree() override { |
1237 scoped_refptr<Layer> root = Layer::Create(); | 1238 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
1238 root->SetBounds(gfx::Size(10, 10)); | 1239 root->SetBounds(gfx::Size(10, 10)); |
1239 root->SetIsDrawable(true); | 1240 root->SetIsDrawable(true); |
1240 | 1241 |
1241 solid_layer_ = SolidColorLayer::Create(); | 1242 solid_layer_ = SolidColorLayer::Create(layer_settings()); |
1242 solid_layer_->SetBounds(gfx::Size(10, 10)); | 1243 solid_layer_->SetBounds(gfx::Size(10, 10)); |
1243 solid_layer_->SetIsDrawable(true); | 1244 solid_layer_->SetIsDrawable(true); |
1244 solid_layer_->SetBackgroundColor(SK_ColorWHITE); | 1245 solid_layer_->SetBackgroundColor(SK_ColorWHITE); |
1245 root->AddChild(solid_layer_); | 1246 root->AddChild(solid_layer_); |
1246 | 1247 |
1247 parent_layer_ = Layer::Create(); | 1248 parent_layer_ = Layer::Create(layer_settings()); |
1248 parent_layer_->SetBounds(gfx::Size(10, 10)); | 1249 parent_layer_->SetBounds(gfx::Size(10, 10)); |
1249 parent_layer_->SetIsDrawable(true); | 1250 parent_layer_->SetIsDrawable(true); |
1250 root->AddChild(parent_layer_); | 1251 root->AddChild(parent_layer_); |
1251 | 1252 |
1252 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1253 texture_layer_ = TextureLayer::CreateForMailbox(layer_settings(), this); |
1253 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1254 texture_layer_->SetBounds(gfx::Size(10, 10)); |
1254 texture_layer_->SetIsDrawable(true); | 1255 texture_layer_->SetIsDrawable(true); |
1255 parent_layer_->AddChild(texture_layer_); | 1256 parent_layer_->AddChild(texture_layer_); |
1256 | 1257 |
1257 layer_tree_host()->SetRootLayer(root); | 1258 layer_tree_host()->SetRootLayer(root); |
1258 LayerTreeTest::SetupTree(); | 1259 LayerTreeTest::SetupTree(); |
1259 } | 1260 } |
1260 | 1261 |
1261 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1262 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1262 | 1263 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 } | 1358 } |
1358 | 1359 |
1359 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1360 void MailboxReleased(unsigned sync_point, bool lost_resource) { |
1360 mailbox_released_ = true; | 1361 mailbox_released_ = true; |
1361 } | 1362 } |
1362 | 1363 |
1363 void SetupTree() override { | 1364 void SetupTree() override { |
1364 LayerTreeTest::SetupTree(); | 1365 LayerTreeTest::SetupTree(); |
1365 | 1366 |
1366 scoped_refptr<TextureLayer> texture_layer = | 1367 scoped_refptr<TextureLayer> texture_layer = |
1367 TextureLayer::CreateForMailbox(this); | 1368 TextureLayer::CreateForMailbox(layer_settings(), this); |
1368 texture_layer->SetBounds(gfx::Size(10, 10)); | 1369 texture_layer->SetBounds(gfx::Size(10, 10)); |
1369 texture_layer->SetIsDrawable(true); | 1370 texture_layer->SetIsDrawable(true); |
1370 | 1371 |
1371 layer_tree_host()->root_layer()->AddChild(texture_layer); | 1372 layer_tree_host()->root_layer()->AddChild(texture_layer); |
1372 } | 1373 } |
1373 | 1374 |
1374 void BeginTest() override { | 1375 void BeginTest() override { |
1375 mailbox_released_ = false; | 1376 mailbox_released_ = false; |
1376 PostSetNeedsCommitToMainThread(); | 1377 PostSetNeedsCommitToMainThread(); |
1377 } | 1378 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 base::Bind( | 1422 base::Bind( |
1422 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 1423 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
1423 base::Unretained(this))); | 1424 base::Unretained(this))); |
1424 layer_->SetTextureMailbox( | 1425 layer_->SetTextureMailbox( |
1425 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1426 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1426 callback.Pass()); | 1427 callback.Pass()); |
1427 } | 1428 } |
1428 | 1429 |
1429 void SetupTree() override { | 1430 void SetupTree() override { |
1430 gfx::Size bounds(100, 100); | 1431 gfx::Size bounds(100, 100); |
1431 root_ = Layer::Create(); | 1432 root_ = Layer::Create(layer_settings()); |
1432 root_->SetBounds(bounds); | 1433 root_->SetBounds(bounds); |
1433 | 1434 |
1434 layer_ = TextureLayer::CreateForMailbox(nullptr); | 1435 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
1435 layer_->SetIsDrawable(true); | 1436 layer_->SetIsDrawable(true); |
1436 layer_->SetBounds(bounds); | 1437 layer_->SetBounds(bounds); |
1437 | 1438 |
1438 root_->AddChild(layer_); | 1439 root_->AddChild(layer_); |
1439 layer_tree_host()->SetRootLayer(root_); | 1440 layer_tree_host()->SetRootLayer(root_); |
1440 layer_tree_host()->SetViewportSize(bounds); | 1441 layer_tree_host()->SetViewportSize(bounds); |
1441 } | 1442 } |
1442 | 1443 |
1443 void BeginTest() override { | 1444 void BeginTest() override { |
1444 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1445 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 base::Bind( | 1491 base::Bind( |
1491 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 1492 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
1492 base::Unretained(this))); | 1493 base::Unretained(this))); |
1493 layer_->SetTextureMailbox( | 1494 layer_->SetTextureMailbox( |
1494 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1495 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1495 callback.Pass()); | 1496 callback.Pass()); |
1496 } | 1497 } |
1497 | 1498 |
1498 void SetupTree() override { | 1499 void SetupTree() override { |
1499 gfx::Size bounds(100, 100); | 1500 gfx::Size bounds(100, 100); |
1500 root_ = Layer::Create(); | 1501 root_ = Layer::Create(layer_settings()); |
1501 root_->SetBounds(bounds); | 1502 root_->SetBounds(bounds); |
1502 | 1503 |
1503 layer_ = TextureLayer::CreateForMailbox(nullptr); | 1504 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
1504 layer_->SetIsDrawable(true); | 1505 layer_->SetIsDrawable(true); |
1505 layer_->SetBounds(bounds); | 1506 layer_->SetBounds(bounds); |
1506 | 1507 |
1507 root_->AddChild(layer_); | 1508 root_->AddChild(layer_); |
1508 layer_tree_host()->SetRootLayer(root_); | 1509 layer_tree_host()->SetRootLayer(root_); |
1509 layer_tree_host()->SetViewportSize(bounds); | 1510 layer_tree_host()->SetViewportSize(bounds); |
1510 } | 1511 } |
1511 | 1512 |
1512 void BeginTest() override { | 1513 void BeginTest() override { |
1513 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1514 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
(...skipping 28 matching lines...) Expand all Loading... |
1542 int callback_count_; | 1543 int callback_count_; |
1543 scoped_refptr<Layer> root_; | 1544 scoped_refptr<Layer> root_; |
1544 scoped_refptr<TextureLayer> layer_; | 1545 scoped_refptr<TextureLayer> layer_; |
1545 }; | 1546 }; |
1546 | 1547 |
1547 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1548 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1548 TextureLayerWithMailboxImplThreadDeleted); | 1549 TextureLayerWithMailboxImplThreadDeleted); |
1549 | 1550 |
1550 } // namespace | 1551 } // namespace |
1551 } // namespace cc | 1552 } // namespace cc |
OLD | NEW |