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() |