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

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

Issue 2360003002: cc: Compute SurfacePropertyChanged without depending on owning layer (Closed)
Patch Set: Address review comment 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/damage_tracker_unittest.cc ('k') | cc/trees/layer_tree_impl.cc » ('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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 } 949 }
950 } 950 }
951 951
952 void AfterTest() override {} 952 void AfterTest() override {}
953 953
954 int index_; 954 int index_;
955 }; 955 };
956 956
957 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDamageWithReplica); 957 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDamageWithReplica);
958 958
959 class LayerTreeHostTestSurfaceDamage : public LayerTreeHostTest {
960 protected:
961 void SetupTree() override {
962 root_ = Layer::Create();
963 child_ = Layer::Create();
964 grand_child_ = Layer::Create();
965
966 layer_tree()->SetRootLayer(root_);
967 root_->AddChild(child_);
968 child_->AddChild(grand_child_);
969
970 root_->SetBounds(gfx::Size(50, 50));
971 root_->SetMasksToBounds(true);
972 child_->SetForceRenderSurfaceForTesting(true);
973
974 LayerTreeHostTest::SetupTree();
975 }
976
977 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
978
979 void DidCommit() override {
980 switch (layer_tree_host()->SourceFrameNumber()) {
981 case 1:
982 grand_child_->SetOpacity(0.9f);
983 break;
984 case 2:
985 root_->SetBounds(gfx::Size(20, 20));
986 break;
987 case 3:
988 child_->SetDoubleSided(false);
989 break;
990 }
991 }
992
993 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl,
994 LayerTreeHostImpl::FrameData* frame_data,
995 DrawResult draw_result) override {
996 LayerImpl* root_impl = impl->active_tree()->LayerById(root_->id());
997 LayerImpl* child_impl = impl->active_tree()->LayerById(child_->id());
998 switch (impl->active_tree()->source_frame_number()) {
999 case 0:
1000 EXPECT_TRUE(root_impl->render_surface()->AncestorPropertyChanged());
1001 EXPECT_TRUE(child_impl->render_surface()->AncestorPropertyChanged());
1002 PostSetNeedsCommitToMainThread();
1003 break;
1004 case 1:
1005 EXPECT_FALSE(root_impl->render_surface()->AncestorPropertyChanged());
1006 EXPECT_FALSE(child_impl->render_surface()->AncestorPropertyChanged());
1007 PostSetNeedsCommitToMainThread();
1008 break;
1009 case 2:
1010 EXPECT_TRUE(root_impl->render_surface()->AncestorPropertyChanged());
1011 EXPECT_TRUE(child_impl->render_surface()->AncestorPropertyChanged());
1012 PostSetNeedsCommitToMainThread();
1013 break;
1014 case 3:
1015 EXPECT_FALSE(root_impl->render_surface()->AncestorPropertyChanged());
1016 EXPECT_TRUE(child_impl->render_surface()->AncestorPropertyChanged());
1017 EndTest();
1018 PostSetNeedsCommitToMainThread();
1019 break;
1020 case 4:
1021 EXPECT_FALSE(root_impl->render_surface()->AncestorPropertyChanged());
1022 EXPECT_FALSE(child_impl->render_surface()->AncestorPropertyChanged());
1023 EndTest();
1024 break;
1025 }
1026
1027 return draw_result;
1028 }
1029
1030 void AfterTest() override {}
1031
1032 private:
1033 scoped_refptr<Layer> root_;
1034 scoped_refptr<Layer> child_;
1035 scoped_refptr<Layer> grand_child_;
1036 };
1037
1038 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceDamage);
1039
959 // Verify damage status of property trees is preserved after commit. 1040 // Verify damage status of property trees is preserved after commit.
960 class LayerTreeHostTestPropertyTreesChangedSync : public LayerTreeHostTest { 1041 class LayerTreeHostTestPropertyTreesChangedSync : public LayerTreeHostTest {
961 protected: 1042 protected:
962 void SetupTree() override { 1043 void SetupTree() override {
963 root_ = Layer::Create(); 1044 root_ = Layer::Create();
964 child_ = Layer::Create(); 1045 child_ = Layer::Create();
965 // This is to force the child to create a transform and effect node. 1046 // This is to force the child to create a transform and effect node.
966 child_->SetForceRenderSurfaceForTesting(true); 1047 child_->SetForceRenderSurfaceForTesting(true);
967 root_->AddChild(child_); 1048 root_->AddChild(child_);
968 layer_tree()->SetRootLayer(root_); 1049 layer_tree()->SetRootLayer(root_);
(...skipping 6204 matching lines...) Expand 10 before | Expand all | Expand 10 after
7173 EndTest(); 7254 EndTest();
7174 } 7255 }
7175 7256
7176 void AfterTest() override {} 7257 void AfterTest() override {}
7177 }; 7258 };
7178 7259
7179 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); 7260 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources);
7180 7261
7181 } // namespace 7262 } // namespace
7182 } // namespace cc 7263 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/damage_tracker_unittest.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698