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

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

Issue 2758343002: cc: Use Element Id to Record Animation Changes (Closed)
Patch Set: fix for test Created 3 years, 9 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/test/layer_tree_test.cc ('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 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 Layer* layer = LayerByElementId(element_id); 1304 Layer* layer = LayerByElementId(element_id);
1305 DCHECK(layer); 1305 DCHECK(layer);
1306 layer->OnScrollOffsetAnimated(scroll_offset); 1306 layer->OnScrollOffsetAnimated(scroll_offset);
1307 } 1307 }
1308 1308
1309 void LayerTreeHost::ElementIsAnimatingChanged( 1309 void LayerTreeHost::ElementIsAnimatingChanged(
1310 ElementId element_id, 1310 ElementId element_id,
1311 ElementListType list_type, 1311 ElementListType list_type,
1312 const PropertyAnimationState& mask, 1312 const PropertyAnimationState& mask,
1313 const PropertyAnimationState& state) { 1313 const PropertyAnimationState& state) {
1314 Layer* layer = LayerByElementId(element_id); 1314 // TODO(weiliangc): Most of the code is duplicated with LayerTeeHostImpl
1315 if (layer) 1315 // version of function. Should try to share code.
1316 layer->OnIsAnimatingChanged(mask, state); 1316 DCHECK_EQ(ElementListType::ACTIVE, list_type);
1317
1318 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
1319 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
1320 if (!mask.currently_running[property] &&
1321 !mask.potentially_animating[property])
1322 continue;
1323
1324 switch (property) {
1325 case TargetProperty::TRANSFORM:
1326 if (TransformNode* transform_node =
1327 property_trees()->transform_tree.FindNodeFromElementId(
1328 element_id)) {
1329 if (mask.currently_running[property])
1330 transform_node->is_currently_animating =
1331 state.currently_running[property];
1332 if (mask.potentially_animating[property]) {
1333 transform_node->has_potential_animation =
1334 state.potentially_animating[property];
1335 transform_node->has_only_translation_animations =
1336 mutator_host()->HasOnlyTranslationTransforms(element_id,
1337 list_type);
1338 property_trees()->transform_tree.set_needs_update(true);
1339 }
1340 } else {
1341 if (state.currently_running[property] ||
1342 state.potentially_animating[property])
1343 DCHECK(property_trees()->needs_rebuild)
1344 << "Attempting to animate non existent transform node";
1345 }
1346 break;
1347 case TargetProperty::OPACITY:
1348 if (EffectNode* effect_node =
1349 property_trees()->effect_tree.FindNodeFromElementId(
1350 element_id)) {
1351 if (mask.currently_running[property])
1352 effect_node->is_currently_animating_opacity =
1353 state.currently_running[property];
1354 if (mask.potentially_animating[property]) {
1355 effect_node->has_potential_opacity_animation =
1356 state.potentially_animating[property];
1357 property_trees()->effect_tree.set_needs_update(true);
1358 }
1359 } else {
1360 if (state.currently_running[property] ||
1361 state.potentially_animating[property])
1362 DCHECK(property_trees()->needs_rebuild)
1363 << "Attempting to animate opacity on non existent effect node";
1364 }
1365 break;
1366 case TargetProperty::FILTER:
1367 if (EffectNode* effect_node =
1368 property_trees()->effect_tree.FindNodeFromElementId(
1369 element_id)) {
1370 if (mask.currently_running[property])
1371 effect_node->is_currently_animating_filter =
1372 state.currently_running[property];
1373 if (mask.potentially_animating[property])
1374 effect_node->has_potential_filter_animation =
1375 state.potentially_animating[property];
1376 } else {
1377 if (state.currently_running[property] ||
1378 state.potentially_animating[property])
1379 DCHECK(property_trees()->needs_rebuild)
1380 << "Attempting to animate filter on non existent effect node";
1381 }
1382 break;
1383 default:
1384 break;
1385 }
1386 }
1317 } 1387 }
1318 1388
1319 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( 1389 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation(
1320 ElementId element_id) const { 1390 ElementId element_id) const {
1321 Layer* layer = LayerByElementId(element_id); 1391 Layer* layer = LayerByElementId(element_id);
1322 DCHECK(layer); 1392 DCHECK(layer);
1323 return layer->ScrollOffsetForAnimation(); 1393 return layer->ScrollOffsetForAnimation();
1324 } 1394 }
1325 1395
1326 void LayerTreeHost::QueueImageDecode( 1396 void LayerTreeHost::QueueImageDecode(
(...skipping 19 matching lines...) Expand all
1346 LayerListReverseIterator<Layer> LayerTreeHost::rend() { 1416 LayerListReverseIterator<Layer> LayerTreeHost::rend() {
1347 return LayerListReverseIterator<Layer>(nullptr); 1417 return LayerListReverseIterator<Layer>(nullptr);
1348 } 1418 }
1349 1419
1350 void LayerTreeHost::SetNeedsDisplayOnAllLayers() { 1420 void LayerTreeHost::SetNeedsDisplayOnAllLayers() {
1351 for (auto* layer : *this) 1421 for (auto* layer : *this)
1352 layer->SetNeedsDisplay(); 1422 layer->SetNeedsDisplay();
1353 } 1423 }
1354 1424
1355 } // namespace cc 1425 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698