OLD | NEW |
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 for (size_t i = 0; i < inputs_.children.size(); ++i) | 156 for (size_t i = 0; i < inputs_.children.size(); ++i) |
157 inputs_.children[i]->SetLayerTreeHost(host); | 157 inputs_.children[i]->SetLayerTreeHost(host); |
158 | 158 |
159 if (inputs_.mask_layer.get()) | 159 if (inputs_.mask_layer.get()) |
160 inputs_.mask_layer->SetLayerTreeHost(host); | 160 inputs_.mask_layer->SetLayerTreeHost(host); |
161 if (inputs_.replica_layer.get()) | 161 if (inputs_.replica_layer.get()) |
162 inputs_.replica_layer->SetLayerTreeHost(host); | 162 inputs_.replica_layer->SetLayerTreeHost(host); |
163 | 163 |
164 const bool has_any_animation = | 164 const bool has_any_animation = |
165 layer_tree_host_ ? layer_tree_host_->HasAnyAnimation(this) : false; | 165 layer_tree_host_ ? GetAnimationHost()->HasAnyAnimation(element_id()) |
| 166 : false; |
166 | 167 |
167 if (host && has_any_animation) | 168 if (host && has_any_animation) |
168 host->SetNeedsCommit(); | 169 host->SetNeedsCommit(); |
169 } | 170 } |
170 | 171 |
171 void Layer::SetNeedsUpdate() { | 172 void Layer::SetNeedsUpdate() { |
172 if (layer_tree_host_ && !ignore_set_needs_commit_) | 173 if (layer_tree_host_ && !ignore_set_needs_commit_) |
173 layer_tree_host_->SetNeedsUpdateLayers(); | 174 layer_tree_host_->SetNeedsUpdateLayers(); |
174 } | 175 } |
175 | 176 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 459 |
459 void Layer::SetFilters(const FilterOperations& filters) { | 460 void Layer::SetFilters(const FilterOperations& filters) { |
460 DCHECK(IsPropertyChangeAllowed()); | 461 DCHECK(IsPropertyChangeAllowed()); |
461 if (inputs_.filters == filters) | 462 if (inputs_.filters == filters) |
462 return; | 463 return; |
463 inputs_.filters = filters; | 464 inputs_.filters = filters; |
464 SetSubtreePropertyChanged(); | 465 SetSubtreePropertyChanged(); |
465 SetNeedsCommit(); | 466 SetNeedsCommit(); |
466 } | 467 } |
467 | 468 |
468 bool Layer::FilterIsAnimating() const { | |
469 DCHECK(layer_tree_host_); | |
470 return layer_tree_host_->IsAnimatingFilterProperty(this); | |
471 } | |
472 | |
473 bool Layer::HasPotentiallyRunningFilterAnimation() const { | |
474 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); | |
475 } | |
476 | |
477 void Layer::SetBackgroundFilters(const FilterOperations& filters) { | 469 void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
478 DCHECK(IsPropertyChangeAllowed()); | 470 DCHECK(IsPropertyChangeAllowed()); |
479 if (inputs_.background_filters == filters) | 471 if (inputs_.background_filters == filters) |
480 return; | 472 return; |
481 inputs_.background_filters = filters; | 473 inputs_.background_filters = filters; |
482 SetLayerPropertyChanged(); | 474 SetLayerPropertyChanged(); |
483 SetNeedsCommit(); | 475 SetNeedsCommit(); |
484 } | 476 } |
485 | 477 |
486 void Layer::SetOpacity(float opacity) { | 478 void Layer::SetOpacity(float opacity) { |
(...skipping 21 matching lines...) Expand all Loading... |
508 return; | 500 return; |
509 } | 501 } |
510 } | 502 } |
511 SetNeedsCommit(); | 503 SetNeedsCommit(); |
512 } | 504 } |
513 | 505 |
514 float Layer::EffectiveOpacity() const { | 506 float Layer::EffectiveOpacity() const { |
515 return inputs_.hide_layer_and_subtree ? 0.f : inputs_.opacity; | 507 return inputs_.hide_layer_and_subtree ? 0.f : inputs_.opacity; |
516 } | 508 } |
517 | 509 |
518 bool Layer::OpacityIsAnimating() const { | |
519 DCHECK(layer_tree_host_); | |
520 return layer_tree_host_->IsAnimatingOpacityProperty(this); | |
521 } | |
522 | |
523 bool Layer::HasPotentiallyRunningOpacityAnimation() const { | |
524 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); | |
525 } | |
526 | |
527 bool Layer::OpacityCanAnimateOnImplThread() const { | 510 bool Layer::OpacityCanAnimateOnImplThread() const { |
528 return false; | 511 return false; |
529 } | 512 } |
530 | 513 |
531 bool Layer::AlwaysUseActiveTreeOpacity() const { | 514 bool Layer::AlwaysUseActiveTreeOpacity() const { |
532 return false; | 515 return false; |
533 } | 516 } |
534 | 517 |
535 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { | 518 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { |
536 DCHECK(IsPropertyChangeAllowed()); | 519 DCHECK(IsPropertyChangeAllowed()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 transform_node->needs_local_transform_update = true; | 693 transform_node->needs_local_transform_update = true; |
711 transform_node->transform_changed = true; | 694 transform_node->transform_changed = true; |
712 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 695 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
713 SetNeedsCommitNoRebuild(); | 696 SetNeedsCommitNoRebuild(); |
714 return; | 697 return; |
715 } | 698 } |
716 | 699 |
717 SetNeedsCommit(); | 700 SetNeedsCommit(); |
718 } | 701 } |
719 | 702 |
720 bool Layer::AnimationsPreserveAxisAlignment() const { | 703 bool Layer::ScrollOffsetAnimationWasInterrupted() const { |
721 DCHECK(layer_tree_host_); | 704 return GetAnimationHost()->ScrollOffsetAnimationWasInterrupted(element_id()); |
722 return layer_tree_host_->AnimationsPreserveAxisAlignment(this); | |
723 } | |
724 | |
725 bool Layer::TransformIsAnimating() const { | |
726 DCHECK(layer_tree_host_); | |
727 return layer_tree_host_->IsAnimatingTransformProperty(this); | |
728 } | |
729 | |
730 bool Layer::HasPotentiallyRunningTransformAnimation() const { | |
731 return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this); | |
732 } | 705 } |
733 | 706 |
734 bool Layer::HasOnlyTranslationTransforms() const { | 707 bool Layer::HasOnlyTranslationTransforms() const { |
735 return layer_tree_host_->HasOnlyTranslationTransforms(this); | 708 return GetAnimationHost()->HasOnlyTranslationTransforms( |
736 } | 709 element_id(), GetElementTypeForAnimation()); |
737 | |
738 bool Layer::MaximumTargetScale(float* max_scale) const { | |
739 return layer_tree_host_->MaximumTargetScale(this, max_scale); | |
740 } | |
741 | |
742 bool Layer::AnimationStartScale(float* start_scale) const { | |
743 return layer_tree_host_->AnimationStartScale(this, start_scale); | |
744 } | |
745 | |
746 bool Layer::HasAnyAnimationTargetingProperty( | |
747 TargetProperty::Type property) const { | |
748 return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); | |
749 } | |
750 | |
751 bool Layer::ScrollOffsetAnimationWasInterrupted() const { | |
752 DCHECK(layer_tree_host_); | |
753 return layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this); | |
754 } | 710 } |
755 | 711 |
756 void Layer::SetScrollParent(Layer* parent) { | 712 void Layer::SetScrollParent(Layer* parent) { |
757 DCHECK(IsPropertyChangeAllowed()); | 713 DCHECK(IsPropertyChangeAllowed()); |
758 if (inputs_.scroll_parent == parent) | 714 if (inputs_.scroll_parent == parent) |
759 return; | 715 return; |
760 | 716 |
761 if (inputs_.scroll_parent) | 717 if (inputs_.scroll_parent) |
762 inputs_.scroll_parent->RemoveScrollChild(this); | 718 inputs_.scroll_parent->RemoveScrollChild(this); |
763 | 719 |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 SetNeedsPushProperties(); | 1586 SetNeedsPushProperties(); |
1631 } | 1587 } |
1632 | 1588 |
1633 void Layer::SetLayerPropertyChanged() { | 1589 void Layer::SetLayerPropertyChanged() { |
1634 if (layer_property_changed_) | 1590 if (layer_property_changed_) |
1635 return; | 1591 return; |
1636 layer_property_changed_ = true; | 1592 layer_property_changed_ = true; |
1637 SetNeedsPushProperties(); | 1593 SetNeedsPushProperties(); |
1638 } | 1594 } |
1639 | 1595 |
| 1596 bool Layer::FilterIsAnimating() const { |
| 1597 return GetAnimationHost()->IsAnimatingFilterProperty( |
| 1598 element_id(), GetElementTypeForAnimation()); |
| 1599 } |
| 1600 |
| 1601 bool Layer::TransformIsAnimating() const { |
| 1602 return GetAnimationHost()->IsAnimatingTransformProperty( |
| 1603 element_id(), GetElementTypeForAnimation()); |
| 1604 } |
| 1605 |
1640 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { | 1606 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { |
1641 return CurrentScrollOffset(); | 1607 return CurrentScrollOffset(); |
1642 } | 1608 } |
1643 | 1609 |
1644 // On<Property>Animated is called due to an ongoing accelerated animation. | 1610 // On<Property>Animated is called due to an ongoing accelerated animation. |
1645 // Since this animation is also being run on the compositor thread, there | 1611 // Since this animation is also being run on the compositor thread, there |
1646 // is no need to request a commit to push this value over, so the value is | 1612 // is no need to request a commit to push this value over, so the value is |
1647 // set directly rather than by calling Set<Property>. | 1613 // set directly rather than by calling Set<Property>. |
1648 void Layer::OnFilterAnimated(const FilterOperations& filters) { | 1614 void Layer::OnFilterAnimated(const FilterOperations& filters) { |
1649 inputs_.filters = filters; | 1615 inputs_.filters = filters; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) | 1720 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) |
1755 return; | 1721 return; |
1756 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); | 1722 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); |
1757 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); | 1723 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); |
1758 node->has_potential_opacity_animation = | 1724 node->has_potential_opacity_animation = |
1759 has_potential_animation || OpacityCanAnimateOnImplThread(); | 1725 has_potential_animation || OpacityCanAnimateOnImplThread(); |
1760 property_trees->effect_tree.set_needs_update(true); | 1726 property_trees->effect_tree.set_needs_update(true); |
1761 } | 1727 } |
1762 | 1728 |
1763 bool Layer::HasActiveAnimationForTesting() const { | 1729 bool Layer::HasActiveAnimationForTesting() const { |
1764 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) | 1730 return layer_tree_host_ |
1765 : false; | 1731 ? GetAnimationHost()->HasActiveAnimationForTesting(element_id()) |
| 1732 : false; |
1766 } | 1733 } |
1767 | 1734 |
1768 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { | 1735 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { |
1769 if (inputs_.has_will_change_transform_hint == has_will_change) | 1736 if (inputs_.has_will_change_transform_hint == has_will_change) |
1770 return; | 1737 return; |
1771 inputs_.has_will_change_transform_hint = has_will_change; | 1738 inputs_.has_will_change_transform_hint = has_will_change; |
1772 SetNeedsCommit(); | 1739 SetNeedsCommit(); |
1773 } | 1740 } |
1774 | 1741 |
| 1742 AnimationHost* Layer::GetAnimationHost() const { |
| 1743 return layer_tree_host_ ? layer_tree_host_->animation_host() : nullptr; |
| 1744 } |
| 1745 |
| 1746 ElementListType Layer::GetElementTypeForAnimation() const { |
| 1747 return ElementListType::ACTIVE; |
| 1748 } |
| 1749 |
1775 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1750 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
1776 return nullptr; | 1751 return nullptr; |
1777 } | 1752 } |
1778 | 1753 |
1779 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | |
1780 return layer_tree_host_->rendering_stats_instrumentation(); | |
1781 } | |
1782 | |
1783 void Layer::RemoveFromScrollTree() { | 1754 void Layer::RemoveFromScrollTree() { |
1784 if (scroll_children_.get()) { | 1755 if (scroll_children_.get()) { |
1785 std::set<Layer*> copy = *scroll_children_; | 1756 std::set<Layer*> copy = *scroll_children_; |
1786 for (std::set<Layer*>::iterator it = copy.begin(); it != copy.end(); ++it) | 1757 for (std::set<Layer*>::iterator it = copy.begin(); it != copy.end(); ++it) |
1787 (*it)->SetScrollParent(nullptr); | 1758 (*it)->SetScrollParent(nullptr); |
1788 } | 1759 } |
1789 | 1760 |
1790 DCHECK(!scroll_children_); | 1761 DCHECK(!scroll_children_); |
1791 SetScrollParent(nullptr); | 1762 SetScrollParent(nullptr); |
1792 } | 1763 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 ->num_copy_requests_in_subtree; | 1836 ->num_copy_requests_in_subtree; |
1866 } | 1837 } |
1867 | 1838 |
1868 gfx::Transform Layer::screen_space_transform() const { | 1839 gfx::Transform Layer::screen_space_transform() const { |
1869 DCHECK_NE(transform_tree_index_, -1); | 1840 DCHECK_NE(transform_tree_index_, -1); |
1870 return draw_property_utils::ScreenSpaceTransform( | 1841 return draw_property_utils::ScreenSpaceTransform( |
1871 this, layer_tree_host_->property_trees()->transform_tree); | 1842 this, layer_tree_host_->property_trees()->transform_tree); |
1872 } | 1843 } |
1873 | 1844 |
1874 } // namespace cc | 1845 } // namespace cc |
OLD | NEW |