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

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

Issue 2183403002: cc: Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layer_tree_change
Patch Set: remove unused test file. Created 4 years, 4 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 DCHECK_EQ(this, inputs_.replica_layer->parent()); 122 DCHECK_EQ(this, inputs_.replica_layer->parent());
123 inputs_.replica_layer->RemoveFromParent(); 123 inputs_.replica_layer->RemoveFromParent();
124 } 124 }
125 } 125 }
126 126
127 void Layer::SetLayerTreeHost(LayerTreeHost* host) { 127 void Layer::SetLayerTreeHost(LayerTreeHost* host) {
128 if (layer_tree_host_ == host) 128 if (layer_tree_host_ == host)
129 return; 129 return;
130 130
131 if (layer_tree_host_) { 131 if (layer_tree_host_) {
132 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); 132 layer_tree_->property_trees()->RemoveIdFromIdToIndexMaps(id());
133 layer_tree_host_->property_trees()->needs_rebuild = true; 133 layer_tree_->property_trees()->needs_rebuild = true;
134 layer_tree_->UnregisterLayer(this); 134 layer_tree_->UnregisterLayer(this);
135 if (inputs_.element_id) { 135 if (inputs_.element_id) {
136 layer_tree_host_->animation_host()->UnregisterElement( 136 layer_tree_->animation_host()->UnregisterElement(inputs_.element_id,
137 inputs_.element_id, ElementListType::ACTIVE); 137 ElementListType::ACTIVE);
138 layer_tree_host_->RemoveFromElementMap(this); 138 layer_tree_host_->RemoveFromElementMap(this);
139 } 139 }
140 } 140 }
141 if (host) { 141 if (host) {
142 host->property_trees()->needs_rebuild = true; 142 host->GetLayerTree()->property_trees()->needs_rebuild = true;
143 host->GetLayerTree()->RegisterLayer(this); 143 host->GetLayerTree()->RegisterLayer(this);
144 if (inputs_.element_id) { 144 if (inputs_.element_id) {
145 host->AddToElementMap(this); 145 host->AddToElementMap(this);
146 host->animation_host()->RegisterElement(inputs_.element_id, 146 host->animation_host()->RegisterElement(inputs_.element_id,
147 ElementListType::ACTIVE); 147 ElementListType::ACTIVE);
148 } 148 }
149 } 149 }
150 150
151 layer_tree_host_ = host; 151 layer_tree_host_ = host;
152 layer_tree_ = host ? host->GetLayerTree() : nullptr; 152 layer_tree_ = host ? host->GetLayerTree() : nullptr;
(...skipping 22 matching lines...) Expand all
175 void Layer::SetNeedsUpdate() { 175 void Layer::SetNeedsUpdate() {
176 if (layer_tree_host_ && !ignore_set_needs_commit_) 176 if (layer_tree_host_ && !ignore_set_needs_commit_)
177 layer_tree_host_->SetNeedsUpdateLayers(); 177 layer_tree_host_->SetNeedsUpdateLayers();
178 } 178 }
179 179
180 void Layer::SetNeedsCommit() { 180 void Layer::SetNeedsCommit() {
181 if (!layer_tree_host_) 181 if (!layer_tree_host_)
182 return; 182 return;
183 183
184 SetNeedsPushProperties(); 184 SetNeedsPushProperties();
185 layer_tree_host_->property_trees()->needs_rebuild = true; 185 layer_tree_->property_trees()->needs_rebuild = true;
186 186
187 if (ignore_set_needs_commit_) 187 if (ignore_set_needs_commit_)
188 return; 188 return;
189 189
190 layer_tree_host_->SetNeedsCommit(); 190 layer_tree_host_->SetNeedsCommit();
191 } 191 }
192 192
193 void Layer::SetNeedsCommitNoRebuild() { 193 void Layer::SetNeedsCommitNoRebuild() {
194 if (!layer_tree_host_) 194 if (!layer_tree_host_)
195 return; 195 return;
196 196
197 SetNeedsPushProperties(); 197 SetNeedsPushProperties();
198 198
199 if (ignore_set_needs_commit_) 199 if (ignore_set_needs_commit_)
200 return; 200 return;
201 201
202 layer_tree_host_->SetNeedsCommit(); 202 layer_tree_host_->SetNeedsCommit();
203 } 203 }
204 204
205 void Layer::SetNeedsFullTreeSync() { 205 void Layer::SetNeedsFullTreeSync() {
206 if (!layer_tree_host_) 206 if (!layer_tree_)
207 return; 207 return;
208 208
209 layer_tree_host_->SetNeedsFullTreeSync(); 209 layer_tree_->SetNeedsFullTreeSync();
210 } 210 }
211 211
212 void Layer::SetNextCommitWaitsForActivation() { 212 void Layer::SetNextCommitWaitsForActivation() {
213 if (!layer_tree_host_) 213 if (!layer_tree_host_)
214 return; 214 return;
215 215
216 layer_tree_host_->SetNextCommitWaitsForActivation(); 216 layer_tree_host_->SetNextCommitWaitsForActivation();
217 } 217 }
218 218
219 void Layer::SetNeedsPushProperties() { 219 void Layer::SetNeedsPushProperties() {
(...skipping 19 matching lines...) Expand all
239 239
240 void Layer::SetParent(Layer* layer) { 240 void Layer::SetParent(Layer* layer) {
241 DCHECK(!layer || !layer->HasAncestor(this)); 241 DCHECK(!layer || !layer->HasAncestor(this));
242 242
243 parent_ = layer; 243 parent_ = layer;
244 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr); 244 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr);
245 245
246 if (!layer_tree_host_) 246 if (!layer_tree_host_)
247 return; 247 return;
248 248
249 layer_tree_host_->property_trees()->needs_rebuild = true; 249 layer_tree_->property_trees()->needs_rebuild = true;
250 } 250 }
251 251
252 void Layer::AddChild(scoped_refptr<Layer> child) { 252 void Layer::AddChild(scoped_refptr<Layer> child) {
253 InsertChild(child, inputs_.children.size()); 253 InsertChild(child, inputs_.children.size());
254 } 254 }
255 255
256 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { 256 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) {
257 DCHECK(IsPropertyChangeAllowed()); 257 DCHECK(IsPropertyChangeAllowed());
258 child->RemoveFromParent(); 258 child->RemoveFromParent();
259 AddDrawableDescendants(child->NumDescendantsThatDrawContent() + 259 AddDrawableDescendants(child->NumDescendantsThatDrawContent() +
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 DCHECK_LE(opacity, 1.f); 485 DCHECK_LE(opacity, 1.f);
486 486
487 if (inputs_.opacity == opacity) 487 if (inputs_.opacity == opacity)
488 return; 488 return;
489 // We need to force a property tree rebuild when opacity changes from 1 to a 489 // We need to force a property tree rebuild when opacity changes from 1 to a
490 // non-1 value or vice-versa as render surfaces can change. 490 // non-1 value or vice-versa as render surfaces can change.
491 bool force_rebuild = opacity == 1.f || inputs_.opacity == 1.f; 491 bool force_rebuild = opacity == 1.f || inputs_.opacity == 1.f;
492 inputs_.opacity = opacity; 492 inputs_.opacity = opacity;
493 SetSubtreePropertyChanged(); 493 SetSubtreePropertyChanged();
494 if (layer_tree_host_ && !force_rebuild) { 494 if (layer_tree_host_ && !force_rebuild) {
495 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 495 PropertyTrees* property_trees = layer_tree_->property_trees();
496 auto effect_id_to_index = property_trees->effect_id_to_index_map.find(id()); 496 auto effect_id_to_index = property_trees->effect_id_to_index_map.find(id());
497 if (effect_id_to_index != property_trees->effect_id_to_index_map.end()) { 497 if (effect_id_to_index != property_trees->effect_id_to_index_map.end()) {
498 EffectNode* node = 498 EffectNode* node =
499 property_trees->effect_tree.Node(effect_id_to_index->second); 499 property_trees->effect_tree.Node(effect_id_to_index->second);
500 node->opacity = opacity; 500 node->opacity = opacity;
501 node->effect_changed = true; 501 node->effect_changed = true;
502 property_trees->effect_tree.set_needs_update(true); 502 property_trees->effect_tree.set_needs_update(true);
503 SetNeedsCommitNoRebuild(); 503 SetNeedsCommitNoRebuild();
504 return; 504 return;
505 } 505 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 void Layer::SetPosition(const gfx::PointF& position) { 589 void Layer::SetPosition(const gfx::PointF& position) {
590 DCHECK(IsPropertyChangeAllowed()); 590 DCHECK(IsPropertyChangeAllowed());
591 if (inputs_.position == position) 591 if (inputs_.position == position)
592 return; 592 return;
593 inputs_.position = position; 593 inputs_.position = position;
594 594
595 if (!layer_tree_host_) 595 if (!layer_tree_host_)
596 return; 596 return;
597 597
598 SetSubtreePropertyChanged(); 598 SetSubtreePropertyChanged();
599 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 599 PropertyTrees* property_trees = layer_tree_->property_trees();
600 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 600 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
601 id())) { 601 id())) {
602 DCHECK_EQ(transform_tree_index(), 602 DCHECK_EQ(transform_tree_index(),
603 property_trees->transform_id_to_index_map[id()]); 603 property_trees->transform_id_to_index_map[id()]);
604 TransformNode* transform_node = 604 TransformNode* transform_node =
605 property_trees->transform_tree.Node(transform_tree_index()); 605 property_trees->transform_tree.Node(transform_tree_index());
606 transform_node->update_post_local_transform(position, transform_origin()); 606 transform_node->update_post_local_transform(position, transform_origin());
607 transform_node->needs_local_transform_update = true; 607 transform_node->needs_local_transform_update = true;
608 transform_node->transform_changed = true; 608 transform_node->transform_changed = true;
609 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); 609 layer_tree_->property_trees()->transform_tree.set_needs_update(true);
610 SetNeedsCommitNoRebuild(); 610 SetNeedsCommitNoRebuild();
611 return; 611 return;
612 } 612 }
613 613
614 SetNeedsCommit(); 614 SetNeedsCommit();
615 } 615 }
616 616
617 bool Layer::IsContainerForFixedPositionLayers() const { 617 bool Layer::IsContainerForFixedPositionLayers() const {
618 if (!inputs_.transform.IsIdentityOrTranslation()) 618 if (!inputs_.transform.IsIdentityOrTranslation())
619 return true; 619 return true;
(...skipping 17 matching lines...) Expand all
637 } 637 }
638 } 638 }
639 639
640 void Layer::SetTransform(const gfx::Transform& transform) { 640 void Layer::SetTransform(const gfx::Transform& transform) {
641 DCHECK(IsPropertyChangeAllowed()); 641 DCHECK(IsPropertyChangeAllowed());
642 if (inputs_.transform == transform) 642 if (inputs_.transform == transform)
643 return; 643 return;
644 644
645 SetSubtreePropertyChanged(); 645 SetSubtreePropertyChanged();
646 if (layer_tree_host_) { 646 if (layer_tree_host_) {
647 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 647 PropertyTrees* property_trees = layer_tree_->property_trees();
648 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 648 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
649 id())) { 649 id())) {
650 // We need to trigger a rebuild if we could have affected 2d axis 650 // We need to trigger a rebuild if we could have affected 2d axis
651 // alignment. We'll check to see if transform and inputs_.transform 651 // alignment. We'll check to see if transform and inputs_.transform
652 // are axis 652 // are axis
653 // align with respect to one another. 653 // align with respect to one another.
654 DCHECK_EQ(transform_tree_index(), 654 DCHECK_EQ(transform_tree_index(),
655 property_trees->transform_id_to_index_map[id()]); 655 property_trees->transform_id_to_index_map[id()]);
656 TransformNode* transform_node = 656 TransformNode* transform_node =
657 property_trees->transform_tree.Node(transform_tree_index()); 657 property_trees->transform_tree.Node(transform_tree_index());
658 bool preserves_2d_axis_alignment = 658 bool preserves_2d_axis_alignment =
659 Are2dAxisAligned(inputs_.transform, transform); 659 Are2dAxisAligned(inputs_.transform, transform);
660 transform_node->local = transform; 660 transform_node->local = transform;
661 transform_node->needs_local_transform_update = true; 661 transform_node->needs_local_transform_update = true;
662 transform_node->transform_changed = true; 662 transform_node->transform_changed = true;
663 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); 663 layer_tree_->property_trees()->transform_tree.set_needs_update(true);
664 if (preserves_2d_axis_alignment) 664 if (preserves_2d_axis_alignment)
665 SetNeedsCommitNoRebuild(); 665 SetNeedsCommitNoRebuild();
666 else 666 else
667 SetNeedsCommit(); 667 SetNeedsCommit();
668 inputs_.transform = transform; 668 inputs_.transform = transform;
669 return; 669 return;
670 } 670 }
671 } 671 }
672 672
673 inputs_.transform = transform; 673 inputs_.transform = transform;
674 674
675 SetNeedsCommit(); 675 SetNeedsCommit();
676 } 676 }
677 677
678 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { 678 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) {
679 DCHECK(IsPropertyChangeAllowed()); 679 DCHECK(IsPropertyChangeAllowed());
680 if (inputs_.transform_origin == transform_origin) 680 if (inputs_.transform_origin == transform_origin)
681 return; 681 return;
682 inputs_.transform_origin = transform_origin; 682 inputs_.transform_origin = transform_origin;
683 683
684 if (!layer_tree_host_) 684 if (!layer_tree_host_)
685 return; 685 return;
686 686
687 SetSubtreePropertyChanged(); 687 SetSubtreePropertyChanged();
688 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 688 PropertyTrees* property_trees = layer_tree_->property_trees();
689 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 689 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
690 id())) { 690 id())) {
691 DCHECK_EQ(transform_tree_index(), 691 DCHECK_EQ(transform_tree_index(),
692 property_trees->transform_id_to_index_map[id()]); 692 property_trees->transform_id_to_index_map[id()]);
693 TransformNode* transform_node = 693 TransformNode* transform_node =
694 property_trees->transform_tree.Node(transform_tree_index()); 694 property_trees->transform_tree.Node(transform_tree_index());
695 transform_node->update_pre_local_transform(transform_origin); 695 transform_node->update_pre_local_transform(transform_origin);
696 transform_node->update_post_local_transform(position(), transform_origin); 696 transform_node->update_post_local_transform(position(), transform_origin);
697 transform_node->needs_local_transform_update = true; 697 transform_node->needs_local_transform_update = true;
698 transform_node->transform_changed = true; 698 transform_node->transform_changed = true;
699 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); 699 layer_tree_->property_trees()->transform_tree.set_needs_update(true);
700 SetNeedsCommitNoRebuild(); 700 SetNeedsCommitNoRebuild();
701 return; 701 return;
702 } 702 }
703 703
704 SetNeedsCommit(); 704 SetNeedsCommit();
705 } 705 }
706 706
707 bool Layer::ScrollOffsetAnimationWasInterrupted() const { 707 bool Layer::ScrollOffsetAnimationWasInterrupted() const {
708 return GetAnimationHost()->ScrollOffsetAnimationWasInterrupted(element_id()); 708 return GetAnimationHost()->ScrollOffsetAnimationWasInterrupted(element_id());
709 } 709 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 750
751 if (inputs_.clip_parent) 751 if (inputs_.clip_parent)
752 inputs_.clip_parent->RemoveClipChild(this); 752 inputs_.clip_parent->RemoveClipChild(this);
753 753
754 inputs_.clip_parent = ancestor; 754 inputs_.clip_parent = ancestor;
755 755
756 if (inputs_.clip_parent) 756 if (inputs_.clip_parent)
757 inputs_.clip_parent->AddClipChild(this); 757 inputs_.clip_parent->AddClipChild(this);
758 758
759 SetNeedsCommit(); 759 SetNeedsCommit();
760 if (layer_tree_host_) 760 if (layer_tree_)
761 layer_tree_host_->SetNeedsMetaInfoRecomputation(true); 761 layer_tree_->SetNeedsMetaInfoRecomputation(true);
762 } 762 }
763 763
764 void Layer::AddClipChild(Layer* child) { 764 void Layer::AddClipChild(Layer* child) {
765 if (!clip_children_) 765 if (!clip_children_)
766 clip_children_.reset(new std::set<Layer*>); 766 clip_children_.reset(new std::set<Layer*>);
767 clip_children_->insert(child); 767 clip_children_->insert(child);
768 SetNeedsCommit(); 768 SetNeedsCommit();
769 } 769 }
770 770
771 void Layer::RemoveClipChild(Layer* child) { 771 void Layer::RemoveClipChild(Layer* child) {
772 clip_children_->erase(child); 772 clip_children_->erase(child);
773 if (clip_children_->empty()) 773 if (clip_children_->empty())
774 clip_children_ = nullptr; 774 clip_children_ = nullptr;
775 SetNeedsCommit(); 775 SetNeedsCommit();
776 } 776 }
777 777
778 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { 778 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) {
779 DCHECK(IsPropertyChangeAllowed()); 779 DCHECK(IsPropertyChangeAllowed());
780 780
781 if (inputs_.scroll_offset == scroll_offset) 781 if (inputs_.scroll_offset == scroll_offset)
782 return; 782 return;
783 inputs_.scroll_offset = scroll_offset; 783 inputs_.scroll_offset = scroll_offset;
784 784
785 if (!layer_tree_host_) 785 if (!layer_tree_host_)
786 return; 786 return;
787 787
788 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 788 PropertyTrees* property_trees = layer_tree_->property_trees();
789 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) 789 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable())
790 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); 790 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset);
791 791
792 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 792 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
793 id())) { 793 id())) {
794 DCHECK_EQ(transform_tree_index(), 794 DCHECK_EQ(transform_tree_index(),
795 property_trees->transform_id_to_index_map[id()]); 795 property_trees->transform_id_to_index_map[id()]);
796 TransformNode* transform_node = 796 TransformNode* transform_node =
797 property_trees->transform_tree.Node(transform_tree_index()); 797 property_trees->transform_tree.Node(transform_tree_index());
798 transform_node->scroll_offset = CurrentScrollOffset(); 798 transform_node->scroll_offset = CurrentScrollOffset();
(...skipping 12 matching lines...) Expand all
811 // This function only gets called during a BeginMainFrame, so there 811 // This function only gets called during a BeginMainFrame, so there
812 // is no need to call SetNeedsUpdate here. 812 // is no need to call SetNeedsUpdate here.
813 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); 813 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested());
814 if (inputs_.scroll_offset == scroll_offset) 814 if (inputs_.scroll_offset == scroll_offset)
815 return; 815 return;
816 inputs_.scroll_offset = scroll_offset; 816 inputs_.scroll_offset = scroll_offset;
817 SetNeedsPushProperties(); 817 SetNeedsPushProperties();
818 818
819 bool needs_rebuild = true; 819 bool needs_rebuild = true;
820 820
821 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 821 PropertyTrees* property_trees = layer_tree_->property_trees();
822 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) 822 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable())
823 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); 823 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset);
824 824
825 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 825 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
826 id())) { 826 id())) {
827 DCHECK_EQ(transform_tree_index(), 827 DCHECK_EQ(transform_tree_index(),
828 property_trees->transform_id_to_index_map[id()]); 828 property_trees->transform_id_to_index_map[id()]);
829 TransformNode* transform_node = 829 TransformNode* transform_node =
830 property_trees->transform_tree.Node(transform_tree_index()); 830 property_trees->transform_tree.Node(transform_tree_index());
831 transform_node->scroll_offset = CurrentScrollOffset(); 831 transform_node->scroll_offset = CurrentScrollOffset();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 void Layer::SetTransformTreeIndex(int index) { 937 void Layer::SetTransformTreeIndex(int index) {
938 DCHECK(IsPropertyChangeAllowed()); 938 DCHECK(IsPropertyChangeAllowed());
939 if (transform_tree_index_ == index) 939 if (transform_tree_index_ == index)
940 return; 940 return;
941 transform_tree_index_ = index; 941 transform_tree_index_ = index;
942 SetNeedsPushProperties(); 942 SetNeedsPushProperties();
943 } 943 }
944 944
945 int Layer::transform_tree_index() const { 945 int Layer::transform_tree_index() const {
946 if (!layer_tree_host_ || 946 if (!layer_tree_host_ ||
947 layer_tree_host_->property_trees()->sequence_number != 947 layer_tree_->property_trees()->sequence_number !=
948 property_tree_sequence_number_) { 948 property_tree_sequence_number_) {
949 return TransformTree::kInvalidNodeId; 949 return TransformTree::kInvalidNodeId;
950 } 950 }
951 return transform_tree_index_; 951 return transform_tree_index_;
952 } 952 }
953 953
954 void Layer::SetClipTreeIndex(int index) { 954 void Layer::SetClipTreeIndex(int index) {
955 DCHECK(IsPropertyChangeAllowed()); 955 DCHECK(IsPropertyChangeAllowed());
956 if (clip_tree_index_ == index) 956 if (clip_tree_index_ == index)
957 return; 957 return;
958 clip_tree_index_ = index; 958 clip_tree_index_ = index;
959 SetNeedsPushProperties(); 959 SetNeedsPushProperties();
960 } 960 }
961 961
962 int Layer::clip_tree_index() const { 962 int Layer::clip_tree_index() const {
963 if (!layer_tree_host_ || 963 if (!layer_tree_host_ ||
964 layer_tree_host_->property_trees()->sequence_number != 964 layer_tree_->property_trees()->sequence_number !=
965 property_tree_sequence_number_) { 965 property_tree_sequence_number_) {
966 return ClipTree::kInvalidNodeId; 966 return ClipTree::kInvalidNodeId;
967 } 967 }
968 return clip_tree_index_; 968 return clip_tree_index_;
969 } 969 }
970 970
971 void Layer::SetEffectTreeIndex(int index) { 971 void Layer::SetEffectTreeIndex(int index) {
972 DCHECK(IsPropertyChangeAllowed()); 972 DCHECK(IsPropertyChangeAllowed());
973 if (effect_tree_index_ == index) 973 if (effect_tree_index_ == index)
974 return; 974 return;
975 effect_tree_index_ = index; 975 effect_tree_index_ = index;
976 SetNeedsPushProperties(); 976 SetNeedsPushProperties();
977 } 977 }
978 978
979 int Layer::effect_tree_index() const { 979 int Layer::effect_tree_index() const {
980 if (!layer_tree_host_ || 980 if (!layer_tree_host_ ||
981 layer_tree_host_->property_trees()->sequence_number != 981 layer_tree_->property_trees()->sequence_number !=
982 property_tree_sequence_number_) { 982 property_tree_sequence_number_) {
983 return EffectTree::kInvalidNodeId; 983 return EffectTree::kInvalidNodeId;
984 } 984 }
985 return effect_tree_index_; 985 return effect_tree_index_;
986 } 986 }
987 987
988 void Layer::SetScrollTreeIndex(int index) { 988 void Layer::SetScrollTreeIndex(int index) {
989 DCHECK(IsPropertyChangeAllowed()); 989 DCHECK(IsPropertyChangeAllowed());
990 if (scroll_tree_index_ == index) 990 if (scroll_tree_index_ == index)
991 return; 991 return;
992 scroll_tree_index_ = index; 992 scroll_tree_index_ = index;
993 SetNeedsPushProperties(); 993 SetNeedsPushProperties();
994 } 994 }
995 995
996 int Layer::scroll_tree_index() const { 996 int Layer::scroll_tree_index() const {
997 if (!layer_tree_host_ || 997 if (!layer_tree_host_ ||
998 layer_tree_host_->property_trees()->sequence_number != 998 layer_tree_->property_trees()->sequence_number !=
999 property_tree_sequence_number_) { 999 property_tree_sequence_number_) {
1000 return ScrollTree::kInvalidNodeId; 1000 return ScrollTree::kInvalidNodeId;
1001 } 1001 }
1002 return scroll_tree_index_; 1002 return scroll_tree_index_;
1003 } 1003 }
1004 1004
1005 void Layer::InvalidatePropertyTreesIndices() { 1005 void Layer::InvalidatePropertyTreesIndices() {
1006 SetTransformTreeIndex(TransformTree::kInvalidNodeId); 1006 SetTransformTreeIndex(TransformTree::kInvalidNodeId);
1007 SetClipTreeIndex(ClipTree::kInvalidNodeId); 1007 SetClipTreeIndex(ClipTree::kInvalidNodeId);
1008 SetEffectTreeIndex(EffectTree::kInvalidNodeId); 1008 SetEffectTreeIndex(EffectTree::kInvalidNodeId);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 layer->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal); 1171 layer->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal);
1172 layer->set_user_scrollable_vertical(inputs_.user_scrollable_vertical); 1172 layer->set_user_scrollable_vertical(inputs_.user_scrollable_vertical);
1173 layer->SetElementId(inputs_.element_id); 1173 layer->SetElementId(inputs_.element_id);
1174 layer->SetMutableProperties(inputs_.mutable_properties); 1174 layer->SetMutableProperties(inputs_.mutable_properties);
1175 1175
1176 // When a scroll offset animation is interrupted the new scroll position on 1176 // When a scroll offset animation is interrupted the new scroll position on
1177 // the pending tree will clobber any impl-side scrolling occuring on the 1177 // the pending tree will clobber any impl-side scrolling occuring on the
1178 // active tree. To do so, avoid scrolling the pending tree along with it 1178 // active tree. To do so, avoid scrolling the pending tree along with it
1179 // instead of trying to undo that scrolling later. 1179 // instead of trying to undo that scrolling later.
1180 if (ScrollOffsetAnimationWasInterrupted()) 1180 if (ScrollOffsetAnimationWasInterrupted())
1181 layer_tree_host() 1181 layer_tree_->property_trees()
1182 ->property_trees()
1183 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); 1182 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id());
1184 1183
1185 // If the main thread commits multiple times before the impl thread actually 1184 // If the main thread commits multiple times before the impl thread actually
1186 // draws, then damage tracking will become incorrect if we simply clobber the 1185 // draws, then damage tracking will become incorrect if we simply clobber the
1187 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 1186 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
1188 // union) any update changes that have occurred on the main thread. 1187 // union) any update changes that have occurred on the main thread.
1189 inputs_.update_rect.Union(layer->update_rect()); 1188 inputs_.update_rect.Union(layer->update_rect());
1190 layer->SetUpdateRect(inputs_.update_rect); 1189 layer->SetUpdateRect(inputs_.update_rect);
1191 1190
1192 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); 1191 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 DCHECK(!layer_tree_host_); 1281 DCHECK(!layer_tree_host_);
1283 DCHECK(inputs_.children.empty()); 1282 DCHECK(inputs_.children.empty());
1284 DCHECK(!inputs_.mask_layer); 1283 DCHECK(!inputs_.mask_layer);
1285 DCHECK(!inputs_.replica_layer); 1284 DCHECK(!inputs_.replica_layer);
1286 DCHECK(layer_tree_host); 1285 DCHECK(layer_tree_host);
1287 DCHECK(proto.has_id()); 1286 DCHECK(proto.has_id());
1288 1287
1289 inputs_.layer_id = proto.id(); 1288 inputs_.layer_id = proto.id();
1290 1289
1291 layer_tree_host_ = layer_tree_host; 1290 layer_tree_host_ = layer_tree_host;
1292 layer_tree_ = layer_tree_host ? layer_tree_host->GetLayerTree() : nullptr; 1291 layer_tree_ = layer_tree_host->GetLayerTree();
1293 layer_tree_->RegisterLayer(this); 1292 layer_tree_->RegisterLayer(this);
1294 1293
1295 for (int i = 0; i < proto.children_size(); ++i) { 1294 for (int i = 0; i < proto.children_size(); ++i) {
1296 const proto::LayerNode& child_proto = proto.children(i); 1295 const proto::LayerNode& child_proto = proto.children(i);
1297 DCHECK(child_proto.has_type()); 1296 DCHECK(child_proto.has_type());
1298 scoped_refptr<Layer> child = 1297 scoped_refptr<Layer> child =
1299 LayerProtoConverter::FindOrAllocateAndConstruct(child_proto, layer_map); 1298 LayerProtoConverter::FindOrAllocateAndConstruct(child_proto, layer_map);
1300 // The child must now refer to this layer as its parent, and must also have 1299 // The child must now refer to this layer as its parent, and must also have
1301 // the same LayerTreeHost. This must be done before deserializing children. 1300 // the same LayerTreeHost. This must be done before deserializing children.
1302 DCHECK(!child->parent_); 1301 DCHECK(!child->parent_);
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 DCHECK_GE(opacity, 0.f); 1639 DCHECK_GE(opacity, 0.f);
1641 DCHECK_LE(opacity, 1.f); 1640 DCHECK_LE(opacity, 1.f);
1642 1641
1643 if (inputs_.opacity == opacity) 1642 if (inputs_.opacity == opacity)
1644 return; 1643 return;
1645 inputs_.opacity = opacity; 1644 inputs_.opacity = opacity;
1646 // Changing the opacity may make a previously hidden layer visible, so a new 1645 // Changing the opacity may make a previously hidden layer visible, so a new
1647 // recording may be needed. 1646 // recording may be needed.
1648 SetNeedsUpdate(); 1647 SetNeedsUpdate();
1649 if (layer_tree_host_) { 1648 if (layer_tree_host_) {
1650 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1649 PropertyTrees* property_trees = layer_tree_->property_trees();
1651 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, 1650 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT,
1652 id())) { 1651 id())) {
1653 DCHECK_EQ(effect_tree_index(), 1652 DCHECK_EQ(effect_tree_index(),
1654 property_trees->effect_id_to_index_map[id()]); 1653 property_trees->effect_id_to_index_map[id()]);
1655 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1654 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
1656 node->opacity = opacity; 1655 node->opacity = opacity;
1657 property_trees->effect_tree.set_needs_update(true); 1656 property_trees->effect_tree.set_needs_update(true);
1658 } 1657 }
1659 } 1658 }
1660 } 1659 }
1661 1660
1662 void Layer::OnTransformAnimated(const gfx::Transform& transform) { 1661 void Layer::OnTransformAnimated(const gfx::Transform& transform) {
1663 if (inputs_.transform == transform) 1662 if (inputs_.transform == transform)
1664 return; 1663 return;
1665 inputs_.transform = transform; 1664 inputs_.transform = transform;
1666 // Changing the transform may change the visible part of this layer, so a new 1665 // Changing the transform may change the visible part of this layer, so a new
1667 // recording may be needed. 1666 // recording may be needed.
1668 SetNeedsUpdate(); 1667 SetNeedsUpdate();
1669 if (layer_tree_host_) { 1668 if (layer_tree_host_) {
1670 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1669 PropertyTrees* property_trees = layer_tree_->property_trees();
1671 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 1670 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1672 id())) { 1671 id())) {
1673 DCHECK_EQ(transform_tree_index(), 1672 DCHECK_EQ(transform_tree_index(),
1674 property_trees->transform_id_to_index_map[id()]); 1673 property_trees->transform_id_to_index_map[id()]);
1675 TransformNode* node = 1674 TransformNode* node =
1676 property_trees->transform_tree.Node(transform_tree_index()); 1675 property_trees->transform_tree.Node(transform_tree_index());
1677 node->local = transform; 1676 node->local = transform;
1678 node->needs_local_transform_update = true; 1677 node->needs_local_transform_update = true;
1679 node->has_potential_animation = true; 1678 node->has_potential_animation = true;
1680 property_trees->transform_tree.set_needs_update(true); 1679 property_trees->transform_tree.set_needs_update(true);
1681 } 1680 }
1682 } 1681 }
1683 } 1682 }
1684 1683
1685 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { 1684 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) {
1686 // Do nothing. Scroll deltas will be sent from the compositor thread back 1685 // Do nothing. Scroll deltas will be sent from the compositor thread back
1687 // to the main thread in the same manner as during non-animated 1686 // to the main thread in the same manner as during non-animated
1688 // compositor-driven scrolling. 1687 // compositor-driven scrolling.
1689 } 1688 }
1690 1689
1691 void Layer::OnTransformIsCurrentlyAnimatingChanged( 1690 void Layer::OnTransformIsCurrentlyAnimatingChanged(
1692 bool is_currently_animating) { 1691 bool is_currently_animating) {
1693 DCHECK(layer_tree_host_); 1692 DCHECK(layer_tree_host_);
1694 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1693 PropertyTrees* property_trees = layer_tree_->property_trees();
1695 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 1694 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1696 id())) 1695 id()))
1697 return; 1696 return;
1698 DCHECK_EQ(transform_tree_index(), 1697 DCHECK_EQ(transform_tree_index(),
1699 property_trees->transform_id_to_index_map[id()]); 1698 property_trees->transform_id_to_index_map[id()]);
1700 TransformNode* node = 1699 TransformNode* node =
1701 property_trees->transform_tree.Node(transform_tree_index()); 1700 property_trees->transform_tree.Node(transform_tree_index());
1702 node->is_currently_animating = is_currently_animating; 1701 node->is_currently_animating = is_currently_animating;
1703 } 1702 }
1704 1703
1705 void Layer::OnTransformIsPotentiallyAnimatingChanged( 1704 void Layer::OnTransformIsPotentiallyAnimatingChanged(
1706 bool has_potential_animation) { 1705 bool has_potential_animation) {
1707 if (!layer_tree_host_) 1706 if (!layer_tree_host_)
1708 return; 1707 return;
1709 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1708 PropertyTrees* property_trees = layer_tree_->property_trees();
1710 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 1709 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1711 id())) 1710 id()))
1712 return; 1711 return;
1713 DCHECK_EQ(transform_tree_index(), 1712 DCHECK_EQ(transform_tree_index(),
1714 property_trees->transform_id_to_index_map[id()]); 1713 property_trees->transform_id_to_index_map[id()]);
1715 TransformNode* node = 1714 TransformNode* node =
1716 property_trees->transform_tree.Node(transform_tree_index()); 1715 property_trees->transform_tree.Node(transform_tree_index());
1717 1716
1718 node->has_potential_animation = has_potential_animation; 1717 node->has_potential_animation = has_potential_animation;
1719 if (has_potential_animation) { 1718 if (has_potential_animation) {
1720 node->has_only_translation_animations = HasOnlyTranslationTransforms(); 1719 node->has_only_translation_animations = HasOnlyTranslationTransforms();
1721 } else { 1720 } else {
1722 node->has_only_translation_animations = true; 1721 node->has_only_translation_animations = true;
1723 } 1722 }
1724 property_trees->transform_tree.set_needs_update(true); 1723 property_trees->transform_tree.set_needs_update(true);
1725 } 1724 }
1726 1725
1727 void Layer::OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating) { 1726 void Layer::OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating) {
1728 DCHECK(layer_tree_host_); 1727 DCHECK(layer_tree_host_);
1729 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1728 PropertyTrees* property_trees = layer_tree_->property_trees();
1730 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1729 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
1731 return; 1730 return;
1732 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1731 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]);
1733 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1732 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
1734 node->is_currently_animating_opacity = is_currently_animating; 1733 node->is_currently_animating_opacity = is_currently_animating;
1735 } 1734 }
1736 1735
1737 void Layer::OnOpacityIsPotentiallyAnimatingChanged( 1736 void Layer::OnOpacityIsPotentiallyAnimatingChanged(
1738 bool has_potential_animation) { 1737 bool has_potential_animation) {
1739 DCHECK(layer_tree_host_); 1738 DCHECK(layer_tree_host_);
1740 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1739 PropertyTrees* property_trees = layer_tree_->property_trees();
1741 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1740 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
1742 return; 1741 return;
1743 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1742 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]);
1744 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1743 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
1745 node->has_potential_opacity_animation = 1744 node->has_potential_opacity_animation =
1746 has_potential_animation || OpacityCanAnimateOnImplThread(); 1745 has_potential_animation || OpacityCanAnimateOnImplThread();
1747 property_trees->effect_tree.set_needs_update(true); 1746 property_trees->effect_tree.set_needs_update(true);
1748 } 1747 }
1749 1748
1750 void Layer::OnFilterIsCurrentlyAnimatingChanged(bool is_currently_animating) { 1749 void Layer::OnFilterIsCurrentlyAnimatingChanged(bool is_currently_animating) {
1751 DCHECK(layer_tree_host_); 1750 DCHECK(layer_tree_host_);
1752 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1751 PropertyTrees* property_trees = layer_tree_->property_trees();
1753 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1752 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
1754 return; 1753 return;
1755 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1754 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]);
1756 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1755 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
1757 node->is_currently_animating_filter = is_currently_animating; 1756 node->is_currently_animating_filter = is_currently_animating;
1758 } 1757 }
1759 1758
1760 void Layer::OnFilterIsPotentiallyAnimatingChanged( 1759 void Layer::OnFilterIsPotentiallyAnimatingChanged(
1761 bool has_potential_animation) { 1760 bool has_potential_animation) {
1762 DCHECK(layer_tree_host_); 1761 DCHECK(layer_tree_host_);
1763 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1762 PropertyTrees* property_trees = layer_tree_->property_trees();
1764 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 1763 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
1765 return; 1764 return;
1766 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]); 1765 DCHECK_EQ(effect_tree_index(), property_trees->effect_id_to_index_map[id()]);
1767 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1766 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
1768 node->has_potential_filter_animation = has_potential_animation; 1767 node->has_potential_filter_animation = has_potential_animation;
1769 } 1768 }
1770 1769
1771 bool Layer::HasActiveAnimationForTesting() const { 1770 bool Layer::HasActiveAnimationForTesting() const {
1772 return layer_tree_host_ 1771 return layer_tree_host_
1773 ? GetAnimationHost()->HasActiveAnimationForTesting(element_id()) 1772 ? GetAnimationHost()->HasActiveAnimationForTesting(element_id())
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 1864
1866 void Layer::DidBeginTracing() { 1865 void Layer::DidBeginTracing() {
1867 // We'll be dumping layer trees as part of trace, so make sure 1866 // We'll be dumping layer trees as part of trace, so make sure
1868 // PushPropertiesTo() propagates layer debug info to the impl 1867 // PushPropertiesTo() propagates layer debug info to the impl
1869 // side -- otherwise this won't happen for the the layers that 1868 // side -- otherwise this won't happen for the the layers that
1870 // remain unchanged since tracing started. 1869 // remain unchanged since tracing started.
1871 SetNeedsPushProperties(); 1870 SetNeedsPushProperties();
1872 } 1871 }
1873 1872
1874 int Layer::num_copy_requests_in_target_subtree() { 1873 int Layer::num_copy_requests_in_target_subtree() {
1875 return layer_tree_host() 1874 return layer_tree_->property_trees()
1876 ->property_trees()
1877 ->effect_tree.Node(effect_tree_index()) 1875 ->effect_tree.Node(effect_tree_index())
1878 ->num_copy_requests_in_subtree; 1876 ->num_copy_requests_in_subtree;
1879 } 1877 }
1880 1878
1881 gfx::Transform Layer::screen_space_transform() const { 1879 gfx::Transform Layer::screen_space_transform() const {
1882 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1880 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1883 return draw_property_utils::ScreenSpaceTransform( 1881 return draw_property_utils::ScreenSpaceTransform(
1884 this, layer_tree_host_->property_trees()->transform_tree); 1882 this, layer_tree_->property_trees()->transform_tree);
1885 } 1883 }
1886 1884
1887 LayerTree* Layer::GetLayerTree() const { 1885 LayerTree* Layer::GetLayerTree() const {
1888 return layer_tree_; 1886 return layer_tree_;
1889 } 1887 }
1890 1888
1891 } // namespace cc 1889 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698