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

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

Issue 2735943002: cc: Clarify that color spaces are for raster (Closed)
Patch Set: Rebase (a few times) Created 3 years, 9 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 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 void AfterTest() override {} 1882 void AfterTest() override {}
1883 1883
1884 private: 1884 private:
1885 FakeContentLayerClient client_; 1885 FakeContentLayerClient client_;
1886 scoped_refptr<Layer> root_layer_; 1886 scoped_refptr<Layer> root_layer_;
1887 scoped_refptr<Layer> child_layer_; 1887 scoped_refptr<Layer> child_layer_;
1888 }; 1888 };
1889 1889
1890 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorChange); 1890 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorChange);
1891 1891
1892 class LayerTreeHostTestDeviceColorSpaceChange : public LayerTreeHostTest { 1892 class LayerTreeHostTestRasterColorSpaceChange : public LayerTreeHostTest {
1893 public: 1893 public:
1894 void SetupTree() override { 1894 void SetupTree() override {
1895 space1_ = gfx::ColorSpace::CreateXYZD50(); 1895 space1_ = gfx::ColorSpace::CreateXYZD50();
1896 space2_ = gfx::ColorSpace::CreateSRGB(); 1896 space2_ = gfx::ColorSpace::CreateSRGB();
1897 1897
1898 root_layer_ = Layer::Create(); 1898 root_layer_ = Layer::Create();
1899 root_layer_->SetBounds(gfx::Size(10, 20)); 1899 root_layer_->SetBounds(gfx::Size(10, 20));
1900 1900
1901 child_layer_ = FakePictureLayer::Create(&client_); 1901 child_layer_ = FakePictureLayer::Create(&client_);
1902 child_layer_->SetBounds(gfx::Size(10, 10)); 1902 child_layer_->SetBounds(gfx::Size(10, 10));
1903 root_layer_->AddChild(child_layer_); 1903 root_layer_->AddChild(child_layer_);
1904 1904
1905 layer_tree_host()->SetRootLayer(root_layer_); 1905 layer_tree_host()->SetRootLayer(root_layer_);
1906 layer_tree_host()->SetDeviceColorSpace(space1_); 1906 layer_tree_host()->SetRasterColorSpace(space1_);
1907 LayerTreeHostTest::SetupTree(); 1907 LayerTreeHostTest::SetupTree();
1908 client_.set_bounds(root_layer_->bounds()); 1908 client_.set_bounds(root_layer_->bounds());
1909 } 1909 }
1910 1910
1911 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1911 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1912 1912
1913 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 1913 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
1914 LayerTreeHostImpl::FrameData* frame_data, 1914 LayerTreeHostImpl::FrameData* frame_data,
1915 DrawResult draw_result) override { 1915 DrawResult draw_result) override {
1916 EXPECT_EQ(DRAW_SUCCESS, draw_result); 1916 EXPECT_EQ(DRAW_SUCCESS, draw_result);
1917 1917
1918 int source_frame = host_impl->active_tree()->source_frame_number(); 1918 int source_frame = host_impl->active_tree()->source_frame_number();
1919 switch (source_frame) { 1919 switch (source_frame) {
1920 case 0: 1920 case 0:
1921 // The first frame will have full damage, and should be in the initial 1921 // The first frame will have full damage, and should be in the initial
1922 // color space. 1922 // color space.
1923 EXPECT_FALSE(frame_data->has_no_damage); 1923 EXPECT_FALSE(frame_data->has_no_damage);
1924 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space()); 1924 EXPECT_TRUE(space1_ == host_impl->active_tree()->raster_color_space());
1925 break; 1925 break;
1926 case 1: 1926 case 1:
1927 // Empty commit. 1927 // Empty commit.
1928 EXPECT_TRUE(frame_data->has_no_damage); 1928 EXPECT_TRUE(frame_data->has_no_damage);
1929 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space()); 1929 EXPECT_TRUE(space1_ == host_impl->active_tree()->raster_color_space());
1930 break; 1930 break;
1931 case 2: 1931 case 2:
1932 // The change from space1 to space2 should cause full damage. 1932 // The change from space1 to space2 should cause full damage.
1933 EXPECT_FALSE(frame_data->has_no_damage); 1933 EXPECT_FALSE(frame_data->has_no_damage);
1934 EXPECT_TRUE(space2_ == host_impl->active_tree()->device_color_space()); 1934 EXPECT_TRUE(space2_ == host_impl->active_tree()->raster_color_space());
1935 break; 1935 break;
1936 case 3: 1936 case 3:
1937 // Empty commit with the color space set to space2 redundantly. 1937 // Empty commit with the color space set to space2 redundantly.
1938 EXPECT_TRUE(frame_data->has_no_damage); 1938 EXPECT_TRUE(frame_data->has_no_damage);
1939 EXPECT_TRUE(space2_ == host_impl->active_tree()->device_color_space()); 1939 EXPECT_TRUE(space2_ == host_impl->active_tree()->raster_color_space());
1940 break; 1940 break;
1941 case 4: 1941 case 4:
1942 // The change from space2 to space1 should cause full damage. 1942 // The change from space2 to space1 should cause full damage.
1943 EXPECT_FALSE(frame_data->has_no_damage); 1943 EXPECT_FALSE(frame_data->has_no_damage);
1944 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space()); 1944 EXPECT_TRUE(space1_ == host_impl->active_tree()->raster_color_space());
1945 break; 1945 break;
1946 case 5: 1946 case 5:
1947 // Empty commit. 1947 // Empty commit.
1948 EXPECT_TRUE(frame_data->has_no_damage); 1948 EXPECT_TRUE(frame_data->has_no_damage);
1949 EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space()); 1949 EXPECT_TRUE(space1_ == host_impl->active_tree()->raster_color_space());
1950 EndTest(); 1950 EndTest();
1951 break; 1951 break;
1952 default: 1952 default:
1953 NOTREACHED(); 1953 NOTREACHED();
1954 break; 1954 break;
1955 } 1955 }
1956 1956
1957 if (!frame_data->has_no_damage) { 1957 if (!frame_data->has_no_damage) {
1958 gfx::Rect root_damage_rect = 1958 gfx::Rect root_damage_rect =
1959 frame_data->render_passes.back()->damage_rect; 1959 frame_data->render_passes.back()->damage_rect;
1960 EXPECT_EQ( 1960 EXPECT_EQ(
1961 gfx::Rect( 1961 gfx::Rect(
1962 host_impl->active_tree()->root_layer_for_testing()->bounds()), 1962 host_impl->active_tree()->root_layer_for_testing()->bounds()),
1963 root_damage_rect); 1963 root_damage_rect);
1964 } 1964 }
1965 1965
1966 return draw_result; 1966 return draw_result;
1967 } 1967 }
1968 1968
1969 void DidCommit() override { 1969 void DidCommit() override {
1970 switch (layer_tree_host()->SourceFrameNumber()) { 1970 switch (layer_tree_host()->SourceFrameNumber()) {
1971 case 1: 1971 case 1:
1972 PostSetNeedsCommitToMainThread(); 1972 PostSetNeedsCommitToMainThread();
1973 break; 1973 break;
1974 case 2: 1974 case 2:
1975 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting()); 1975 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1976 layer_tree_host()->SetDeviceColorSpace(space2_); 1976 layer_tree_host()->SetRasterColorSpace(space2_);
1977 EXPECT_TRUE(child_layer_->NeedsDisplayForTesting()); 1977 EXPECT_TRUE(child_layer_->NeedsDisplayForTesting());
1978 break; 1978 break;
1979 case 3: 1979 case 3:
1980 // The redundant SetDeviceColorSpace should cause no commit and no 1980 // The redundant SetRasterColorSpace should cause no commit and no
1981 // damage. Force a commit for the test to continue. 1981 // damage. Force a commit for the test to continue.
1982 layer_tree_host()->SetDeviceColorSpace(space2_); 1982 layer_tree_host()->SetRasterColorSpace(space2_);
1983 PostSetNeedsCommitToMainThread(); 1983 PostSetNeedsCommitToMainThread();
1984 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting()); 1984 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1985 break; 1985 break;
1986 case 4: 1986 case 4:
1987 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting()); 1987 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1988 layer_tree_host()->SetDeviceColorSpace(space1_); 1988 layer_tree_host()->SetRasterColorSpace(space1_);
1989 EXPECT_TRUE(child_layer_->NeedsDisplayForTesting()); 1989 EXPECT_TRUE(child_layer_->NeedsDisplayForTesting());
1990 break; 1990 break;
1991 case 5: 1991 case 5:
1992 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting()); 1992 EXPECT_FALSE(child_layer_->NeedsDisplayForTesting());
1993 PostSetNeedsCommitToMainThread(); 1993 PostSetNeedsCommitToMainThread();
1994 break; 1994 break;
1995 case 6: 1995 case 6:
1996 break; 1996 break;
1997 default: 1997 default:
1998 NOTREACHED(); 1998 NOTREACHED();
1999 break; 1999 break;
2000 } 2000 }
2001 } 2001 }
2002 2002
2003 void AfterTest() override {} 2003 void AfterTest() override {}
2004 2004
2005 private: 2005 private:
2006 gfx::ColorSpace space1_; 2006 gfx::ColorSpace space1_;
2007 gfx::ColorSpace space2_; 2007 gfx::ColorSpace space2_;
2008 FakeContentLayerClient client_; 2008 FakeContentLayerClient client_;
2009 scoped_refptr<Layer> root_layer_; 2009 scoped_refptr<Layer> root_layer_;
2010 scoped_refptr<Layer> child_layer_; 2010 scoped_refptr<Layer> child_layer_;
2011 }; 2011 };
2012 2012
2013 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceColorSpaceChange); 2013 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestRasterColorSpaceChange);
2014 2014
2015 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { 2015 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
2016 public: 2016 public:
2017 LayerTreeHostTestSetNextCommitForcesRedraw() 2017 LayerTreeHostTestSetNextCommitForcesRedraw()
2018 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} 2018 : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {}
2019 2019
2020 void BeginTest() override { 2020 void BeginTest() override {
2021 root_layer_ = FakePictureLayer::Create(&client_); 2021 root_layer_ = FakePictureLayer::Create(&client_);
2022 root_layer_->SetIsDrawable(true); 2022 root_layer_->SetIsDrawable(true);
2023 root_layer_->SetBounds(bounds_); 2023 root_layer_->SetBounds(bounds_);
(...skipping 5086 matching lines...) Expand 10 before | Expand all | Expand 10 after
7110 BeginFrameArgs current_begin_frame_args_; 7110 BeginFrameArgs current_begin_frame_args_;
7111 BeginFrameArgs current_begin_main_frame_args_; 7111 BeginFrameArgs current_begin_main_frame_args_;
7112 BeginFrameArgs current_begin_main_frame_args_on_impl_; 7112 BeginFrameArgs current_begin_main_frame_args_on_impl_;
7113 LayerTreeHostImpl::FrameData* frame_data_; 7113 LayerTreeHostImpl::FrameData* frame_data_;
7114 }; 7114 };
7115 7115
7116 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestBeginFrameSequenceNumbers); 7116 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestBeginFrameSequenceNumbers);
7117 7117
7118 } // namespace 7118 } // namespace
7119 } // namespace cc 7119 } // 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