Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2336853002: cc: Plumb device color space through to rasterization (Closed)
Patch Set: Remove damage Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
1762 LayerTreeHostImpl::FrameData* frame_data,
1763 DrawResult draw_result) override {
1764 EXPECT_EQ(DRAW_SUCCESS, draw_result);
1765
1766 int source_frame = host_impl->active_tree()->source_frame_number();
1767 switch (source_frame) {
1768 case 0:
1769 // The first frame will have full damage, and should be in the initial
1770 // color space.
1771 EXPECT_FALSE(frame_data->has_no_damage);
1772 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
1773 break;
1774 case 1:
1775 // Empty commit.
1776 EXPECT_TRUE(frame_data->has_no_damage);
1777 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
1778 break;
1779 case 2:
1780 // The change from space1 to space2 should cause full damage.
1781 EXPECT_FALSE(frame_data->has_no_damage);
1782 EXPECT_TRUE(space2_ == host_impl->active_tree()->device_color_space());
1783 break;
1784 case 3:
1785 // Empty commit with the color space set to space2 redundantly.
1786 EXPECT_TRUE(frame_data->has_no_damage);
1787 EXPECT_TRUE(space2_ == host_impl->active_tree()->device_color_space());
1788 break;
1789 case 4:
1790 // The change from space2 to space1 should cause full damage.
1791 EXPECT_FALSE(frame_data->has_no_damage);
1792 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
1793 break;
1794 case 5:
1795 // Empty commit.
1796 EXPECT_TRUE(frame_data->has_no_damage);
1797 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
1798 EndTest();
1799 break;
1800 default:
1801 NOTREACHED();
1802 break;
1803 }
1804
1805 if (!frame_data->has_no_damage) {
1806 gfx::Rect root_damage_rect =
1807 frame_data->render_passes.back()->damage_rect;
1808 EXPECT_EQ(
1809 gfx::Rect(
1810 host_impl->active_tree()->root_layer_for_testing()->bounds()),
1811 root_damage_rect);
1812 }
1813
1814 return draw_result;
1815 }
1816
1817 void DidCommit() override {
1818 switch (layer_tree_host()->SourceFrameNumber()) {
1819 case 1:
1820 PostSetNeedsCommitToMainThread();
1821 break;
1822 case 2:
1823 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1824 layer_tree()->SetDeviceColorSpace(space2_);
1825 EXPECT_TRUE(child_layer_->NeedsDisplayForTesting());
1826 break;
1827 case 3:
1828 // The redundant SetDeviceColorSpace should cause no commit and no
1829 // damage. Force a commit for the test to continue.
1830 layer_tree()->SetDeviceColorSpace(space2_);
1831 PostSetNeedsCommitToMainThread();
1832 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1833 break;
1834 case 4:
1835 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1836 layer_tree()->SetDeviceColorSpace(space1_);
1837 EXPECT_TRUE(child_layer_->NeedsDisplayForTesting());
1838 break;
1839 case 5:
1840 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1841 PostSetNeedsCommitToMainThread();
1842 break;
1843 case 6:
1844 break;
1845 default:
1846 NOTREACHED();
1847 break;
1848 }
1849 }
1850
1851 void AfterTest() override {}
1852
1853 private:
1854 gfx::ColorSpace space1_;
1855 gfx::ColorSpace space2_;
1856 FakeContentLayerClient client_;
1857 scoped_refptr<Layer> root_layer_;
1858 scoped_refptr<Layer> child_layer_;
1859 };
1860
1861 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceColorSpaceChange);
1862
1740 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { 1863 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
1741 public: 1864 public:
1742 LayerTreeHostTestSetNextCommitForcesRedraw() 1865 LayerTreeHostTestSetNextCommitForcesRedraw()
1743 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} 1866 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}
1744 1867
1745 void BeginTest() override { 1868 void BeginTest() override {
1746 root_layer_ = FakePictureLayer::Create(&client_); 1869 root_layer_ = FakePictureLayer::Create(&client_);
1747 root_layer_->SetIsDrawable(true); 1870 root_layer_->SetIsDrawable(true);
1748 root_layer_->SetBounds(bounds_); 1871 root_layer_->SetBounds(bounds_);
1749 layer_tree()->SetRootLayer(root_layer_); 1872 layer_tree()->SetRootLayer(root_layer_);
(...skipping 5311 matching lines...) Expand 10 before | Expand all | Expand 10 after
7061 EndTest(); 7184 EndTest();
7062 } 7185 }
7063 7186
7064 void AfterTest() override {} 7187 void AfterTest() override {}
7065 }; 7188 };
7066 7189
7067 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); 7190 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources);
7068 7191
7069 } // namespace 7192 } // namespace
7070 } // namespace cc 7193 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698