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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "cc/resources/single_release_callback.h" | 21 #include "cc/resources/single_release_callback.h" |
22 #include "cc/test/fake_content_layer.h" | 22 #include "cc/test/fake_content_layer.h" |
23 #include "cc/test/fake_content_layer_client.h" | 23 #include "cc/test/fake_content_layer_client.h" |
24 #include "cc/test/fake_content_layer_impl.h" | 24 #include "cc/test/fake_content_layer_impl.h" |
25 #include "cc/test/fake_delegated_renderer_layer.h" | 25 #include "cc/test/fake_delegated_renderer_layer.h" |
26 #include "cc/test/fake_delegated_renderer_layer_impl.h" | 26 #include "cc/test/fake_delegated_renderer_layer_impl.h" |
27 #include "cc/test/fake_layer_tree_host_client.h" | 27 #include "cc/test/fake_layer_tree_host_client.h" |
28 #include "cc/test/fake_output_surface.h" | 28 #include "cc/test/fake_output_surface.h" |
29 #include "cc/test/fake_output_surface_client.h" | 29 #include "cc/test/fake_output_surface_client.h" |
30 #include "cc/test/fake_painted_scrollbar_layer.h" | 30 #include "cc/test/fake_painted_scrollbar_layer.h" |
| 31 #include "cc/test/fake_picture_layer.h" |
| 32 #include "cc/test/fake_picture_layer_impl.h" |
31 #include "cc/test/fake_scoped_ui_resource.h" | 33 #include "cc/test/fake_scoped_ui_resource.h" |
32 #include "cc/test/fake_scrollbar.h" | 34 #include "cc/test/fake_scrollbar.h" |
33 #include "cc/test/fake_video_frame_provider.h" | 35 #include "cc/test/fake_video_frame_provider.h" |
34 #include "cc/test/layer_tree_test.h" | 36 #include "cc/test/layer_tree_test.h" |
35 #include "cc/test/render_pass_test_common.h" | 37 #include "cc/test/render_pass_test_common.h" |
36 #include "cc/test/test_context_provider.h" | 38 #include "cc/test/test_context_provider.h" |
37 #include "cc/test/test_shared_bitmap_manager.h" | 39 #include "cc/test/test_shared_bitmap_manager.h" |
38 #include "cc/test/test_web_graphics_context_3d.h" | 40 #include "cc/test/test_web_graphics_context_3d.h" |
39 #include "cc/trees/layer_tree_host_impl.h" | 41 #include "cc/trees/layer_tree_host_impl.h" |
40 #include "cc/trees/layer_tree_impl.h" | 42 #include "cc/trees/layer_tree_impl.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); | 318 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); |
317 | 319 |
318 class LayerTreeHostContextTestLostContextSucceedsWithContent | 320 class LayerTreeHostContextTestLostContextSucceedsWithContent |
319 : public LayerTreeHostContextTestLostContextSucceeds { | 321 : public LayerTreeHostContextTestLostContextSucceeds { |
320 public: | 322 public: |
321 virtual void SetupTree() OVERRIDE { | 323 virtual void SetupTree() OVERRIDE { |
322 root_ = Layer::Create(); | 324 root_ = Layer::Create(); |
323 root_->SetBounds(gfx::Size(10, 10)); | 325 root_->SetBounds(gfx::Size(10, 10)); |
324 root_->SetIsDrawable(true); | 326 root_->SetIsDrawable(true); |
325 | 327 |
326 content_ = FakeContentLayer::Create(&client_); | 328 // Paint non-solid color. |
327 content_->SetBounds(gfx::Size(10, 10)); | 329 SkPaint paint; |
328 content_->SetIsDrawable(true); | 330 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 331 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); |
329 | 332 |
330 root_->AddChild(content_); | 333 if (layer_tree_host()->settings().impl_side_painting) |
| 334 layer_ = FakePictureLayer::Create(&client_); |
| 335 else |
| 336 layer_ = FakeContentLayer::Create(&client_); |
| 337 layer_->SetBounds(gfx::Size(10, 10)); |
| 338 layer_->SetIsDrawable(true); |
| 339 |
| 340 root_->AddChild(layer_); |
331 | 341 |
332 layer_tree_host()->SetRootLayer(root_); | 342 layer_tree_host()->SetRootLayer(root_); |
333 LayerTreeHostContextTest::SetupTree(); | 343 LayerTreeHostContextTest::SetupTree(); |
334 } | 344 } |
335 | 345 |
336 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { | 346 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { |
337 // Invalidate the render surface so we don't try to use a cached copy of the | 347 // Invalidate the render surface so we don't try to use a cached copy of the |
338 // surface. We want to make sure to test the drawing paths for drawing to | 348 // surface. We want to make sure to test the drawing paths for drawing to |
339 // a child surface. | 349 // a child surface. |
340 content_->SetNeedsDisplay(); | 350 layer_->SetNeedsDisplay(); |
341 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); | 351 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); |
342 } | 352 } |
343 | 353 |
344 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 354 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
345 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( | 355 if (!host_impl->settings().impl_side_painting) { |
346 host_impl->active_tree()->root_layer()->children()[0]); | 356 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( |
347 // Even though the context was lost, we should have a resource. The | 357 host_impl->active_tree()->root_layer()->children()[0]); |
348 // TestWebGraphicsContext3D ensures that this resource is created with | 358 // Even though the context was lost, we should have a resource. The |
349 // the active context. | 359 // TestWebGraphicsContext3D ensures that this resource is created with |
350 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | 360 // the active context. |
| 361 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); |
| 362 } else { |
| 363 FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( |
| 364 host_impl->active_tree()->root_layer()->children()[0]); |
| 365 EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw()); |
| 366 } |
351 } | 367 } |
352 | 368 |
353 protected: | 369 protected: |
354 FakeContentLayerClient client_; | 370 FakeContentLayerClient client_; |
355 scoped_refptr<Layer> root_; | 371 scoped_refptr<Layer> root_; |
356 scoped_refptr<ContentLayer> content_; | 372 scoped_refptr<Layer> layer_; |
357 }; | 373 }; |
358 | 374 |
359 // This test uses TiledLayer to check for a working context. | 375 // This test uses TiledLayer and PictureLayer to check for a working context. |
360 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( | 376 SINGLE_AND_MULTI_THREAD_TEST_F( |
361 LayerTreeHostContextTestLostContextSucceedsWithContent); | 377 LayerTreeHostContextTestLostContextSucceedsWithContent); |
362 | 378 |
363 class LayerTreeHostContextTestCreateOutputSurfaceFails | 379 class LayerTreeHostContextTestCreateOutputSurfaceFails |
364 : public LayerTreeHostContextTest { | 380 : public LayerTreeHostContextTest { |
365 public: | 381 public: |
366 // Run a test that initially fails OutputSurface creation |times_to_fail| | 382 // Run a test that initially fails OutputSurface creation |times_to_fail| |
367 // times. If |expect_fallback_attempt| is |true|, an attempt to create a | 383 // times. If |expect_fallback_attempt| is |true|, an attempt to create a |
368 // fallback/software OutputSurface is expected to occur. | 384 // fallback/software OutputSurface is expected to occur. |
369 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, | 385 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, |
370 bool expect_fallback_attempt) | 386 bool expect_fallback_attempt) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 }; | 446 }; |
431 | 447 |
432 SINGLE_AND_MULTI_THREAD_TEST_F( | 448 SINGLE_AND_MULTI_THREAD_TEST_F( |
433 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback); | 449 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback); |
434 | 450 |
435 class LayerTreeHostContextTestLostContextAndEvictTextures | 451 class LayerTreeHostContextTestLostContextAndEvictTextures |
436 : public LayerTreeHostContextTest { | 452 : public LayerTreeHostContextTest { |
437 public: | 453 public: |
438 LayerTreeHostContextTestLostContextAndEvictTextures() | 454 LayerTreeHostContextTestLostContextAndEvictTextures() |
439 : LayerTreeHostContextTest(), | 455 : LayerTreeHostContextTest(), |
440 layer_(FakeContentLayer::Create(&client_)), | |
441 impl_host_(0), | 456 impl_host_(0), |
442 num_commits_(0) {} | 457 num_commits_(0), |
| 458 lost_context_(false) {} |
443 | 459 |
444 virtual void SetupTree() OVERRIDE { | 460 virtual void SetupTree() OVERRIDE { |
445 layer_->SetBounds(gfx::Size(10, 20)); | 461 // Paint non-solid color. |
446 layer_tree_host()->SetRootLayer(layer_); | 462 SkPaint paint; |
| 463 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 464 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); |
| 465 |
| 466 if (layer_tree_host()->settings().impl_side_painting) { |
| 467 picture_layer_ = FakePictureLayer::Create(&client_); |
| 468 picture_layer_->SetBounds(gfx::Size(10, 20)); |
| 469 layer_tree_host()->SetRootLayer(picture_layer_); |
| 470 } else { |
| 471 content_layer_ = FakeContentLayer::Create(&client_); |
| 472 content_layer_->SetBounds(gfx::Size(10, 20)); |
| 473 layer_tree_host()->SetRootLayer(content_layer_); |
| 474 } |
| 475 |
447 LayerTreeHostContextTest::SetupTree(); | 476 LayerTreeHostContextTest::SetupTree(); |
448 } | 477 } |
449 | 478 |
450 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 479 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
451 | 480 |
452 void PostEvictTextures() { | 481 void PostEvictTextures() { |
453 if (HasImplThread()) { | 482 if (HasImplThread()) { |
454 ImplThreadTaskRunner()->PostTask( | 483 ImplThreadTaskRunner()->PostTask( |
455 FROM_HERE, | 484 FROM_HERE, |
456 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: | 485 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: |
457 EvictTexturesOnImplThread, | 486 EvictTexturesOnImplThread, |
458 base::Unretained(this))); | 487 base::Unretained(this))); |
459 } else { | 488 } else { |
460 DebugScopedSetImplThread impl(proxy()); | 489 DebugScopedSetImplThread impl(proxy()); |
461 EvictTexturesOnImplThread(); | 490 EvictTexturesOnImplThread(); |
462 } | 491 } |
463 } | 492 } |
464 | 493 |
465 void EvictTexturesOnImplThread() { | 494 void EvictTexturesOnImplThread() { |
466 impl_host_->EvictTexturesForTesting(); | 495 impl_host_->EvictTexturesForTesting(); |
467 if (lose_after_evict_) | 496 |
| 497 if (lose_after_evict_) { |
468 LoseContext(); | 498 LoseContext(); |
| 499 lost_context_ = true; |
| 500 } |
469 } | 501 } |
470 | 502 |
471 virtual void DidCommitAndDrawFrame() OVERRIDE { | 503 virtual void DidCommitAndDrawFrame() OVERRIDE { |
472 if (num_commits_ > 1) | 504 if (num_commits_ > 1) |
473 return; | 505 return; |
474 EXPECT_TRUE(layer_->HaveBackingAt(0, 0)); | 506 if (!layer_tree_host()->settings().impl_side_painting) { |
| 507 EXPECT_TRUE(content_layer_->HaveBackingAt(0, 0)); |
| 508 } |
475 PostEvictTextures(); | 509 PostEvictTextures(); |
476 } | 510 } |
477 | 511 |
478 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 512 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
479 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 513 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
480 if (num_commits_ > 1) | 514 if (num_commits_ > 1) |
481 return; | 515 return; |
482 ++num_commits_; | 516 ++num_commits_; |
483 if (!lose_after_evict_) | 517 if (!lose_after_evict_) { |
484 LoseContext(); | 518 LoseContext(); |
485 impl_host_ = impl; | 519 lost_context_ = true; |
| 520 } |
486 } | 521 } |
487 | 522 |
488 virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); } | 523 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 524 if (impl->settings().impl_side_painting) { |
| 525 FakePictureLayerImpl* picture_impl = |
| 526 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
| 527 EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw()); |
| 528 } else { |
| 529 FakeContentLayerImpl* content_impl = |
| 530 static_cast<FakeContentLayerImpl*>(impl->active_tree()->root_layer()); |
| 531 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); |
| 532 } |
| 533 |
| 534 impl_host_ = impl; |
| 535 if (lost_context_) |
| 536 EndTest(); |
| 537 } |
| 538 |
| 539 virtual void DidInitializeOutputSurface() OVERRIDE {} |
489 | 540 |
490 virtual void AfterTest() OVERRIDE {} | 541 virtual void AfterTest() OVERRIDE {} |
491 | 542 |
492 protected: | 543 protected: |
493 bool lose_after_evict_; | 544 bool lose_after_evict_; |
494 FakeContentLayerClient client_; | 545 FakeContentLayerClient client_; |
495 scoped_refptr<FakeContentLayer> layer_; | 546 scoped_refptr<FakeContentLayer> content_layer_; |
| 547 scoped_refptr<FakePictureLayer> picture_layer_; |
496 LayerTreeHostImpl* impl_host_; | 548 LayerTreeHostImpl* impl_host_; |
497 int num_commits_; | 549 int num_commits_; |
| 550 bool lost_context_; |
498 }; | 551 }; |
499 | 552 |
500 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 553 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
501 LoseAfterEvict_SingleThread_DirectRenderer) { | 554 LoseAfterEvict_SingleThread_DirectRenderer) { |
502 lose_after_evict_ = true; | 555 lose_after_evict_ = true; |
503 RunTest(false, false, false); | 556 RunTest(false, false, false); |
504 } | 557 } |
505 | 558 |
506 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 559 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
507 LoseAfterEvict_SingleThread_DelegatingRenderer) { | 560 LoseAfterEvict_SingleThread_DelegatingRenderer) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 614 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
562 LoseBeforeEvict_MultiThread_DelegatingRenderer_ImplSidePaint) { | 615 LoseBeforeEvict_MultiThread_DelegatingRenderer_ImplSidePaint) { |
563 lose_after_evict_ = false; | 616 lose_after_evict_ = false; |
564 RunTest(true, true, true); | 617 RunTest(true, true, true); |
565 } | 618 } |
566 | 619 |
567 class LayerTreeHostContextTestLostContextWhileUpdatingResources | 620 class LayerTreeHostContextTestLostContextWhileUpdatingResources |
568 : public LayerTreeHostContextTest { | 621 : public LayerTreeHostContextTest { |
569 public: | 622 public: |
570 LayerTreeHostContextTestLostContextWhileUpdatingResources() | 623 LayerTreeHostContextTestLostContextWhileUpdatingResources() |
571 : parent_(FakeContentLayer::Create(&client_)), | 624 : num_children_(50), times_to_lose_on_end_query_(3) {} |
572 num_children_(50), | |
573 times_to_lose_on_end_query_(3) {} | |
574 | 625 |
575 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { | 626 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { |
576 scoped_ptr<TestWebGraphicsContext3D> context = | 627 scoped_ptr<TestWebGraphicsContext3D> context = |
577 LayerTreeHostContextTest::CreateContext3d(); | 628 LayerTreeHostContextTest::CreateContext3d(); |
578 if (times_to_lose_on_end_query_) { | 629 if (times_to_lose_on_end_query_) { |
579 --times_to_lose_on_end_query_; | 630 --times_to_lose_on_end_query_; |
580 context->set_times_end_query_succeeds(5); | 631 context->set_times_end_query_succeeds(5); |
581 } | 632 } |
582 return context.Pass(); | 633 return context.Pass(); |
583 } | 634 } |
584 | 635 |
585 virtual void SetupTree() OVERRIDE { | 636 virtual void SetupTree() OVERRIDE { |
| 637 if (layer_tree_host()->settings().impl_side_painting) |
| 638 parent_ = FakePictureLayer::Create(&client_); |
| 639 else |
| 640 parent_ = FakeContentLayer::Create(&client_); |
| 641 |
586 parent_->SetBounds(gfx::Size(num_children_, 1)); | 642 parent_->SetBounds(gfx::Size(num_children_, 1)); |
587 | 643 |
588 for (int i = 0; i < num_children_; i++) { | 644 for (int i = 0; i < num_children_; i++) { |
589 scoped_refptr<FakeContentLayer> child = | 645 scoped_refptr<Layer> child; |
590 FakeContentLayer::Create(&client_); | 646 if (layer_tree_host()->settings().impl_side_painting) |
| 647 child = FakePictureLayer::Create(&client_); |
| 648 else |
| 649 child = FakeContentLayer::Create(&client_); |
591 child->SetPosition(gfx::PointF(i, 0.f)); | 650 child->SetPosition(gfx::PointF(i, 0.f)); |
592 child->SetBounds(gfx::Size(1, 1)); | 651 child->SetBounds(gfx::Size(1, 1)); |
593 parent_->AddChild(child); | 652 parent_->AddChild(child); |
594 } | 653 } |
595 | 654 |
596 layer_tree_host()->SetRootLayer(parent_); | 655 layer_tree_host()->SetRootLayer(parent_); |
597 LayerTreeHostContextTest::SetupTree(); | 656 LayerTreeHostContextTest::SetupTree(); |
598 } | 657 } |
599 | 658 |
600 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 659 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
601 | 660 |
602 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 661 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
603 EXPECT_EQ(0, times_to_lose_on_end_query_); | 662 EXPECT_EQ(0, times_to_lose_on_end_query_); |
604 EndTest(); | 663 EndTest(); |
605 } | 664 } |
606 | 665 |
607 virtual void AfterTest() OVERRIDE { | 666 virtual void AfterTest() OVERRIDE { |
608 EXPECT_EQ(0, times_to_lose_on_end_query_); | 667 EXPECT_EQ(0, times_to_lose_on_end_query_); |
609 } | 668 } |
610 | 669 |
611 private: | 670 private: |
612 FakeContentLayerClient client_; | 671 FakeContentLayerClient client_; |
613 scoped_refptr<FakeContentLayer> parent_; | 672 scoped_refptr<Layer> parent_; |
614 int num_children_; | 673 int num_children_; |
615 int times_to_lose_on_end_query_; | 674 int times_to_lose_on_end_query_; |
616 }; | 675 }; |
617 | 676 |
618 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( | 677 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( |
619 LayerTreeHostContextTestLostContextWhileUpdatingResources); | 678 LayerTreeHostContextTestLostContextWhileUpdatingResources); |
620 | 679 |
621 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { | 680 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
622 public: | 681 public: |
623 LayerTreeHostContextTestLayersNotified() | 682 LayerTreeHostContextTestLayersNotified() |
624 : LayerTreeHostContextTest(), num_commits_(0) {} | 683 : LayerTreeHostContextTest(), num_commits_(0) {} |
625 | 684 |
626 virtual void SetupTree() OVERRIDE { | 685 virtual void SetupTree() OVERRIDE { |
627 root_ = FakeContentLayer::Create(&client_); | 686 if (layer_tree_host()->settings().impl_side_painting) { |
628 child_ = FakeContentLayer::Create(&client_); | 687 root_ = FakePictureLayer::Create(&client_); |
629 grandchild_ = FakeContentLayer::Create(&client_); | 688 child_ = FakePictureLayer::Create(&client_); |
| 689 grandchild_ = FakePictureLayer::Create(&client_); |
| 690 } else { |
| 691 root_ = FakeContentLayer::Create(&client_); |
| 692 child_ = FakeContentLayer::Create(&client_); |
| 693 grandchild_ = FakeContentLayer::Create(&client_); |
| 694 } |
630 | 695 |
631 root_->AddChild(child_); | 696 root_->AddChild(child_); |
632 child_->AddChild(grandchild_); | 697 child_->AddChild(grandchild_); |
633 | 698 |
634 layer_tree_host()->SetRootLayer(root_); | 699 layer_tree_host()->SetRootLayer(root_); |
635 LayerTreeHostContextTest::SetupTree(); | 700 LayerTreeHostContextTest::SetupTree(); |
636 } | 701 } |
637 | 702 |
638 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 703 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
639 | 704 |
640 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 705 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
641 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); | 706 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
642 | 707 |
643 FakeContentLayerImpl* root = static_cast<FakeContentLayerImpl*>( | 708 FakePictureLayerImpl* root_picture = NULL; |
644 host_impl->active_tree()->root_layer()); | 709 FakePictureLayerImpl* child_picture = NULL; |
645 FakeContentLayerImpl* child = | 710 FakePictureLayerImpl* grandchild_picture = NULL; |
646 static_cast<FakeContentLayerImpl*>(root->children()[0]); | 711 FakeContentLayerImpl* root_content = NULL; |
647 FakeContentLayerImpl* grandchild = | 712 FakeContentLayerImpl* child_content = NULL; |
648 static_cast<FakeContentLayerImpl*>(child->children()[0]); | 713 FakeContentLayerImpl* grandchild_content = NULL; |
| 714 |
| 715 if (layer_tree_host()->settings().impl_side_painting) { |
| 716 root_picture = static_cast<FakePictureLayerImpl*>( |
| 717 host_impl->active_tree()->root_layer()); |
| 718 child_picture = |
| 719 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]); |
| 720 grandchild_picture = |
| 721 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]); |
| 722 |
| 723 } else { |
| 724 root_content = static_cast<FakeContentLayerImpl*>( |
| 725 host_impl->active_tree()->root_layer()); |
| 726 child_content = |
| 727 static_cast<FakeContentLayerImpl*>(root_content->children()[0]); |
| 728 grandchild_content = |
| 729 static_cast<FakeContentLayerImpl*>(child_content->children()[0]); |
| 730 } |
649 | 731 |
650 ++num_commits_; | 732 ++num_commits_; |
651 switch (num_commits_) { | 733 switch (num_commits_) { |
652 case 1: | 734 case 1: |
653 EXPECT_EQ(0u, root->lost_output_surface_count()); | 735 if (layer_tree_host()->settings().impl_side_painting) { |
654 EXPECT_EQ(0u, child->lost_output_surface_count()); | 736 EXPECT_EQ(0u, root_picture->release_resources_count()); |
655 EXPECT_EQ(0u, grandchild->lost_output_surface_count()); | 737 EXPECT_EQ(0u, child_picture->release_resources_count()); |
| 738 EXPECT_EQ(0u, grandchild_picture->release_resources_count()); |
| 739 } else { |
| 740 EXPECT_EQ(0u, root_content->lost_output_surface_count()); |
| 741 EXPECT_EQ(0u, child_content->lost_output_surface_count()); |
| 742 EXPECT_EQ(0u, grandchild_content->lost_output_surface_count()); |
| 743 } |
| 744 |
656 // Lose the context and struggle to recreate it. | 745 // Lose the context and struggle to recreate it. |
657 LoseContext(); | 746 LoseContext(); |
658 times_to_fail_create_ = 1; | 747 times_to_fail_create_ = 1; |
659 break; | 748 break; |
660 case 2: | 749 case 2: |
661 EXPECT_GE(1u, root->lost_output_surface_count()); | 750 if (layer_tree_host()->settings().impl_side_painting) { |
662 EXPECT_GE(1u, child->lost_output_surface_count()); | 751 EXPECT_TRUE(root_picture->release_resources_count()); |
663 EXPECT_GE(1u, grandchild->lost_output_surface_count()); | 752 EXPECT_TRUE(child_picture->release_resources_count()); |
| 753 EXPECT_TRUE(grandchild_picture->release_resources_count()); |
| 754 } else { |
| 755 EXPECT_TRUE(root_content->lost_output_surface_count()); |
| 756 EXPECT_TRUE(child_content->lost_output_surface_count()); |
| 757 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); |
| 758 } |
| 759 |
664 EndTest(); | 760 EndTest(); |
665 break; | 761 break; |
666 default: | 762 default: |
667 NOTREACHED(); | 763 NOTREACHED(); |
668 } | 764 } |
669 } | 765 } |
670 | 766 |
671 virtual void AfterTest() OVERRIDE {} | 767 virtual void AfterTest() OVERRIDE {} |
672 | 768 |
673 private: | 769 private: |
674 int num_commits_; | 770 int num_commits_; |
675 | 771 |
676 FakeContentLayerClient client_; | 772 FakeContentLayerClient client_; |
677 scoped_refptr<FakeContentLayer> root_; | 773 scoped_refptr<Layer> root_; |
678 scoped_refptr<FakeContentLayer> child_; | 774 scoped_refptr<Layer> child_; |
679 scoped_refptr<FakeContentLayer> grandchild_; | 775 scoped_refptr<Layer> grandchild_; |
680 }; | 776 }; |
681 | 777 |
682 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); | 778 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); |
683 | 779 |
684 class LayerTreeHostContextTestDontUseLostResources | 780 class LayerTreeHostContextTestDontUseLostResources |
685 : public LayerTreeHostContextTest { | 781 : public LayerTreeHostContextTest { |
686 public: | 782 public: |
687 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { | 783 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { |
688 context_should_support_io_surface_ = true; | 784 context_should_support_io_surface_ = true; |
689 | 785 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 scoped_refptr<Layer> root = Layer::Create(); | 843 scoped_refptr<Layer> root = Layer::Create(); |
748 root->SetBounds(gfx::Size(10, 10)); | 844 root->SetBounds(gfx::Size(10, 10)); |
749 root->SetIsDrawable(true); | 845 root->SetIsDrawable(true); |
750 | 846 |
751 scoped_refptr<FakeDelegatedRendererLayer> delegated = | 847 scoped_refptr<FakeDelegatedRendererLayer> delegated = |
752 FakeDelegatedRendererLayer::Create(delegated_frame_provider_.get()); | 848 FakeDelegatedRendererLayer::Create(delegated_frame_provider_.get()); |
753 delegated->SetBounds(gfx::Size(10, 10)); | 849 delegated->SetBounds(gfx::Size(10, 10)); |
754 delegated->SetIsDrawable(true); | 850 delegated->SetIsDrawable(true); |
755 root->AddChild(delegated); | 851 root->AddChild(delegated); |
756 | 852 |
757 scoped_refptr<ContentLayer> content = ContentLayer::Create(&client_); | 853 scoped_refptr<Layer> layer; |
758 content->SetBounds(gfx::Size(10, 10)); | 854 if (layer_tree_host()->settings().impl_side_painting) |
759 content->SetIsDrawable(true); | 855 layer = PictureLayer::Create(&client_); |
760 root->AddChild(content); | 856 else |
| 857 layer = ContentLayer::Create(&client_); |
| 858 layer->SetBounds(gfx::Size(10, 10)); |
| 859 layer->SetIsDrawable(true); |
| 860 root->AddChild(layer); |
761 | 861 |
762 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); | 862 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); |
763 texture->SetBounds(gfx::Size(10, 10)); | 863 texture->SetBounds(gfx::Size(10, 10)); |
764 texture->SetIsDrawable(true); | 864 texture->SetIsDrawable(true); |
765 texture->SetTextureMailbox( | 865 texture->SetTextureMailbox( |
766 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), | 866 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
767 SingleReleaseCallback::Create( | 867 SingleReleaseCallback::Create( |
768 base::Bind(&LayerTreeHostContextTestDontUseLostResources:: | 868 base::Bind(&LayerTreeHostContextTestDontUseLostResources:: |
769 EmptyReleaseCallback))); | 869 EmptyReleaseCallback))); |
770 root->AddChild(texture); | 870 root->AddChild(texture); |
771 | 871 |
772 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_); | 872 scoped_refptr<Layer> mask; |
| 873 if (layer_tree_host()->settings().impl_side_painting) |
| 874 mask = PictureLayer::Create(&client_); |
| 875 else |
| 876 mask = ContentLayer::Create(&client_); |
773 mask->SetBounds(gfx::Size(10, 10)); | 877 mask->SetBounds(gfx::Size(10, 10)); |
774 | 878 |
775 scoped_refptr<ContentLayer> content_with_mask = | 879 scoped_refptr<Layer> layer_with_mask; |
776 ContentLayer::Create(&client_); | 880 if (layer_tree_host()->settings().impl_side_painting) |
777 content_with_mask->SetBounds(gfx::Size(10, 10)); | 881 layer_with_mask = PictureLayer::Create(&client_); |
778 content_with_mask->SetIsDrawable(true); | 882 else |
779 content_with_mask->SetMaskLayer(mask.get()); | 883 layer_with_mask = ContentLayer::Create(&client_); |
780 root->AddChild(content_with_mask); | 884 layer_with_mask->SetBounds(gfx::Size(10, 10)); |
| 885 layer_with_mask->SetIsDrawable(true); |
| 886 layer_with_mask->SetMaskLayer(mask.get()); |
| 887 root->AddChild(layer_with_mask); |
781 | 888 |
782 scoped_refptr<VideoLayer> video_color = | 889 scoped_refptr<VideoLayer> video_color = |
783 VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0); | 890 VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0); |
784 video_color->SetBounds(gfx::Size(10, 10)); | 891 video_color->SetBounds(gfx::Size(10, 10)); |
785 video_color->SetIsDrawable(true); | 892 video_color->SetIsDrawable(true); |
786 root->AddChild(video_color); | 893 root->AddChild(video_color); |
787 | 894 |
788 scoped_refptr<VideoLayer> video_hw = | 895 scoped_refptr<VideoLayer> video_hw = |
789 VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0); | 896 VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0); |
790 video_hw->SetBounds(gfx::Size(10, 10)); | 897 video_hw->SetBounds(gfx::Size(10, 10)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 root->AddChild(io_surface); | 938 root->AddChild(io_surface); |
832 } | 939 } |
833 | 940 |
834 // Enable the hud. | 941 // Enable the hud. |
835 LayerTreeDebugState debug_state; | 942 LayerTreeDebugState debug_state; |
836 debug_state.show_property_changed_rects = true; | 943 debug_state.show_property_changed_rects = true; |
837 layer_tree_host()->SetDebugState(debug_state); | 944 layer_tree_host()->SetDebugState(debug_state); |
838 | 945 |
839 scoped_refptr<PaintedScrollbarLayer> scrollbar = | 946 scoped_refptr<PaintedScrollbarLayer> scrollbar = |
840 PaintedScrollbarLayer::Create( | 947 PaintedScrollbarLayer::Create( |
841 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), content->id()); | 948 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id()); |
842 scrollbar->SetBounds(gfx::Size(10, 10)); | 949 scrollbar->SetBounds(gfx::Size(10, 10)); |
843 scrollbar->SetIsDrawable(true); | 950 scrollbar->SetIsDrawable(true); |
844 root->AddChild(scrollbar); | 951 root->AddChild(scrollbar); |
845 | 952 |
846 layer_tree_host()->SetRootLayer(root); | 953 layer_tree_host()->SetRootLayer(root); |
847 LayerTreeHostContextTest::SetupTree(); | 954 LayerTreeHostContextTest::SetupTree(); |
848 } | 955 } |
849 | 956 |
850 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 957 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
851 | 958 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 } | 1511 } |
1405 } | 1512 } |
1406 }; | 1513 }; |
1407 | 1514 |
1408 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); | 1515 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); |
1409 | 1516 |
1410 class LayerTreeHostContextTestSurfaceCreateCallback | 1517 class LayerTreeHostContextTestSurfaceCreateCallback |
1411 : public LayerTreeHostContextTest { | 1518 : public LayerTreeHostContextTest { |
1412 public: | 1519 public: |
1413 LayerTreeHostContextTestSurfaceCreateCallback() | 1520 LayerTreeHostContextTestSurfaceCreateCallback() |
1414 : LayerTreeHostContextTest(), | 1521 : LayerTreeHostContextTest() {} |
1415 layer_(FakeContentLayer::Create(&client_)) {} | |
1416 | 1522 |
1417 virtual void SetupTree() OVERRIDE { | 1523 virtual void SetupTree() OVERRIDE { |
1418 layer_->SetBounds(gfx::Size(10, 20)); | 1524 if (layer_tree_host()->settings().impl_side_painting) { |
1419 layer_tree_host()->SetRootLayer(layer_); | 1525 picture_layer_ = FakePictureLayer::Create(&client_); |
| 1526 picture_layer_->SetBounds(gfx::Size(10, 20)); |
| 1527 layer_tree_host()->SetRootLayer(picture_layer_); |
| 1528 } else { |
| 1529 content_layer_ = FakeContentLayer::Create(&client_); |
| 1530 content_layer_->SetBounds(gfx::Size(10, 20)); |
| 1531 layer_tree_host()->SetRootLayer(content_layer_); |
| 1532 } |
| 1533 |
1420 LayerTreeHostContextTest::SetupTree(); | 1534 LayerTreeHostContextTest::SetupTree(); |
1421 } | 1535 } |
1422 | 1536 |
1423 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1537 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
1424 | 1538 |
1425 virtual void DidCommit() OVERRIDE { | 1539 virtual void DidCommit() OVERRIDE { |
1426 switch (layer_tree_host()->source_frame_number()) { | 1540 switch (layer_tree_host()->source_frame_number()) { |
1427 case 1: | 1541 case 1: |
1428 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1542 if (layer_tree_host()->settings().impl_side_painting) |
| 1543 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); |
| 1544 else |
| 1545 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); |
1429 layer_tree_host()->SetNeedsCommit(); | 1546 layer_tree_host()->SetNeedsCommit(); |
1430 break; | 1547 break; |
1431 case 2: | 1548 case 2: |
1432 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1549 if (layer_tree_host()->settings().impl_side_painting) |
| 1550 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); |
| 1551 else |
| 1552 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); |
1433 layer_tree_host()->SetNeedsCommit(); | 1553 layer_tree_host()->SetNeedsCommit(); |
1434 break; | 1554 break; |
1435 case 3: | 1555 case 3: |
1436 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1556 if (layer_tree_host()->settings().impl_side_painting) |
| 1557 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); |
| 1558 else |
| 1559 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); |
1437 break; | 1560 break; |
1438 case 4: | 1561 case 4: |
1439 EXPECT_EQ(2u, layer_->output_surface_created_count()); | 1562 if (layer_tree_host()->settings().impl_side_painting) |
| 1563 EXPECT_EQ(2u, picture_layer_->output_surface_created_count()); |
| 1564 else |
| 1565 EXPECT_EQ(2u, content_layer_->output_surface_created_count()); |
1440 layer_tree_host()->SetNeedsCommit(); | 1566 layer_tree_host()->SetNeedsCommit(); |
1441 break; | 1567 break; |
1442 } | 1568 } |
1443 } | 1569 } |
1444 | 1570 |
1445 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1571 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1446 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1572 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
1447 switch (LastCommittedSourceFrameNumber(impl)) { | 1573 switch (LastCommittedSourceFrameNumber(impl)) { |
1448 case 0: | 1574 case 0: |
1449 break; | 1575 break; |
1450 case 1: | 1576 case 1: |
1451 break; | 1577 break; |
1452 case 2: | 1578 case 2: |
1453 LoseContext(); | 1579 LoseContext(); |
1454 break; | 1580 break; |
1455 case 3: | 1581 case 3: |
1456 EndTest(); | 1582 EndTest(); |
1457 break; | 1583 break; |
1458 } | 1584 } |
1459 } | 1585 } |
1460 | 1586 |
1461 virtual void AfterTest() OVERRIDE {} | 1587 virtual void AfterTest() OVERRIDE {} |
1462 | 1588 |
1463 protected: | 1589 protected: |
1464 FakeContentLayerClient client_; | 1590 FakeContentLayerClient client_; |
1465 scoped_refptr<FakeContentLayer> layer_; | 1591 scoped_refptr<FakePictureLayer> picture_layer_; |
| 1592 scoped_refptr<FakeContentLayer> content_layer_; |
1466 }; | 1593 }; |
1467 | 1594 |
1468 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); | 1595 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); |
1469 | 1596 |
1470 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame | 1597 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame |
1471 : public LayerTreeHostContextTest { | 1598 : public LayerTreeHostContextTest { |
1472 protected: | 1599 protected: |
1473 virtual void BeginTest() OVERRIDE { | 1600 virtual void BeginTest() OVERRIDE { |
1474 deferred_ = false; | 1601 deferred_ = false; |
1475 PostSetNeedsCommitToMainThread(); | 1602 PostSetNeedsCommitToMainThread(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 virtual void AfterTest() OVERRIDE {} | 1648 virtual void AfterTest() OVERRIDE {} |
1522 | 1649 |
1523 bool deferred_; | 1650 bool deferred_; |
1524 }; | 1651 }; |
1525 | 1652 |
1526 SINGLE_AND_MULTI_THREAD_TEST_F( | 1653 SINGLE_AND_MULTI_THREAD_TEST_F( |
1527 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1654 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
1528 | 1655 |
1529 } // namespace | 1656 } // namespace |
1530 } // namespace cc | 1657 } // namespace cc |
OLD | NEW |