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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 layer_tree_host_ = nullptr; | 194 layer_tree_host_ = nullptr; |
195 } | 195 } |
196 | 196 |
197 scoped_ptr<MockLayerTreeHost> layer_tree_host_; | 197 scoped_ptr<MockLayerTreeHost> layer_tree_host_; |
198 FakeImplProxy proxy_; | 198 FakeImplProxy proxy_; |
199 FakeLayerTreeHostClient fake_client_; | 199 FakeLayerTreeHostClient fake_client_; |
200 TestSharedBitmapManager shared_bitmap_manager_; | 200 TestSharedBitmapManager shared_bitmap_manager_; |
201 TestTaskGraphRunner task_graph_runner_; | 201 TestTaskGraphRunner task_graph_runner_; |
202 FakeLayerTreeHostImpl host_impl_; | 202 FakeLayerTreeHostImpl host_impl_; |
203 CommonMailboxObjects test_data_; | 203 CommonMailboxObjects test_data_; |
| 204 LayerSettings layer_settings_; |
204 }; | 205 }; |
205 | 206 |
206 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 207 TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
207 scoped_refptr<TextureLayer> test_layer = | 208 scoped_refptr<TextureLayer> test_layer = |
208 TextureLayer::CreateForMailbox(nullptr); | 209 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
209 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); | 210 EXPECT_SET_NEEDS_COMMIT(1, layer_tree_host_->SetRootLayer(test_layer)); |
210 | 211 |
211 // Test properties that should call SetNeedsCommit. All properties need to | 212 // Test properties that should call SetNeedsCommit. All properties need to |
212 // be set to new values in order for SetNeedsCommit to be called. | 213 // be set to new values in order for SetNeedsCommit to be called. |
213 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); | 214 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFlipped(false)); |
214 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); | 215 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNearestNeighbor(true)); |
215 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( | 216 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetUV( |
216 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); | 217 gfx::PointF(0.25f, 0.25f), gfx::PointF(0.75f, 0.75f))); |
217 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( | 218 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetVertexOpacity( |
218 0.5f, 0.5f, 0.5f, 0.5f)); | 219 0.5f, 0.5f, 0.5f, 0.5f)); |
219 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); | 220 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetPremultipliedAlpha(false)); |
220 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); | 221 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBlendBackgroundColor(true)); |
221 } | 222 } |
222 | 223 |
223 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { | 224 TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { |
224 const gfx::Size layer_bounds(100, 100); | 225 const gfx::Size layer_bounds(100, 100); |
225 const gfx::Rect layer_rect(layer_bounds); | 226 const gfx::Rect layer_rect(layer_bounds); |
226 const Region layer_region(layer_rect); | 227 const Region layer_region(layer_rect); |
227 | 228 |
228 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(nullptr); | 229 scoped_refptr<TextureLayer> layer = |
| 230 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
229 layer->SetBounds(layer_bounds); | 231 layer->SetBounds(layer_bounds); |
230 layer->draw_properties().visible_content_rect = layer_rect; | 232 layer->draw_properties().visible_content_rect = layer_rect; |
231 layer->SetBlendBackgroundColor(true); | 233 layer->SetBlendBackgroundColor(true); |
232 | 234 |
233 // Verify initial conditions. | 235 // Verify initial conditions. |
234 EXPECT_FALSE(layer->contents_opaque()); | 236 EXPECT_FALSE(layer->contents_opaque()); |
235 EXPECT_EQ(0u, layer->background_color()); | 237 EXPECT_EQ(0u, layer->background_color()); |
236 EXPECT_EQ(Region().ToString(), | 238 EXPECT_EQ(Region().ToString(), |
237 layer->VisibleContentOpaqueRegion().ToString()); | 239 layer->VisibleContentOpaqueRegion().ToString()); |
238 | 240 |
239 // Opaque background. | 241 // Opaque background. |
240 layer->SetBackgroundColor(SK_ColorWHITE); | 242 layer->SetBackgroundColor(SK_ColorWHITE); |
241 EXPECT_EQ(layer_region.ToString(), | 243 EXPECT_EQ(layer_region.ToString(), |
242 layer->VisibleContentOpaqueRegion().ToString()); | 244 layer->VisibleContentOpaqueRegion().ToString()); |
243 | 245 |
244 // Transparent background. | 246 // Transparent background. |
245 layer->SetBackgroundColor(SkColorSetARGB(100, 255, 255, 255)); | 247 layer->SetBackgroundColor(SkColorSetARGB(100, 255, 255, 255)); |
246 EXPECT_EQ(Region().ToString(), | 248 EXPECT_EQ(Region().ToString(), |
247 layer->VisibleContentOpaqueRegion().ToString()); | 249 layer->VisibleContentOpaqueRegion().ToString()); |
248 } | 250 } |
249 | 251 |
250 TEST_F(TextureLayerTest, RateLimiter) { | 252 TEST_F(TextureLayerTest, RateLimiter) { |
251 FakeTextureLayerClient client; | 253 FakeTextureLayerClient client; |
252 scoped_refptr<TextureLayer> test_layer = TextureLayer::CreateForMailbox( | 254 scoped_refptr<TextureLayer> test_layer = |
253 &client); | 255 TextureLayer::CreateForMailbox(layer_settings_, &client); |
254 test_layer->SetIsDrawable(true); | 256 test_layer->SetIsDrawable(true); |
255 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 257 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
256 layer_tree_host_->SetRootLayer(test_layer); | 258 layer_tree_host_->SetRootLayer(test_layer); |
257 | 259 |
258 // Don't rate limit until we invalidate. | 260 // Don't rate limit until we invalidate. |
259 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | 261 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); |
260 test_layer->SetRateLimitContext(true); | 262 test_layer->SetRateLimitContext(true); |
261 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 263 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
262 | 264 |
263 // Do rate limit after we invalidate. | 265 // Do rate limit after we invalidate. |
264 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); | 266 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); |
265 test_layer->SetNeedsDisplay(); | 267 test_layer->SetNeedsDisplay(); |
266 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 268 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
267 | 269 |
268 // Stop rate limiter when we don't want it any more. | 270 // Stop rate limiter when we don't want it any more. |
269 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | 271 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); |
270 test_layer->SetRateLimitContext(false); | 272 test_layer->SetRateLimitContext(false); |
271 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 273 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
272 | 274 |
273 // Or we clear the client. | 275 // Or we clear the client. |
274 test_layer->SetRateLimitContext(true); | 276 test_layer->SetRateLimitContext(true); |
275 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); | 277 EXPECT_CALL(*layer_tree_host_, StopRateLimiter()); |
276 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 278 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
277 test_layer->ClearClient(); | 279 test_layer->ClearClient(); |
278 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 280 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
279 | 281 |
280 // Reset to a layer with a client, that started the rate limiter. | 282 // Reset to a layer with a client, that started the rate limiter. |
281 test_layer = TextureLayer::CreateForMailbox( | 283 test_layer = TextureLayer::CreateForMailbox(layer_settings_, &client); |
282 &client); | |
283 test_layer->SetIsDrawable(true); | 284 test_layer->SetIsDrawable(true); |
284 test_layer->SetRateLimitContext(true); | 285 test_layer->SetRateLimitContext(true); |
285 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 286 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
286 layer_tree_host_->SetRootLayer(test_layer); | 287 layer_tree_host_->SetRootLayer(test_layer); |
287 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); | 288 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()).Times(0); |
288 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 289 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
289 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); | 290 EXPECT_CALL(*layer_tree_host_, StartRateLimiter()); |
290 test_layer->SetNeedsDisplay(); | 291 test_layer->SetNeedsDisplay(); |
291 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 292 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
292 | 293 |
(...skipping 19 matching lines...) Expand all Loading... |
312 EXPECT_CALL(test_data_.mock_callback_, | 313 EXPECT_CALL(test_data_.mock_callback_, |
313 Release(test_data_.mailbox_name1_, | 314 Release(test_data_.mailbox_name1_, |
314 test_data_.sync_point1_, | 315 test_data_.sync_point1_, |
315 false)).Times(1); | 316 false)).Times(1); |
316 TextureLayerTest::TearDown(); | 317 TextureLayerTest::TearDown(); |
317 } | 318 } |
318 }; | 319 }; |
319 | 320 |
320 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { | 321 TEST_F(TextureLayerWithMailboxTest, ReplaceMailboxOnMainThreadBeforeCommit) { |
321 scoped_refptr<TextureLayer> test_layer = | 322 scoped_refptr<TextureLayer> test_layer = |
322 TextureLayer::CreateForMailbox(nullptr); | 323 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
323 ASSERT_TRUE(test_layer.get()); | 324 ASSERT_TRUE(test_layer.get()); |
324 | 325 |
325 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 326 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
326 layer_tree_host_->SetRootLayer(test_layer); | 327 layer_tree_host_->SetRootLayer(test_layer); |
327 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 328 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
328 | 329 |
329 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 330 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
330 test_layer->SetTextureMailbox( | 331 test_layer->SetTextureMailbox( |
331 test_data_.mailbox1_, | 332 test_data_.mailbox1_, |
332 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 333 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 371 |
371 // Test destructor. | 372 // Test destructor. |
372 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 373 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
373 test_layer->SetTextureMailbox( | 374 test_layer->SetTextureMailbox( |
374 test_data_.mailbox1_, | 375 test_data_.mailbox1_, |
375 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 376 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
376 } | 377 } |
377 | 378 |
378 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { | 379 TEST_F(TextureLayerTest, SetTextureMailboxWithoutReleaseCallback) { |
379 scoped_refptr<TextureLayer> test_layer = | 380 scoped_refptr<TextureLayer> test_layer = |
380 TextureLayer::CreateForMailbox(nullptr); | 381 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
381 ASSERT_TRUE(test_layer.get()); | 382 ASSERT_TRUE(test_layer.get()); |
382 | 383 |
383 // These use the same gpu::Mailbox, but different sync points. | 384 // These use the same gpu::Mailbox, but different sync points. |
384 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); | 385 TextureMailbox mailbox1(MailboxFromChar('a'), GL_TEXTURE_2D, 1); |
385 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); | 386 TextureMailbox mailbox2(MailboxFromChar('a'), GL_TEXTURE_2D, 2); |
386 | 387 |
387 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 388 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
388 layer_tree_host_->SetRootLayer(test_layer); | 389 layer_tree_host_->SetRootLayer(test_layer); |
389 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 390 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
390 | 391 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 451 } |
451 | 452 |
452 scoped_ptr<TestMailboxHolder::MainThreadReference> | 453 scoped_ptr<TestMailboxHolder::MainThreadReference> |
453 main_ref_; | 454 main_ref_; |
454 base::Thread main_thread_; | 455 base::Thread main_thread_; |
455 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; | 456 scoped_ptr<BlockingTaskRunner> main_thread_task_runner_; |
456 }; | 457 }; |
457 | 458 |
458 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { | 459 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_BothReleaseThenMain) { |
459 scoped_refptr<TextureLayer> test_layer = | 460 scoped_refptr<TextureLayer> test_layer = |
460 TextureLayer::CreateForMailbox(nullptr); | 461 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
461 ASSERT_TRUE(test_layer.get()); | 462 ASSERT_TRUE(test_layer.get()); |
462 | 463 |
463 main_thread_.message_loop()->task_runner()->PostTask( | 464 main_thread_.message_loop()->task_runner()->PostTask( |
464 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 465 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
465 base::Unretained(this))); | 466 base::Unretained(this))); |
466 | 467 |
467 Wait(main_thread_); | 468 Wait(main_thread_); |
468 | 469 |
469 // The texture layer is attached to compositor1, and passes a reference to its | 470 // The texture layer is attached to compositor1, and passes a reference to its |
470 // impl tree. | 471 // impl tree. |
(...skipping 29 matching lines...) Expand all Loading... |
500 | 501 |
501 main_thread_.message_loop()->task_runner()->PostTask( | 502 main_thread_.message_loop()->task_runner()->PostTask( |
502 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, | 503 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::ReleaseMainRef, |
503 base::Unretained(this))); | 504 base::Unretained(this))); |
504 Wait(main_thread_); | 505 Wait(main_thread_); |
505 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 506 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
506 } | 507 } |
507 | 508 |
508 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { | 509 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleaseBetween) { |
509 scoped_refptr<TextureLayer> test_layer = | 510 scoped_refptr<TextureLayer> test_layer = |
510 TextureLayer::CreateForMailbox(nullptr); | 511 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
511 ASSERT_TRUE(test_layer.get()); | 512 ASSERT_TRUE(test_layer.get()); |
512 | 513 |
513 main_thread_.message_loop()->task_runner()->PostTask( | 514 main_thread_.message_loop()->task_runner()->PostTask( |
514 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 515 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
515 base::Unretained(this))); | 516 base::Unretained(this))); |
516 | 517 |
517 Wait(main_thread_); | 518 Wait(main_thread_); |
518 | 519 |
519 // The texture layer is attached to compositor1, and passes a reference to its | 520 // The texture layer is attached to compositor1, and passes a reference to its |
520 // impl tree. | 521 // impl tree. |
(...skipping 30 matching lines...) Expand all Loading... |
551 EXPECT_CALL(test_data_.mock_callback_, | 552 EXPECT_CALL(test_data_.mock_callback_, |
552 Release(test_data_.mailbox_name1_, 200, true)).Times(1); | 553 Release(test_data_.mailbox_name1_, 200, true)).Times(1); |
553 | 554 |
554 compositor2->Run(200, true, main_thread_task_runner_.get()); | 555 compositor2->Run(200, true, main_thread_task_runner_.get()); |
555 Wait(main_thread_); | 556 Wait(main_thread_); |
556 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 557 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
557 } | 558 } |
558 | 559 |
559 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { | 560 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_MainReleasedFirst) { |
560 scoped_refptr<TextureLayer> test_layer = | 561 scoped_refptr<TextureLayer> test_layer = |
561 TextureLayer::CreateForMailbox(nullptr); | 562 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
562 ASSERT_TRUE(test_layer.get()); | 563 ASSERT_TRUE(test_layer.get()); |
563 | 564 |
564 main_thread_.message_loop()->task_runner()->PostTask( | 565 main_thread_.message_loop()->task_runner()->PostTask( |
565 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 566 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
566 base::Unretained(this))); | 567 base::Unretained(this))); |
567 | 568 |
568 Wait(main_thread_); | 569 Wait(main_thread_); |
569 | 570 |
570 // The texture layer is attached to compositor1, and passes a reference to its | 571 // The texture layer is attached to compositor1, and passes a reference to its |
571 // impl tree. | 572 // impl tree. |
(...skipping 30 matching lines...) Expand all Loading... |
602 EXPECT_CALL(test_data_.mock_callback_, | 603 EXPECT_CALL(test_data_.mock_callback_, |
603 Release(test_data_.mailbox_name1_, 100, true)).Times(1); | 604 Release(test_data_.mailbox_name1_, 100, true)).Times(1); |
604 | 605 |
605 compositor1->Run(100, true, main_thread_task_runner_.get()); | 606 compositor1->Run(100, true, main_thread_task_runner_.get()); |
606 Wait(main_thread_); | 607 Wait(main_thread_); |
607 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 608 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
608 } | 609 } |
609 | 610 |
610 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { | 611 TEST_F(TextureLayerMailboxHolderTest, TwoCompositors_SecondImplRefShortcut) { |
611 scoped_refptr<TextureLayer> test_layer = | 612 scoped_refptr<TextureLayer> test_layer = |
612 TextureLayer::CreateForMailbox(nullptr); | 613 TextureLayer::CreateForMailbox(layer_settings_, nullptr); |
613 ASSERT_TRUE(test_layer.get()); | 614 ASSERT_TRUE(test_layer.get()); |
614 | 615 |
615 main_thread_.message_loop()->task_runner()->PostTask( | 616 main_thread_.message_loop()->task_runner()->PostTask( |
616 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, | 617 FROM_HERE, base::Bind(&TextureLayerMailboxHolderTest::CreateMainRef, |
617 base::Unretained(this))); | 618 base::Unretained(this))); |
618 | 619 |
619 Wait(main_thread_); | 620 Wait(main_thread_); |
620 | 621 |
621 // The texture layer is attached to compositor1, and passes a reference to its | 622 // The texture layer is attached to compositor1, and passes a reference to its |
622 // impl tree. | 623 // impl tree. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 base::Unretained(this))); | 701 base::Unretained(this))); |
701 layer_->SetTextureMailbox( | 702 layer_->SetTextureMailbox( |
702 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 703 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
703 callback.Pass()); | 704 callback.Pass()); |
704 } | 705 } |
705 | 706 |
706 void BeginTest() override { | 707 void BeginTest() override { |
707 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 708 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
708 | 709 |
709 gfx::Size bounds(100, 100); | 710 gfx::Size bounds(100, 100); |
710 root_ = Layer::Create(); | 711 root_ = Layer::Create(layer_settings()); |
711 root_->SetBounds(bounds); | 712 root_->SetBounds(bounds); |
712 | 713 |
713 layer_ = TextureLayer::CreateForMailbox(nullptr); | 714 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
714 layer_->SetIsDrawable(true); | 715 layer_->SetIsDrawable(true); |
715 layer_->SetBounds(bounds); | 716 layer_->SetBounds(bounds); |
716 | 717 |
717 root_->AddChild(layer_); | 718 root_->AddChild(layer_); |
718 layer_tree_host()->SetRootLayer(root_); | 719 layer_tree_host()->SetRootLayer(root_); |
719 layer_tree_host()->SetViewportSize(bounds); | 720 layer_tree_host()->SetViewportSize(bounds); |
720 SetMailbox('1'); | 721 SetMailbox('1'); |
721 EXPECT_EQ(0, callback_count_); | 722 EXPECT_EQ(0, callback_count_); |
722 | 723 |
723 // Case #1: change mailbox before the commit. The old mailbox should be | 724 // 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... |
821 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 822 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
822 base::Bind( | 823 base::Bind( |
823 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 824 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
824 layer_->SetTextureMailbox( | 825 layer_->SetTextureMailbox( |
825 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 826 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
826 callback.Pass()); | 827 callback.Pass()); |
827 } | 828 } |
828 | 829 |
829 void BeginTest() override { | 830 void BeginTest() override { |
830 gfx::Size bounds(100, 100); | 831 gfx::Size bounds(100, 100); |
831 root_ = Layer::Create(); | 832 root_ = Layer::Create(layer_settings()); |
832 root_->SetBounds(bounds); | 833 root_->SetBounds(bounds); |
833 | 834 |
834 layer_ = TextureLayer::CreateForMailbox(nullptr); | 835 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
835 layer_->SetIsDrawable(true); | 836 layer_->SetIsDrawable(true); |
836 layer_->SetBounds(bounds); | 837 layer_->SetBounds(bounds); |
837 | 838 |
838 root_->AddChild(layer_); | 839 root_->AddChild(layer_); |
839 layer_tree_host()->SetRootLayer(root_); | 840 layer_tree_host()->SetRootLayer(root_); |
840 layer_tree_host()->SetViewportSize(bounds); | 841 layer_tree_host()->SetViewportSize(bounds); |
841 SetMailbox('1'); | 842 SetMailbox('1'); |
842 | 843 |
843 PostSetNeedsCommitToMainThread(); | 844 PostSetNeedsCommitToMainThread(); |
844 } | 845 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 } | 1123 } |
1123 | 1124 |
1124 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1125 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1125 // Source frame number during callback is the same as the source frame | 1126 // Source frame number during callback is the same as the source frame |
1126 // on which it was released. | 1127 // on which it was released. |
1127 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); | 1128 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); |
1128 EndTest(); | 1129 EndTest(); |
1129 } | 1130 } |
1130 | 1131 |
1131 void SetupTree() override { | 1132 void SetupTree() override { |
1132 scoped_refptr<Layer> root = Layer::Create(); | 1133 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
1133 root->SetBounds(gfx::Size(10, 10)); | 1134 root->SetBounds(gfx::Size(10, 10)); |
1134 root->SetIsDrawable(true); | 1135 root->SetIsDrawable(true); |
1135 | 1136 |
1136 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1137 texture_layer_ = TextureLayer::CreateForMailbox(layer_settings(), this); |
1137 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1138 texture_layer_->SetBounds(gfx::Size(10, 10)); |
1138 texture_layer_->SetIsDrawable(true); | 1139 texture_layer_->SetIsDrawable(true); |
1139 root->AddChild(texture_layer_); | 1140 root->AddChild(texture_layer_); |
1140 | 1141 |
1141 layer_tree_host()->SetRootLayer(root); | 1142 layer_tree_host()->SetRootLayer(root); |
1142 LayerTreeTest::SetupTree(); | 1143 LayerTreeTest::SetupTree(); |
1143 } | 1144 } |
1144 | 1145 |
1145 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1146 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1146 | 1147 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 | 1218 |
1218 TextureMailbox MakeMailbox(char name) { | 1219 TextureMailbox MakeMailbox(char name) { |
1219 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); | 1220 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); |
1220 } | 1221 } |
1221 | 1222 |
1222 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1223 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1223 ++mailbox_returned_; | 1224 ++mailbox_returned_; |
1224 } | 1225 } |
1225 | 1226 |
1226 void SetupTree() override { | 1227 void SetupTree() override { |
1227 scoped_refptr<Layer> root = Layer::Create(); | 1228 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
1228 root->SetBounds(gfx::Size(10, 10)); | 1229 root->SetBounds(gfx::Size(10, 10)); |
1229 root->SetIsDrawable(true); | 1230 root->SetIsDrawable(true); |
1230 | 1231 |
1231 solid_layer_ = SolidColorLayer::Create(); | 1232 solid_layer_ = SolidColorLayer::Create(layer_settings()); |
1232 solid_layer_->SetBounds(gfx::Size(10, 10)); | 1233 solid_layer_->SetBounds(gfx::Size(10, 10)); |
1233 solid_layer_->SetIsDrawable(true); | 1234 solid_layer_->SetIsDrawable(true); |
1234 solid_layer_->SetBackgroundColor(SK_ColorWHITE); | 1235 solid_layer_->SetBackgroundColor(SK_ColorWHITE); |
1235 root->AddChild(solid_layer_); | 1236 root->AddChild(solid_layer_); |
1236 | 1237 |
1237 parent_layer_ = Layer::Create(); | 1238 parent_layer_ = Layer::Create(layer_settings()); |
1238 parent_layer_->SetBounds(gfx::Size(10, 10)); | 1239 parent_layer_->SetBounds(gfx::Size(10, 10)); |
1239 parent_layer_->SetIsDrawable(true); | 1240 parent_layer_->SetIsDrawable(true); |
1240 root->AddChild(parent_layer_); | 1241 root->AddChild(parent_layer_); |
1241 | 1242 |
1242 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1243 texture_layer_ = TextureLayer::CreateForMailbox(layer_settings(), this); |
1243 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1244 texture_layer_->SetBounds(gfx::Size(10, 10)); |
1244 texture_layer_->SetIsDrawable(true); | 1245 texture_layer_->SetIsDrawable(true); |
1245 parent_layer_->AddChild(texture_layer_); | 1246 parent_layer_->AddChild(texture_layer_); |
1246 | 1247 |
1247 layer_tree_host()->SetRootLayer(root); | 1248 layer_tree_host()->SetRootLayer(root); |
1248 LayerTreeTest::SetupTree(); | 1249 LayerTreeTest::SetupTree(); |
1249 } | 1250 } |
1250 | 1251 |
1251 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1252 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1252 | 1253 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 } | 1348 } |
1348 | 1349 |
1349 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1350 void MailboxReleased(unsigned sync_point, bool lost_resource) { |
1350 mailbox_released_ = true; | 1351 mailbox_released_ = true; |
1351 } | 1352 } |
1352 | 1353 |
1353 void SetupTree() override { | 1354 void SetupTree() override { |
1354 LayerTreeTest::SetupTree(); | 1355 LayerTreeTest::SetupTree(); |
1355 | 1356 |
1356 scoped_refptr<TextureLayer> texture_layer = | 1357 scoped_refptr<TextureLayer> texture_layer = |
1357 TextureLayer::CreateForMailbox(this); | 1358 TextureLayer::CreateForMailbox(layer_settings(), this); |
1358 texture_layer->SetBounds(gfx::Size(10, 10)); | 1359 texture_layer->SetBounds(gfx::Size(10, 10)); |
1359 texture_layer->SetIsDrawable(true); | 1360 texture_layer->SetIsDrawable(true); |
1360 | 1361 |
1361 layer_tree_host()->root_layer()->AddChild(texture_layer); | 1362 layer_tree_host()->root_layer()->AddChild(texture_layer); |
1362 } | 1363 } |
1363 | 1364 |
1364 void BeginTest() override { | 1365 void BeginTest() override { |
1365 mailbox_released_ = false; | 1366 mailbox_released_ = false; |
1366 PostSetNeedsCommitToMainThread(); | 1367 PostSetNeedsCommitToMainThread(); |
1367 } | 1368 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 base::Bind( | 1412 base::Bind( |
1412 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 1413 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
1413 base::Unretained(this))); | 1414 base::Unretained(this))); |
1414 layer_->SetTextureMailbox( | 1415 layer_->SetTextureMailbox( |
1415 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1416 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1416 callback.Pass()); | 1417 callback.Pass()); |
1417 } | 1418 } |
1418 | 1419 |
1419 void SetupTree() override { | 1420 void SetupTree() override { |
1420 gfx::Size bounds(100, 100); | 1421 gfx::Size bounds(100, 100); |
1421 root_ = Layer::Create(); | 1422 root_ = Layer::Create(layer_settings()); |
1422 root_->SetBounds(bounds); | 1423 root_->SetBounds(bounds); |
1423 | 1424 |
1424 layer_ = TextureLayer::CreateForMailbox(nullptr); | 1425 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
1425 layer_->SetIsDrawable(true); | 1426 layer_->SetIsDrawable(true); |
1426 layer_->SetBounds(bounds); | 1427 layer_->SetBounds(bounds); |
1427 | 1428 |
1428 root_->AddChild(layer_); | 1429 root_->AddChild(layer_); |
1429 layer_tree_host()->SetRootLayer(root_); | 1430 layer_tree_host()->SetRootLayer(root_); |
1430 layer_tree_host()->SetViewportSize(bounds); | 1431 layer_tree_host()->SetViewportSize(bounds); |
1431 } | 1432 } |
1432 | 1433 |
1433 void BeginTest() override { | 1434 void BeginTest() override { |
1434 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1435 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 base::Bind( | 1481 base::Bind( |
1481 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 1482 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
1482 base::Unretained(this))); | 1483 base::Unretained(this))); |
1483 layer_->SetTextureMailbox( | 1484 layer_->SetTextureMailbox( |
1484 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1485 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1485 callback.Pass()); | 1486 callback.Pass()); |
1486 } | 1487 } |
1487 | 1488 |
1488 void SetupTree() override { | 1489 void SetupTree() override { |
1489 gfx::Size bounds(100, 100); | 1490 gfx::Size bounds(100, 100); |
1490 root_ = Layer::Create(); | 1491 root_ = Layer::Create(layer_settings()); |
1491 root_->SetBounds(bounds); | 1492 root_->SetBounds(bounds); |
1492 | 1493 |
1493 layer_ = TextureLayer::CreateForMailbox(nullptr); | 1494 layer_ = TextureLayer::CreateForMailbox(layer_settings(), nullptr); |
1494 layer_->SetIsDrawable(true); | 1495 layer_->SetIsDrawable(true); |
1495 layer_->SetBounds(bounds); | 1496 layer_->SetBounds(bounds); |
1496 | 1497 |
1497 root_->AddChild(layer_); | 1498 root_->AddChild(layer_); |
1498 layer_tree_host()->SetRootLayer(root_); | 1499 layer_tree_host()->SetRootLayer(root_); |
1499 layer_tree_host()->SetViewportSize(bounds); | 1500 layer_tree_host()->SetViewportSize(bounds); |
1500 } | 1501 } |
1501 | 1502 |
1502 void BeginTest() override { | 1503 void BeginTest() override { |
1503 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1504 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
(...skipping 28 matching lines...) Expand all Loading... |
1532 int callback_count_; | 1533 int callback_count_; |
1533 scoped_refptr<Layer> root_; | 1534 scoped_refptr<Layer> root_; |
1534 scoped_refptr<TextureLayer> layer_; | 1535 scoped_refptr<TextureLayer> layer_; |
1535 }; | 1536 }; |
1536 | 1537 |
1537 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1538 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1538 TextureLayerWithMailboxImplThreadDeleted); | 1539 TextureLayerWithMailboxImplThreadDeleted); |
1539 | 1540 |
1540 } // namespace | 1541 } // namespace |
1541 } // namespace cc | 1542 } // namespace cc |
OLD | NEW |