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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index b2ab289e122e09c577a7f4eee6049567c17579a9..520f2c7354c60bd97e77adbf984a680ecd2ef9fc 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -1736,6 +1736,74 @@ class LayerTreeHostTestDeviceScaleFactorChange : public LayerTreeHostTest {
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorChange);
+class LayerTreeHostTestDeviceColorSpaceChange : public LayerTreeHostTest {
+ public:
+ void SetupTree() override {
+ space1_ = gfx::ColorSpace::CreateXYZD50();
+ space2_ = gfx::ColorSpace::CreateSRGB();
+
+ root_layer_ = Layer::Create();
+ root_layer_->SetBounds(gfx::Size(10, 20));
+
+ child_layer_ = FakePictureLayer::Create(&client_);
+ child_layer_->SetBounds(gfx::Size(10, 10));
+ root_layer_->AddChild(child_layer_);
+
+ layer_tree()->SetRootLayer(root_layer_);
+ layer_tree()->SetDeviceColorSpace(space1_);
+ LayerTreeHostTest::SetupTree();
+ client_.set_bounds(root_layer_->bounds());
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DidCommit() override {
+ if (layer_tree_host()->SourceFrameNumber() == 1)
+ layer_tree()->SetDeviceColorSpace(space2_);
+ }
+
+ void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
+ if (host_impl->sync_tree()->source_frame_number() == 1) {
+ EXPECT_TRUE(space2_ == host_impl->sync_tree()->device_color_space());
+ if (host_impl->pending_tree()) {
+ // The active tree's device color space shouldn't change until
+ // activation.
+ EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
+ }
+ }
+ }
+
+ DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
+ LayerTreeHostImpl::FrameData* frame_data,
+ DrawResult draw_result) override {
+ if (host_impl->active_tree()->source_frame_number() == 0) {
+ EXPECT_TRUE(space1_ == host_impl->active_tree()->device_color_space());
+ } else {
+ gfx::Rect root_damage_rect =
+ frame_data->render_passes.back()->damage_rect;
+ EXPECT_EQ(
+ gfx::Rect(
+ host_impl->active_tree()->root_layer_for_testing()->bounds()),
+ root_damage_rect);
+ EXPECT_TRUE(space2_ == host_impl->active_tree()->device_color_space());
+ EndTest();
+ }
+
+ return draw_result;
+ }
+
+ void AfterTest() override {}
+
+ private:
+ gfx::ColorSpace space1_;
+ gfx::ColorSpace space2_;
+ FakeContentLayerClient client_;
+ scoped_refptr<Layer> root_layer_;
+ scoped_refptr<Layer> child_layer_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceColorSpaceChange);
+
class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest {
public:
LayerTreeHostTestSetNextCommitForcesRedraw()

Powered by Google App Engine
This is Rietveld 408576698