| OLD | NEW |
| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); |
| 133 layer_tree_host_->property_trees()->needs_rebuild = true; | 133 layer_tree_host_->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_->UnregisterElement(inputs_.element_id, |
| 137 inputs_.element_id, ElementListType::ACTIVE); | 137 ElementListType::ACTIVE, this); |
| 138 layer_tree_host_->RemoveFromElementMap(this); | |
| 139 } | 138 } |
| 140 } | 139 } |
| 141 if (host) { | 140 if (host) { |
| 142 host->property_trees()->needs_rebuild = true; | 141 host->property_trees()->needs_rebuild = true; |
| 143 host->GetLayerTree()->RegisterLayer(this); | 142 host->GetLayerTree()->RegisterLayer(this); |
| 144 if (inputs_.element_id) { | 143 if (inputs_.element_id) { |
| 145 host->AddToElementMap(this); | 144 host->GetLayerTree()->RegisterElement(inputs_.element_id, |
| 146 host->animation_host()->RegisterElement(inputs_.element_id, | 145 ElementListType::ACTIVE, this); |
| 147 ElementListType::ACTIVE); | |
| 148 } | 146 } |
| 149 } | 147 } |
| 150 | 148 |
| 151 layer_tree_host_ = host; | 149 layer_tree_host_ = host; |
| 152 layer_tree_ = host ? host->GetLayerTree() : nullptr; | 150 layer_tree_ = host ? host->GetLayerTree() : nullptr; |
| 153 InvalidatePropertyTreesIndices(); | 151 InvalidatePropertyTreesIndices(); |
| 154 | 152 |
| 155 // When changing hosts, the layer needs to commit its properties to the impl | 153 // When changing hosts, the layer needs to commit its properties to the impl |
| 156 // side for the new host. | 154 // side for the new host. |
| 157 SetNeedsPushProperties(); | 155 SetNeedsPushProperties(); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 | 843 |
| 846 void Layer::SetScrollClipLayerId(int clip_layer_id) { | 844 void Layer::SetScrollClipLayerId(int clip_layer_id) { |
| 847 DCHECK(IsPropertyChangeAllowed()); | 845 DCHECK(IsPropertyChangeAllowed()); |
| 848 if (inputs_.scroll_clip_layer_id == clip_layer_id) | 846 if (inputs_.scroll_clip_layer_id == clip_layer_id) |
| 849 return; | 847 return; |
| 850 inputs_.scroll_clip_layer_id = clip_layer_id; | 848 inputs_.scroll_clip_layer_id = clip_layer_id; |
| 851 SetNeedsCommit(); | 849 SetNeedsCommit(); |
| 852 } | 850 } |
| 853 | 851 |
| 854 Layer* Layer::scroll_clip_layer() const { | 852 Layer* Layer::scroll_clip_layer() const { |
| 855 return layer_tree_host()->LayerById(inputs_.scroll_clip_layer_id); | 853 DCHECK(layer_tree_); |
| 854 return layer_tree_->LayerById(inputs_.scroll_clip_layer_id); |
| 856 } | 855 } |
| 857 | 856 |
| 858 void Layer::SetUserScrollable(bool horizontal, bool vertical) { | 857 void Layer::SetUserScrollable(bool horizontal, bool vertical) { |
| 859 DCHECK(IsPropertyChangeAllowed()); | 858 DCHECK(IsPropertyChangeAllowed()); |
| 860 if (inputs_.user_scrollable_horizontal == horizontal && | 859 if (inputs_.user_scrollable_horizontal == horizontal && |
| 861 inputs_.user_scrollable_vertical == vertical) | 860 inputs_.user_scrollable_vertical == vertical) |
| 862 return; | 861 return; |
| 863 inputs_.user_scrollable_horizontal = horizontal; | 862 inputs_.user_scrollable_horizontal = horizontal; |
| 864 inputs_.user_scrollable_vertical = vertical; | 863 inputs_.user_scrollable_vertical = vertical; |
| 865 SetNeedsCommit(); | 864 SetNeedsCommit(); |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 inputs_.use_parent_backface_visibility = | 1473 inputs_.use_parent_backface_visibility = |
| 1475 base.use_parent_backface_visibility(); | 1474 base.use_parent_backface_visibility(); |
| 1476 inputs_.transform = ProtoToTransform(base.transform()); | 1475 inputs_.transform = ProtoToTransform(base.transform()); |
| 1477 inputs_.sorting_context_id = base.sorting_context_id(); | 1476 inputs_.sorting_context_id = base.sorting_context_id(); |
| 1478 num_descendants_that_draw_content_ = base.num_descendants_that_draw_content(); | 1477 num_descendants_that_draw_content_ = base.num_descendants_that_draw_content(); |
| 1479 | 1478 |
| 1480 inputs_.scroll_clip_layer_id = base.scroll_clip_layer_id(); | 1479 inputs_.scroll_clip_layer_id = base.scroll_clip_layer_id(); |
| 1481 inputs_.user_scrollable_horizontal = base.user_scrollable_horizontal(); | 1480 inputs_.user_scrollable_horizontal = base.user_scrollable_horizontal(); |
| 1482 inputs_.user_scrollable_vertical = base.user_scrollable_vertical(); | 1481 inputs_.user_scrollable_vertical = base.user_scrollable_vertical(); |
| 1483 | 1482 |
| 1484 inputs_.scroll_parent = | 1483 inputs_.scroll_parent = base.scroll_parent_id() == INVALID_ID |
| 1485 base.scroll_parent_id() == INVALID_ID | 1484 ? nullptr |
| 1486 ? nullptr | 1485 : layer_tree_->LayerById(base.scroll_parent_id()); |
| 1487 : layer_tree_host_->LayerById(base.scroll_parent_id()); | |
| 1488 | 1486 |
| 1489 // If there have been scroll children entries in previous deserializations, | 1487 // If there have been scroll children entries in previous deserializations, |
| 1490 // clear out the set. If there have been none, initialize the set of children. | 1488 // clear out the set. If there have been none, initialize the set of children. |
| 1491 // After this, the set is in the correct state to only add the new children. | 1489 // After this, the set is in the correct state to only add the new children. |
| 1492 // If the set of children has not changed, for now this code still rebuilds | 1490 // If the set of children has not changed, for now this code still rebuilds |
| 1493 // the set. | 1491 // the set. |
| 1494 if (scroll_children_) | 1492 if (scroll_children_) |
| 1495 scroll_children_->clear(); | 1493 scroll_children_->clear(); |
| 1496 else if (base.scroll_children_ids_size() > 0) | 1494 else if (base.scroll_children_ids_size() > 0) |
| 1497 scroll_children_.reset(new std::set<Layer*>); | 1495 scroll_children_.reset(new std::set<Layer*>); |
| 1498 for (int i = 0; i < base.scroll_children_ids_size(); ++i) { | 1496 for (int i = 0; i < base.scroll_children_ids_size(); ++i) { |
| 1499 int child_id = base.scroll_children_ids(i); | 1497 int child_id = base.scroll_children_ids(i); |
| 1500 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1498 scoped_refptr<Layer> child = layer_tree_->LayerById(child_id); |
| 1501 scroll_children_->insert(child.get()); | 1499 scroll_children_->insert(child.get()); |
| 1502 } | 1500 } |
| 1503 | 1501 |
| 1504 inputs_.clip_parent = | 1502 inputs_.clip_parent = base.clip_parent_id() == INVALID_ID |
| 1505 base.clip_parent_id() == INVALID_ID | 1503 ? nullptr |
| 1506 ? nullptr | 1504 : layer_tree_->LayerById(base.clip_parent_id()); |
| 1507 : layer_tree_host_->LayerById(base.clip_parent_id()); | |
| 1508 | 1505 |
| 1509 // If there have been clip children entries in previous deserializations, | 1506 // If there have been clip children entries in previous deserializations, |
| 1510 // clear out the set. If there have been none, initialize the set of children. | 1507 // clear out the set. If there have been none, initialize the set of children. |
| 1511 // After this, the set is in the correct state to only add the new children. | 1508 // After this, the set is in the correct state to only add the new children. |
| 1512 // If the set of children has not changed, for now this code still rebuilds | 1509 // If the set of children has not changed, for now this code still rebuilds |
| 1513 // the set. | 1510 // the set. |
| 1514 if (clip_children_) | 1511 if (clip_children_) |
| 1515 clip_children_->clear(); | 1512 clip_children_->clear(); |
| 1516 else if (base.clip_children_ids_size() > 0) | 1513 else if (base.clip_children_ids_size() > 0) |
| 1517 clip_children_.reset(new std::set<Layer*>); | 1514 clip_children_.reset(new std::set<Layer*>); |
| 1518 for (int i = 0; i < base.clip_children_ids_size(); ++i) { | 1515 for (int i = 0; i < base.clip_children_ids_size(); ++i) { |
| 1519 int child_id = base.clip_children_ids(i); | 1516 int child_id = base.clip_children_ids(i); |
| 1520 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1517 scoped_refptr<Layer> child = layer_tree_->LayerById(child_id); |
| 1521 clip_children_->insert(child.get()); | 1518 clip_children_->insert(child.get()); |
| 1522 } | 1519 } |
| 1523 | 1520 |
| 1524 inputs_.scroll_offset = ProtoToScrollOffset(base.scroll_offset()); | 1521 inputs_.scroll_offset = ProtoToScrollOffset(base.scroll_offset()); |
| 1525 | 1522 |
| 1526 inputs_.update_rect.Union(ProtoToRect(base.update_rect())); | 1523 inputs_.update_rect.Union(ProtoToRect(base.update_rect())); |
| 1527 | 1524 |
| 1528 inputs_.has_will_change_transform_hint = | 1525 inputs_.has_will_change_transform_hint = |
| 1529 base.has_will_change_transform_hint(); | 1526 base.has_will_change_transform_hint(); |
| 1530 } | 1527 } |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 benchmark->RunOnLayer(this); | 1827 benchmark->RunOnLayer(this); |
| 1831 } | 1828 } |
| 1832 | 1829 |
| 1833 void Layer::SetElementId(ElementId id) { | 1830 void Layer::SetElementId(ElementId id) { |
| 1834 DCHECK(IsPropertyChangeAllowed()); | 1831 DCHECK(IsPropertyChangeAllowed()); |
| 1835 if (inputs_.element_id == id) | 1832 if (inputs_.element_id == id) |
| 1836 return; | 1833 return; |
| 1837 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1834 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1838 "Layer::SetElementId", "element", id.AsValue().release()); | 1835 "Layer::SetElementId", "element", id.AsValue().release()); |
| 1839 if (inputs_.element_id && layer_tree_host()) { | 1836 if (inputs_.element_id && layer_tree_host()) { |
| 1840 layer_tree_host()->animation_host()->UnregisterElement( | 1837 layer_tree_->UnregisterElement(inputs_.element_id, ElementListType::ACTIVE, |
| 1841 inputs_.element_id, ElementListType::ACTIVE); | 1838 this); |
| 1842 layer_tree_host()->RemoveFromElementMap(this); | |
| 1843 } | 1839 } |
| 1844 | 1840 |
| 1845 inputs_.element_id = id; | 1841 inputs_.element_id = id; |
| 1846 | 1842 |
| 1847 if (inputs_.element_id && layer_tree_host()) { | 1843 if (inputs_.element_id && layer_tree_host()) { |
| 1848 layer_tree_host()->animation_host()->RegisterElement( | 1844 layer_tree_->RegisterElement(inputs_.element_id, ElementListType::ACTIVE, |
| 1849 inputs_.element_id, ElementListType::ACTIVE); | 1845 this); |
| 1850 layer_tree_host()->AddToElementMap(this); | |
| 1851 } | 1846 } |
| 1852 | 1847 |
| 1853 SetNeedsCommit(); | 1848 SetNeedsCommit(); |
| 1854 } | 1849 } |
| 1855 | 1850 |
| 1856 void Layer::SetMutableProperties(uint32_t properties) { | 1851 void Layer::SetMutableProperties(uint32_t properties) { |
| 1857 DCHECK(IsPropertyChangeAllowed()); | 1852 DCHECK(IsPropertyChangeAllowed()); |
| 1858 if (inputs_.mutable_properties == properties) | 1853 if (inputs_.mutable_properties == properties) |
| 1859 return; | 1854 return; |
| 1860 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1855 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1882 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1877 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1883 return draw_property_utils::ScreenSpaceTransform( | 1878 return draw_property_utils::ScreenSpaceTransform( |
| 1884 this, layer_tree_host_->property_trees()->transform_tree); | 1879 this, layer_tree_host_->property_trees()->transform_tree); |
| 1885 } | 1880 } |
| 1886 | 1881 |
| 1887 LayerTree* Layer::GetLayerTree() const { | 1882 LayerTree* Layer::GetLayerTree() const { |
| 1888 return layer_tree_; | 1883 return layer_tree_; |
| 1889 } | 1884 } |
| 1890 | 1885 |
| 1891 } // namespace cc | 1886 } // namespace cc |
| OLD | NEW |