| 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_->property_trees()->RemoveIdFromIdToIndexMaps(id()); | 132 layer_tree_->property_trees()->RemoveIdFromIdToIndexMaps(id()); |
| 133 layer_tree_->property_trees()->needs_rebuild = true; | 133 layer_tree_->property_trees()->needs_rebuild = true; |
| 134 layer_tree_->UnregisterLayer(this); | 134 layer_tree_->UnregisterLayer(this); |
| 135 if (inputs_.element_id) { | 135 if (inputs_.element_id) { |
| 136 layer_tree_->animation_host()->UnregisterElement(inputs_.element_id, | 136 layer_tree_->UnregisterElement(inputs_.element_id, |
| 137 ElementListType::ACTIVE); | 137 ElementListType::ACTIVE, this); |
| 138 layer_tree_host_->RemoveFromElementMap(this); | |
| 139 } | 138 } |
| 140 } | 139 } |
| 141 if (host) { | 140 if (host) { |
| 142 host->GetLayerTree()->property_trees()->needs_rebuild = true; | 141 host->GetLayerTree()->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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 inputs_.use_parent_backface_visibility = | 1472 inputs_.use_parent_backface_visibility = |
| 1474 base.use_parent_backface_visibility(); | 1473 base.use_parent_backface_visibility(); |
| 1475 inputs_.transform = ProtoToTransform(base.transform()); | 1474 inputs_.transform = ProtoToTransform(base.transform()); |
| 1476 inputs_.sorting_context_id = base.sorting_context_id(); | 1475 inputs_.sorting_context_id = base.sorting_context_id(); |
| 1477 num_descendants_that_draw_content_ = base.num_descendants_that_draw_content(); | 1476 num_descendants_that_draw_content_ = base.num_descendants_that_draw_content(); |
| 1478 | 1477 |
| 1479 inputs_.scroll_clip_layer_id = base.scroll_clip_layer_id(); | 1478 inputs_.scroll_clip_layer_id = base.scroll_clip_layer_id(); |
| 1480 inputs_.user_scrollable_horizontal = base.user_scrollable_horizontal(); | 1479 inputs_.user_scrollable_horizontal = base.user_scrollable_horizontal(); |
| 1481 inputs_.user_scrollable_vertical = base.user_scrollable_vertical(); | 1480 inputs_.user_scrollable_vertical = base.user_scrollable_vertical(); |
| 1482 | 1481 |
| 1483 inputs_.scroll_parent = | 1482 inputs_.scroll_parent = base.scroll_parent_id() == INVALID_ID |
| 1484 base.scroll_parent_id() == INVALID_ID | 1483 ? nullptr |
| 1485 ? nullptr | 1484 : layer_tree_->LayerById(base.scroll_parent_id()); |
| 1486 : layer_tree_host_->LayerById(base.scroll_parent_id()); | |
| 1487 | 1485 |
| 1488 // If there have been scroll children entries in previous deserializations, | 1486 // If there have been scroll children entries in previous deserializations, |
| 1489 // clear out the set. If there have been none, initialize the set of children. | 1487 // clear out the set. If there have been none, initialize the set of children. |
| 1490 // After this, the set is in the correct state to only add the new children. | 1488 // After this, the set is in the correct state to only add the new children. |
| 1491 // If the set of children has not changed, for now this code still rebuilds | 1489 // If the set of children has not changed, for now this code still rebuilds |
| 1492 // the set. | 1490 // the set. |
| 1493 if (scroll_children_) | 1491 if (scroll_children_) |
| 1494 scroll_children_->clear(); | 1492 scroll_children_->clear(); |
| 1495 else if (base.scroll_children_ids_size() > 0) | 1493 else if (base.scroll_children_ids_size() > 0) |
| 1496 scroll_children_.reset(new std::set<Layer*>); | 1494 scroll_children_.reset(new std::set<Layer*>); |
| 1497 for (int i = 0; i < base.scroll_children_ids_size(); ++i) { | 1495 for (int i = 0; i < base.scroll_children_ids_size(); ++i) { |
| 1498 int child_id = base.scroll_children_ids(i); | 1496 int child_id = base.scroll_children_ids(i); |
| 1499 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1497 scoped_refptr<Layer> child = layer_tree_->LayerById(child_id); |
| 1500 scroll_children_->insert(child.get()); | 1498 scroll_children_->insert(child.get()); |
| 1501 } | 1499 } |
| 1502 | 1500 |
| 1503 inputs_.clip_parent = | 1501 inputs_.clip_parent = base.clip_parent_id() == INVALID_ID |
| 1504 base.clip_parent_id() == INVALID_ID | 1502 ? nullptr |
| 1505 ? nullptr | 1503 : layer_tree_->LayerById(base.clip_parent_id()); |
| 1506 : layer_tree_host_->LayerById(base.clip_parent_id()); | |
| 1507 | 1504 |
| 1508 // If there have been clip children entries in previous deserializations, | 1505 // If there have been clip children entries in previous deserializations, |
| 1509 // clear out the set. If there have been none, initialize the set of children. | 1506 // clear out the set. If there have been none, initialize the set of children. |
| 1510 // After this, the set is in the correct state to only add the new children. | 1507 // After this, the set is in the correct state to only add the new children. |
| 1511 // If the set of children has not changed, for now this code still rebuilds | 1508 // If the set of children has not changed, for now this code still rebuilds |
| 1512 // the set. | 1509 // the set. |
| 1513 if (clip_children_) | 1510 if (clip_children_) |
| 1514 clip_children_->clear(); | 1511 clip_children_->clear(); |
| 1515 else if (base.clip_children_ids_size() > 0) | 1512 else if (base.clip_children_ids_size() > 0) |
| 1516 clip_children_.reset(new std::set<Layer*>); | 1513 clip_children_.reset(new std::set<Layer*>); |
| 1517 for (int i = 0; i < base.clip_children_ids_size(); ++i) { | 1514 for (int i = 0; i < base.clip_children_ids_size(); ++i) { |
| 1518 int child_id = base.clip_children_ids(i); | 1515 int child_id = base.clip_children_ids(i); |
| 1519 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1516 scoped_refptr<Layer> child = layer_tree_->LayerById(child_id); |
| 1520 clip_children_->insert(child.get()); | 1517 clip_children_->insert(child.get()); |
| 1521 } | 1518 } |
| 1522 | 1519 |
| 1523 inputs_.scroll_offset = ProtoToScrollOffset(base.scroll_offset()); | 1520 inputs_.scroll_offset = ProtoToScrollOffset(base.scroll_offset()); |
| 1524 | 1521 |
| 1525 inputs_.update_rect.Union(ProtoToRect(base.update_rect())); | 1522 inputs_.update_rect.Union(ProtoToRect(base.update_rect())); |
| 1526 | 1523 |
| 1527 inputs_.has_will_change_transform_hint = | 1524 inputs_.has_will_change_transform_hint = |
| 1528 base.has_will_change_transform_hint(); | 1525 base.has_will_change_transform_hint(); |
| 1529 } | 1526 } |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 benchmark->RunOnLayer(this); | 1826 benchmark->RunOnLayer(this); |
| 1830 } | 1827 } |
| 1831 | 1828 |
| 1832 void Layer::SetElementId(ElementId id) { | 1829 void Layer::SetElementId(ElementId id) { |
| 1833 DCHECK(IsPropertyChangeAllowed()); | 1830 DCHECK(IsPropertyChangeAllowed()); |
| 1834 if (inputs_.element_id == id) | 1831 if (inputs_.element_id == id) |
| 1835 return; | 1832 return; |
| 1836 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1833 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1837 "Layer::SetElementId", "element", id.AsValue().release()); | 1834 "Layer::SetElementId", "element", id.AsValue().release()); |
| 1838 if (inputs_.element_id && layer_tree_host()) { | 1835 if (inputs_.element_id && layer_tree_host()) { |
| 1839 layer_tree_host()->animation_host()->UnregisterElement( | 1836 layer_tree_->UnregisterElement(inputs_.element_id, ElementListType::ACTIVE, |
| 1840 inputs_.element_id, ElementListType::ACTIVE); | 1837 this); |
| 1841 layer_tree_host()->RemoveFromElementMap(this); | |
| 1842 } | 1838 } |
| 1843 | 1839 |
| 1844 inputs_.element_id = id; | 1840 inputs_.element_id = id; |
| 1845 | 1841 |
| 1846 if (inputs_.element_id && layer_tree_host()) { | 1842 if (inputs_.element_id && layer_tree_host()) { |
| 1847 layer_tree_host()->animation_host()->RegisterElement( | 1843 layer_tree_->RegisterElement(inputs_.element_id, ElementListType::ACTIVE, |
| 1848 inputs_.element_id, ElementListType::ACTIVE); | 1844 this); |
| 1849 layer_tree_host()->AddToElementMap(this); | |
| 1850 } | 1845 } |
| 1851 | 1846 |
| 1852 SetNeedsCommit(); | 1847 SetNeedsCommit(); |
| 1853 } | 1848 } |
| 1854 | 1849 |
| 1855 void Layer::SetMutableProperties(uint32_t properties) { | 1850 void Layer::SetMutableProperties(uint32_t properties) { |
| 1856 DCHECK(IsPropertyChangeAllowed()); | 1851 DCHECK(IsPropertyChangeAllowed()); |
| 1857 if (inputs_.mutable_properties == properties) | 1852 if (inputs_.mutable_properties == properties) |
| 1858 return; | 1853 return; |
| 1859 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1854 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1880 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1875 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1881 return draw_property_utils::ScreenSpaceTransform( | 1876 return draw_property_utils::ScreenSpaceTransform( |
| 1882 this, layer_tree_->property_trees()->transform_tree); | 1877 this, layer_tree_->property_trees()->transform_tree); |
| 1883 } | 1878 } |
| 1884 | 1879 |
| 1885 LayerTree* Layer::GetLayerTree() const { | 1880 LayerTree* Layer::GetLayerTree() const { |
| 1886 return layer_tree_; | 1881 return layer_tree_; |
| 1887 } | 1882 } |
| 1888 | 1883 |
| 1889 } // namespace cc | 1884 } // namespace cc |
| OLD | NEW |