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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 void AfterTest() override {} | 1173 void AfterTest() override {} |
1174 | 1174 |
1175 private: | 1175 private: |
1176 int index_; | 1176 int index_; |
1177 scoped_refptr<Layer> root_; | 1177 scoped_refptr<Layer> root_; |
1178 scoped_refptr<Layer> child_; | 1178 scoped_refptr<Layer> child_; |
1179 }; | 1179 }; |
1180 | 1180 |
1181 SINGLE_THREAD_TEST_F(LayerTreeHostTestPropertyTreesChangedSync); | 1181 SINGLE_THREAD_TEST_F(LayerTreeHostTestPropertyTreesChangedSync); |
1182 | 1182 |
| 1183 class LayerTreeHostTestAnimationFilterMutatedNotUsingLayerLists |
| 1184 : public LayerTreeHostTest { |
| 1185 public: |
| 1186 void InitializeSettings(LayerTreeSettings* settings) override { |
| 1187 settings->use_layer_lists = false; |
| 1188 } |
| 1189 |
| 1190 protected: |
| 1191 void SetupTree() override { |
| 1192 root_ = Layer::Create(); |
| 1193 layer_tree_host()->SetRootLayer(root_); |
| 1194 LayerTreeHostTest::SetupTree(); |
| 1195 } |
| 1196 |
| 1197 void BeginTest() override { |
| 1198 FilterOperations filters; |
| 1199 EXPECT_EQ(FilterOperations(), root_->filters()); |
| 1200 filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
| 1201 layer_tree_host()->SetElementFilterMutated( |
| 1202 root_->element_id(), ElementListType::ACTIVE, filters); |
| 1203 // When not using layer lists, filters are just stored directly on the |
| 1204 // layer. |
| 1205 EXPECT_EQ(filters, root_->filters()); |
| 1206 EndTest(); |
| 1207 } |
| 1208 |
| 1209 void AfterTest() override {} |
| 1210 |
| 1211 private: |
| 1212 scoped_refptr<Layer> root_; |
| 1213 }; |
| 1214 |
| 1215 SINGLE_THREAD_TEST_F(LayerTreeHostTestAnimationFilterMutatedNotUsingLayerLists); |
| 1216 |
| 1217 class LayerTreeHostTestAnimationFilterMutatedUsingLayerLists |
| 1218 : public LayerTreeHostTest { |
| 1219 public: |
| 1220 void InitializeSettings(LayerTreeSettings* settings) override { |
| 1221 settings->use_layer_lists = true; |
| 1222 } |
| 1223 |
| 1224 protected: |
| 1225 void SetupTree() override { |
| 1226 root_ = Layer::Create(); |
| 1227 layer_tree_host()->SetRootLayer(root_); |
| 1228 LayerTreeHostTest::SetupTree(); |
| 1229 } |
| 1230 |
| 1231 void BeginTest() override { |
| 1232 // Insert a dummy effect node to observe its mutation. This would |
| 1233 // normally have been created by PaintArtifactCompositor. |
| 1234 int effect_node_id = |
| 1235 layer_tree_host()->property_trees()->effect_tree.Insert( |
| 1236 EffectNode(), EffectTree::kInvalidNodeId); |
| 1237 layer_tree_host() |
| 1238 ->property_trees() |
| 1239 ->element_id_to_effect_node_index[root_->element_id()] = effect_node_id; |
| 1240 |
| 1241 EXPECT_EQ(FilterOperations(), root_->filters()); |
| 1242 EXPECT_EQ(FilterOperations(), |
| 1243 layer_tree_host() |
| 1244 ->property_trees() |
| 1245 ->effect_tree.FindNodeFromElementId(root_->element_id()) |
| 1246 ->filters); |
| 1247 |
| 1248 FilterOperations filters; |
| 1249 filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
| 1250 layer_tree_host()->SetElementFilterMutated( |
| 1251 root_->element_id(), ElementListType::ACTIVE, filters); |
| 1252 |
| 1253 // When using layer lists, we don't have to store the filters on the layer. |
| 1254 EXPECT_EQ(FilterOperations(), root_->filters()); |
| 1255 // The filter should have been set directly on the effect node instead. |
| 1256 EXPECT_EQ(filters, |
| 1257 layer_tree_host() |
| 1258 ->property_trees() |
| 1259 ->effect_tree.FindNodeFromElementId(root_->element_id()) |
| 1260 ->filters); |
| 1261 EndTest(); |
| 1262 } |
| 1263 |
| 1264 void AfterTest() override {} |
| 1265 |
| 1266 private: |
| 1267 scoped_refptr<Layer> root_; |
| 1268 }; |
| 1269 |
| 1270 SINGLE_THREAD_TEST_F(LayerTreeHostTestAnimationFilterMutatedUsingLayerLists); |
| 1271 |
1183 class LayerTreeHostTestEffectTreeSync : public LayerTreeHostTest { | 1272 class LayerTreeHostTestEffectTreeSync : public LayerTreeHostTest { |
1184 protected: | 1273 protected: |
1185 void SetupTree() override { | 1274 void SetupTree() override { |
1186 root_ = Layer::Create(); | 1275 root_ = Layer::Create(); |
1187 layer_tree_host()->SetRootLayer(root_); | 1276 layer_tree_host()->SetRootLayer(root_); |
1188 blur_filter_.Append(FilterOperation::CreateBlurFilter(0.5f)); | 1277 blur_filter_.Append(FilterOperation::CreateBlurFilter(0.5f)); |
1189 brightness_filter_.Append(FilterOperation::CreateBrightnessFilter(0.25f)); | 1278 brightness_filter_.Append(FilterOperation::CreateBrightnessFilter(0.25f)); |
1190 sepia_filter_.Append(FilterOperation::CreateSepiaFilter(0.75f)); | 1279 sepia_filter_.Append(FilterOperation::CreateSepiaFilter(0.75f)); |
1191 LayerTreeHostTest::SetupTree(); | 1280 LayerTreeHostTest::SetupTree(); |
1192 } | 1281 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 // to be updated at draw time. | 1459 // to be updated at draw time. |
1371 class LayerTreeHostTestTransformTreeDamageIsUpdated : public LayerTreeHostTest { | 1460 class LayerTreeHostTestTransformTreeDamageIsUpdated : public LayerTreeHostTest { |
1372 protected: | 1461 protected: |
1373 void SetupTree() override { | 1462 void SetupTree() override { |
1374 root_ = Layer::Create(); | 1463 root_ = Layer::Create(); |
1375 child_ = Layer::Create(); | 1464 child_ = Layer::Create(); |
1376 grand_child_ = Layer::Create(); | 1465 grand_child_ = Layer::Create(); |
1377 | 1466 |
1378 root_->SetBounds(gfx::Size(50, 50)); | 1467 root_->SetBounds(gfx::Size(50, 50)); |
1379 | 1468 |
1380 // Make sure child is registerd for animation. | 1469 // Make sure child is registered for animation. |
1381 child_->SetElementId(ElementId(2)); | 1470 child_->SetElementId(ElementId(2)); |
1382 | 1471 |
1383 // Make sure child and grand_child have transform nodes. | 1472 // Make sure child and grand_child have transform nodes. |
1384 gfx::Transform rotation; | 1473 gfx::Transform rotation; |
1385 rotation.RotateAboutZAxis(45.0); | 1474 rotation.RotateAboutZAxis(45.0); |
1386 child_->SetTransform(rotation); | 1475 child_->SetTransform(rotation); |
1387 grand_child_->SetTransform(rotation); | 1476 grand_child_->SetTransform(rotation); |
1388 | 1477 |
1389 root_->AddChild(child_); | 1478 root_->AddChild(child_); |
1390 child_->AddChild(grand_child_); | 1479 child_->AddChild(grand_child_); |
(...skipping 6345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7736 void AfterTest() override {} | 7825 void AfterTest() override {} |
7737 | 7826 |
7738 private: | 7827 private: |
7739 bool received_ack_ = false; | 7828 bool received_ack_ = false; |
7740 }; | 7829 }; |
7741 | 7830 |
7742 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); | 7831 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); |
7743 | 7832 |
7744 } // namespace | 7833 } // namespace |
7745 } // namespace cc | 7834 } // namespace cc |
OLD | NEW |