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

Side by Side Diff: cc/layers/layer.cc

Issue 2357533002: CC Animation: Use std::bitset to update animation state. (Closed)
Patch Set: Reparent. Created 4 years, 2 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/layers/layer.h ('k') | cc/layers/layer_impl.h » ('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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/layers/layer.h" 5 #include "cc/layers/layer.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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 } 1642 }
1643 } 1643 }
1644 } 1644 }
1645 1645
1646 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { 1646 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) {
1647 // Do nothing. Scroll deltas will be sent from the compositor thread back 1647 // Do nothing. Scroll deltas will be sent from the compositor thread back
1648 // to the main thread in the same manner as during non-animated 1648 // to the main thread in the same manner as during non-animated
1649 // compositor-driven scrolling. 1649 // compositor-driven scrolling.
1650 } 1650 }
1651 1651
1652 void Layer::OnTransformIsCurrentlyAnimatingChanged( 1652 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask,
1653 bool is_currently_animating) { 1653 const PropertyAnimationState& state) {
1654 DCHECK(layer_tree_host_); 1654 DCHECK(layer_tree_host_);
1655 PropertyTrees* property_trees = layer_tree_->property_trees(); 1655 PropertyTrees* property_trees = layer_tree_->property_trees();
1656 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1657 id()))
1658 return;
1659 DCHECK_EQ(transform_tree_index(),
1660 property_trees->transform_id_to_index_map[id()]);
1661 TransformNode* node =
1662 property_trees->transform_tree.Node(transform_tree_index());
1663 node->is_currently_animating = is_currently_animating;
1664 }
1665 1656
1666 void Layer::OnTransformIsPotentiallyAnimatingChanged( 1657 TransformNode* transform_node = nullptr;
1667 bool has_potential_animation) { 1658 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1668 if (!layer_tree_host_) 1659 id())) {
1669 return; 1660 DCHECK_EQ(transform_tree_index(),
1670 PropertyTrees* property_trees = layer_tree_->property_trees(); 1661 property_trees->transform_id_to_index_map[id()]);
1671 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 1662 transform_node =
1672 id())) 1663 property_trees->transform_tree.Node(transform_tree_index());
1673 return; 1664 }
1674 DCHECK_EQ(transform_tree_index(),
1675 property_trees->transform_id_to_index_map[id()]);
1676 TransformNode* node =
1677 property_trees->transform_tree.Node(transform_tree_index());
1678 1665
1679 node->has_potential_animation = has_potential_animation; 1666 EffectNode* effect_node = nullptr;
1680 if (has_potential_animation) { 1667 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) {
1681 node->has_only_translation_animations = HasOnlyTranslationTransforms(); 1668 DCHECK_EQ(effect_tree_index(),
1682 } else { 1669 property_trees->effect_id_to_index_map[id()]);
1683 node->has_only_translation_animations = true; 1670 effect_node = property_trees->effect_tree.Node(effect_tree_index());
1684 } 1671 }
1685 property_trees->transform_tree.set_needs_update(true);
1686 }
1687 1672
1688 void Layer::OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating) { 1673 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
1689 DCHECK(layer_tree_host_); 1674 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
1690 PropertyTrees* property_trees = layer_tree_->property_trees(); 1675 switch (property) {
1691 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1676 case TargetProperty::TRANSFORM:
1692 return; 1677 if (transform_node) {
1693 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1678 if (mask.currently_running[property])
1694 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1679 transform_node->is_currently_animating =
1695 node->is_currently_animating_opacity = is_currently_animating; 1680 state.currently_running[property];
1696 } 1681 if (mask.potentially_animating[property]) {
1697 1682 transform_node->has_potential_animation =
1698 void Layer::OnOpacityIsPotentiallyAnimatingChanged( 1683 state.potentially_animating[property];
1699 bool has_potential_animation) { 1684 if (state.potentially_animating[property]) {
1700 DCHECK(layer_tree_host_); 1685 transform_node->has_only_translation_animations =
1701 PropertyTrees* property_trees = layer_tree_->property_trees(); 1686 HasOnlyTranslationTransforms();
1702 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1687 } else {
1703 return; 1688 transform_node->has_only_translation_animations = true;
1704 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1689 }
1705 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1690 property_trees->transform_tree.set_needs_update(true);
1706 node->has_potential_opacity_animation = 1691 }
1707 has_potential_animation || OpacityCanAnimateOnImplThread(); 1692 }
1708 property_trees->effect_tree.set_needs_update(true); 1693 break;
1709 } 1694 case TargetProperty::OPACITY:
1710 1695 if (effect_node) {
1711 void Layer::OnFilterIsCurrentlyAnimatingChanged(bool is_currently_animating) { 1696 if (mask.currently_running[property])
1712 DCHECK(layer_tree_host_); 1697 effect_node->is_currently_animating_opacity =
1713 PropertyTrees* property_trees = layer_tree_->property_trees(); 1698 state.currently_running[property];
1714 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1699 if (mask.potentially_animating[property]) {
1715 return; 1700 effect_node->has_potential_opacity_animation =
1716 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1701 state.potentially_animating[property] ||
1717 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1702 OpacityCanAnimateOnImplThread();
1718 node->is_currently_animating_filter = is_currently_animating; 1703 property_trees->effect_tree.set_needs_update(true);
1719 } 1704 }
1720 1705 }
1721 void Layer::OnFilterIsPotentiallyAnimatingChanged( 1706 break;
1722 bool has_potential_animation) { 1707 case TargetProperty::FILTER:
1723 DCHECK(layer_tree_host_); 1708 if (effect_node) {
1724 PropertyTrees* property_trees = layer_tree_->property_trees(); 1709 if (mask.currently_running[property])
1725 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1710 effect_node->is_currently_animating_filter =
1726 return; 1711 state.currently_running[property];
1727 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1712 if (mask.potentially_animating[property])
1728 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1713 effect_node->has_potential_filter_animation =
1729 node->has_potential_filter_animation = has_potential_animation; 1714 state.potentially_animating[property];
1715 }
1716 break;
1717 default:
1718 break;
1719 }
1720 }
1730 } 1721 }
1731 1722
1732 bool Layer::HasActiveAnimationForTesting() const { 1723 bool Layer::HasActiveAnimationForTesting() const {
1733 return layer_tree_host_ 1724 return layer_tree_host_
1734 ? GetAnimationHost()->HasActiveAnimationForTesting(element_id()) 1725 ? GetAnimationHost()->HasActiveAnimationForTesting(element_id())
1735 : false; 1726 : false;
1736 } 1727 }
1737 1728
1738 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { 1729 void Layer::SetHasWillChangeTransformHint(bool has_will_change) {
1739 if (inputs_.has_will_change_transform_hint == has_will_change) 1730 if (inputs_.has_will_change_transform_hint == has_will_change)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1831 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1841 return draw_property_utils::ScreenSpaceTransform( 1832 return draw_property_utils::ScreenSpaceTransform(
1842 this, layer_tree_->property_trees()->transform_tree); 1833 this, layer_tree_->property_trees()->transform_tree);
1843 } 1834 }
1844 1835
1845 LayerTree* Layer::GetLayerTree() const { 1836 LayerTree* Layer::GetLayerTree() const {
1846 return layer_tree_; 1837 return layer_tree_;
1847 } 1838 }
1848 1839
1849 } // namespace cc 1840 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698