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

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

Powered by Google App Engine
This is Rietveld 408576698