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

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

Issue 2357533002: CC Animation: Use std::bitset to update animation state. (Closed)
Patch Set: Clean it up. Created 4 years, 3 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
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 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 } 1683 }
1684 } 1684 }
1685 } 1685 }
1686 1686
1687 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { 1687 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) {
1688 // Do nothing. Scroll deltas will be sent from the compositor thread back 1688 // Do nothing. Scroll deltas will be sent from the compositor thread back
1689 // to the main thread in the same manner as during non-animated 1689 // to the main thread in the same manner as during non-animated
1690 // compositor-driven scrolling. 1690 // compositor-driven scrolling.
1691 } 1691 }
1692 1692
1693 void Layer::OnTransformIsCurrentlyAnimatingChanged( 1693 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask,
1694 bool is_currently_animating) { 1694 const PropertyAnimationState& state) {
1695 DCHECK(layer_tree_host_); 1695 DCHECK(layer_tree_host_);
1696 PropertyTrees* property_trees = layer_tree_->property_trees(); 1696 PropertyTrees* property_trees = layer_tree_->property_trees();
1697 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1698 id()))
1699 return;
1700 DCHECK_EQ(transform_tree_index(),
1701 property_trees->transform_id_to_index_map[id()]);
1702 TransformNode* node =
1703 property_trees->transform_tree.Node(transform_tree_index());
1704 node->is_currently_animating = is_currently_animating;
1705 }
1706 1697
1707 void Layer::OnTransformIsPotentiallyAnimatingChanged( 1698 TransformNode* transform_node = nullptr;
1708 bool has_potential_animation) { 1699 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1709 if (!layer_tree_host_) 1700 id())) {
1710 return; 1701 DCHECK_EQ(transform_tree_index(),
1711 PropertyTrees* property_trees = layer_tree_->property_trees(); 1702 property_trees->transform_id_to_index_map[id()]);
1712 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 1703 transform_node =
1713 id())) 1704 property_trees->transform_tree.Node(transform_tree_index());
1714 return; 1705 }
1715 DCHECK_EQ(transform_tree_index(),
1716 property_trees->transform_id_to_index_map[id()]);
1717 TransformNode* node =
1718 property_trees->transform_tree.Node(transform_tree_index());
1719 1706
1720 node->has_potential_animation = has_potential_animation; 1707 EffectNode* effect_node = nullptr;
1721 if (has_potential_animation) { 1708 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) {
1722 node->has_only_translation_animations = HasOnlyTranslationTransforms(); 1709 DCHECK_EQ(effect_tree_index(),
1723 } else { 1710 property_trees->effect_id_to_index_map[id()]);
1724 node->has_only_translation_animations = true; 1711 effect_node = property_trees->effect_tree.Node(effect_tree_index());
1725 } 1712 }
1726 property_trees->transform_tree.set_needs_update(true);
1727 }
1728 1713
1729 void Layer::OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating) { 1714 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
1730 DCHECK(layer_tree_host_); 1715 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
1731 PropertyTrees* property_trees = layer_tree_->property_trees(); 1716 switch (property) {
1732 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1717 case TargetProperty::TRANSFORM:
1733 return; 1718 if (transform_node) {
1734 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1719 if (mask.currently_running[property])
1735 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1720 transform_node->is_currently_animating =
1736 node->is_currently_animating_opacity = is_currently_animating; 1721 state.currently_running[property];
1737 } 1722 if (mask.potentially_animating[property]) {
1738 1723 transform_node->has_potential_animation =
1739 void Layer::OnOpacityIsPotentiallyAnimatingChanged( 1724 state.potentially_animating[property];
1740 bool has_potential_animation) { 1725 if (state.potentially_animating[property]) {
1741 DCHECK(layer_tree_host_); 1726 transform_node->has_only_translation_animations =
1742 PropertyTrees* property_trees = layer_tree_->property_trees(); 1727 HasOnlyTranslationTransforms();
1743 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1728 } else {
1744 return; 1729 transform_node->has_only_translation_animations = true;
1745 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1730 }
1746 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1731 property_trees->transform_tree.set_needs_update(true);
1747 node->has_potential_opacity_animation = 1732 }
1748 has_potential_animation || OpacityCanAnimateOnImplThread(); 1733 }
1749 property_trees->effect_tree.set_needs_update(true); 1734 break;
1750 } 1735 case TargetProperty::OPACITY:
1751 1736 if (effect_node) {
1752 void Layer::OnFilterIsCurrentlyAnimatingChanged(bool is_currently_animating) { 1737 if (mask.currently_running[property])
1753 DCHECK(layer_tree_host_); 1738 effect_node->is_currently_animating_opacity =
1754 PropertyTrees* property_trees = layer_tree_->property_trees(); 1739 state.currently_running[property];
1755 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1740 if (mask.potentially_animating[property]) {
1756 return; 1741 effect_node->has_potential_opacity_animation =
1757 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1742 state.potentially_animating[property] ||
1758 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1743 OpacityCanAnimateOnImplThread();
1759 node->is_currently_animating_filter = is_currently_animating; 1744 property_trees->effect_tree.set_needs_update(true);
1760 } 1745 }
1761 1746 }
1762 void Layer::OnFilterIsPotentiallyAnimatingChanged( 1747 break;
1763 bool has_potential_animation) { 1748 case TargetProperty::FILTER:
1764 DCHECK(layer_tree_host_); 1749 if (effect_node) {
1765 PropertyTrees* property_trees = layer_tree_->property_trees(); 1750 if (mask.currently_running[property])
1766 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1751 effect_node->is_currently_animating_filter =
1767 return; 1752 state.currently_running[property];
1768 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1753 if (mask.potentially_animating[property])
1769 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1754 effect_node->has_potential_filter_animation =
1770 node->has_potential_filter_animation = has_potential_animation; 1755 state.potentially_animating[property];
1756 }
1757 break;
1758 default:
1759 break;
1760 }
1761 }
1771 } 1762 }
1772 1763
1773 bool Layer::HasActiveAnimationForTesting() const { 1764 bool Layer::HasActiveAnimationForTesting() const {
1774 return layer_tree_host_ 1765 return layer_tree_host_
1775 ? GetAnimationHost()->HasActiveAnimationForTesting(element_id()) 1766 ? GetAnimationHost()->HasActiveAnimationForTesting(element_id())
1776 : false; 1767 : false;
1777 } 1768 }
1778 1769
1779 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { 1770 void Layer::SetHasWillChangeTransformHint(bool has_will_change) {
1780 if (inputs_.has_will_change_transform_hint == has_will_change) 1771 if (inputs_.has_will_change_transform_hint == has_will_change)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1872 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1882 return draw_property_utils::ScreenSpaceTransform( 1873 return draw_property_utils::ScreenSpaceTransform(
1883 this, layer_tree_->property_trees()->transform_tree); 1874 this, layer_tree_->property_trees()->transform_tree);
1884 } 1875 }
1885 1876
1886 LayerTree* Layer::GetLayerTree() const { 1877 LayerTree* Layer::GetLayerTree() const {
1887 return layer_tree_; 1878 return layer_tree_;
1888 } 1879 }
1889 1880
1890 } // namespace cc 1881 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698