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

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

Issue 1752993002: cc : Delete LayerImpl::NoteLayerPropertyChangedForSubtree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 699
700 list = new base::ListValue; 700 list = new base::ListValue;
701 for (size_t i = 0; i < children_.size(); ++i) 701 for (size_t i = 0; i < children_.size(); ++i)
702 list->Append(children_[i]->LayerTreeAsJson()); 702 list->Append(children_[i]->LayerTreeAsJson());
703 result->Set("Children", list); 703 result->Set("Children", list);
704 704
705 return result; 705 return result;
706 } 706 }
707 707
708 bool LayerImpl::LayerPropertyChanged() const { 708 bool LayerImpl::LayerPropertyChanged() const {
709 if (layer_property_changed_) 709 if (layer_property_changed_ ||
710 (layer_tree_impl()->property_trees() &&
711 layer_tree_impl()->property_trees()->full_tree_damaged))
710 return true; 712 return true;
711 if (transform_tree_index() == -1) 713 if (transform_tree_index() == -1)
712 return false; 714 return false;
713 TransformNode* transform_node = 715 TransformNode* transform_node =
714 layer_tree_impl()->property_trees()->transform_tree.Node( 716 layer_tree_impl()->property_trees()->transform_tree.Node(
715 transform_tree_index()); 717 transform_tree_index());
716 if (transform_node && transform_node->data.transform_changed) 718 if (transform_node && transform_node->data.transform_changed)
717 return true; 719 return true;
718 if (effect_tree_index() == -1) 720 if (effect_tree_index() == -1)
719 return false; 721 return false;
720 EffectNode* effect_node = 722 EffectNode* effect_node =
721 layer_tree_impl()->property_trees()->effect_tree.Node( 723 layer_tree_impl()->property_trees()->effect_tree.Node(
722 effect_tree_index()); 724 effect_tree_index());
723 if (effect_node && effect_node->data.opacity_changed) 725 if (effect_node && effect_node->data.effect_changed)
724 return true; 726 return true;
725 return false; 727 return false;
726 } 728 }
727 729
728 void LayerImpl::NoteLayerPropertyChanged() { 730 void LayerImpl::NoteLayerPropertyChanged() {
729 layer_property_changed_ = true; 731 layer_property_changed_ = true;
730 layer_tree_impl()->set_needs_update_draw_properties(); 732 layer_tree_impl()->set_needs_update_draw_properties();
731 SetNeedsPushProperties(); 733 SetNeedsPushProperties();
732 } 734 }
733 735
734 void LayerImpl::NoteLayerPropertyChangedForSubtree() {
735 layer_property_changed_ = true;
736 layer_tree_impl()->set_needs_update_draw_properties();
737 for (size_t i = 0; i < children_.size(); ++i)
738 children_[i]->NoteLayerPropertyChangedForDescendantsInternal();
739 SetNeedsPushProperties();
740 }
741
742 void LayerImpl::NoteLayerPropertyChangedForDescendantsInternal() {
743 layer_property_changed_ = true;
744 for (size_t i = 0; i < children_.size(); ++i)
745 children_[i]->NoteLayerPropertyChangedForDescendantsInternal();
746 }
747
748 void LayerImpl::NoteLayerPropertyChangedForDescendants() {
749 layer_tree_impl()->set_needs_update_draw_properties();
750 for (size_t i = 0; i < children_.size(); ++i)
751 children_[i]->NoteLayerPropertyChangedForDescendantsInternal();
752 SetNeedsPushProperties();
753 }
754
755 void LayerImpl::PushLayerPropertyChangedForSubtreeInternal() { 736 void LayerImpl::PushLayerPropertyChangedForSubtreeInternal() {
756 if (LayerPropertyChanged()) 737 if (LayerPropertyChanged())
757 NoteLayerPropertyChanged(); 738 NoteLayerPropertyChanged();
758 for (size_t i = 0; i < children_.size(); ++i) 739 for (size_t i = 0; i < children_.size(); ++i)
759 children_[i]->PushLayerPropertyChangedForSubtreeInternal(); 740 children_[i]->PushLayerPropertyChangedForSubtreeInternal();
760 } 741 }
761 742
762 void LayerImpl::PushLayerPropertyChangedForSubtree() { 743 void LayerImpl::PushLayerPropertyChangedForSubtree() {
763 // We need to update property trees first as layer property can change 744 // We need to update property trees first as layer property can change
764 // when its corresponsing property tree node changes. 745 // when its corresponsing property tree node changes.
765 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 746 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
766 EffectTree effect_tree = property_trees->effect_tree; 747 EffectTree effect_tree = property_trees->effect_tree;
767 TransformTree transform_tree = property_trees->transform_tree; 748 TransformTree transform_tree = property_trees->transform_tree;
768 for (int i = 1; i < static_cast<int>(effect_tree.size()); ++i) { 749 for (int i = 1; i < static_cast<int>(effect_tree.size()); ++i) {
769 EffectNode* node = effect_tree.Node(i); 750 EffectNode* node = effect_tree.Node(i);
770 EffectNode* parent_node = effect_tree.parent(node); 751 EffectNode* parent_node = effect_tree.parent(node);
771 effect_tree.UpdateOpacityChanged(node, parent_node); 752 effect_tree.UpdateEffectChanged(node, parent_node);
772 } 753 }
773 for (int i = 1; i < static_cast<int>(transform_tree.size()); ++i) { 754 for (int i = 1; i < static_cast<int>(transform_tree.size()); ++i) {
774 TransformNode* node = transform_tree.Node(i); 755 TransformNode* node = transform_tree.Node(i);
775 TransformNode* parent_node = transform_tree.parent(node); 756 TransformNode* parent_node = transform_tree.parent(node);
776 TransformNode* source_node = transform_tree.Node(node->data.source_node_id); 757 TransformNode* source_node = transform_tree.Node(node->data.source_node_id);
777 transform_tree.UpdateTransformChanged(node, parent_node, source_node); 758 transform_tree.UpdateTransformChanged(node, parent_node, source_node);
778 } 759 }
779 PushLayerPropertyChangedForSubtreeInternal(); 760 PushLayerPropertyChangedForSubtreeInternal();
780 } 761 }
781 762
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 EffectNode* node = effect_tree.Node(effect_tree_index_); 889 EffectNode* node = effect_tree.Node(effect_tree_index_);
909 // A LayerImpl's own current state is insufficient for determining whether 890 // A LayerImpl's own current state is insufficient for determining whether
910 // it owns an OpacityNode, since this depends on the state of the 891 // it owns an OpacityNode, since this depends on the state of the
911 // corresponding Layer at the time of the last commit. For example, an 892 // corresponding Layer at the time of the last commit. For example, an
912 // opacity animation might have been in progress at the time the last commit 893 // opacity animation might have been in progress at the time the last commit
913 // started, but might have finished since then on the compositor thread. 894 // started, but might have finished since then on the compositor thread.
914 float effective_opacity = EffectiveOpacity(); 895 float effective_opacity = EffectiveOpacity();
915 if (node->owner_id != id() || node->data.opacity == effective_opacity) 896 if (node->owner_id != id() || node->data.opacity == effective_opacity)
916 return; 897 return;
917 node->data.opacity = effective_opacity; 898 node->data.opacity = effective_opacity;
918 node->data.opacity_changed = true; 899 node->data.effect_changed = true;
919 layer_tree_impl()->property_trees()->changed = true; 900 layer_tree_impl()->property_trees()->changed = true;
920 effect_tree.set_needs_update(true); 901 effect_tree.set_needs_update(true);
921 } 902 }
922 } 903 }
923 904
924 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { 905 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() {
925 if (scrollable()) 906 if (scrollable())
926 UpdatePropertyTreeScrollOffset(); 907 UpdatePropertyTreeScrollOffset();
927 908
928 if (HasAnyAnimationTargetingProperty(TargetProperty::OPACITY)) 909 if (HasAnyAnimationTargetingProperty(TargetProperty::OPACITY))
929 UpdatePropertyTreeOpacity(); 910 UpdatePropertyTreeOpacity();
930 911
931 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) { 912 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) {
932 UpdatePropertyTreeTransform(); 913 UpdatePropertyTreeTransform();
933 UpdatePropertyTreeTransformIsAnimated( 914 UpdatePropertyTreeTransformIsAnimated(
934 HasPotentiallyRunningTransformAnimation()); 915 HasPotentiallyRunningTransformAnimation());
935 } 916 }
936 } 917 }
937 918
938 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 919 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
939 return CurrentScrollOffset(); 920 return CurrentScrollOffset();
940 } 921 }
941 922
942 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) { 923 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) {
943 SetFilters(filters); 924 if (filters_ != filters) {
925 SetFilters(filters);
926 SetNeedsPushProperties();
927 layer_tree_impl()->set_needs_update_draw_properties();
928 EffectTree& effect_tree = layer_tree_impl()->property_trees()->effect_tree;
929 EffectNode* node = effect_tree.Node(effect_tree_index_);
930 DCHECK_EQ(node->owner_id, id());
931 node->data.effect_changed = true;
932 layer_tree_impl()->property_trees()->changed = true;
933 effect_tree.set_needs_update(true);
934 }
944 } 935 }
945 936
946 void LayerImpl::OnOpacityAnimated(float opacity) { 937 void LayerImpl::OnOpacityAnimated(float opacity) {
947 SetOpacity(opacity); 938 SetOpacity(opacity);
948 // When hide_layer_and_subtree is true, the effective opacity is zero and we 939 // When hide_layer_and_subtree is true, the effective opacity is zero and we
949 // need not update the opacity on property trees. 940 // need not update the opacity on property trees.
950 if (!hide_layer_and_subtree_) { 941 if (!hide_layer_and_subtree_) {
951 UpdatePropertyTreeOpacity(); 942 UpdatePropertyTreeOpacity();
952 SetNeedsPushProperties(); 943 SetNeedsPushProperties();
953 layer_tree_impl()->set_needs_update_draw_properties(); 944 layer_tree_impl()->set_needs_update_draw_properties();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1021
1031 if (masks_to_bounds()) { 1022 if (masks_to_bounds()) {
1032 // If layer is clipping, then update the clip node using the new bounds. 1023 // If layer is clipping, then update the clip node using the new bounds.
1033 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index()); 1024 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index());
1034 if (clip_node) { 1025 if (clip_node) {
1035 DCHECK(id() == clip_node->owner_id); 1026 DCHECK(id() == clip_node->owner_id);
1036 clip_node->data.clip = gfx::RectF( 1027 clip_node->data.clip = gfx::RectF(
1037 gfx::PointF() + offset_to_transform_parent(), gfx::SizeF(bounds())); 1028 gfx::PointF() + offset_to_transform_parent(), gfx::SizeF(bounds()));
1038 property_trees->clip_tree.set_needs_update(true); 1029 property_trees->clip_tree.set_needs_update(true);
1039 } 1030 }
1040 1031 property_trees->full_tree_damaged = true;
1041 NoteLayerPropertyChangedForSubtree(); 1032 layer_tree_impl()->set_needs_update_draw_properties();
1042 } else { 1033 } else {
1043 NoteLayerPropertyChanged(); 1034 NoteLayerPropertyChanged();
1044 } 1035 }
1045 } 1036 }
1046 1037
1047 void LayerImpl::SetMaskLayer(scoped_ptr<LayerImpl> mask_layer) { 1038 void LayerImpl::SetMaskLayer(scoped_ptr<LayerImpl> mask_layer) {
1048 int new_layer_id = mask_layer ? mask_layer->id() : -1; 1039 int new_layer_id = mask_layer ? mask_layer->id() : -1;
1049 1040
1050 if (mask_layer) { 1041 if (mask_layer) {
1051 DCHECK_EQ(layer_tree_impl(), mask_layer->layer_tree_impl()); 1042 DCHECK_EQ(layer_tree_impl(), mask_layer->layer_tree_impl());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 color = SkColorSetA(color, 255); 1127 color = SkColorSetA(color, 255);
1137 } 1128 }
1138 return color; 1129 return color;
1139 } 1130 }
1140 1131
1141 void LayerImpl::SetFilters(const FilterOperations& filters) { 1132 void LayerImpl::SetFilters(const FilterOperations& filters) {
1142 if (filters_ == filters) 1133 if (filters_ == filters)
1143 return; 1134 return;
1144 1135
1145 filters_ = filters; 1136 filters_ = filters;
1146 NoteLayerPropertyChangedForSubtree();
1147 } 1137 }
1148 1138
1149 bool LayerImpl::FilterIsAnimating() const { 1139 bool LayerImpl::FilterIsAnimating() const {
1150 LayerAnimationController::ObserverType observer_type = 1140 LayerAnimationController::ObserverType observer_type =
1151 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1141 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1152 : LayerAnimationController::ObserverType::PENDING; 1142 : LayerAnimationController::ObserverType::PENDING;
1153 return layer_animation_controller_ 1143 return layer_animation_controller_
1154 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( 1144 ? layer_animation_controller_->IsCurrentlyAnimatingProperty(
1155 TargetProperty::FILTER, observer_type) 1145 TargetProperty::FILTER, observer_type)
1156 : layer_tree_impl_->IsAnimatingFilterProperty(this); 1146 : layer_tree_impl_->IsAnimatingFilterProperty(this);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 node->data.needs_local_transform_update = true; 1532 node->data.needs_local_transform_update = true;
1543 transform_tree.set_needs_update(true); 1533 transform_tree.set_needs_update(true);
1544 } 1534 }
1545 } 1535 }
1546 } 1536 }
1547 1537
1548 void LayerImpl::DidUpdateScrollOffset() { 1538 void LayerImpl::DidUpdateScrollOffset() {
1549 DCHECK(scroll_offset_); 1539 DCHECK(scroll_offset_);
1550 1540
1551 layer_tree_impl()->DidUpdateScrollState(id()); 1541 layer_tree_impl()->DidUpdateScrollState(id());
1552 NoteLayerPropertyChangedForSubtree();
1553 1542
1554 UpdatePropertyTreeScrollOffset(); 1543 if (transform_tree_index_ != -1) {
1544 UpdatePropertyTreeScrollOffset();
1545 TransformTree& transform_tree =
1546 layer_tree_impl()->property_trees()->transform_tree;
1547 TransformNode* node = transform_tree.Node(transform_tree_index_);
1548 node->data.transform_changed = true;
1549 layer_tree_impl()->property_trees()->changed = true;
1550 layer_tree_impl()->set_needs_update_draw_properties();
1551 SetNeedsPushProperties();
1552 }
1555 1553
1556 // Inform the pending twin that a property changed. 1554 // Inform the pending twin that a property changed.
1557 if (layer_tree_impl()->IsActiveTree()) { 1555 if (layer_tree_impl()->IsActiveTree()) {
1558 LayerImpl* pending_twin = layer_list_impl_->FindPendingLayerById(id()); 1556 LayerImpl* pending_twin = layer_list_impl_->FindPendingLayerById(id());
1559 if (pending_twin) 1557 if (pending_twin)
1560 pending_twin->DidUpdateScrollOffset(); 1558 pending_twin->DidUpdateScrollOffset();
1561 } 1559 }
1562 } 1560 }
1563 1561
1564 void LayerImpl::SetDoubleSided(bool double_sided) { 1562 void LayerImpl::SetDoubleSided(bool double_sided) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 .layer_transforms_should_scale_layer_contents) { 1842 .layer_transforms_should_scale_layer_contents) {
1845 return default_scale; 1843 return default_scale;
1846 } 1844 }
1847 1845
1848 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1846 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1849 DrawTransform(), default_scale); 1847 DrawTransform(), default_scale);
1850 return std::max(transform_scales.x(), transform_scales.y()); 1848 return std::max(transform_scales.x(), transform_scales.y());
1851 } 1849 }
1852 1850
1853 } // namespace cc 1851 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698