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

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

Issue 2336853002: cc: Plumb device color space through to rasterization (Closed)
Patch Set: Use suggested approach 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
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 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 void AfterTest() override {} 1729 void AfterTest() override {}
1730 1730
1731 private: 1731 private:
1732 FakeContentLayerClient client_; 1732 FakeContentLayerClient client_;
1733 scoped_refptr<Layer> root_layer_; 1733 scoped_refptr<Layer> root_layer_;
1734 scoped_refptr<Layer> child_layer_; 1734 scoped_refptr<Layer> child_layer_;
1735 }; 1735 };
1736 1736
1737 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorChange); 1737 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorChange);
1738 1738
1739 class LayerTreeHostTestDeviceColorSpaceChange : public LayerTreeHostTest {
1740 public:
1741 void SetupTree() override {
1742 space1_ = gfx::ColorSpace::CreateXYZD50();
1743 space2_ = gfx::ColorSpace::CreateSRGB();
1744
1745 root_layer_ = Layer::Create();
1746 root_layer_->SetBounds(gfx::Size(10, 20));
1747
1748 child_layer_ = FakePictureLayer::Create(&client_);
1749 child_layer_->SetBounds(gfx::Size(10, 10));
1750 root_layer_->AddChild(child_layer_);
1751
1752 layer_tree()->SetRootLayer(root_layer_);
1753 layer_tree()->SetDeviceColorSpace(space1_);
1754 LayerTreeHostTest::SetupTree();
1755 client_.set_bounds(root_layer_->bounds());
1756 }
1757
1758 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1759
1760 void DidCommit() override {
1761 if (layer_tree_host()->SourceFrameNumber() == 1)
1762 layer_tree()->SetDeviceColorSpace(space2_);
1763 }
1764
1765 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1766 if (host_impl->sync_tree()->source_frame_number() == 1) {
1767 EXPECT_TRUE(space2_ == host_impl->sync_tree()->device_color_space());
1768 if (host_impl->pending_tree()) {
1769 // The active tree's device color space shouldn't change until
1770 // activation.
1771 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
1772 }
1773 }
1774 }
1775
1776 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
1777 LayerTreeHostImpl::FrameData* frame_data,
1778 DrawResult draw_result) override {
1779 if (host_impl->active_tree()->source_frame_number() == 0) {
1780 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
1781 } else {
1782 gfx::Rect root_damage_rect =
1783 frame_data->render_passes.back()->damage_rect;
1784 EXPECT_EQ(
1785 gfx::Rect(
1786 host_impl->active_tree()->root_layer_for_testing()->bounds()),
1787 root_damage_rect);
1788 EXPECT_TRUE(space2_ == host_impl->active_tree()->device_color_space());
1789 EndTest();
1790 }
1791
1792 return draw_result;
1793 }
1794
1795 void AfterTest() override {}
1796
1797 private:
1798 gfx::ColorSpace space1_;
1799 gfx::ColorSpace space2_;
1800 FakeContentLayerClient client_;
1801 scoped_refptr<Layer> root_layer_;
1802 scoped_refptr<Layer> child_layer_;
1803 };
1804
1805 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceColorSpaceChange);
1806
1739 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { 1807 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
1740 public: 1808 public:
1741 LayerTreeHostTestSetNextCommitForcesRedraw() 1809 LayerTreeHostTestSetNextCommitForcesRedraw()
1742 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} 1810 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}
1743 1811
1744 void BeginTest() override { 1812 void BeginTest() override {
1745 root_layer_ = FakePictureLayer::Create(&client_); 1813 root_layer_ = FakePictureLayer::Create(&client_);
1746 root_layer_->SetIsDrawable(true); 1814 root_layer_->SetIsDrawable(true);
1747 root_layer_->SetBounds(bounds_); 1815 root_layer_->SetBounds(bounds_);
1748 layer_tree()->SetRootLayer(root_layer_); 1816 layer_tree()->SetRootLayer(root_layer_);
(...skipping 5303 matching lines...) Expand 10 before | Expand all | Expand 10 after
7052 EndTest(); 7120 EndTest();
7053 } 7121 }
7054 7122
7055 void AfterTest() override {} 7123 void AfterTest() override {}
7056 }; 7124 };
7057 7125
7058 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); 7126 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources);
7059 7127
7060 } // namespace 7128 } // namespace
7061 } // namespace cc 7129 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698