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

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

Issue 1994333002: cc : Add IsInIdtoIndexMap to property tres (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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.cc ('k') | cc/trees/property_tree.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 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 <algorithm> 10 #include <algorithm>
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 617 }
618 618
619 int LayerImpl::num_copy_requests_in_target_subtree() { 619 int LayerImpl::num_copy_requests_in_target_subtree() {
620 return layer_tree_impl() 620 return layer_tree_impl()
621 ->property_trees() 621 ->property_trees()
622 ->effect_tree.Node(effect_tree_index()) 622 ->effect_tree.Node(effect_tree_index())
623 ->data.num_copy_requests_in_subtree; 623 ->data.num_copy_requests_in_subtree;
624 } 624 }
625 625
626 void LayerImpl::UpdatePropertyTreeTransform() { 626 void LayerImpl::UpdatePropertyTreeTransform() {
627 if (transform_tree_index_ != -1) { 627 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
628 TransformTree& transform_tree = 628 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
629 layer_tree_impl()->property_trees()->transform_tree; 629 id())) {
630 TransformNode* node = transform_tree.Node(transform_tree_index_);
631 // A LayerImpl's own current state is insufficient for determining whether 630 // A LayerImpl's own current state is insufficient for determining whether
632 // it owns a TransformNode, since this depends on the state of the 631 // it owns a TransformNode, since this depends on the state of the
633 // corresponding Layer at the time of the last commit. For example, a 632 // corresponding Layer at the time of the last commit. For example, a
634 // transform animation might have been in progress at the time the last 633 // transform animation might have been in progress at the time the last
635 // commit started, but might have finished since then on the compositor 634 // commit started, but might have finished since then on the compositor
636 // thread. 635 // thread.
637 if (node->owner_id != id()) 636 TransformNode* node =
638 return; 637 property_trees->transform_tree.Node(transform_tree_index());
639 if (node->data.local != transform_) { 638 if (node->data.local != transform_) {
640 node->data.local = transform_; 639 node->data.local = transform_;
641 node->data.needs_local_transform_update = true; 640 node->data.needs_local_transform_update = true;
642 node->data.transform_changed = true; 641 node->data.transform_changed = true;
643 layer_tree_impl()->property_trees()->changed = true; 642 property_trees->changed = true;
644 transform_tree.set_needs_update(true); 643 property_trees->transform_tree.set_needs_update(true);
645 // TODO(ajuma): The current criteria for creating clip nodes means that 644 // TODO(ajuma): The current criteria for creating clip nodes means that
646 // property trees may need to be rebuilt when the new transform isn't 645 // property trees may need to be rebuilt when the new transform isn't
647 // axis-aligned wrt the old transform (see Layer::SetTransform). Since 646 // axis-aligned wrt the old transform (see Layer::SetTransform). Since
648 // rebuilding property trees every frame of a transform animation is 647 // rebuilding property trees every frame of a transform animation is
649 // something we should try to avoid, change property tree-building so that 648 // something we should try to avoid, change property tree-building so that
650 // it doesn't depend on axis aliginment. 649 // it doesn't depend on axis aliginment.
651 } 650 }
652 } 651 }
653 } 652 }
654 653
655 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) { 654 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) {
656 if (transform_tree_index_ != -1) { 655 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
657 TransformTree& transform_tree = 656 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
658 layer_tree_impl()->property_trees()->transform_tree; 657 id())) {
659 TransformNode* node = transform_tree.Node(transform_tree_index_); 658 TransformNode* node = property_trees->transform_tree.Node(
659 property_trees->transform_id_to_index_map[id()]);
jaydasika 2016/05/19 22:16:22 There is unit tests for which transform_tree_index
660 // A LayerImpl's own current state is insufficient for determining whether 660 // A LayerImpl's own current state is insufficient for determining whether
661 // it owns a TransformNode, since this depends on the state of the 661 // it owns a TransformNode, since this depends on the state of the
662 // corresponding Layer at the time of the last commit. For example, if 662 // corresponding Layer at the time of the last commit. For example, if
663 // |is_animated| is false, this might mean a transform animation just ticked 663 // |is_animated| is false, this might mean a transform animation just ticked
664 // past its finish point (so the LayerImpl still owns a TransformNode) or it 664 // past its finish point (so the LayerImpl still owns a TransformNode) or it
665 // might mean that a transform animation was removed during commit or 665 // might mean that a transform animation was removed during commit or
666 // activation (and, in that case, the LayerImpl will no longer own a 666 // activation (and, in that case, the LayerImpl will no longer own a
667 // TransformNode, unless it has non-animation-related reasons for owning a 667 // TransformNode, unless it has non-animation-related reasons for owning a
668 // node). 668 // node).
669 if (node->owner_id != id())
670 return;
671 if (node->data.has_potential_animation != is_animated) { 669 if (node->data.has_potential_animation != is_animated) {
672 node->data.has_potential_animation = is_animated; 670 node->data.has_potential_animation = is_animated;
673 if (is_animated) { 671 if (is_animated) {
674 float maximum_target_scale = 0.f; 672 float maximum_target_scale = 0.f;
675 node->data.local_maximum_animation_target_scale = 673 node->data.local_maximum_animation_target_scale =
676 MaximumTargetScale(&maximum_target_scale) ? maximum_target_scale 674 MaximumTargetScale(&maximum_target_scale) ? maximum_target_scale
677 : 0.f; 675 : 0.f;
678 676
679 float animation_start_scale = 0.f; 677 float animation_start_scale = 0.f;
680 node->data.local_starting_animation_scale = 678 node->data.local_starting_animation_scale =
681 AnimationStartScale(&animation_start_scale) ? animation_start_scale 679 AnimationStartScale(&animation_start_scale) ? animation_start_scale
682 : 0.f; 680 : 0.f;
683 681
684 node->data.has_only_translation_animations = 682 node->data.has_only_translation_animations =
685 HasOnlyTranslationTransforms(); 683 HasOnlyTranslationTransforms();
686 } else { 684 } else {
687 node->data.local_maximum_animation_target_scale = 0.f; 685 node->data.local_maximum_animation_target_scale = 0.f;
688 node->data.local_starting_animation_scale = 0.f; 686 node->data.local_starting_animation_scale = 0.f;
689 node->data.has_only_translation_animations = true; 687 node->data.has_only_translation_animations = true;
690 } 688 }
691 689
692 transform_tree.set_needs_update(true); 690 property_trees->transform_tree.set_needs_update(true);
693 layer_tree_impl()->set_needs_update_draw_properties(); 691 layer_tree_impl()->set_needs_update_draw_properties();
694 } 692 }
695 } 693 }
696 } 694 }
697 695
698 void LayerImpl::UpdatePropertyTreeOpacity() { 696 void LayerImpl::UpdatePropertyTreeOpacity() {
699 if (effect_tree_index_ != -1) { 697 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
700 EffectTree& effect_tree = layer_tree_impl()->property_trees()->effect_tree; 698 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) {
701 if (effect_tree_index_ >= static_cast<int>(effect_tree.size()))
702 return;
703 EffectNode* node = effect_tree.Node(effect_tree_index_);
704 // A LayerImpl's own current state is insufficient for determining whether 699 // A LayerImpl's own current state is insufficient for determining whether
705 // it owns an OpacityNode, since this depends on the state of the 700 // it owns an OpacityNode, since this depends on the state of the
706 // corresponding Layer at the time of the last commit. For example, an 701 // corresponding Layer at the time of the last commit. For example, an
707 // opacity animation might have been in progress at the time the last commit 702 // opacity animation might have been in progress at the time the last commit
708 // started, but might have finished since then on the compositor thread. 703 // started, but might have finished since then on the compositor thread.
709 if (node->owner_id != id() || node->data.opacity == opacity_) 704 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index_);
710 return;
711 node->data.opacity = opacity_; 705 node->data.opacity = opacity_;
712 node->data.effect_changed = true; 706 node->data.effect_changed = true;
713 layer_tree_impl()->property_trees()->changed = true; 707 property_trees->changed = true;
714 effect_tree.set_needs_update(true); 708 property_trees->effect_tree.set_needs_update(true);
715 } 709 }
716 } 710 }
717 711
718 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { 712 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() {
719 if (scrollable()) 713 if (scrollable())
720 UpdatePropertyTreeScrollOffset(); 714 UpdatePropertyTreeScrollOffset();
721 715
722 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) { 716 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) {
723 UpdatePropertyTreeTransform(); 717 UpdatePropertyTreeTransform();
724 UpdatePropertyTreeTransformIsAnimated( 718 UpdatePropertyTreeTransformIsAnimated(
725 HasPotentiallyRunningTransformAnimation()); 719 HasPotentiallyRunningTransformAnimation());
726 } 720 }
727 } 721 }
728 722
729 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 723 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
730 return CurrentScrollOffset(); 724 return CurrentScrollOffset();
731 } 725 }
732 726
733 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) { 727 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) {
734 if (filters_ != filters) { 728 if (filters_ != filters) {
735 SetFilters(filters); 729 SetFilters(filters);
736 SetNeedsPushProperties(); 730 SetNeedsPushProperties();
737 layer_tree_impl()->set_needs_update_draw_properties(); 731 layer_tree_impl()->set_needs_update_draw_properties();
738 EffectTree& effect_tree = layer_tree_impl()->property_trees()->effect_tree; 732 EffectTree& effect_tree = layer_tree_impl()->property_trees()->effect_tree;
739 EffectNode* node = effect_tree.Node(effect_tree_index_); 733 EffectNode* node = effect_tree.Node(effect_tree_index_);
740 DCHECK_EQ(node->owner_id, id()); 734 DCHECK(layer_tree_impl()->property_trees()->IsInIdToIndexMap(
735 PropertyTrees::TreeType::EFFECT, id()));
741 node->data.effect_changed = true; 736 node->data.effect_changed = true;
742 layer_tree_impl()->property_trees()->changed = true; 737 layer_tree_impl()->property_trees()->changed = true;
743 effect_tree.set_needs_update(true); 738 effect_tree.set_needs_update(true);
744 } 739 }
745 } 740 }
746 741
747 void LayerImpl::OnOpacityAnimated(float opacity) { 742 void LayerImpl::OnOpacityAnimated(float opacity) {
748 SetOpacity(opacity); 743 SetOpacity(opacity);
749 UpdatePropertyTreeOpacity(); 744 UpdatePropertyTreeOpacity();
750 SetNeedsPushProperties(); 745 SetNeedsPushProperties();
(...skipping 20 matching lines...) Expand all
771 return; 766 return;
772 767
773 SetCurrentScrollOffset(ClampScrollOffsetToLimits(scroll_offset)); 768 SetCurrentScrollOffset(ClampScrollOffsetToLimits(scroll_offset));
774 769
775 layer_tree_impl_->DidAnimateScrollOffset(); 770 layer_tree_impl_->DidAnimateScrollOffset();
776 } 771 }
777 772
778 void LayerImpl::OnTransformIsCurrentlyAnimatingChanged( 773 void LayerImpl::OnTransformIsCurrentlyAnimatingChanged(
779 bool is_currently_animating) { 774 bool is_currently_animating) {
780 DCHECK(layer_tree_impl_); 775 DCHECK(layer_tree_impl_);
781 TransformTree& transform_tree = 776 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
782 layer_tree_impl_->property_trees()->transform_tree; 777 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
783 TransformNode* node = transform_tree.Node(transform_tree_index()); 778 id()))
784 if (!node)
785 return; 779 return;
786 780 TransformNode* node = property_trees->transform_tree.Node(
787 if (node->owner_id == id()) 781 property_trees->transform_id_to_index_map[id()]);
788 node->data.is_currently_animating = is_currently_animating; 782 node->data.is_currently_animating = is_currently_animating;
789 } 783 }
790 784
791 void LayerImpl::OnTransformIsPotentiallyAnimatingChanged( 785 void LayerImpl::OnTransformIsPotentiallyAnimatingChanged(
792 bool has_potential_animation) { 786 bool has_potential_animation) {
793 UpdatePropertyTreeTransformIsAnimated(has_potential_animation); 787 UpdatePropertyTreeTransformIsAnimated(has_potential_animation);
794 was_ever_ready_since_last_transform_animation_ = false; 788 was_ever_ready_since_last_transform_animation_ = false;
795 } 789 }
796 790
797 void LayerImpl::OnOpacityIsCurrentlyAnimatingChanged( 791 void LayerImpl::OnOpacityIsCurrentlyAnimatingChanged(
798 bool is_currently_animating) { 792 bool is_currently_animating) {
799 DCHECK(layer_tree_impl_); 793 DCHECK(layer_tree_impl_);
800 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree; 794 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
801 EffectNode* node = effect_tree.Node(effect_tree_index()); 795 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
796 return;
797 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
802 798
803 if (node->owner_id == id()) 799 node->data.is_currently_animating_opacity = is_currently_animating;
804 node->data.is_currently_animating_opacity = is_currently_animating;
805 } 800 }
806 801
807 void LayerImpl::OnOpacityIsPotentiallyAnimatingChanged( 802 void LayerImpl::OnOpacityIsPotentiallyAnimatingChanged(
808 bool has_potential_animation) { 803 bool has_potential_animation) {
809 DCHECK(layer_tree_impl_); 804 DCHECK(layer_tree_impl_);
810 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree; 805 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
811 EffectNode* node = effect_tree.Node(effect_tree_index()); 806 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
812 if (node->owner_id == id()) { 807 return;
813 node->data.has_potential_opacity_animation = has_potential_animation; 808 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
814 effect_tree.set_needs_update(true); 809 node->data.has_potential_opacity_animation = has_potential_animation;
815 } 810 property_trees->effect_tree.set_needs_update(true);
816 } 811 }
817 812
818 bool LayerImpl::IsActive() const { 813 bool LayerImpl::IsActive() const {
819 return layer_tree_impl_->IsActiveTree(); 814 return layer_tree_impl_->IsActiveTree();
820 } 815 }
821 816
822 gfx::Size LayerImpl::bounds() const { 817 gfx::Size LayerImpl::bounds() const {
823 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 818 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_);
824 return gfx::Size(bounds_.width() + delta.x(), 819 return gfx::Size(bounds_.width() + delta.x(),
825 bounds_.height() + delta.y()); 820 bounds_.height() + delta.y());
(...skipping 29 matching lines...) Expand all
855 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); 850 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta);
856 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) 851 else if (this == layer_tree_impl()->InnerViewportScrollLayer())
857 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); 852 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta);
858 853
859 layer_tree_impl()->DidUpdateScrollState(id()); 854 layer_tree_impl()->DidUpdateScrollState(id());
860 855
861 if (masks_to_bounds()) { 856 if (masks_to_bounds()) {
862 // If layer is clipping, then update the clip node using the new bounds. 857 // If layer is clipping, then update the clip node using the new bounds.
863 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index()); 858 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index());
864 if (clip_node) { 859 if (clip_node) {
865 DCHECK(id() == clip_node->owner_id); 860 DCHECK(property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::CLIP,
861 id()));
866 clip_node->data.clip = gfx::RectF( 862 clip_node->data.clip = gfx::RectF(
867 gfx::PointF() + offset_to_transform_parent(), gfx::SizeF(bounds())); 863 gfx::PointF() + offset_to_transform_parent(), gfx::SizeF(bounds()));
868 property_trees->clip_tree.set_needs_update(true); 864 property_trees->clip_tree.set_needs_update(true);
869 } 865 }
870 property_trees->full_tree_damaged = true; 866 property_trees->full_tree_damaged = true;
871 layer_tree_impl()->set_needs_update_draw_properties(); 867 layer_tree_impl()->set_needs_update_draw_properties();
872 } else { 868 } else {
873 NoteLayerPropertyChanged(); 869 NoteLayerPropertyChanged();
874 } 870 }
875 } 871 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 } 1137 }
1142 1138
1143 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const { 1139 gfx::ScrollOffset LayerImpl::CurrentScrollOffset() const {
1144 return layer_tree_impl()->property_trees()->scroll_tree.current_scroll_offset( 1140 return layer_tree_impl()->property_trees()->scroll_tree.current_scroll_offset(
1145 id()); 1141 id());
1146 } 1142 }
1147 1143
1148 void LayerImpl::UpdatePropertyTreeScrollOffset() { 1144 void LayerImpl::UpdatePropertyTreeScrollOffset() {
1149 // TODO(enne): in the future, scrolling should update the scroll tree 1145 // TODO(enne): in the future, scrolling should update the scroll tree
1150 // directly instead of going through layers. 1146 // directly instead of going through layers.
1151 if (transform_tree_index_ != -1) {
1152 TransformTree& transform_tree = 1147 TransformTree& transform_tree =
1153 layer_tree_impl()->property_trees()->transform_tree; 1148 layer_tree_impl()->property_trees()->transform_tree;
1154 TransformNode* node = transform_tree.Node(transform_tree_index_); 1149 TransformNode* node = transform_tree.Node(transform_tree_index_);
1155 gfx::ScrollOffset current_offset = CurrentScrollOffset(); 1150 gfx::ScrollOffset current_offset = CurrentScrollOffset();
1156 if (node->data.scroll_offset != current_offset) { 1151 if (node->data.scroll_offset != current_offset) {
1157 node->data.scroll_offset = current_offset; 1152 node->data.scroll_offset = current_offset;
1158 node->data.needs_local_transform_update = true; 1153 node->data.needs_local_transform_update = true;
1159 transform_tree.set_needs_update(true); 1154 transform_tree.set_needs_update(true);
1160 } 1155 }
1161 }
1162 } 1156 }
1163 1157
1164 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const { 1158 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const {
1165 if (contents_opaque()) 1159 if (contents_opaque())
1166 return SimpleEnclosedRegion(visible_layer_rect()); 1160 return SimpleEnclosedRegion(visible_layer_rect());
1167 return SimpleEnclosedRegion(); 1161 return SimpleEnclosedRegion();
1168 } 1162 }
1169 1163
1170 void LayerImpl::DidBeginTracing() {} 1164 void LayerImpl::DidBeginTracing() {}
1171 1165
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 .layer_transforms_should_scale_layer_contents) { 1408 .layer_transforms_should_scale_layer_contents) {
1415 return default_scale; 1409 return default_scale;
1416 } 1410 }
1417 1411
1418 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1412 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1419 DrawTransform(), default_scale); 1413 DrawTransform(), default_scale);
1420 return std::max(transform_scales.x(), transform_scales.y()); 1414 return std::max(transform_scales.x(), transform_scales.y());
1421 } 1415 }
1422 1416
1423 } // namespace cc 1417 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698