OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 void AfterTest() override {} | 1730 void AfterTest() override {} |
1731 | 1731 |
1732 private: | 1732 private: |
1733 FakeContentLayerClient client_; | 1733 FakeContentLayerClient client_; |
1734 scoped_refptr<Layer> root_layer_; | 1734 scoped_refptr<Layer> root_layer_; |
1735 scoped_refptr<Layer> child_layer_; | 1735 scoped_refptr<Layer> child_layer_; |
1736 }; | 1736 }; |
1737 | 1737 |
1738 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorChange); | 1738 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorChange); |
1739 | 1739 |
| 1740 class LayerTreeHostTestDeviceColorSpaceChange : public LayerTreeHostTest { |
| 1741 public: |
| 1742 void SetupTree() override { |
| 1743 space1_ = gfx::ColorSpace::CreateXYZD50(); |
| 1744 space2_ = gfx::ColorSpace::CreateSRGB(); |
| 1745 |
| 1746 root_layer_ = Layer::Create(); |
| 1747 root_layer_->SetBounds(gfx::Size(10, 20)); |
| 1748 |
| 1749 child_layer_ = FakePictureLayer::Create(&client_); |
| 1750 child_layer_->SetBounds(gfx::Size(10, 10)); |
| 1751 root_layer_->AddChild(child_layer_); |
| 1752 |
| 1753 layer_tree()->SetRootLayer(root_layer_); |
| 1754 layer_tree()->SetDeviceColorSpace(space1_); |
| 1755 LayerTreeHostTest::SetupTree(); |
| 1756 client_.set_bounds(root_layer_->bounds()); |
| 1757 } |
| 1758 |
| 1759 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1760 |
| 1761 void DidCommit() override { |
| 1762 if (layer_tree_host()->SourceFrameNumber() == 1) |
| 1763 layer_tree()->SetDeviceColorSpace(space2_); |
| 1764 } |
| 1765 |
| 1766 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 1767 if (host_impl->sync_tree()->source_frame_number() == 1) { |
| 1768 EXPECT_TRUE(space2_ == host_impl->sync_tree()->device_color_space()); |
| 1769 if (host_impl->pending_tree()) { |
| 1770 // The active tree's device color space shouldn't change until |
| 1771 // activation. |
| 1772 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space()); |
| 1773 } |
| 1774 } |
| 1775 } |
| 1776 |
| 1777 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 1778 LayerTreeHostImpl::FrameData* frame_data, |
| 1779 DrawResult draw_result) override { |
| 1780 if (host_impl->active_tree()->source_frame_number() == 0) { |
| 1781 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space()); |
| 1782 } else { |
| 1783 gfx::Rect root_damage_rect = |
| 1784 frame_data->render_passes.back()->damage_rect; |
| 1785 EXPECT_EQ( |
| 1786 gfx::Rect( |
| 1787 host_impl->active_tree()->root_layer_for_testing()->bounds()), |
| 1788 root_damage_rect); |
| 1789 EXPECT_TRUE(space2_ == host_impl->active_tree()->device_color_space()); |
| 1790 EndTest(); |
| 1791 } |
| 1792 |
| 1793 return draw_result; |
| 1794 } |
| 1795 |
| 1796 void AfterTest() override {} |
| 1797 |
| 1798 private: |
| 1799 gfx::ColorSpace space1_; |
| 1800 gfx::ColorSpace space2_; |
| 1801 FakeContentLayerClient client_; |
| 1802 scoped_refptr<Layer> root_layer_; |
| 1803 scoped_refptr<Layer> child_layer_; |
| 1804 }; |
| 1805 |
| 1806 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceColorSpaceChange); |
| 1807 |
1740 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { | 1808 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
1741 public: | 1809 public: |
1742 LayerTreeHostTestSetNextCommitForcesRedraw() | 1810 LayerTreeHostTestSetNextCommitForcesRedraw() |
1743 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} | 1811 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} |
1744 | 1812 |
1745 void BeginTest() override { | 1813 void BeginTest() override { |
1746 root_layer_ = FakePictureLayer::Create(&client_); | 1814 root_layer_ = FakePictureLayer::Create(&client_); |
1747 root_layer_->SetIsDrawable(true); | 1815 root_layer_->SetIsDrawable(true); |
1748 root_layer_->SetBounds(bounds_); | 1816 root_layer_->SetBounds(bounds_); |
1749 layer_tree()->SetRootLayer(root_layer_); | 1817 layer_tree()->SetRootLayer(root_layer_); |
(...skipping 5311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7061 EndTest(); | 7129 EndTest(); |
7062 } | 7130 } |
7063 | 7131 |
7064 void AfterTest() override {} | 7132 void AfterTest() override {} |
7065 }; | 7133 }; |
7066 | 7134 |
7067 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); | 7135 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); |
7068 | 7136 |
7069 } // namespace | 7137 } // namespace |
7070 } // namespace cc | 7138 } // namespace cc |
OLD | NEW |