OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 layer_tree_host()->SetRootLayer(root_layer_); | 728 layer_tree_host()->SetRootLayer(root_layer_); |
729 layer_tree_host()->SetViewportSize(bounds_); | 729 layer_tree_host()->SetViewportSize(bounds_); |
730 PostSetNeedsCommitToMainThread(); | 730 PostSetNeedsCommitToMainThread(); |
731 } | 731 } |
732 | 732 |
733 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 733 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
734 LayerTreeHostImpl::FrameData* frame_data, | 734 LayerTreeHostImpl::FrameData* frame_data, |
735 DrawResult draw_result) override { | 735 DrawResult draw_result) override { |
736 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 736 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
737 | 737 |
738 gfx::RectF root_damage_rect; | 738 gfx::Rect root_damage_rect; |
739 if (!frame_data->render_passes.empty()) | 739 if (!frame_data->render_passes.empty()) |
740 root_damage_rect = frame_data->render_passes.back()->damage_rect; | 740 root_damage_rect = frame_data->render_passes.back()->damage_rect; |
741 | 741 |
742 if (!num_draws_) { | 742 if (!num_draws_) { |
743 // If this is the first frame, expect full frame damage. | 743 // If this is the first frame, expect full frame damage. |
744 EXPECT_EQ(root_damage_rect, gfx::Rect(bounds_)); | 744 EXPECT_EQ(root_damage_rect, gfx::Rect(bounds_)); |
745 } else { | 745 } else { |
746 // Check that invalid_rect_ is indeed repainted. | 746 // Check that invalid_rect_ is indeed repainted. |
747 EXPECT_TRUE(root_damage_rect.Contains(invalid_rect_)); | 747 EXPECT_TRUE(root_damage_rect.Contains(invalid_rect_)); |
748 } | 748 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 974 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
975 if (num_draws_ == 3) | 975 if (num_draws_ == 3) |
976 host_impl->SetNeedsRedrawRect(invalid_rect_); | 976 host_impl->SetNeedsRedrawRect(invalid_rect_); |
977 } | 977 } |
978 | 978 |
979 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 979 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
980 LayerTreeHostImpl::FrameData* frame_data, | 980 LayerTreeHostImpl::FrameData* frame_data, |
981 DrawResult draw_result) override { | 981 DrawResult draw_result) override { |
982 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 982 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
983 | 983 |
984 gfx::RectF root_damage_rect; | 984 gfx::Rect root_damage_rect; |
985 if (!frame_data->render_passes.empty()) | 985 if (!frame_data->render_passes.empty()) |
986 root_damage_rect = frame_data->render_passes.back()->damage_rect; | 986 root_damage_rect = frame_data->render_passes.back()->damage_rect; |
987 | 987 |
988 switch (num_draws_) { | 988 switch (num_draws_) { |
989 case 0: | 989 case 0: |
990 EXPECT_EQ(gfx::Rect(bounds_), root_damage_rect); | 990 EXPECT_EQ(gfx::Rect(bounds_), root_damage_rect); |
991 break; | 991 break; |
992 case 1: | 992 case 1: |
993 case 2: | 993 case 2: |
994 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect); | 994 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 LayerTreeHostTest::SetupTree(); | 1074 LayerTreeHostTest::SetupTree(); |
1075 } | 1075 } |
1076 | 1076 |
1077 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1077 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1078 | 1078 |
1079 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 1079 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
1080 LayerTreeHostImpl::FrameData* frame_data, | 1080 LayerTreeHostImpl::FrameData* frame_data, |
1081 DrawResult draw_result) override { | 1081 DrawResult draw_result) override { |
1082 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 1082 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
1083 | 1083 |
1084 gfx::RectF root_damage_rect; | 1084 gfx::Rect root_damage_rect; |
1085 if (!frame_data->render_passes.empty()) | 1085 if (!frame_data->render_passes.empty()) |
1086 root_damage_rect = frame_data->render_passes.back()->damage_rect; | 1086 root_damage_rect = frame_data->render_passes.back()->damage_rect; |
1087 | 1087 |
1088 // The first time, the whole view needs be drawn. | 1088 // The first time, the whole view needs be drawn. |
1089 // Afterwards, just the opacity of surface_layer1 is changed a few times, | 1089 // Afterwards, just the opacity of surface_layer1 is changed a few times, |
1090 // and each damage should be the bounding box of it and its child. If this | 1090 // and each damage should be the bounding box of it and its child. If this |
1091 // was working improperly, the damage might not include its childs bounding | 1091 // was working improperly, the damage might not include its childs bounding |
1092 // box. | 1092 // box. |
1093 switch (host_impl->active_tree()->source_frame_number()) { | 1093 switch (host_impl->active_tree()->source_frame_number()) { |
1094 case 0: | 1094 case 0: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 child_layer_impl->AddTilingUntilNextDraw(1.3f); | 1178 child_layer_impl->AddTilingUntilNextDraw(1.3f); |
1179 } | 1179 } |
1180 | 1180 |
1181 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1181 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1182 | 1182 |
1183 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 1183 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
1184 LayerTreeHostImpl::FrameData* frame_data, | 1184 LayerTreeHostImpl::FrameData* frame_data, |
1185 DrawResult draw_result) override { | 1185 DrawResult draw_result) override { |
1186 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 1186 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
1187 | 1187 |
1188 gfx::RectF root_damage_rect; | 1188 gfx::Rect root_damage_rect; |
1189 if (!frame_data->render_passes.empty()) | 1189 if (!frame_data->render_passes.empty()) |
1190 root_damage_rect = frame_data->render_passes.back()->damage_rect; | 1190 root_damage_rect = frame_data->render_passes.back()->damage_rect; |
1191 | 1191 |
1192 // The first time, the whole view needs be drawn. | 1192 // The first time, the whole view needs be drawn. |
1193 // Afterwards, just the opacity of surface_layer1 is changed a few times, | 1193 // Afterwards, just the opacity of surface_layer1 is changed a few times, |
1194 // and each damage should be the bounding box of it and its child. If this | 1194 // and each damage should be the bounding box of it and its child. If this |
1195 // was working improperly, the damage might not include its childs bounding | 1195 // was working improperly, the damage might not include its childs bounding |
1196 // box. | 1196 // box. |
1197 switch (host_impl->active_tree()->source_frame_number()) { | 1197 switch (host_impl->active_tree()->source_frame_number()) { |
1198 case 0: | 1198 case 0: |
(...skipping 5052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6251 ScrollAndScaleSet scale_info_; | 6251 ScrollAndScaleSet scale_info_; |
6252 ScrollAndScaleSet no_op_info_; | 6252 ScrollAndScaleSet no_op_info_; |
6253 bool requested_update_layers_; | 6253 bool requested_update_layers_; |
6254 int commit_count_; | 6254 int commit_count_; |
6255 }; | 6255 }; |
6256 | 6256 |
6257 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); | 6257 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); |
6258 | 6258 |
6259 } // namespace | 6259 } // namespace |
6260 } // namespace cc | 6260 } // namespace cc |
OLD | NEW |