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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 clip_tree_index_(ClipTree::kInvalidNodeId), | 89 clip_tree_index_(ClipTree::kInvalidNodeId), |
90 scroll_tree_index_(ScrollTree::kInvalidNodeId), | 90 scroll_tree_index_(ScrollTree::kInvalidNodeId), |
91 property_tree_sequence_number_(-1), | 91 property_tree_sequence_number_(-1), |
92 should_flatten_transform_from_property_tree_(false), | 92 should_flatten_transform_from_property_tree_(false), |
93 draws_content_(false), | 93 draws_content_(false), |
94 use_local_transform_for_backface_visibility_(false), | 94 use_local_transform_for_backface_visibility_(false), |
95 should_check_backface_visibility_(false), | 95 should_check_backface_visibility_(false), |
96 force_render_surface_for_testing_(false), | 96 force_render_surface_for_testing_(false), |
97 subtree_property_changed_(false), | 97 subtree_property_changed_(false), |
98 layer_property_changed_(false), | 98 layer_property_changed_(false), |
| 99 may_contain_video_(false), |
99 safe_opaque_background_color_(0), | 100 safe_opaque_background_color_(0), |
100 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 101 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
101 num_unclipped_descendants_(0) {} | 102 num_unclipped_descendants_(0) {} |
102 | 103 |
103 Layer::~Layer() { | 104 Layer::~Layer() { |
104 // Our parent should be holding a reference to us so there should be no | 105 // Our parent should be holding a reference to us so there should be no |
105 // way for us to be destroyed while we still have a parent. | 106 // way for us to be destroyed while we still have a parent. |
106 DCHECK(!parent()); | 107 DCHECK(!parent()); |
107 // Similarly we shouldn't have a layer tree host since it also keeps a | 108 // Similarly we shouldn't have a layer tree host since it also keeps a |
108 // reference to us. | 109 // reference to us. |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 layer->SetTransformTreeIndex(transform_tree_index()); | 1150 layer->SetTransformTreeIndex(transform_tree_index()); |
1150 layer->SetEffectTreeIndex(effect_tree_index()); | 1151 layer->SetEffectTreeIndex(effect_tree_index()); |
1151 layer->SetClipTreeIndex(clip_tree_index()); | 1152 layer->SetClipTreeIndex(clip_tree_index()); |
1152 layer->SetScrollTreeIndex(scroll_tree_index()); | 1153 layer->SetScrollTreeIndex(scroll_tree_index()); |
1153 layer->set_offset_to_transform_parent(offset_to_transform_parent_); | 1154 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
1154 layer->SetDrawsContent(DrawsContent()); | 1155 layer->SetDrawsContent(DrawsContent()); |
1155 // subtree_property_changed_ is propagated to all descendants while building | 1156 // subtree_property_changed_ is propagated to all descendants while building |
1156 // property trees. So, it is enough to check it only for the current layer. | 1157 // property trees. So, it is enough to check it only for the current layer. |
1157 if (subtree_property_changed_ || layer_property_changed_) | 1158 if (subtree_property_changed_ || layer_property_changed_) |
1158 layer->NoteLayerPropertyChanged(); | 1159 layer->NoteLayerPropertyChanged(); |
| 1160 layer->set_may_contain_video(may_contain_video_); |
1159 layer->SetMasksToBounds(inputs_.masks_to_bounds); | 1161 layer->SetMasksToBounds(inputs_.masks_to_bounds); |
1160 layer->set_main_thread_scrolling_reasons( | 1162 layer->set_main_thread_scrolling_reasons( |
1161 inputs_.main_thread_scrolling_reasons); | 1163 inputs_.main_thread_scrolling_reasons); |
1162 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); | 1164 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); |
1163 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); | 1165 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); |
1164 layer->SetContentsOpaque(inputs_.contents_opaque); | 1166 layer->SetContentsOpaque(inputs_.contents_opaque); |
1165 layer->SetPosition(inputs_.position); | 1167 layer->SetPosition(inputs_.position); |
1166 layer->set_should_flatten_transform_from_property_tree( | 1168 layer->set_should_flatten_transform_from_property_tree( |
1167 should_flatten_transform_from_property_tree_); | 1169 should_flatten_transform_from_property_tree_); |
1168 layer->set_draw_blend_mode(draw_blend_mode_); | 1170 layer->set_draw_blend_mode(draw_blend_mode_); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. | 1360 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. |
1359 | 1361 |
1360 base->set_transform_free_index(transform_tree_index_); | 1362 base->set_transform_free_index(transform_tree_index_); |
1361 base->set_effect_tree_index(effect_tree_index_); | 1363 base->set_effect_tree_index(effect_tree_index_); |
1362 base->set_clip_tree_index(clip_tree_index_); | 1364 base->set_clip_tree_index(clip_tree_index_); |
1363 base->set_scroll_tree_index(scroll_tree_index_); | 1365 base->set_scroll_tree_index(scroll_tree_index_); |
1364 Vector2dFToProto(offset_to_transform_parent_, | 1366 Vector2dFToProto(offset_to_transform_parent_, |
1365 base->mutable_offset_to_transform_parent()); | 1367 base->mutable_offset_to_transform_parent()); |
1366 base->set_double_sided(inputs_.double_sided); | 1368 base->set_double_sided(inputs_.double_sided); |
1367 base->set_draws_content(draws_content_); | 1369 base->set_draws_content(draws_content_); |
| 1370 base->set_may_contain_video(may_contain_video_); |
1368 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); | 1371 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); |
1369 base->set_subtree_property_changed(subtree_property_changed_); | 1372 base->set_subtree_property_changed(subtree_property_changed_); |
1370 base->set_layer_property_changed(layer_property_changed_); | 1373 base->set_layer_property_changed(layer_property_changed_); |
1371 | 1374 |
1372 // TODO(nyquist): Add support for serializing FilterOperations for | 1375 // TODO(nyquist): Add support for serializing FilterOperations for |
1373 // |filters_| and |background_filters_|. See crbug.com/541321. | 1376 // |filters_| and |background_filters_|. See crbug.com/541321. |
1374 | 1377 |
1375 base->set_masks_to_bounds(inputs_.masks_to_bounds); | 1378 base->set_masks_to_bounds(inputs_.masks_to_bounds); |
1376 base->set_main_thread_scrolling_reasons( | 1379 base->set_main_thread_scrolling_reasons( |
1377 inputs_.main_thread_scrolling_reasons); | 1380 inputs_.main_thread_scrolling_reasons); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 inputs_.bounds = ProtoToSize(base.bounds()); | 1451 inputs_.bounds = ProtoToSize(base.bounds()); |
1449 | 1452 |
1450 transform_tree_index_ = base.transform_free_index(); | 1453 transform_tree_index_ = base.transform_free_index(); |
1451 effect_tree_index_ = base.effect_tree_index(); | 1454 effect_tree_index_ = base.effect_tree_index(); |
1452 clip_tree_index_ = base.clip_tree_index(); | 1455 clip_tree_index_ = base.clip_tree_index(); |
1453 scroll_tree_index_ = base.scroll_tree_index(); | 1456 scroll_tree_index_ = base.scroll_tree_index(); |
1454 offset_to_transform_parent_ = | 1457 offset_to_transform_parent_ = |
1455 ProtoToVector2dF(base.offset_to_transform_parent()); | 1458 ProtoToVector2dF(base.offset_to_transform_parent()); |
1456 inputs_.double_sided = base.double_sided(); | 1459 inputs_.double_sided = base.double_sided(); |
1457 draws_content_ = base.draws_content(); | 1460 draws_content_ = base.draws_content(); |
| 1461 may_contain_video_ = base.may_contain_video(); |
1458 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); | 1462 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); |
1459 subtree_property_changed_ = base.subtree_property_changed(); | 1463 subtree_property_changed_ = base.subtree_property_changed(); |
1460 layer_property_changed_ = base.layer_property_changed(); | 1464 layer_property_changed_ = base.layer_property_changed(); |
1461 inputs_.masks_to_bounds = base.masks_to_bounds(); | 1465 inputs_.masks_to_bounds = base.masks_to_bounds(); |
1462 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); | 1466 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); |
1463 inputs_.non_fast_scrollable_region = | 1467 inputs_.non_fast_scrollable_region = |
1464 RegionFromProto(base.non_fast_scrollable_region()); | 1468 RegionFromProto(base.non_fast_scrollable_region()); |
1465 inputs_.touch_event_handler_region = | 1469 inputs_.touch_event_handler_region = |
1466 RegionFromProto(base.touch_event_handler_region()); | 1470 RegionFromProto(base.touch_event_handler_region()); |
1467 inputs_.contents_opaque = base.contents_opaque(); | 1471 inputs_.contents_opaque = base.contents_opaque(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 SetNeedsPushProperties(); | 1609 SetNeedsPushProperties(); |
1606 } | 1610 } |
1607 | 1611 |
1608 void Layer::SetLayerPropertyChanged() { | 1612 void Layer::SetLayerPropertyChanged() { |
1609 if (layer_property_changed_) | 1613 if (layer_property_changed_) |
1610 return; | 1614 return; |
1611 layer_property_changed_ = true; | 1615 layer_property_changed_ = true; |
1612 SetNeedsPushProperties(); | 1616 SetNeedsPushProperties(); |
1613 } | 1617 } |
1614 | 1618 |
| 1619 void Layer::SetMayContainVideo(bool yes) { |
| 1620 if (may_contain_video_ == yes) |
| 1621 return; |
| 1622 may_contain_video_ = yes; |
| 1623 SetNeedsPushProperties(); |
| 1624 } |
| 1625 |
1615 bool Layer::FilterIsAnimating() const { | 1626 bool Layer::FilterIsAnimating() const { |
1616 return GetAnimationHost()->IsAnimatingFilterProperty( | 1627 return GetAnimationHost()->IsAnimatingFilterProperty( |
1617 element_id(), GetElementTypeForAnimation()); | 1628 element_id(), GetElementTypeForAnimation()); |
1618 } | 1629 } |
1619 | 1630 |
1620 bool Layer::TransformIsAnimating() const { | 1631 bool Layer::TransformIsAnimating() const { |
1621 return GetAnimationHost()->IsAnimatingTransformProperty( | 1632 return GetAnimationHost()->IsAnimatingTransformProperty( |
1622 element_id(), GetElementTypeForAnimation()); | 1633 element_id(), GetElementTypeForAnimation()); |
1623 } | 1634 } |
1624 | 1635 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1891 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
1881 return draw_property_utils::ScreenSpaceTransform( | 1892 return draw_property_utils::ScreenSpaceTransform( |
1882 this, layer_tree_host_->property_trees()->transform_tree); | 1893 this, layer_tree_host_->property_trees()->transform_tree); |
1883 } | 1894 } |
1884 | 1895 |
1885 LayerTree* Layer::GetLayerTree() const { | 1896 LayerTree* Layer::GetLayerTree() const { |
1886 return layer_tree_; | 1897 return layer_tree_; |
1887 } | 1898 } |
1888 | 1899 |
1889 } // namespace cc | 1900 } // namespace cc |
OLD | NEW |