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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 | 1300 |
1301 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) { | 1301 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) { |
1302 return layers_that_should_push_properties_.find(layer) != | 1302 return layers_that_should_push_properties_.find(layer) != |
1303 layers_that_should_push_properties_.end(); | 1303 layers_that_should_push_properties_.end(); |
1304 } | 1304 } |
1305 | 1305 |
1306 void LayerTreeHost::RegisterLayer(Layer* layer) { | 1306 void LayerTreeHost::RegisterLayer(Layer* layer) { |
1307 DCHECK(!LayerById(layer->id())); | 1307 DCHECK(!LayerById(layer->id())); |
1308 DCHECK(!in_paint_layer_contents_); | 1308 DCHECK(!in_paint_layer_contents_); |
1309 layer_id_map_[layer->id()] = layer; | 1309 layer_id_map_[layer->id()] = layer; |
1310 animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE); | 1310 animation_host_->RegisterElement(layer->id(), ElementListType::ACTIVE); |
1311 } | 1311 } |
1312 | 1312 |
1313 void LayerTreeHost::UnregisterLayer(Layer* layer) { | 1313 void LayerTreeHost::UnregisterLayer(Layer* layer) { |
1314 DCHECK(LayerById(layer->id())); | 1314 DCHECK(LayerById(layer->id())); |
1315 DCHECK(!in_paint_layer_contents_); | 1315 DCHECK(!in_paint_layer_contents_); |
1316 animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE); | 1316 animation_host_->UnregisterElement(layer->id(), ElementListType::ACTIVE); |
1317 RemoveLayerShouldPushProperties(layer); | 1317 RemoveLayerShouldPushProperties(layer); |
1318 layer_id_map_.erase(layer->id()); | 1318 layer_id_map_.erase(layer->id()); |
1319 } | 1319 } |
1320 | 1320 |
1321 bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const { | 1321 bool LayerTreeHost::IsElementInList(ElementId element_id, |
1322 return tree_type == LayerTreeType::ACTIVE && LayerById(layer_id); | 1322 ElementListType list_type) const { |
| 1323 return list_type == ElementListType::ACTIVE && LayerById(element_id); |
1323 } | 1324 } |
1324 | 1325 |
1325 void LayerTreeHost::SetMutatorsNeedCommit() { | 1326 void LayerTreeHost::SetMutatorsNeedCommit() { |
1326 SetNeedsCommit(); | 1327 SetNeedsCommit(); |
1327 } | 1328 } |
1328 | 1329 |
1329 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { | 1330 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { |
1330 property_trees_.needs_rebuild = true; | 1331 property_trees_.needs_rebuild = true; |
1331 } | 1332 } |
1332 | 1333 |
1333 void LayerTreeHost::SetLayerFilterMutated(int layer_id, | 1334 void LayerTreeHost::SetElementFilterMutated(ElementId element_id, |
1334 LayerTreeType tree_type, | 1335 ElementListType list_type, |
1335 const FilterOperations& filters) { | 1336 const FilterOperations& filters) { |
1336 Layer* layer = LayerById(layer_id); | 1337 Layer* layer = LayerById(element_id); |
1337 DCHECK(layer); | 1338 DCHECK(layer); |
1338 layer->OnFilterAnimated(filters); | 1339 layer->OnFilterAnimated(filters); |
1339 } | 1340 } |
1340 | 1341 |
1341 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, | 1342 void LayerTreeHost::SetElementOpacityMutated(ElementId element_id, |
1342 LayerTreeType tree_type, | 1343 ElementListType list_type, |
1343 float opacity) { | 1344 float opacity) { |
1344 Layer* layer = LayerById(layer_id); | 1345 Layer* layer = LayerById(element_id); |
1345 DCHECK(layer); | 1346 DCHECK(layer); |
1346 layer->OnOpacityAnimated(opacity); | 1347 layer->OnOpacityAnimated(opacity); |
1347 } | 1348 } |
1348 | 1349 |
1349 void LayerTreeHost::SetLayerTransformMutated(int layer_id, | 1350 void LayerTreeHost::SetElementTransformMutated( |
1350 LayerTreeType tree_type, | 1351 ElementId element_id, |
1351 const gfx::Transform& transform) { | 1352 ElementListType list_type, |
1352 Layer* layer = LayerById(layer_id); | 1353 const gfx::Transform& transform) { |
| 1354 Layer* layer = LayerById(element_id); |
1353 DCHECK(layer); | 1355 DCHECK(layer); |
1354 layer->OnTransformAnimated(transform); | 1356 layer->OnTransformAnimated(transform); |
1355 } | 1357 } |
1356 | 1358 |
1357 void LayerTreeHost::SetLayerScrollOffsetMutated( | 1359 void LayerTreeHost::SetElementScrollOffsetMutated( |
1358 int layer_id, | 1360 ElementId element_id, |
1359 LayerTreeType tree_type, | 1361 ElementListType list_type, |
1360 const gfx::ScrollOffset& scroll_offset) { | 1362 const gfx::ScrollOffset& scroll_offset) { |
1361 Layer* layer = LayerById(layer_id); | 1363 Layer* layer = LayerById(element_id); |
1362 DCHECK(layer); | 1364 DCHECK(layer); |
1363 layer->OnScrollOffsetAnimated(scroll_offset); | 1365 layer->OnScrollOffsetAnimated(scroll_offset); |
1364 } | 1366 } |
1365 | 1367 |
1366 void LayerTreeHost::LayerTransformIsPotentiallyAnimatingChanged( | 1368 void LayerTreeHost::ElementTransformIsPotentiallyAnimatingChanged( |
1367 int layer_id, | 1369 ElementId element_id, |
1368 LayerTreeType tree_type, | 1370 ElementListType list_type, |
1369 bool is_animating) { | 1371 bool is_animating) { |
1370 Layer* layer = LayerById(layer_id); | 1372 Layer* layer = LayerById(element_id); |
1371 DCHECK(layer); | 1373 DCHECK(layer); |
1372 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); | 1374 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); |
1373 } | 1375 } |
1374 | 1376 |
1375 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( | 1377 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( |
1376 int layer_id) const { | 1378 ElementId element_id) const { |
1377 Layer* layer = LayerById(layer_id); | 1379 Layer* layer = LayerById(element_id); |
1378 DCHECK(layer); | 1380 DCHECK(layer); |
1379 return layer->ScrollOffsetForAnimation(); | 1381 return layer->ScrollOffsetForAnimation(); |
1380 } | 1382 } |
1381 | 1383 |
1382 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( | 1384 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( |
1383 const Layer* layer) const { | 1385 const Layer* layer) const { |
1384 return animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id()); | 1386 return animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id()); |
1385 } | 1387 } |
1386 | 1388 |
1387 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const { | 1389 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const { |
1388 return animation_host_->IsAnimatingFilterProperty(layer->id(), | 1390 return animation_host_->IsAnimatingFilterProperty(layer->id(), |
1389 LayerTreeType::ACTIVE); | 1391 ElementListType::ACTIVE); |
1390 } | 1392 } |
1391 | 1393 |
1392 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const { | 1394 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const { |
1393 return animation_host_->IsAnimatingOpacityProperty(layer->id(), | 1395 return animation_host_->IsAnimatingOpacityProperty(layer->id(), |
1394 LayerTreeType::ACTIVE); | 1396 ElementListType::ACTIVE); |
1395 } | 1397 } |
1396 | 1398 |
1397 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const { | 1399 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const { |
1398 return animation_host_->IsAnimatingTransformProperty(layer->id(), | 1400 return animation_host_->IsAnimatingTransformProperty(layer->id(), |
1399 LayerTreeType::ACTIVE); | 1401 ElementListType::ACTIVE); |
1400 } | 1402 } |
1401 | 1403 |
1402 bool LayerTreeHost::HasPotentiallyRunningFilterAnimation( | 1404 bool LayerTreeHost::HasPotentiallyRunningFilterAnimation( |
1403 const Layer* layer) const { | 1405 const Layer* layer) const { |
1404 return animation_host_->HasPotentiallyRunningFilterAnimation( | 1406 return animation_host_->HasPotentiallyRunningFilterAnimation( |
1405 layer->id(), LayerTreeType::ACTIVE); | 1407 layer->id(), ElementListType::ACTIVE); |
1406 } | 1408 } |
1407 | 1409 |
1408 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation( | 1410 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation( |
1409 const Layer* layer) const { | 1411 const Layer* layer) const { |
1410 return animation_host_->HasPotentiallyRunningOpacityAnimation( | 1412 return animation_host_->HasPotentiallyRunningOpacityAnimation( |
1411 layer->id(), LayerTreeType::ACTIVE); | 1413 layer->id(), ElementListType::ACTIVE); |
1412 } | 1414 } |
1413 | 1415 |
1414 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation( | 1416 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation( |
1415 const Layer* layer) const { | 1417 const Layer* layer) const { |
1416 return animation_host_->HasPotentiallyRunningTransformAnimation( | 1418 return animation_host_->HasPotentiallyRunningTransformAnimation( |
1417 layer->id(), LayerTreeType::ACTIVE); | 1419 layer->id(), ElementListType::ACTIVE); |
1418 } | 1420 } |
1419 | 1421 |
1420 bool LayerTreeHost::HasOnlyTranslationTransforms(const Layer* layer) const { | 1422 bool LayerTreeHost::HasOnlyTranslationTransforms(const Layer* layer) const { |
1421 return animation_host_->HasOnlyTranslationTransforms(layer->id(), | 1423 return animation_host_->HasOnlyTranslationTransforms(layer->id(), |
1422 LayerTreeType::ACTIVE); | 1424 ElementListType::ACTIVE); |
1423 } | 1425 } |
1424 | 1426 |
1425 bool LayerTreeHost::MaximumTargetScale(const Layer* layer, | 1427 bool LayerTreeHost::MaximumTargetScale(const Layer* layer, |
1426 float* max_scale) const { | 1428 float* max_scale) const { |
1427 return animation_host_->MaximumTargetScale(layer->id(), LayerTreeType::ACTIVE, | 1429 return animation_host_->MaximumTargetScale( |
1428 max_scale); | 1430 layer->id(), ElementListType::ACTIVE, max_scale); |
1429 } | 1431 } |
1430 | 1432 |
1431 bool LayerTreeHost::AnimationStartScale(const Layer* layer, | 1433 bool LayerTreeHost::AnimationStartScale(const Layer* layer, |
1432 float* start_scale) const { | 1434 float* start_scale) const { |
1433 return animation_host_->AnimationStartScale( | 1435 return animation_host_->AnimationStartScale( |
1434 layer->id(), LayerTreeType::ACTIVE, start_scale); | 1436 layer->id(), ElementListType::ACTIVE, start_scale); |
1435 } | 1437 } |
1436 | 1438 |
1437 bool LayerTreeHost::HasAnyAnimationTargetingProperty( | 1439 bool LayerTreeHost::HasAnyAnimationTargetingProperty( |
1438 const Layer* layer, | 1440 const Layer* layer, |
1439 TargetProperty::Type property) const { | 1441 TargetProperty::Type property) const { |
1440 return animation_host_->HasAnyAnimationTargetingProperty(layer->id(), | 1442 return animation_host_->HasAnyAnimationTargetingProperty(layer->id(), |
1441 property); | 1443 property); |
1442 } | 1444 } |
1443 | 1445 |
1444 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const { | 1446 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 int seq_num = property_trees_.sequence_number; | 1653 int seq_num = property_trees_.sequence_number; |
1652 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { | 1654 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { |
1653 layer->set_property_tree_sequence_number(seq_num); | 1655 layer->set_property_tree_sequence_number(seq_num); |
1654 }); | 1656 }); |
1655 | 1657 |
1656 surface_id_namespace_ = proto.surface_id_namespace(); | 1658 surface_id_namespace_ = proto.surface_id_namespace(); |
1657 next_surface_sequence_ = proto.next_surface_sequence(); | 1659 next_surface_sequence_ = proto.next_surface_sequence(); |
1658 } | 1660 } |
1659 | 1661 |
1660 } // namespace cc | 1662 } // namespace cc |
OLD | NEW |