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

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

Issue 2049063002: Revert of Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/layer_tree_host.h ('k') | cc/trees/layer_tree_host_common_unittest.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 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 } 942 }
943 943
944 void LayerTreeHost::ReportFixedRasterScaleUseCounters( 944 void LayerTreeHost::ReportFixedRasterScaleUseCounters(
945 bool has_fixed_raster_scale_blurry_content, 945 bool has_fixed_raster_scale_blurry_content,
946 bool has_fixed_raster_scale_potential_performance_regression) { 946 bool has_fixed_raster_scale_potential_performance_regression) {
947 client_->ReportFixedRasterScaleUseCounters( 947 client_->ReportFixedRasterScaleUseCounters(
948 has_fixed_raster_scale_blurry_content, 948 has_fixed_raster_scale_blurry_content,
949 has_fixed_raster_scale_potential_performance_regression); 949 has_fixed_raster_scale_potential_performance_regression);
950 } 950 }
951 951
952 static void SetElementIdForTesting(Layer* layer) {
953 layer->SetElementId(LayerIdToElementIdForTesting(layer->id()));
954 }
955
956 void LayerTreeHost::SetElementIdsForTesting() {
957 LayerTreeHostCommon::CallFunctionForEveryLayer(this, SetElementIdForTesting);
958 }
959
960 bool LayerTreeHost::UsingSharedMemoryResources() { 952 bool LayerTreeHost::UsingSharedMemoryResources() {
961 return GetRendererCapabilities().using_shared_memory_resources; 953 return GetRendererCapabilities().using_shared_memory_resources;
962 } 954 }
963 955
964 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { 956 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {
965 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number", 957 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number",
966 source_frame_number()); 958 source_frame_number());
967 959
968 UpdateHudLayer(); 960 UpdateHudLayer();
969 961
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 return SurfaceSequence(surface_id_namespace_, next_surface_sequence_++); 1260 return SurfaceSequence(surface_id_namespace_, next_surface_sequence_++);
1269 } 1261 }
1270 1262
1271 void LayerTreeHost::SetLayerTreeMutator( 1263 void LayerTreeHost::SetLayerTreeMutator(
1272 std::unique_ptr<LayerTreeMutator> mutator) { 1264 std::unique_ptr<LayerTreeMutator> mutator) {
1273 proxy_->SetMutator(std::move(mutator)); 1265 proxy_->SetMutator(std::move(mutator));
1274 } 1266 }
1275 1267
1276 Layer* LayerTreeHost::LayerById(int id) const { 1268 Layer* LayerTreeHost::LayerById(int id) const {
1277 LayerIdMap::const_iterator iter = layer_id_map_.find(id); 1269 LayerIdMap::const_iterator iter = layer_id_map_.find(id);
1278 return iter != layer_id_map_.end() ? iter->second : nullptr; 1270 return iter != layer_id_map_.end() ? iter->second : NULL;
1279 }
1280
1281 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const {
1282 ElementLayersMap::const_iterator iter = element_layers_map_.find(element_id);
1283 return iter != element_layers_map_.end() ? iter->second : nullptr;
1284 }
1285
1286 void LayerTreeHost::AddToElementMap(Layer* layer) {
1287 if (!layer->element_id())
1288 return;
1289
1290 element_layers_map_[layer->element_id()] = layer;
1291 }
1292
1293 void LayerTreeHost::RemoveFromElementMap(Layer* layer) {
1294 if (!layer->element_id())
1295 return;
1296
1297 element_layers_map_.erase(layer->element_id());
1298 } 1271 }
1299 1272
1300 void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) { 1273 void LayerTreeHost::AddLayerShouldPushProperties(Layer* layer) {
1301 layers_that_should_push_properties_.insert(layer); 1274 layers_that_should_push_properties_.insert(layer);
1302 } 1275 }
1303 1276
1304 void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) { 1277 void LayerTreeHost::RemoveLayerShouldPushProperties(Layer* layer) {
1305 layers_that_should_push_properties_.erase(layer); 1278 layers_that_should_push_properties_.erase(layer);
1306 } 1279 }
1307 1280
1308 std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() { 1281 std::unordered_set<Layer*>& LayerTreeHost::LayersThatShouldPushProperties() {
1309 return layers_that_should_push_properties_; 1282 return layers_that_should_push_properties_;
1310 } 1283 }
1311 1284
1312 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) { 1285 bool LayerTreeHost::LayerNeedsPushPropertiesForTesting(Layer* layer) {
1313 return layers_that_should_push_properties_.find(layer) != 1286 return layers_that_should_push_properties_.find(layer) !=
1314 layers_that_should_push_properties_.end(); 1287 layers_that_should_push_properties_.end();
1315 } 1288 }
1316 1289
1317 void LayerTreeHost::RegisterLayer(Layer* layer) { 1290 void LayerTreeHost::RegisterLayer(Layer* layer) {
1318 DCHECK(!LayerById(layer->id())); 1291 DCHECK(!LayerById(layer->id()));
1319 DCHECK(!in_paint_layer_contents_); 1292 DCHECK(!in_paint_layer_contents_);
1320 layer_id_map_[layer->id()] = layer; 1293 layer_id_map_[layer->id()] = layer;
1321 if (layer->element_id()) { 1294 animation_host_->RegisterElement(layer->id(), ElementListType::ACTIVE);
1322 animation_host_->RegisterElement(layer->element_id(),
1323 ElementListType::ACTIVE);
1324 }
1325 } 1295 }
1326 1296
1327 void LayerTreeHost::UnregisterLayer(Layer* layer) { 1297 void LayerTreeHost::UnregisterLayer(Layer* layer) {
1328 DCHECK(LayerById(layer->id())); 1298 DCHECK(LayerById(layer->id()));
1329 DCHECK(!in_paint_layer_contents_); 1299 DCHECK(!in_paint_layer_contents_);
1330 if (layer->element_id()) { 1300 animation_host_->UnregisterElement(layer->id(), ElementListType::ACTIVE);
1331 animation_host_->UnregisterElement(layer->element_id(),
1332 ElementListType::ACTIVE);
1333 }
1334 RemoveLayerShouldPushProperties(layer); 1301 RemoveLayerShouldPushProperties(layer);
1335 layer_id_map_.erase(layer->id()); 1302 layer_id_map_.erase(layer->id());
1336 } 1303 }
1337 1304
1338 bool LayerTreeHost::IsElementInList(ElementId element_id, 1305 bool LayerTreeHost::IsElementInList(ElementId element_id,
1339 ElementListType list_type) const { 1306 ElementListType list_type) const {
1340 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); 1307 return list_type == ElementListType::ACTIVE && LayerById(element_id);
1341 } 1308 }
1342 1309
1343 void LayerTreeHost::SetMutatorsNeedCommit() { 1310 void LayerTreeHost::SetMutatorsNeedCommit() {
1344 SetNeedsCommit(); 1311 SetNeedsCommit();
1345 } 1312 }
1346 1313
1347 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { 1314 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() {
1348 property_trees_.needs_rebuild = true; 1315 property_trees_.needs_rebuild = true;
1349 } 1316 }
1350 1317
1351 void LayerTreeHost::SetElementFilterMutated(ElementId element_id, 1318 void LayerTreeHost::SetElementFilterMutated(ElementId element_id,
1352 ElementListType list_type, 1319 ElementListType list_type,
1353 const FilterOperations& filters) { 1320 const FilterOperations& filters) {
1354 Layer* layer = LayerByElementId(element_id); 1321 Layer* layer = LayerById(element_id);
1355 DCHECK(layer); 1322 DCHECK(layer);
1356 layer->OnFilterAnimated(filters); 1323 layer->OnFilterAnimated(filters);
1357 } 1324 }
1358 1325
1359 void LayerTreeHost::SetElementOpacityMutated(ElementId element_id, 1326 void LayerTreeHost::SetElementOpacityMutated(ElementId element_id,
1360 ElementListType list_type, 1327 ElementListType list_type,
1361 float opacity) { 1328 float opacity) {
1362 Layer* layer = LayerByElementId(element_id); 1329 Layer* layer = LayerById(element_id);
1363 DCHECK(layer); 1330 DCHECK(layer);
1364 layer->OnOpacityAnimated(opacity); 1331 layer->OnOpacityAnimated(opacity);
1365 } 1332 }
1366 1333
1367 void LayerTreeHost::SetElementTransformMutated( 1334 void LayerTreeHost::SetElementTransformMutated(
1368 ElementId element_id, 1335 ElementId element_id,
1369 ElementListType list_type, 1336 ElementListType list_type,
1370 const gfx::Transform& transform) { 1337 const gfx::Transform& transform) {
1371 Layer* layer = LayerByElementId(element_id); 1338 Layer* layer = LayerById(element_id);
1372 DCHECK(layer); 1339 DCHECK(layer);
1373 layer->OnTransformAnimated(transform); 1340 layer->OnTransformAnimated(transform);
1374 } 1341 }
1375 1342
1376 void LayerTreeHost::SetElementScrollOffsetMutated( 1343 void LayerTreeHost::SetElementScrollOffsetMutated(
1377 ElementId element_id, 1344 ElementId element_id,
1378 ElementListType list_type, 1345 ElementListType list_type,
1379 const gfx::ScrollOffset& scroll_offset) { 1346 const gfx::ScrollOffset& scroll_offset) {
1380 Layer* layer = LayerByElementId(element_id); 1347 Layer* layer = LayerById(element_id);
1381 DCHECK(layer); 1348 DCHECK(layer);
1382 layer->OnScrollOffsetAnimated(scroll_offset); 1349 layer->OnScrollOffsetAnimated(scroll_offset);
1383 } 1350 }
1384 1351
1385 void LayerTreeHost::ElementTransformIsAnimatingChanged( 1352 void LayerTreeHost::ElementTransformIsAnimatingChanged(
1386 ElementId element_id, 1353 ElementId element_id,
1387 ElementListType list_type, 1354 ElementListType list_type,
1388 AnimationChangeType change_type, 1355 AnimationChangeType change_type,
1389 bool is_animating) { 1356 bool is_animating) {
1390 Layer* layer = LayerByElementId(element_id); 1357 Layer* layer = LayerById(element_id);
1391 if (layer) { 1358 if (layer) {
1392 switch (change_type) { 1359 switch (change_type) {
1393 case AnimationChangeType::POTENTIAL: 1360 case AnimationChangeType::POTENTIAL:
1394 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); 1361 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating);
1395 break; 1362 break;
1396 case AnimationChangeType::RUNNING: 1363 case AnimationChangeType::RUNNING:
1397 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); 1364 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating);
1398 break; 1365 break;
1399 case AnimationChangeType::BOTH: 1366 case AnimationChangeType::BOTH:
1400 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); 1367 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating);
1401 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); 1368 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating);
1402 break; 1369 break;
1403 } 1370 }
1404 } 1371 }
1405 } 1372 }
1406 1373
1407 void LayerTreeHost::ElementOpacityIsAnimatingChanged( 1374 void LayerTreeHost::ElementOpacityIsAnimatingChanged(
1408 ElementId element_id, 1375 ElementId element_id,
1409 ElementListType list_type, 1376 ElementListType list_type,
1410 AnimationChangeType change_type, 1377 AnimationChangeType change_type,
1411 bool is_animating) { 1378 bool is_animating) {
1412 Layer* layer = LayerByElementId(element_id); 1379 Layer* layer = LayerById(element_id);
1413 if (layer) { 1380 if (layer) {
1414 switch (change_type) { 1381 switch (change_type) {
1415 case AnimationChangeType::POTENTIAL: 1382 case AnimationChangeType::POTENTIAL:
1416 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); 1383 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating);
1417 break; 1384 break;
1418 case AnimationChangeType::RUNNING: 1385 case AnimationChangeType::RUNNING:
1419 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); 1386 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating);
1420 break; 1387 break;
1421 case AnimationChangeType::BOTH: 1388 case AnimationChangeType::BOTH:
1422 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); 1389 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating);
1423 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); 1390 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating);
1424 break; 1391 break;
1425 } 1392 }
1426 } 1393 }
1427 } 1394 }
1428 1395
1429 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( 1396 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation(
1430 ElementId element_id) const { 1397 ElementId element_id) const {
1431 Layer* layer = LayerByElementId(element_id); 1398 Layer* layer = LayerById(element_id);
1432 DCHECK(layer); 1399 DCHECK(layer);
1433 return layer->ScrollOffsetForAnimation(); 1400 return layer->ScrollOffsetForAnimation();
1434 } 1401 }
1435 1402
1436 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( 1403 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted(
1437 const Layer* layer) const { 1404 const Layer* layer) const {
1438 return animation_host_->ScrollOffsetAnimationWasInterrupted( 1405 return animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id());
1439 layer->element_id());
1440 } 1406 }
1441 1407
1442 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const { 1408 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const {
1443 return animation_host_->IsAnimatingFilterProperty(layer->element_id(), 1409 return animation_host_->IsAnimatingFilterProperty(layer->id(),
1444 ElementListType::ACTIVE); 1410 ElementListType::ACTIVE);
1445 } 1411 }
1446 1412
1447 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const { 1413 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const {
1448 return animation_host_->IsAnimatingOpacityProperty(layer->element_id(), 1414 return animation_host_->IsAnimatingOpacityProperty(layer->id(),
1449 ElementListType::ACTIVE); 1415 ElementListType::ACTIVE);
1450 } 1416 }
1451 1417
1452 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const { 1418 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const {
1453 return animation_host_->IsAnimatingTransformProperty(layer->element_id(), 1419 return animation_host_->IsAnimatingTransformProperty(layer->id(),
1454 ElementListType::ACTIVE); 1420 ElementListType::ACTIVE);
1455 } 1421 }
1456 1422
1457 bool LayerTreeHost::HasPotentiallyRunningFilterAnimation( 1423 bool LayerTreeHost::HasPotentiallyRunningFilterAnimation(
1458 const Layer* layer) const { 1424 const Layer* layer) const {
1459 return animation_host_->HasPotentiallyRunningFilterAnimation( 1425 return animation_host_->HasPotentiallyRunningFilterAnimation(
1460 layer->element_id(), ElementListType::ACTIVE); 1426 layer->id(), ElementListType::ACTIVE);
1461 } 1427 }
1462 1428
1463 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation( 1429 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation(
1464 const Layer* layer) const { 1430 const Layer* layer) const {
1465 return animation_host_->HasPotentiallyRunningOpacityAnimation( 1431 return animation_host_->HasPotentiallyRunningOpacityAnimation(
1466 layer->element_id(), ElementListType::ACTIVE); 1432 layer->id(), ElementListType::ACTIVE);
1467 } 1433 }
1468 1434
1469 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation( 1435 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation(
1470 const Layer* layer) const { 1436 const Layer* layer) const {
1471 return animation_host_->HasPotentiallyRunningTransformAnimation( 1437 return animation_host_->HasPotentiallyRunningTransformAnimation(
1472 layer->element_id(), ElementListType::ACTIVE); 1438 layer->id(), ElementListType::ACTIVE);
1473 } 1439 }
1474 1440
1475 bool LayerTreeHost::HasOnlyTranslationTransforms(const Layer* layer) const { 1441 bool LayerTreeHost::HasOnlyTranslationTransforms(const Layer* layer) const {
1476 return animation_host_->HasOnlyTranslationTransforms(layer->element_id(), 1442 return animation_host_->HasOnlyTranslationTransforms(layer->id(),
1477 ElementListType::ACTIVE); 1443 ElementListType::ACTIVE);
1478 } 1444 }
1479 1445
1480 bool LayerTreeHost::MaximumTargetScale(const Layer* layer, 1446 bool LayerTreeHost::MaximumTargetScale(const Layer* layer,
1481 float* max_scale) const { 1447 float* max_scale) const {
1482 return animation_host_->MaximumTargetScale( 1448 return animation_host_->MaximumTargetScale(
1483 layer->element_id(), ElementListType::ACTIVE, max_scale); 1449 layer->id(), ElementListType::ACTIVE, max_scale);
1484 } 1450 }
1485 1451
1486 bool LayerTreeHost::AnimationStartScale(const Layer* layer, 1452 bool LayerTreeHost::AnimationStartScale(const Layer* layer,
1487 float* start_scale) const { 1453 float* start_scale) const {
1488 return animation_host_->AnimationStartScale( 1454 return animation_host_->AnimationStartScale(
1489 layer->element_id(), ElementListType::ACTIVE, start_scale); 1455 layer->id(), ElementListType::ACTIVE, start_scale);
1490 } 1456 }
1491 1457
1492 bool LayerTreeHost::HasAnyAnimationTargetingProperty( 1458 bool LayerTreeHost::HasAnyAnimationTargetingProperty(
1493 const Layer* layer, 1459 const Layer* layer,
1494 TargetProperty::Type property) const { 1460 TargetProperty::Type property) const {
1495 return animation_host_->HasAnyAnimationTargetingProperty(layer->element_id(), 1461 return animation_host_->HasAnyAnimationTargetingProperty(layer->id(),
1496 property); 1462 property);
1497 } 1463 }
1498 1464
1499 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const { 1465 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const {
1500 return animation_host_->AnimationsPreserveAxisAlignment(layer->element_id()); 1466 return animation_host_->AnimationsPreserveAxisAlignment(layer->id());
1501 } 1467 }
1502 1468
1503 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const { 1469 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const {
1504 return animation_host_->HasAnyAnimation(layer->element_id()); 1470 return animation_host_->HasAnyAnimation(layer->id());
1505 } 1471 }
1506 1472
1507 bool LayerTreeHost::HasActiveAnimationForTesting(const Layer* layer) const { 1473 bool LayerTreeHost::HasActiveAnimationForTesting(const Layer* layer) const {
1508 return animation_host_->HasActiveAnimationForTesting(layer->element_id()); 1474 return animation_host_->HasActiveAnimationForTesting(layer->id());
1509 } 1475 }
1510 1476
1511 bool LayerTreeHost::IsSingleThreaded() const { 1477 bool LayerTreeHost::IsSingleThreaded() const {
1512 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || 1478 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED ||
1513 !task_runner_provider_->HasImplThread()); 1479 !task_runner_provider_->HasImplThread());
1514 return compositor_mode_ == CompositorMode::SINGLE_THREADED; 1480 return compositor_mode_ == CompositorMode::SINGLE_THREADED;
1515 } 1481 }
1516 1482
1517 bool LayerTreeHost::IsThreaded() const { 1483 bool LayerTreeHost::IsThreaded() const {
1518 DCHECK(compositor_mode_ != CompositorMode::THREADED || 1484 DCHECK(compositor_mode_ != CompositorMode::THREADED ||
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 int seq_num = property_trees_.sequence_number; 1674 int seq_num = property_trees_.sequence_number;
1709 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { 1675 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) {
1710 layer->set_property_tree_sequence_number(seq_num); 1676 layer->set_property_tree_sequence_number(seq_num);
1711 }); 1677 });
1712 1678
1713 surface_id_namespace_ = proto.surface_id_namespace(); 1679 surface_id_namespace_ = proto.surface_id_namespace();
1714 next_surface_sequence_ = proto.next_surface_sequence(); 1680 next_surface_sequence_ = proto.next_surface_sequence();
1715 } 1681 }
1716 1682
1717 } // namespace cc 1683 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698