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

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

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 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.h ('k') | cc/layers/layer_list_iterator_unittest.cc » ('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 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 Layer::Inputs::~Inputs() {} 69 Layer::Inputs::~Inputs() {}
70 70
71 scoped_refptr<Layer> Layer::Create() { 71 scoped_refptr<Layer> Layer::Create() {
72 return make_scoped_refptr(new Layer()); 72 return make_scoped_refptr(new Layer());
73 } 73 }
74 74
75 Layer::Layer() 75 Layer::Layer()
76 : ignore_set_needs_commit_(false), 76 : ignore_set_needs_commit_(false),
77 parent_(nullptr), 77 parent_(nullptr),
78 layer_tree_host_(nullptr), 78 layer_tree_host_(nullptr),
79 layer_tree_(nullptr),
80 // Layer IDs start from 1. 79 // Layer IDs start from 1.
81 inputs_(g_next_layer_id.GetNext() + 1), 80 inputs_(g_next_layer_id.GetNext() + 1),
82 num_descendants_that_draw_content_(0), 81 num_descendants_that_draw_content_(0),
83 transform_tree_index_(TransformTree::kInvalidNodeId), 82 transform_tree_index_(TransformTree::kInvalidNodeId),
84 effect_tree_index_(EffectTree::kInvalidNodeId), 83 effect_tree_index_(EffectTree::kInvalidNodeId),
85 clip_tree_index_(ClipTree::kInvalidNodeId), 84 clip_tree_index_(ClipTree::kInvalidNodeId),
86 scroll_tree_index_(ScrollTree::kInvalidNodeId), 85 scroll_tree_index_(ScrollTree::kInvalidNodeId),
87 property_tree_sequence_number_(-1), 86 property_tree_sequence_number_(-1),
88 should_flatten_transform_from_property_tree_(false), 87 should_flatten_transform_from_property_tree_(false),
89 draws_content_(false), 88 draws_content_(false),
(...skipping 23 matching lines...) Expand all
113 DCHECK_EQ(this, inputs_.mask_layer->parent()); 112 DCHECK_EQ(this, inputs_.mask_layer->parent());
114 inputs_.mask_layer->RemoveFromParent(); 113 inputs_.mask_layer->RemoveFromParent();
115 } 114 }
116 } 115 }
117 116
118 void Layer::SetLayerTreeHost(LayerTreeHost* host) { 117 void Layer::SetLayerTreeHost(LayerTreeHost* host) {
119 if (layer_tree_host_ == host) 118 if (layer_tree_host_ == host)
120 return; 119 return;
121 120
122 if (layer_tree_host_) { 121 if (layer_tree_host_) {
123 layer_tree_->property_trees()->RemoveIdFromIdToIndexMaps(id()); 122 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id());
124 layer_tree_->property_trees()->needs_rebuild = true; 123 layer_tree_host_->property_trees()->needs_rebuild = true;
125 layer_tree_->UnregisterLayer(this); 124 layer_tree_host_->UnregisterLayer(this);
126 if (inputs_.element_id) { 125 if (inputs_.element_id) {
127 layer_tree_->UnregisterElement(inputs_.element_id, 126 layer_tree_host_->UnregisterElement(inputs_.element_id,
128 ElementListType::ACTIVE, this); 127 ElementListType::ACTIVE, this);
129 } 128 }
130 } 129 }
131 if (host) { 130 if (host) {
132 host->GetLayerTree()->property_trees()->needs_rebuild = true; 131 host->property_trees()->needs_rebuild = true;
133 host->GetLayerTree()->RegisterLayer(this); 132 host->RegisterLayer(this);
134 if (inputs_.element_id) { 133 if (inputs_.element_id) {
135 host->GetLayerTree()->RegisterElement(inputs_.element_id, 134 host->RegisterElement(inputs_.element_id, ElementListType::ACTIVE, this);
136 ElementListType::ACTIVE, this);
137 } 135 }
138 } 136 }
139 137
140 layer_tree_host_ = host; 138 layer_tree_host_ = host;
141 layer_tree_ = host ? host->GetLayerTree() : nullptr;
142 InvalidatePropertyTreesIndices(); 139 InvalidatePropertyTreesIndices();
143 140
144 // When changing hosts, the layer needs to commit its properties to the impl 141 // When changing hosts, the layer needs to commit its properties to the impl
145 // side for the new host. 142 // side for the new host.
146 SetNeedsPushProperties(); 143 SetNeedsPushProperties();
147 144
148 for (size_t i = 0; i < inputs_.children.size(); ++i) 145 for (size_t i = 0; i < inputs_.children.size(); ++i)
149 inputs_.children[i]->SetLayerTreeHost(host); 146 inputs_.children[i]->SetLayerTreeHost(host);
150 147
151 if (inputs_.mask_layer.get()) 148 if (inputs_.mask_layer.get())
(...skipping 10 matching lines...) Expand all
162 void Layer::SetNeedsUpdate() { 159 void Layer::SetNeedsUpdate() {
163 if (layer_tree_host_ && !ignore_set_needs_commit_) 160 if (layer_tree_host_ && !ignore_set_needs_commit_)
164 layer_tree_host_->SetNeedsUpdateLayers(); 161 layer_tree_host_->SetNeedsUpdateLayers();
165 } 162 }
166 163
167 void Layer::SetNeedsCommit() { 164 void Layer::SetNeedsCommit() {
168 if (!layer_tree_host_) 165 if (!layer_tree_host_)
169 return; 166 return;
170 167
171 SetNeedsPushProperties(); 168 SetNeedsPushProperties();
172 layer_tree_->property_trees()->needs_rebuild = true; 169 layer_tree_host_->property_trees()->needs_rebuild = true;
173 170
174 if (ignore_set_needs_commit_) 171 if (ignore_set_needs_commit_)
175 return; 172 return;
176 173
177 layer_tree_host_->SetNeedsCommit(); 174 layer_tree_host_->SetNeedsCommit();
178 } 175 }
179 176
180 void Layer::SetNeedsCommitNoRebuild() { 177 void Layer::SetNeedsCommitNoRebuild() {
181 if (!layer_tree_host_) 178 if (!layer_tree_host_)
182 return; 179 return;
183 180
184 SetNeedsPushProperties(); 181 SetNeedsPushProperties();
185 182
186 if (ignore_set_needs_commit_) 183 if (ignore_set_needs_commit_)
187 return; 184 return;
188 185
189 layer_tree_host_->SetNeedsCommit(); 186 layer_tree_host_->SetNeedsCommit();
190 } 187 }
191 188
192 void Layer::SetNeedsFullTreeSync() { 189 void Layer::SetNeedsFullTreeSync() {
193 if (!layer_tree_) 190 if (!layer_tree_host_)
194 return; 191 return;
195 192
196 layer_tree_->SetNeedsFullTreeSync(); 193 layer_tree_host_->SetNeedsFullTreeSync();
197 } 194 }
198 195
199 void Layer::SetNextCommitWaitsForActivation() { 196 void Layer::SetNextCommitWaitsForActivation() {
200 if (!layer_tree_host_) 197 if (!layer_tree_host_)
201 return; 198 return;
202 199
203 layer_tree_host_->SetNextCommitWaitsForActivation(); 200 layer_tree_host_->SetNextCommitWaitsForActivation();
204 } 201 }
205 202
206 void Layer::SetNeedsPushProperties() { 203 void Layer::SetNeedsPushProperties() {
207 if (layer_tree_) 204 if (layer_tree_host_)
208 layer_tree_->AddLayerShouldPushProperties(this); 205 layer_tree_host_->AddLayerShouldPushProperties(this);
209 } 206 }
210 207
211 void Layer::ResetNeedsPushPropertiesForTesting() { 208 void Layer::ResetNeedsPushPropertiesForTesting() {
212 if (layer_tree_) 209 if (layer_tree_host_)
213 layer_tree_->RemoveLayerShouldPushProperties(this); 210 layer_tree_host_->RemoveLayerShouldPushProperties(this);
214 } 211 }
215 212
216 bool Layer::IsPropertyChangeAllowed() const { 213 bool Layer::IsPropertyChangeAllowed() const {
217 if (!layer_tree_) 214 if (!layer_tree_host_)
218 return true; 215 return true;
219 216
220 return !layer_tree_->in_paint_layer_contents(); 217 return !layer_tree_host_->in_paint_layer_contents();
221 } 218 }
222 219
223 sk_sp<SkPicture> Layer::GetPicture() const { 220 sk_sp<SkPicture> Layer::GetPicture() const {
224 return nullptr; 221 return nullptr;
225 } 222 }
226 223
227 void Layer::SetParent(Layer* layer) { 224 void Layer::SetParent(Layer* layer) {
228 DCHECK(!layer || !layer->HasAncestor(this)); 225 DCHECK(!layer || !layer->HasAncestor(this));
229 226
230 parent_ = layer; 227 parent_ = layer;
231 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr); 228 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr);
232 229
233 if (!layer_tree_host_) 230 if (!layer_tree_host_)
234 return; 231 return;
235 232
236 layer_tree_->property_trees()->needs_rebuild = true; 233 layer_tree_host_->property_trees()->needs_rebuild = true;
237 } 234 }
238 235
239 void Layer::AddChild(scoped_refptr<Layer> child) { 236 void Layer::AddChild(scoped_refptr<Layer> child) {
240 InsertChild(child, inputs_.children.size()); 237 InsertChild(child, inputs_.children.size());
241 } 238 }
242 239
243 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { 240 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) {
244 DCHECK(IsPropertyChangeAllowed()); 241 DCHECK(IsPropertyChangeAllowed());
245 child->RemoveFromParent(); 242 child->RemoveFromParent();
246 AddDrawableDescendants(child->NumDescendantsThatDrawContent() + 243 AddDrawableDescendants(child->NumDescendantsThatDrawContent() +
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 DCHECK_LE(opacity, 1.f); 457 DCHECK_LE(opacity, 1.f);
461 458
462 if (inputs_.opacity == opacity) 459 if (inputs_.opacity == opacity)
463 return; 460 return;
464 // We need to force a property tree rebuild when opacity changes from 1 to a 461 // We need to force a property tree rebuild when opacity changes from 1 to a
465 // non-1 value or vice-versa as render surfaces can change. 462 // non-1 value or vice-versa as render surfaces can change.
466 bool force_rebuild = opacity == 1.f || inputs_.opacity == 1.f; 463 bool force_rebuild = opacity == 1.f || inputs_.opacity == 1.f;
467 inputs_.opacity = opacity; 464 inputs_.opacity = opacity;
468 SetSubtreePropertyChanged(); 465 SetSubtreePropertyChanged();
469 if (layer_tree_host_ && !force_rebuild) { 466 if (layer_tree_host_ && !force_rebuild) {
470 PropertyTrees* property_trees = layer_tree_->property_trees(); 467 PropertyTrees* property_trees = layer_tree_host_->property_trees();
471 auto effect_id_to_index = 468 auto effect_id_to_index =
472 property_trees->layer_id_to_effect_node_index.find(id()); 469 property_trees->layer_id_to_effect_node_index.find(id());
473 if (effect_id_to_index != 470 if (effect_id_to_index !=
474 property_trees->layer_id_to_effect_node_index.end()) { 471 property_trees->layer_id_to_effect_node_index.end()) {
475 EffectNode* node = 472 EffectNode* node =
476 property_trees->effect_tree.Node(effect_id_to_index->second); 473 property_trees->effect_tree.Node(effect_id_to_index->second);
477 node->opacity = opacity; 474 node->opacity = opacity;
478 node->effect_changed = true; 475 node->effect_changed = true;
479 property_trees->effect_tree.set_needs_update(true); 476 property_trees->effect_tree.set_needs_update(true);
480 SetNeedsCommitNoRebuild(); 477 SetNeedsCommitNoRebuild();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 void Layer::SetPosition(const gfx::PointF& position) { 563 void Layer::SetPosition(const gfx::PointF& position) {
567 DCHECK(IsPropertyChangeAllowed()); 564 DCHECK(IsPropertyChangeAllowed());
568 if (inputs_.position == position) 565 if (inputs_.position == position)
569 return; 566 return;
570 inputs_.position = position; 567 inputs_.position = position;
571 568
572 if (!layer_tree_host_) 569 if (!layer_tree_host_)
573 return; 570 return;
574 571
575 SetSubtreePropertyChanged(); 572 SetSubtreePropertyChanged();
576 PropertyTrees* property_trees = layer_tree_->property_trees(); 573 PropertyTrees* property_trees = layer_tree_host_->property_trees();
577 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 574 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
578 id())) { 575 id())) {
579 DCHECK_EQ(transform_tree_index(), 576 DCHECK_EQ(transform_tree_index(),
580 property_trees->layer_id_to_transform_node_index[id()]); 577 property_trees->layer_id_to_transform_node_index[id()]);
581 TransformNode* transform_node = 578 TransformNode* transform_node =
582 property_trees->transform_tree.Node(transform_tree_index()); 579 property_trees->transform_tree.Node(transform_tree_index());
583 transform_node->update_post_local_transform(position, transform_origin()); 580 transform_node->update_post_local_transform(position, transform_origin());
584 if (transform_node->sticky_position_constraint_id >= 0) { 581 if (transform_node->sticky_position_constraint_id >= 0) {
585 StickyPositionNodeData* sticky_data = 582 StickyPositionNodeData* sticky_data =
586 property_trees->transform_tree.StickyPositionData( 583 property_trees->transform_tree.StickyPositionData(
587 transform_tree_index()); 584 transform_tree_index());
588 sticky_data->main_thread_offset = 585 sticky_data->main_thread_offset =
589 position.OffsetFromOrigin() - 586 position.OffsetFromOrigin() -
590 sticky_data->constraints.parent_relative_sticky_box_offset 587 sticky_data->constraints.parent_relative_sticky_box_offset
591 .OffsetFromOrigin(); 588 .OffsetFromOrigin();
592 } 589 }
593 transform_node->needs_local_transform_update = true; 590 transform_node->needs_local_transform_update = true;
594 transform_node->transform_changed = true; 591 transform_node->transform_changed = true;
595 layer_tree_->property_trees()->transform_tree.set_needs_update(true); 592 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
596 SetNeedsCommitNoRebuild(); 593 SetNeedsCommitNoRebuild();
597 return; 594 return;
598 } 595 }
599 596
600 SetNeedsCommit(); 597 SetNeedsCommit();
601 } 598 }
602 599
603 bool Layer::IsContainerForFixedPositionLayers() const { 600 bool Layer::IsContainerForFixedPositionLayers() const {
604 if (!inputs_.transform.IsIdentityOrTranslation()) 601 if (!inputs_.transform.IsIdentityOrTranslation())
605 return true; 602 return true;
(...skipping 17 matching lines...) Expand all
623 } 620 }
624 } 621 }
625 622
626 void Layer::SetTransform(const gfx::Transform& transform) { 623 void Layer::SetTransform(const gfx::Transform& transform) {
627 DCHECK(IsPropertyChangeAllowed()); 624 DCHECK(IsPropertyChangeAllowed());
628 if (inputs_.transform == transform) 625 if (inputs_.transform == transform)
629 return; 626 return;
630 627
631 SetSubtreePropertyChanged(); 628 SetSubtreePropertyChanged();
632 if (layer_tree_host_) { 629 if (layer_tree_host_) {
633 PropertyTrees* property_trees = layer_tree_->property_trees(); 630 PropertyTrees* property_trees = layer_tree_host_->property_trees();
634 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 631 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
635 id())) { 632 id())) {
636 // We need to trigger a rebuild if we could have affected 2d axis 633 // We need to trigger a rebuild if we could have affected 2d axis
637 // alignment. We'll check to see if transform and inputs_.transform 634 // alignment. We'll check to see if transform and inputs_.transform
638 // are axis 635 // are axis
639 // align with respect to one another. 636 // align with respect to one another.
640 DCHECK_EQ(transform_tree_index(), 637 DCHECK_EQ(transform_tree_index(),
641 property_trees->layer_id_to_transform_node_index[id()]); 638 property_trees->layer_id_to_transform_node_index[id()]);
642 TransformNode* transform_node = 639 TransformNode* transform_node =
643 property_trees->transform_tree.Node(transform_tree_index()); 640 property_trees->transform_tree.Node(transform_tree_index());
644 bool preserves_2d_axis_alignment = 641 bool preserves_2d_axis_alignment =
645 Are2dAxisAligned(inputs_.transform, transform); 642 Are2dAxisAligned(inputs_.transform, transform);
646 transform_node->local = transform; 643 transform_node->local = transform;
647 transform_node->needs_local_transform_update = true; 644 transform_node->needs_local_transform_update = true;
648 transform_node->transform_changed = true; 645 transform_node->transform_changed = true;
649 layer_tree_->property_trees()->transform_tree.set_needs_update(true); 646 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
650 if (preserves_2d_axis_alignment) 647 if (preserves_2d_axis_alignment)
651 SetNeedsCommitNoRebuild(); 648 SetNeedsCommitNoRebuild();
652 else 649 else
653 SetNeedsCommit(); 650 SetNeedsCommit();
654 inputs_.transform = transform; 651 inputs_.transform = transform;
655 return; 652 return;
656 } 653 }
657 } 654 }
658 655
659 inputs_.transform = transform; 656 inputs_.transform = transform;
660 657
661 SetNeedsCommit(); 658 SetNeedsCommit();
662 } 659 }
663 660
664 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { 661 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) {
665 DCHECK(IsPropertyChangeAllowed()); 662 DCHECK(IsPropertyChangeAllowed());
666 if (inputs_.transform_origin == transform_origin) 663 if (inputs_.transform_origin == transform_origin)
667 return; 664 return;
668 inputs_.transform_origin = transform_origin; 665 inputs_.transform_origin = transform_origin;
669 666
670 if (!layer_tree_host_) 667 if (!layer_tree_host_)
671 return; 668 return;
672 669
673 SetSubtreePropertyChanged(); 670 SetSubtreePropertyChanged();
674 PropertyTrees* property_trees = layer_tree_->property_trees(); 671 PropertyTrees* property_trees = layer_tree_host_->property_trees();
675 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 672 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
676 id())) { 673 id())) {
677 DCHECK_EQ(transform_tree_index(), 674 DCHECK_EQ(transform_tree_index(),
678 property_trees->layer_id_to_transform_node_index[id()]); 675 property_trees->layer_id_to_transform_node_index[id()]);
679 TransformNode* transform_node = 676 TransformNode* transform_node =
680 property_trees->transform_tree.Node(transform_tree_index()); 677 property_trees->transform_tree.Node(transform_tree_index());
681 transform_node->update_pre_local_transform(transform_origin); 678 transform_node->update_pre_local_transform(transform_origin);
682 transform_node->update_post_local_transform(position(), transform_origin); 679 transform_node->update_post_local_transform(position(), transform_origin);
683 transform_node->needs_local_transform_update = true; 680 transform_node->needs_local_transform_update = true;
684 transform_node->transform_changed = true; 681 transform_node->transform_changed = true;
685 layer_tree_->property_trees()->transform_tree.set_needs_update(true); 682 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
686 SetNeedsCommitNoRebuild(); 683 SetNeedsCommitNoRebuild();
687 return; 684 return;
688 } 685 }
689 686
690 SetNeedsCommit(); 687 SetNeedsCommit();
691 } 688 }
692 689
693 bool Layer::ScrollOffsetAnimationWasInterrupted() const { 690 bool Layer::ScrollOffsetAnimationWasInterrupted() const {
694 return GetMutatorHost()->ScrollOffsetAnimationWasInterrupted(element_id()); 691 return GetMutatorHost()->ScrollOffsetAnimationWasInterrupted(element_id());
695 } 692 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 733
737 if (inputs_.clip_parent) 734 if (inputs_.clip_parent)
738 inputs_.clip_parent->RemoveClipChild(this); 735 inputs_.clip_parent->RemoveClipChild(this);
739 736
740 inputs_.clip_parent = ancestor; 737 inputs_.clip_parent = ancestor;
741 738
742 if (inputs_.clip_parent) 739 if (inputs_.clip_parent)
743 inputs_.clip_parent->AddClipChild(this); 740 inputs_.clip_parent->AddClipChild(this);
744 741
745 SetNeedsCommit(); 742 SetNeedsCommit();
746 if (layer_tree_) 743 if (layer_tree_host_)
747 layer_tree_->SetNeedsMetaInfoRecomputation(true); 744 layer_tree_host_->SetNeedsMetaInfoRecomputation(true);
748 } 745 }
749 746
750 void Layer::AddClipChild(Layer* child) { 747 void Layer::AddClipChild(Layer* child) {
751 if (!clip_children_) 748 if (!clip_children_)
752 clip_children_.reset(new std::set<Layer*>); 749 clip_children_.reset(new std::set<Layer*>);
753 clip_children_->insert(child); 750 clip_children_->insert(child);
754 SetNeedsCommit(); 751 SetNeedsCommit();
755 } 752 }
756 753
757 void Layer::RemoveClipChild(Layer* child) { 754 void Layer::RemoveClipChild(Layer* child) {
758 clip_children_->erase(child); 755 clip_children_->erase(child);
759 if (clip_children_->empty()) 756 if (clip_children_->empty())
760 clip_children_ = nullptr; 757 clip_children_ = nullptr;
761 SetNeedsCommit(); 758 SetNeedsCommit();
762 } 759 }
763 760
764 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { 761 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) {
765 DCHECK(IsPropertyChangeAllowed()); 762 DCHECK(IsPropertyChangeAllowed());
766 763
767 if (inputs_.scroll_offset == scroll_offset) 764 if (inputs_.scroll_offset == scroll_offset)
768 return; 765 return;
769 inputs_.scroll_offset = scroll_offset; 766 inputs_.scroll_offset = scroll_offset;
770 767
771 if (!layer_tree_host_) 768 if (!layer_tree_host_)
772 return; 769 return;
773 770
774 PropertyTrees* property_trees = layer_tree_->property_trees(); 771 PropertyTrees* property_trees = layer_tree_host_->property_trees();
775 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) 772 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable())
776 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); 773 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset);
777 774
778 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 775 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
779 id())) { 776 id())) {
780 DCHECK_EQ(transform_tree_index(), 777 DCHECK_EQ(transform_tree_index(),
781 property_trees->layer_id_to_transform_node_index[id()]); 778 property_trees->layer_id_to_transform_node_index[id()]);
782 TransformNode* transform_node = 779 TransformNode* transform_node =
783 property_trees->transform_tree.Node(transform_tree_index()); 780 property_trees->transform_tree.Node(transform_tree_index());
784 transform_node->scroll_offset = CurrentScrollOffset(); 781 transform_node->scroll_offset = CurrentScrollOffset();
(...skipping 12 matching lines...) Expand all
797 // This function only gets called during a BeginMainFrame, so there 794 // This function only gets called during a BeginMainFrame, so there
798 // is no need to call SetNeedsUpdate here. 795 // is no need to call SetNeedsUpdate here.
799 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); 796 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested());
800 if (inputs_.scroll_offset == scroll_offset) 797 if (inputs_.scroll_offset == scroll_offset)
801 return; 798 return;
802 inputs_.scroll_offset = scroll_offset; 799 inputs_.scroll_offset = scroll_offset;
803 SetNeedsPushProperties(); 800 SetNeedsPushProperties();
804 801
805 bool needs_rebuild = true; 802 bool needs_rebuild = true;
806 803
807 PropertyTrees* property_trees = layer_tree_->property_trees(); 804 PropertyTrees* property_trees = layer_tree_host_->property_trees();
808 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) 805 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable())
809 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); 806 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset);
810 807
811 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 808 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
812 id())) { 809 id())) {
813 DCHECK_EQ(transform_tree_index(), 810 DCHECK_EQ(transform_tree_index(),
814 property_trees->layer_id_to_transform_node_index[id()]); 811 property_trees->layer_id_to_transform_node_index[id()]);
815 TransformNode* transform_node = 812 TransformNode* transform_node =
816 property_trees->transform_tree.Node(transform_tree_index()); 813 property_trees->transform_tree.Node(transform_tree_index());
817 transform_node->scroll_offset = CurrentScrollOffset(); 814 transform_node->scroll_offset = CurrentScrollOffset();
(...skipping 13 matching lines...) Expand all
831 828
832 void Layer::SetScrollClipLayerId(int clip_layer_id) { 829 void Layer::SetScrollClipLayerId(int clip_layer_id) {
833 DCHECK(IsPropertyChangeAllowed()); 830 DCHECK(IsPropertyChangeAllowed());
834 if (inputs_.scroll_clip_layer_id == clip_layer_id) 831 if (inputs_.scroll_clip_layer_id == clip_layer_id)
835 return; 832 return;
836 inputs_.scroll_clip_layer_id = clip_layer_id; 833 inputs_.scroll_clip_layer_id = clip_layer_id;
837 SetNeedsCommit(); 834 SetNeedsCommit();
838 } 835 }
839 836
840 Layer* Layer::scroll_clip_layer() const { 837 Layer* Layer::scroll_clip_layer() const {
841 DCHECK(layer_tree_); 838 DCHECK(layer_tree_host_);
842 return layer_tree_->LayerById(inputs_.scroll_clip_layer_id); 839 return layer_tree_host_->LayerById(inputs_.scroll_clip_layer_id);
843 } 840 }
844 841
845 void Layer::SetUserScrollable(bool horizontal, bool vertical) { 842 void Layer::SetUserScrollable(bool horizontal, bool vertical) {
846 DCHECK(IsPropertyChangeAllowed()); 843 DCHECK(IsPropertyChangeAllowed());
847 if (inputs_.user_scrollable_horizontal == horizontal && 844 if (inputs_.user_scrollable_horizontal == horizontal &&
848 inputs_.user_scrollable_vertical == vertical) 845 inputs_.user_scrollable_vertical == vertical)
849 return; 846 return;
850 inputs_.user_scrollable_horizontal = horizontal; 847 inputs_.user_scrollable_horizontal = horizontal;
851 inputs_.user_scrollable_vertical = vertical; 848 inputs_.user_scrollable_vertical = vertical;
852 SetNeedsCommit(); 849 SetNeedsCommit();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 void Layer::SetTransformTreeIndex(int index) { 921 void Layer::SetTransformTreeIndex(int index) {
925 DCHECK(IsPropertyChangeAllowed()); 922 DCHECK(IsPropertyChangeAllowed());
926 if (transform_tree_index_ == index) 923 if (transform_tree_index_ == index)
927 return; 924 return;
928 transform_tree_index_ = index; 925 transform_tree_index_ = index;
929 SetNeedsPushProperties(); 926 SetNeedsPushProperties();
930 } 927 }
931 928
932 int Layer::transform_tree_index() const { 929 int Layer::transform_tree_index() const {
933 if (!layer_tree_host_ || 930 if (!layer_tree_host_ ||
934 layer_tree_->property_trees()->sequence_number != 931 layer_tree_host_->property_trees()->sequence_number !=
935 property_tree_sequence_number_) { 932 property_tree_sequence_number_) {
936 return TransformTree::kInvalidNodeId; 933 return TransformTree::kInvalidNodeId;
937 } 934 }
938 return transform_tree_index_; 935 return transform_tree_index_;
939 } 936 }
940 937
941 void Layer::SetClipTreeIndex(int index) { 938 void Layer::SetClipTreeIndex(int index) {
942 DCHECK(IsPropertyChangeAllowed()); 939 DCHECK(IsPropertyChangeAllowed());
943 if (clip_tree_index_ == index) 940 if (clip_tree_index_ == index)
944 return; 941 return;
945 clip_tree_index_ = index; 942 clip_tree_index_ = index;
946 SetNeedsPushProperties(); 943 SetNeedsPushProperties();
947 } 944 }
948 945
949 int Layer::clip_tree_index() const { 946 int Layer::clip_tree_index() const {
950 if (!layer_tree_host_ || 947 if (!layer_tree_host_ ||
951 layer_tree_->property_trees()->sequence_number != 948 layer_tree_host_->property_trees()->sequence_number !=
952 property_tree_sequence_number_) { 949 property_tree_sequence_number_) {
953 return ClipTree::kInvalidNodeId; 950 return ClipTree::kInvalidNodeId;
954 } 951 }
955 return clip_tree_index_; 952 return clip_tree_index_;
956 } 953 }
957 954
958 void Layer::SetEffectTreeIndex(int index) { 955 void Layer::SetEffectTreeIndex(int index) {
959 DCHECK(IsPropertyChangeAllowed()); 956 DCHECK(IsPropertyChangeAllowed());
960 if (effect_tree_index_ == index) 957 if (effect_tree_index_ == index)
961 return; 958 return;
962 effect_tree_index_ = index; 959 effect_tree_index_ = index;
963 SetNeedsPushProperties(); 960 SetNeedsPushProperties();
964 } 961 }
965 962
966 int Layer::effect_tree_index() const { 963 int Layer::effect_tree_index() const {
967 if (!layer_tree_host_ || 964 if (!layer_tree_host_ ||
968 layer_tree_->property_trees()->sequence_number != 965 layer_tree_host_->property_trees()->sequence_number !=
969 property_tree_sequence_number_) { 966 property_tree_sequence_number_) {
970 return EffectTree::kInvalidNodeId; 967 return EffectTree::kInvalidNodeId;
971 } 968 }
972 return effect_tree_index_; 969 return effect_tree_index_;
973 } 970 }
974 971
975 void Layer::SetScrollTreeIndex(int index) { 972 void Layer::SetScrollTreeIndex(int index) {
976 DCHECK(IsPropertyChangeAllowed()); 973 DCHECK(IsPropertyChangeAllowed());
977 if (scroll_tree_index_ == index) 974 if (scroll_tree_index_ == index)
978 return; 975 return;
979 scroll_tree_index_ = index; 976 scroll_tree_index_ = index;
980 SetNeedsPushProperties(); 977 SetNeedsPushProperties();
981 } 978 }
982 979
983 int Layer::scroll_tree_index() const { 980 int Layer::scroll_tree_index() const {
984 if (!layer_tree_host_ || 981 if (!layer_tree_host_ ||
985 layer_tree_->property_trees()->sequence_number != 982 layer_tree_host_->property_trees()->sequence_number !=
986 property_tree_sequence_number_) { 983 property_tree_sequence_number_) {
987 return ScrollTree::kInvalidNodeId; 984 return ScrollTree::kInvalidNodeId;
988 } 985 }
989 return scroll_tree_index_; 986 return scroll_tree_index_;
990 } 987 }
991 988
992 void Layer::InvalidatePropertyTreesIndices() { 989 void Layer::InvalidatePropertyTreesIndices() {
993 SetTransformTreeIndex(TransformTree::kInvalidNodeId); 990 SetTransformTreeIndex(TransformTree::kInvalidNodeId);
994 SetClipTreeIndex(ClipTree::kInvalidNodeId); 991 SetClipTreeIndex(ClipTree::kInvalidNodeId);
995 SetEffectTreeIndex(EffectTree::kInvalidNodeId); 992 SetEffectTreeIndex(EffectTree::kInvalidNodeId);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 if (has_preferred_raster_bounds()) 1187 if (has_preferred_raster_bounds())
1191 layer->SetPreferredRasterBounds(preferred_raster_bounds()); 1188 layer->SetPreferredRasterBounds(preferred_raster_bounds());
1192 else 1189 else
1193 layer->ClearPreferredRasterBounds(); 1190 layer->ClearPreferredRasterBounds();
1194 layer->SetNeedsPushProperties(); 1191 layer->SetNeedsPushProperties();
1195 1192
1196 // Reset any state that should be cleared for the next update. 1193 // Reset any state that should be cleared for the next update.
1197 subtree_property_changed_ = false; 1194 subtree_property_changed_ = false;
1198 inputs_.update_rect = gfx::Rect(); 1195 inputs_.update_rect = gfx::Rect();
1199 1196
1200 layer_tree_->RemoveLayerShouldPushProperties(this); 1197 layer_tree_host_->RemoveLayerShouldPushProperties(this);
1201 } 1198 }
1202 1199
1203 void Layer::TakeCopyRequests( 1200 void Layer::TakeCopyRequests(
1204 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { 1201 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) {
1205 for (auto& it : inputs_.copy_requests) { 1202 for (auto& it : inputs_.copy_requests) {
1206 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = 1203 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
1207 layer_tree_host()->GetTaskRunnerProvider()->MainThreadTaskRunner(); 1204 layer_tree_host()->GetTaskRunnerProvider()->MainThreadTaskRunner();
1208 std::unique_ptr<CopyOutputRequest> original_request = std::move(it); 1205 std::unique_ptr<CopyOutputRequest> original_request = std::move(it);
1209 const CopyOutputRequest& original_request_ref = *original_request; 1206 const CopyOutputRequest& original_request_ref = *original_request;
1210 std::unique_ptr<CopyOutputRequest> main_thread_request = 1207 std::unique_ptr<CopyOutputRequest> main_thread_request =
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 DCHECK_GE(opacity, 0.f); 1327 DCHECK_GE(opacity, 0.f);
1331 DCHECK_LE(opacity, 1.f); 1328 DCHECK_LE(opacity, 1.f);
1332 1329
1333 if (inputs_.opacity == opacity) 1330 if (inputs_.opacity == opacity)
1334 return; 1331 return;
1335 inputs_.opacity = opacity; 1332 inputs_.opacity = opacity;
1336 // Changing the opacity may make a previously hidden layer visible, so a new 1333 // Changing the opacity may make a previously hidden layer visible, so a new
1337 // recording may be needed. 1334 // recording may be needed.
1338 SetNeedsUpdate(); 1335 SetNeedsUpdate();
1339 if (layer_tree_host_) { 1336 if (layer_tree_host_) {
1340 PropertyTrees* property_trees = layer_tree_->property_trees(); 1337 PropertyTrees* property_trees = layer_tree_host_->property_trees();
1341 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, 1338 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT,
1342 id())) { 1339 id())) {
1343 DCHECK_EQ(effect_tree_index(), 1340 DCHECK_EQ(effect_tree_index(),
1344 property_trees->layer_id_to_effect_node_index[id()]); 1341 property_trees->layer_id_to_effect_node_index[id()]);
1345 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); 1342 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index());
1346 node->opacity = opacity; 1343 node->opacity = opacity;
1347 property_trees->effect_tree.set_needs_update(true); 1344 property_trees->effect_tree.set_needs_update(true);
1348 } 1345 }
1349 } 1346 }
1350 } 1347 }
1351 1348
1352 void Layer::OnTransformAnimated(const gfx::Transform& transform) { 1349 void Layer::OnTransformAnimated(const gfx::Transform& transform) {
1353 if (inputs_.transform == transform) 1350 if (inputs_.transform == transform)
1354 return; 1351 return;
1355 inputs_.transform = transform; 1352 inputs_.transform = transform;
1356 // Changing the transform may change the visible part of this layer, so a new 1353 // Changing the transform may change the visible part of this layer, so a new
1357 // recording may be needed. 1354 // recording may be needed.
1358 SetNeedsUpdate(); 1355 SetNeedsUpdate();
1359 if (layer_tree_host_) { 1356 if (layer_tree_host_) {
1360 PropertyTrees* property_trees = layer_tree_->property_trees(); 1357 PropertyTrees* property_trees = layer_tree_host_->property_trees();
1361 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 1358 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1362 id())) { 1359 id())) {
1363 DCHECK_EQ(transform_tree_index(), 1360 DCHECK_EQ(transform_tree_index(),
1364 property_trees->layer_id_to_transform_node_index[id()]); 1361 property_trees->layer_id_to_transform_node_index[id()]);
1365 TransformNode* node = 1362 TransformNode* node =
1366 property_trees->transform_tree.Node(transform_tree_index()); 1363 property_trees->transform_tree.Node(transform_tree_index());
1367 node->local = transform; 1364 node->local = transform;
1368 node->needs_local_transform_update = true; 1365 node->needs_local_transform_update = true;
1369 node->has_potential_animation = true; 1366 node->has_potential_animation = true;
1370 property_trees->transform_tree.set_needs_update(true); 1367 property_trees->transform_tree.set_needs_update(true);
1371 } 1368 }
1372 } 1369 }
1373 } 1370 }
1374 1371
1375 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { 1372 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) {
1376 // Do nothing. Scroll deltas will be sent from the compositor thread back 1373 // Do nothing. Scroll deltas will be sent from the compositor thread back
1377 // to the main thread in the same manner as during non-animated 1374 // to the main thread in the same manner as during non-animated
1378 // compositor-driven scrolling. 1375 // compositor-driven scrolling.
1379 } 1376 }
1380 1377
1381 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, 1378 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask,
1382 const PropertyAnimationState& state) { 1379 const PropertyAnimationState& state) {
1383 DCHECK(layer_tree_host_); 1380 DCHECK(layer_tree_host_);
1384 PropertyTrees* property_trees = layer_tree_->property_trees(); 1381 PropertyTrees* property_trees = layer_tree_host_->property_trees();
1385 1382
1386 TransformNode* transform_node = nullptr; 1383 TransformNode* transform_node = nullptr;
1387 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 1384 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
1388 id())) { 1385 id())) {
1389 DCHECK_EQ(transform_tree_index(), 1386 DCHECK_EQ(transform_tree_index(),
1390 property_trees->layer_id_to_transform_node_index[id()]); 1387 property_trees->layer_id_to_transform_node_index[id()]);
1391 transform_node = 1388 transform_node =
1392 property_trees->transform_tree.Node(transform_tree_index()); 1389 property_trees->transform_tree.Node(transform_tree_index());
1393 } 1390 }
1394 1391
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 1471
1475 void Layer::ClearPreferredRasterBounds() { 1472 void Layer::ClearPreferredRasterBounds() {
1476 if (!inputs_.has_preferred_raster_bounds) 1473 if (!inputs_.has_preferred_raster_bounds)
1477 return; 1474 return;
1478 inputs_.has_preferred_raster_bounds = false; 1475 inputs_.has_preferred_raster_bounds = false;
1479 inputs_.preferred_raster_bounds = gfx::Size(); 1476 inputs_.preferred_raster_bounds = gfx::Size();
1480 SetNeedsCommit(); 1477 SetNeedsCommit();
1481 } 1478 }
1482 1479
1483 MutatorHost* Layer::GetMutatorHost() const { 1480 MutatorHost* Layer::GetMutatorHost() const {
1484 return layer_tree_ ? layer_tree_->mutator_host() : nullptr; 1481 return layer_tree_host_ ? layer_tree_host_->mutator_host() : nullptr;
1485 } 1482 }
1486 1483
1487 ElementListType Layer::GetElementTypeForAnimation() const { 1484 ElementListType Layer::GetElementTypeForAnimation() const {
1488 return ElementListType::ACTIVE; 1485 return ElementListType::ACTIVE;
1489 } 1486 }
1490 1487
1491 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { 1488 ScrollbarLayerInterface* Layer::ToScrollbarLayer() {
1492 return nullptr; 1489 return nullptr;
1493 } 1490 }
1494 1491
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 benchmark->RunOnLayer(this); 1526 benchmark->RunOnLayer(this);
1530 } 1527 }
1531 1528
1532 void Layer::SetElementId(ElementId id) { 1529 void Layer::SetElementId(ElementId id) {
1533 DCHECK(IsPropertyChangeAllowed()); 1530 DCHECK(IsPropertyChangeAllowed());
1534 if (inputs_.element_id == id) 1531 if (inputs_.element_id == id)
1535 return; 1532 return;
1536 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 1533 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1537 "Layer::SetElementId", "element", id.AsValue().release()); 1534 "Layer::SetElementId", "element", id.AsValue().release());
1538 if (inputs_.element_id && layer_tree_host()) { 1535 if (inputs_.element_id && layer_tree_host()) {
1539 layer_tree_->UnregisterElement(inputs_.element_id, ElementListType::ACTIVE, 1536 layer_tree_host_->UnregisterElement(inputs_.element_id,
1540 this); 1537 ElementListType::ACTIVE, this);
1541 } 1538 }
1542 1539
1543 inputs_.element_id = id; 1540 inputs_.element_id = id;
1544 1541
1545 if (inputs_.element_id && layer_tree_host()) { 1542 if (inputs_.element_id && layer_tree_host()) {
1546 layer_tree_->RegisterElement(inputs_.element_id, ElementListType::ACTIVE, 1543 layer_tree_host_->RegisterElement(inputs_.element_id,
1547 this); 1544 ElementListType::ACTIVE, this);
1548 } 1545 }
1549 1546
1550 SetNeedsCommit(); 1547 SetNeedsCommit();
1551 } 1548 }
1552 1549
1553 void Layer::SetMutableProperties(uint32_t properties) { 1550 void Layer::SetMutableProperties(uint32_t properties) {
1554 DCHECK(IsPropertyChangeAllowed()); 1551 DCHECK(IsPropertyChangeAllowed());
1555 if (inputs_.mutable_properties == properties) 1552 if (inputs_.mutable_properties == properties)
1556 return; 1553 return;
1557 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 1554 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1558 "Layer::SetMutableProperties", "properties", properties); 1555 "Layer::SetMutableProperties", "properties", properties);
1559 inputs_.mutable_properties = properties; 1556 inputs_.mutable_properties = properties;
1560 SetNeedsCommit(); 1557 SetNeedsCommit();
1561 } 1558 }
1562 1559
1563 void Layer::DidBeginTracing() { 1560 void Layer::DidBeginTracing() {
1564 // We'll be dumping layer trees as part of trace, so make sure 1561 // We'll be dumping layer trees as part of trace, so make sure
1565 // PushPropertiesTo() propagates layer debug info to the impl 1562 // PushPropertiesTo() propagates layer debug info to the impl
1566 // side -- otherwise this won't happen for the the layers that 1563 // side -- otherwise this won't happen for the the layers that
1567 // remain unchanged since tracing started. 1564 // remain unchanged since tracing started.
1568 SetNeedsPushProperties(); 1565 SetNeedsPushProperties();
1569 } 1566 }
1570 1567
1571 int Layer::num_copy_requests_in_target_subtree() { 1568 int Layer::num_copy_requests_in_target_subtree() {
1572 return layer_tree_->property_trees() 1569 return layer_tree_host_->property_trees()
1573 ->effect_tree.Node(effect_tree_index()) 1570 ->effect_tree.Node(effect_tree_index())
1574 ->num_copy_requests_in_subtree; 1571 ->num_copy_requests_in_subtree;
1575 } 1572 }
1576 1573
1577 gfx::Transform Layer::screen_space_transform() const { 1574 gfx::Transform Layer::screen_space_transform() const {
1578 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1575 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1579 return draw_property_utils::ScreenSpaceTransform( 1576 return draw_property_utils::ScreenSpaceTransform(
1580 this, layer_tree_->property_trees()->transform_tree); 1577 this, layer_tree_host_->property_trees()->transform_tree);
1581 }
1582
1583 LayerTree* Layer::GetLayerTree() const {
1584 return layer_tree_;
1585 } 1578 }
1586 1579
1587 } // namespace cc 1580 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_list_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698