| 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/base/thread_impl.h" | 8 #include "cc/base/thread_impl.h" |
| 9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
| 10 #include "cc/layers/heads_up_display_layer.h" | 10 #include "cc/layers/heads_up_display_layer.h" |
| 11 #include "cc/layers/io_surface_layer.h" | 11 #include "cc/layers/io_surface_layer.h" |
| 12 #include "cc/layers/layer_impl.h" | 12 #include "cc/layers/layer_impl.h" |
| 13 #include "cc/layers/picture_layer.h" | 13 #include "cc/layers/picture_layer.h" |
| 14 #include "cc/layers/scrollbar_layer.h" | 14 #include "cc/layers/scrollbar_layer.h" |
| 15 #include "cc/layers/texture_layer.h" | 15 #include "cc/layers/texture_layer.h" |
| 16 #include "cc/layers/texture_layer_impl.h" |
| 16 #include "cc/layers/video_layer.h" | 17 #include "cc/layers/video_layer.h" |
| 17 #include "cc/layers/video_layer_impl.h" | 18 #include "cc/layers/video_layer_impl.h" |
| 18 #include "cc/test/fake_content_layer.h" | 19 #include "cc/test/fake_content_layer.h" |
| 19 #include "cc/test/fake_content_layer_client.h" | 20 #include "cc/test/fake_content_layer_client.h" |
| 20 #include "cc/test/fake_content_layer_impl.h" | 21 #include "cc/test/fake_content_layer_impl.h" |
| 21 #include "cc/test/fake_context_provider.h" | 22 #include "cc/test/fake_context_provider.h" |
| 22 #include "cc/test/fake_delegated_renderer_layer.h" | 23 #include "cc/test/fake_delegated_renderer_layer.h" |
| 23 #include "cc/test/fake_delegated_renderer_layer_impl.h" | 24 #include "cc/test/fake_delegated_renderer_layer_impl.h" |
| 24 #include "cc/test/fake_layer_tree_host_client.h" | 25 #include "cc/test/fake_layer_tree_host_client.h" |
| 25 #include "cc/test/fake_output_surface.h" | 26 #include "cc/test/fake_output_surface.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // The number of times MakeCurrent succeeds is not important, and | 100 // The number of times MakeCurrent succeeds is not important, and |
| 100 // can be changed if needed to make this pass with future changes. | 101 // can be changed if needed to make this pass with future changes. |
| 101 context3d_->set_times_make_current_succeeds(2); | 102 context3d_->set_times_make_current_succeeds(2); |
| 102 ExpectCreateToFail(); | 103 ExpectCreateToFail(); |
| 103 } else if (times_to_lose_on_create_) { | 104 } else if (times_to_lose_on_create_) { |
| 104 --times_to_lose_on_create_; | 105 --times_to_lose_on_create_; |
| 105 LoseContext(); | 106 LoseContext(); |
| 106 ExpectCreateToFail(); | 107 ExpectCreateToFail(); |
| 107 } | 108 } |
| 108 | 109 |
| 110 if (delegating_renderer()) { |
| 111 return FakeOutputSurface::CreateDelegating3d( |
| 112 context3d.PassAs<WebGraphicsContext3D>()).PassAs<OutputSurface>(); |
| 113 } |
| 109 return FakeOutputSurface::Create3d( | 114 return FakeOutputSurface::Create3d( |
| 110 context3d.PassAs<WebGraphicsContext3D>()).PassAs<OutputSurface>(); | 115 context3d.PassAs<WebGraphicsContext3D>()).PassAs<OutputSurface>(); |
| 111 } | 116 } |
| 112 | 117 |
| 113 scoped_ptr<TestWebGraphicsContext3D> CreateOffscreenContext3d() { | 118 scoped_ptr<TestWebGraphicsContext3D> CreateOffscreenContext3d() { |
| 114 if (!context3d_) | 119 if (!context3d_) |
| 115 return scoped_ptr<TestWebGraphicsContext3D>(); | 120 return scoped_ptr<TestWebGraphicsContext3D>(); |
| 116 | 121 |
| 117 ++times_offscreen_created_; | 122 ++times_offscreen_created_; |
| 118 | 123 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 } | 477 } |
| 473 | 478 |
| 474 protected: | 479 protected: |
| 475 bool use_surface_; | 480 bool use_surface_; |
| 476 FakeContentLayerClient client_; | 481 FakeContentLayerClient client_; |
| 477 scoped_refptr<Layer> root_; | 482 scoped_refptr<Layer> root_; |
| 478 scoped_refptr<ContentLayer> content_; | 483 scoped_refptr<ContentLayer> content_; |
| 479 }; | 484 }; |
| 480 | 485 |
| 481 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, | 486 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, |
| 482 NoSurface_SingleThread) { | 487 NoSurface_SingleThread_DirectRenderer) { |
| 483 use_surface_ = false; | 488 use_surface_ = false; |
| 484 RunTest(false); | 489 RunTest(false, false); |
| 485 } | 490 } |
| 486 | 491 |
| 487 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, | 492 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, |
| 488 NoSurface_MultiThread) { | 493 NoSurface_SingleThread_DelegatingRenderer) { |
| 489 use_surface_ = false; | 494 use_surface_ = false; |
| 490 RunTest(true); | 495 RunTest(false, true); |
| 491 } | 496 } |
| 492 | 497 |
| 493 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, | 498 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, |
| 494 WithSurface_SingleThread) { | 499 NoSurface_MultiThread_DirectRenderer) { |
| 495 use_surface_ = true; | 500 use_surface_ = false; |
| 496 RunTest(false); | 501 RunTest(true, false); |
| 497 } | 502 } |
| 498 | 503 |
| 499 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, | 504 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, |
| 500 WithSurface_MultiThread) { | 505 NoSurface_MultiThread_DelegatingRenderer) { |
| 506 use_surface_ = false; |
| 507 RunTest(true, true); |
| 508 } |
| 509 |
| 510 // Surfaces don't exist with a delegating renderer. |
| 511 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, |
| 512 WithSurface_SingleThread_DirectRenderer) { |
| 501 use_surface_ = true; | 513 use_surface_ = true; |
| 502 RunTest(true); | 514 RunTest(false, false); |
| 515 } |
| 516 |
| 517 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, |
| 518 WithSurface_MultiThread_DirectRenderer) { |
| 519 use_surface_ = true; |
| 520 RunTest(true, false); |
| 503 } | 521 } |
| 504 | 522 |
| 505 class LayerTreeHostContextTestOffscreenContextFails | 523 class LayerTreeHostContextTestOffscreenContextFails |
| 506 : public LayerTreeHostContextTest { | 524 : public LayerTreeHostContextTest { |
| 507 public: | 525 public: |
| 508 virtual void SetupTree() OVERRIDE { | 526 virtual void SetupTree() OVERRIDE { |
| 509 root_ = Layer::Create(); | 527 root_ = Layer::Create(); |
| 510 root_->SetBounds(gfx::Size(10, 10)); | 528 root_->SetBounds(gfx::Size(10, 10)); |
| 511 root_->SetAnchorPoint(gfx::PointF()); | 529 root_->SetAnchorPoint(gfx::PointF()); |
| 512 root_->SetIsDrawable(true); | 530 root_->SetIsDrawable(true); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 } | 613 } |
| 596 | 614 |
| 597 virtual void AfterTest() OVERRIDE {} | 615 virtual void AfterTest() OVERRIDE {} |
| 598 | 616 |
| 599 private: | 617 private: |
| 600 int num_commits_; | 618 int num_commits_; |
| 601 bool first_initialized_; | 619 bool first_initialized_; |
| 602 }; | 620 }; |
| 603 | 621 |
| 604 TEST_F(LayerTreeHostContextTestLostContextFails, | 622 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 605 FailReinitialize100_SingleThread) { | 623 FailReinitialize100_SingleThread_DirectRenderer) { |
| 606 times_to_fail_reinitialize_ = 100; | 624 times_to_fail_reinitialize_ = 100; |
| 607 times_to_fail_recreate_ = 0; | 625 times_to_fail_recreate_ = 0; |
| 608 times_to_lose_on_recreate_ = 0; | 626 times_to_lose_on_recreate_ = 0; |
| 609 RunTest(false); | 627 RunTest(false, false); |
| 610 } | 628 } |
| 611 | 629 |
| 612 TEST_F(LayerTreeHostContextTestLostContextFails, | 630 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 613 FailReinitialize100_MultiThread) { | 631 FailReinitialize100_SingleThread_DelegatingRenderer) { |
| 614 times_to_fail_reinitialize_ = 100; | 632 times_to_fail_reinitialize_ = 100; |
| 615 times_to_fail_recreate_ = 0; | 633 times_to_fail_recreate_ = 0; |
| 616 times_to_lose_on_recreate_ = 0; | 634 times_to_lose_on_recreate_ = 0; |
| 617 RunTest(true); | 635 RunTest(false, true); |
| 618 } | 636 } |
| 619 | 637 |
| 620 TEST_F(LayerTreeHostContextTestLostContextFails, | 638 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 621 FailRecreate100_SingleThread) { | 639 FailReinitialize100_MultiThread_DirectRenderer) { |
| 640 times_to_fail_reinitialize_ = 100; |
| 641 times_to_fail_recreate_ = 0; |
| 642 times_to_lose_on_recreate_ = 0; |
| 643 RunTest(true, false); |
| 644 } |
| 645 |
| 646 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 647 FailReinitialize100_MultiThread_DelegatingRenderer) { |
| 648 times_to_fail_reinitialize_ = 100; |
| 649 times_to_fail_recreate_ = 0; |
| 650 times_to_lose_on_recreate_ = 0; |
| 651 RunTest(true, true); |
| 652 } |
| 653 |
| 654 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 655 FailRecreate100_SingleThread_DirectRenderer) { |
| 622 times_to_fail_reinitialize_ = 0; | 656 times_to_fail_reinitialize_ = 0; |
| 623 times_to_fail_recreate_ = 100; | 657 times_to_fail_recreate_ = 100; |
| 624 times_to_lose_on_recreate_ = 0; | 658 times_to_lose_on_recreate_ = 0; |
| 625 RunTest(false); | 659 RunTest(false, false); |
| 626 } | 660 } |
| 627 | 661 |
| 628 TEST_F(LayerTreeHostContextTestLostContextFails, | 662 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 629 FailRecreate100_MultiThread) { | 663 FailRecreate100_SingleThread_DelegatingRenderer) { |
| 630 times_to_fail_reinitialize_ = 0; | 664 times_to_fail_reinitialize_ = 0; |
| 631 times_to_fail_recreate_ = 100; | 665 times_to_fail_recreate_ = 100; |
| 632 times_to_lose_on_recreate_ = 0; | 666 times_to_lose_on_recreate_ = 0; |
| 633 RunTest(true); | 667 RunTest(false, true); |
| 634 } | 668 } |
| 635 | 669 |
| 636 TEST_F(LayerTreeHostContextTestLostContextFails, | 670 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 637 LoseOnRecreate100_SingleThread) { | 671 FailRecreate100_MultiThread_DirectRenderer) { |
| 672 times_to_fail_reinitialize_ = 0; |
| 673 times_to_fail_recreate_ = 100; |
| 674 times_to_lose_on_recreate_ = 0; |
| 675 RunTest(true, false); |
| 676 } |
| 677 |
| 678 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 679 FailRecreate100_MultiThread_DelegatingRenderer) { |
| 680 times_to_fail_reinitialize_ = 0; |
| 681 times_to_fail_recreate_ = 100; |
| 682 times_to_lose_on_recreate_ = 0; |
| 683 RunTest(true, true); |
| 684 } |
| 685 |
| 686 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 687 LoseOnRecreate100_SingleThread_DirectRenderer) { |
| 638 times_to_fail_reinitialize_ = 0; | 688 times_to_fail_reinitialize_ = 0; |
| 639 times_to_fail_recreate_ = 0; | 689 times_to_fail_recreate_ = 0; |
| 640 times_to_lose_on_recreate_ = 100; | 690 times_to_lose_on_recreate_ = 100; |
| 641 RunTest(false); | 691 RunTest(false, false); |
| 642 } | 692 } |
| 643 | 693 |
| 644 TEST_F(LayerTreeHostContextTestLostContextFails, | 694 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 645 LoseOnRecreate100_MultiThread) { | 695 LoseOnRecreate100_SingleThread_DelegatingRenderer) { |
| 646 times_to_fail_reinitialize_ = 0; | 696 times_to_fail_reinitialize_ = 0; |
| 647 times_to_fail_recreate_ = 0; | 697 times_to_fail_recreate_ = 0; |
| 648 times_to_lose_on_recreate_ = 100; | 698 times_to_lose_on_recreate_ = 100; |
| 649 RunTest(true); | 699 RunTest(false, true); |
| 700 } |
| 701 |
| 702 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 703 LoseOnRecreate100_MultiThread_DirectRenderer) { |
| 704 times_to_fail_reinitialize_ = 0; |
| 705 times_to_fail_recreate_ = 0; |
| 706 times_to_lose_on_recreate_ = 100; |
| 707 RunTest(true, false); |
| 708 } |
| 709 |
| 710 TEST_F(LayerTreeHostContextTestLostContextFails, |
| 711 LoseOnRecreate100_MultiThread_DelegatingRenderer) { |
| 712 times_to_fail_reinitialize_ = 0; |
| 713 times_to_fail_recreate_ = 0; |
| 714 times_to_lose_on_recreate_ = 100; |
| 715 RunTest(true, true); |
| 650 } | 716 } |
| 651 | 717 |
| 652 class LayerTreeHostContextTestFinishAllRenderingAfterLoss | 718 class LayerTreeHostContextTestFinishAllRenderingAfterLoss |
| 653 : public LayerTreeHostContextTest { | 719 : public LayerTreeHostContextTest { |
| 654 public: | 720 public: |
| 655 virtual void BeginTest() OVERRIDE { | 721 virtual void BeginTest() OVERRIDE { |
| 656 // Lose the context until the compositor gives up on it. | 722 // Lose the context until the compositor gives up on it. |
| 657 first_initialized_ = false; | 723 first_initialized_ = false; |
| 658 times_to_lose_during_commit_ = 1; | 724 times_to_lose_during_commit_ = 1; |
| 659 times_to_fail_reinitialize_ = 10; | 725 times_to_fail_reinitialize_ = 10; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 809 |
| 744 protected: | 810 protected: |
| 745 bool lose_after_evict_; | 811 bool lose_after_evict_; |
| 746 FakeContentLayerClient client_; | 812 FakeContentLayerClient client_; |
| 747 scoped_refptr<FakeContentLayer> layer_; | 813 scoped_refptr<FakeContentLayer> layer_; |
| 748 LayerTreeHostImpl* impl_host_; | 814 LayerTreeHostImpl* impl_host_; |
| 749 int num_commits_; | 815 int num_commits_; |
| 750 }; | 816 }; |
| 751 | 817 |
| 752 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 818 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 753 LoseAfterEvict_SingleThread) { | 819 LoseAfterEvict_SingleThread_DirectRenderer) { |
| 754 lose_after_evict_ = true; | 820 lose_after_evict_ = true; |
| 755 RunTest(false); | 821 RunTest(false, false); |
| 756 } | 822 } |
| 757 | 823 |
| 758 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 824 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 759 LoseAfterEvict_MultiThread) { | 825 LoseAfterEvict_SingleThread_DelegatingRenderer) { |
| 760 lose_after_evict_ = true; | 826 lose_after_evict_ = true; |
| 761 RunTest(true); | 827 RunTest(false, true); |
| 762 } | 828 } |
| 763 | 829 |
| 764 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 830 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 765 LoseBeforeEvict_SingleThread) { | 831 LoseAfterEvict_MultiThread_DirectRenderer) { |
| 766 lose_after_evict_ = false; | 832 lose_after_evict_ = true; |
| 767 RunTest(false); | 833 RunTest(true, false); |
| 768 } | 834 } |
| 769 | 835 |
| 770 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 836 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 771 LoseBeforeEvict_MultiThread) { | 837 LoseAfterEvict_MultiThread_DelegatingRenderer) { |
| 838 lose_after_evict_ = true; |
| 839 RunTest(true, true); |
| 840 } |
| 841 |
| 842 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 843 LoseBeforeEvict_SingleThread_DirectRenderer) { |
| 772 lose_after_evict_ = false; | 844 lose_after_evict_ = false; |
| 773 RunTest(true); | 845 RunTest(false, false); |
| 846 } |
| 847 |
| 848 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 849 LoseBeforeEvict_SingleThread_DelegatingRenderer) { |
| 850 lose_after_evict_ = false; |
| 851 RunTest(false, true); |
| 852 } |
| 853 |
| 854 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 855 LoseBeforeEvict_MultiThread_DirectRenderer) { |
| 856 lose_after_evict_ = false; |
| 857 RunTest(true, false); |
| 858 } |
| 859 |
| 860 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 861 LoseBeforeEvict_MultiThread_DelegatingRenderer) { |
| 862 lose_after_evict_ = false; |
| 863 RunTest(true, true); |
| 774 } | 864 } |
| 775 | 865 |
| 776 class LayerTreeHostContextTestLostContextWhileUpdatingResources | 866 class LayerTreeHostContextTestLostContextWhileUpdatingResources |
| 777 : public LayerTreeHostContextTest { | 867 : public LayerTreeHostContextTest { |
| 778 public: | 868 public: |
| 779 LayerTreeHostContextTestLostContextWhileUpdatingResources() | 869 LayerTreeHostContextTestLostContextWhileUpdatingResources() |
| 780 : parent_(FakeContentLayer::Create(&client_)), | 870 : parent_(FakeContentLayer::Create(&client_)), |
| 781 num_children_(50), | 871 num_children_(50), |
| 782 times_to_lose_on_end_query_(3) {} | 872 times_to_lose_on_end_query_(3) {} |
| 783 | 873 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 | 1024 |
| 935 scoped_refptr<ContentLayer> content_ = ContentLayer::Create(&client_); | 1025 scoped_refptr<ContentLayer> content_ = ContentLayer::Create(&client_); |
| 936 content_->SetBounds(gfx::Size(10, 10)); | 1026 content_->SetBounds(gfx::Size(10, 10)); |
| 937 content_->SetAnchorPoint(gfx::PointF()); | 1027 content_->SetAnchorPoint(gfx::PointF()); |
| 938 content_->SetIsDrawable(true); | 1028 content_->SetIsDrawable(true); |
| 939 root_->AddChild(content_); | 1029 root_->AddChild(content_); |
| 940 | 1030 |
| 941 scoped_refptr<TextureLayer> texture_ = TextureLayer::Create(NULL); | 1031 scoped_refptr<TextureLayer> texture_ = TextureLayer::Create(NULL); |
| 942 texture_->SetBounds(gfx::Size(10, 10)); | 1032 texture_->SetBounds(gfx::Size(10, 10)); |
| 943 texture_->SetAnchorPoint(gfx::PointF()); | 1033 texture_->SetAnchorPoint(gfx::PointF()); |
| 944 texture_->SetTextureId(TestWebGraphicsContext3D::kExternalTextureId); | |
| 945 texture_->SetIsDrawable(true); | 1034 texture_->SetIsDrawable(true); |
| 946 root_->AddChild(texture_); | 1035 root_->AddChild(texture_); |
| 947 | 1036 |
| 948 scoped_refptr<ContentLayer> mask_ = ContentLayer::Create(&client_); | 1037 scoped_refptr<ContentLayer> mask_ = ContentLayer::Create(&client_); |
| 949 mask_->SetBounds(gfx::Size(10, 10)); | 1038 mask_->SetBounds(gfx::Size(10, 10)); |
| 950 mask_->SetAnchorPoint(gfx::PointF()); | 1039 mask_->SetAnchorPoint(gfx::PointF()); |
| 951 | 1040 |
| 952 scoped_refptr<ContentLayer> content_with_mask_ = | 1041 scoped_refptr<ContentLayer> content_with_mask_ = |
| 953 ContentLayer::Create(&client_); | 1042 ContentLayer::Create(&client_); |
| 954 content_with_mask_->SetBounds(gfx::Size(10, 10)); | 1043 content_with_mask_->SetBounds(gfx::Size(10, 10)); |
| 955 content_with_mask_->SetAnchorPoint(gfx::PointF()); | 1044 content_with_mask_->SetAnchorPoint(gfx::PointF()); |
| 956 content_with_mask_->SetIsDrawable(true); | 1045 content_with_mask_->SetIsDrawable(true); |
| 957 content_with_mask_->SetMaskLayer(mask_.get()); | 1046 content_with_mask_->SetMaskLayer(mask_.get()); |
| 958 root_->AddChild(content_with_mask_); | 1047 root_->AddChild(content_with_mask_); |
| 959 | 1048 |
| 960 scoped_refptr<VideoLayer> video_color_ = VideoLayer::Create( | 1049 scoped_refptr<VideoLayer> video_color_ = VideoLayer::Create( |
| 961 &color_frame_provider_); | 1050 &color_frame_provider_); |
| 962 video_color_->SetBounds(gfx::Size(10, 10)); | 1051 video_color_->SetBounds(gfx::Size(10, 10)); |
| 963 video_color_->SetAnchorPoint(gfx::PointF()); | 1052 video_color_->SetAnchorPoint(gfx::PointF()); |
| 964 video_color_->SetIsDrawable(true); | 1053 video_color_->SetIsDrawable(true); |
| 965 root_->AddChild(video_color_); | 1054 root_->AddChild(video_color_); |
| 966 | 1055 |
| 967 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::Create( | 1056 if (!delegating_renderer()) { |
| 968 &hw_frame_provider_); | 1057 // TODO(danakj): Hardware video decode can not be transported. |
| 969 video_hw_->SetBounds(gfx::Size(10, 10)); | 1058 // crbug.com/179729 |
| 970 video_hw_->SetAnchorPoint(gfx::PointF()); | 1059 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::Create( |
| 971 video_hw_->SetIsDrawable(true); | 1060 &hw_frame_provider_); |
| 972 root_->AddChild(video_hw_); | 1061 video_hw_->SetBounds(gfx::Size(10, 10)); |
| 1062 video_hw_->SetAnchorPoint(gfx::PointF()); |
| 1063 video_hw_->SetIsDrawable(true); |
| 1064 root_->AddChild(video_hw_); |
| 973 | 1065 |
| 974 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::Create( | 1066 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::Create( |
| 975 &scaled_hw_frame_provider_); | 1067 &scaled_hw_frame_provider_); |
| 976 video_scaled_hw_->SetBounds(gfx::Size(10, 10)); | 1068 video_scaled_hw_->SetBounds(gfx::Size(10, 10)); |
| 977 video_scaled_hw_->SetAnchorPoint(gfx::PointF()); | 1069 video_scaled_hw_->SetAnchorPoint(gfx::PointF()); |
| 978 video_scaled_hw_->SetIsDrawable(true); | 1070 video_scaled_hw_->SetIsDrawable(true); |
| 979 root_->AddChild(video_scaled_hw_); | 1071 root_->AddChild(video_scaled_hw_); |
| 1072 } |
| 980 | 1073 |
| 981 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::Create(); | 1074 if (!delegating_renderer()) { |
| 982 io_surface_->SetBounds(gfx::Size(10, 10)); | 1075 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 |
| 983 io_surface_->SetAnchorPoint(gfx::PointF()); | 1076 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::Create(); |
| 984 io_surface_->SetIsDrawable(true); | 1077 io_surface_->SetBounds(gfx::Size(10, 10)); |
| 985 io_surface_->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 1078 io_surface_->SetAnchorPoint(gfx::PointF()); |
| 986 root_->AddChild(io_surface_); | 1079 io_surface_->SetIsDrawable(true); |
| 1080 io_surface_->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
| 1081 root_->AddChild(io_surface_); |
| 1082 } |
| 987 | 1083 |
| 988 // Enable the hud. | 1084 // Enable the hud. |
| 989 LayerTreeDebugState debug_state; | 1085 LayerTreeDebugState debug_state; |
| 990 debug_state.show_property_changed_rects = true; | 1086 debug_state.show_property_changed_rects = true; |
| 991 layer_tree_host()->SetDebugState(debug_state); | 1087 layer_tree_host()->SetDebugState(debug_state); |
| 992 | 1088 |
| 993 bool paint_scrollbar = true; | 1089 bool paint_scrollbar = true; |
| 994 bool has_thumb = true; | 1090 bool has_thumb = true; |
| 995 scoped_refptr<ScrollbarLayer> scrollbar_ = ScrollbarLayer::Create( | 1091 scoped_refptr<ScrollbarLayer> scrollbar_ = ScrollbarLayer::Create( |
| 996 FakeWebScrollbar::Create().PassAs<WebKit::WebScrollbar>(), | 1092 FakeWebScrollbar::Create().PassAs<WebKit::WebScrollbar>(), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 pass_list.push_back(pass_for_quad.PassAs<RenderPass>()); | 1137 pass_list.push_back(pass_for_quad.PassAs<RenderPass>()); |
| 1042 pass_list.push_back(pass.PassAs<RenderPass>()); | 1138 pass_list.push_back(pass.PassAs<RenderPass>()); |
| 1043 | 1139 |
| 1044 // First child is the delegated layer. | 1140 // First child is the delegated layer. |
| 1045 FakeDelegatedRendererLayerImpl* delegated_impl = | 1141 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 1046 static_cast<FakeDelegatedRendererLayerImpl*>( | 1142 static_cast<FakeDelegatedRendererLayerImpl*>( |
| 1047 host_impl->active_tree()->root_layer()->children()[0]); | 1143 host_impl->active_tree()->root_layer()->children()[0]); |
| 1048 delegated_impl->SetFrameDataForRenderPasses(&pass_list); | 1144 delegated_impl->SetFrameDataForRenderPasses(&pass_list); |
| 1049 EXPECT_TRUE(pass_list.empty()); | 1145 EXPECT_TRUE(pass_list.empty()); |
| 1050 | 1146 |
| 1147 // Third child is the texture layer. |
| 1148 TextureLayerImpl* texture_impl = |
| 1149 static_cast<TextureLayerImpl*>( |
| 1150 host_impl->active_tree()->root_layer()->children()[2]); |
| 1151 texture_impl->set_texture_id( |
| 1152 resource_provider->GraphicsContext3D()->createTexture()); |
| 1153 |
| 1154 DCHECK(resource_provider->GraphicsContext3D()); |
| 1155 ResourceProvider::ResourceId texture = resource_provider->CreateResource( |
| 1156 gfx::Size(4, 4), |
| 1157 resource_provider->default_resource_type(), |
| 1158 ResourceProvider::TextureUsageAny); |
| 1159 ResourceProvider::ScopedWriteLockGL lock(resource_provider, texture); |
| 1160 |
| 1051 color_video_frame_ = VideoFrame::CreateColorFrame( | 1161 color_video_frame_ = VideoFrame::CreateColorFrame( |
| 1052 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 1162 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 1053 hw_video_frame_ = VideoFrame::WrapNativeTexture( | 1163 hw_video_frame_ = VideoFrame::WrapNativeTexture( |
| 1054 resource_provider->GraphicsContext3D()->createTexture(), | 1164 lock.texture_id(), |
| 1055 GL_TEXTURE_2D, | 1165 GL_TEXTURE_2D, |
| 1056 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), | 1166 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), |
| 1057 base::TimeDelta(), | 1167 base::TimeDelta(), |
| 1058 VideoFrame::ReadPixelsCB(), | 1168 VideoFrame::ReadPixelsCB(), |
| 1059 base::Closure()); | 1169 base::Closure()); |
| 1060 scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture( | 1170 scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture( |
| 1061 resource_provider->GraphicsContext3D()->createTexture(), | 1171 lock.texture_id(), |
| 1062 GL_TEXTURE_2D, | 1172 GL_TEXTURE_2D, |
| 1063 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), | 1173 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), |
| 1064 base::TimeDelta(), | 1174 base::TimeDelta(), |
| 1065 VideoFrame::ReadPixelsCB(), | 1175 VideoFrame::ReadPixelsCB(), |
| 1066 base::Closure()); | 1176 base::Closure()); |
| 1067 | 1177 |
| 1068 color_frame_provider_.set_frame(color_video_frame_); | 1178 color_frame_provider_.set_frame(color_video_frame_); |
| 1069 hw_frame_provider_.set_frame(hw_video_frame_); | 1179 hw_frame_provider_.set_frame(hw_video_frame_); |
| 1070 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_); | 1180 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_); |
| 1071 return; | 1181 return; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 : public LayerTreeHostContextTest { | 1310 : public LayerTreeHostContextTest { |
| 1201 public: | 1311 public: |
| 1202 virtual void BeginTest() OVERRIDE { | 1312 virtual void BeginTest() OVERRIDE { |
| 1203 // This must be called immediately after creating LTH, before the first | 1313 // This must be called immediately after creating LTH, before the first |
| 1204 // OutputSurface is initialized. | 1314 // OutputSurface is initialized. |
| 1205 ASSERT_TRUE(layer_tree_host()->output_surface_lost()); | 1315 ASSERT_TRUE(layer_tree_host()->output_surface_lost()); |
| 1206 | 1316 |
| 1207 times_output_surface_created_ = 0; | 1317 times_output_surface_created_ = 0; |
| 1208 | 1318 |
| 1209 char pixels[4]; | 1319 char pixels[4]; |
| 1210 EXPECT_TRUE(layer_tree_host()->CompositeAndReadback( | 1320 bool result = layer_tree_host()->CompositeAndReadback( |
| 1211 &pixels, gfx::Rect(1, 1))); | 1321 &pixels, gfx::Rect(1, 1)); |
| 1322 EXPECT_EQ(!delegating_renderer(), result); |
| 1212 EXPECT_EQ(1, times_output_surface_created_); | 1323 EXPECT_EQ(1, times_output_surface_created_); |
| 1213 | 1324 |
| 1214 PostSetNeedsCommitToMainThread(); | 1325 PostSetNeedsCommitToMainThread(); |
| 1215 } | 1326 } |
| 1216 | 1327 |
| 1217 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { | 1328 virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { |
| 1218 EXPECT_TRUE(succeeded); | 1329 EXPECT_TRUE(succeeded); |
| 1219 ++times_output_surface_created_; | 1330 ++times_output_surface_created_; |
| 1220 } | 1331 } |
| 1221 | 1332 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 EXPECT_FALSE( | 1467 EXPECT_FALSE( |
| 1357 layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(1, 1))); | 1468 layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(1, 1))); |
| 1358 // If we've made it this far without crashing, we've succeeded. | 1469 // If we've made it this far without crashing, we've succeeded. |
| 1359 EndTest(); | 1470 EndTest(); |
| 1360 } | 1471 } |
| 1361 | 1472 |
| 1362 private: | 1473 private: |
| 1363 int failure_count_; | 1474 int failure_count_; |
| 1364 }; | 1475 }; |
| 1365 | 1476 |
| 1366 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestFailsToCreateSurface); | 1477 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1478 LayerTreeHostContextTestFailsToCreateSurface); |
| 1367 | 1479 |
| 1368 // Not reusing LayerTreeTest because it expects creating LTH to always succeed. | 1480 // Not reusing LayerTreeTest because it expects creating LTH to always succeed. |
| 1369 class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface | 1481 class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface |
| 1370 : public testing::Test, | 1482 : public testing::Test, |
| 1371 public FakeLayerTreeHostClient { | 1483 public FakeLayerTreeHostClient { |
| 1372 public: | 1484 public: |
| 1373 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface() | 1485 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface() |
| 1374 : FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) {} | 1486 : FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) {} |
| 1375 | 1487 |
| 1376 // FakeLayerTreeHostClient | 1488 // FakeLayerTreeHostClient implementation. |
| 1377 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { | 1489 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { |
| 1378 return scoped_ptr<OutputSurface>(); | 1490 return scoped_ptr<OutputSurface>(); |
| 1379 } | 1491 } |
| 1380 | 1492 |
| 1381 void RunTest(bool threaded) { | 1493 void RunTest(bool threaded, bool delegating_renderer) { |
| 1382 scoped_ptr<base::Thread> impl_thread; | 1494 scoped_ptr<base::Thread> impl_thread; |
| 1383 scoped_ptr<cc::Thread> impl_ccthread(NULL); | 1495 scoped_ptr<cc::Thread> impl_ccthread(NULL); |
| 1384 if (threaded) { | 1496 if (threaded) { |
| 1385 impl_thread.reset(new base::Thread("LayerTreeTest")); | 1497 impl_thread.reset(new base::Thread("LayerTreeTest")); |
| 1386 impl_ccthread = cc::ThreadImpl::CreateForDifferentThread( | 1498 impl_ccthread = cc::ThreadImpl::CreateForDifferentThread( |
| 1387 impl_thread->message_loop_proxy()); | 1499 impl_thread->message_loop_proxy()); |
| 1388 ASSERT_TRUE(impl_ccthread); | 1500 ASSERT_TRUE(impl_ccthread); |
| 1389 } | 1501 } |
| 1390 | 1502 |
| 1391 LayerTreeSettings settings; | 1503 LayerTreeSettings settings; |
| 1392 scoped_ptr<LayerTreeHost> layer_tree_host = | 1504 scoped_ptr<LayerTreeHost> layer_tree_host = |
| 1393 LayerTreeHost::Create(this, settings, impl_ccthread.Pass()); | 1505 LayerTreeHost::Create(this, settings, impl_ccthread.Pass()); |
| 1394 EXPECT_FALSE(layer_tree_host); | 1506 EXPECT_FALSE(layer_tree_host); |
| 1395 } | 1507 } |
| 1396 }; | 1508 }; |
| 1397 | 1509 |
| 1398 SINGLE_AND_MULTI_THREAD_TEST_F( | 1510 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1399 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface); | 1511 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface); |
| 1400 | 1512 |
| 1401 } // namespace | 1513 } // namespace |
| 1402 } // namespace cc | 1514 } // namespace cc |
| OLD | NEW |