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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 clip_tree_index_(ClipTree::kInvalidNodeId), | 88 clip_tree_index_(ClipTree::kInvalidNodeId), |
89 scroll_tree_index_(ScrollTree::kInvalidNodeId), | 89 scroll_tree_index_(ScrollTree::kInvalidNodeId), |
90 property_tree_sequence_number_(-1), | 90 property_tree_sequence_number_(-1), |
91 should_flatten_transform_from_property_tree_(false), | 91 should_flatten_transform_from_property_tree_(false), |
92 draws_content_(false), | 92 draws_content_(false), |
93 use_local_transform_for_backface_visibility_(false), | 93 use_local_transform_for_backface_visibility_(false), |
94 should_check_backface_visibility_(false), | 94 should_check_backface_visibility_(false), |
95 force_render_surface_for_testing_(false), | 95 force_render_surface_for_testing_(false), |
96 subtree_property_changed_(false), | 96 subtree_property_changed_(false), |
97 layer_property_changed_(false), | 97 layer_property_changed_(false), |
| 98 may_contain_video_(false), |
98 safe_opaque_background_color_(0), | 99 safe_opaque_background_color_(0), |
99 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 100 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
100 num_unclipped_descendants_(0) {} | 101 num_unclipped_descendants_(0) {} |
101 | 102 |
102 Layer::~Layer() { | 103 Layer::~Layer() { |
103 // Our parent should be holding a reference to us so there should be no | 104 // Our parent should be holding a reference to us so there should be no |
104 // way for us to be destroyed while we still have a parent. | 105 // way for us to be destroyed while we still have a parent. |
105 DCHECK(!parent()); | 106 DCHECK(!parent()); |
106 // Similarly we shouldn't have a layer tree host since it also keeps a | 107 // Similarly we shouldn't have a layer tree host since it also keeps a |
107 // reference to us. | 108 // reference to us. |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 layer->SetTransformTreeIndex(transform_tree_index()); | 1147 layer->SetTransformTreeIndex(transform_tree_index()); |
1147 layer->SetEffectTreeIndex(effect_tree_index()); | 1148 layer->SetEffectTreeIndex(effect_tree_index()); |
1148 layer->SetClipTreeIndex(clip_tree_index()); | 1149 layer->SetClipTreeIndex(clip_tree_index()); |
1149 layer->SetScrollTreeIndex(scroll_tree_index()); | 1150 layer->SetScrollTreeIndex(scroll_tree_index()); |
1150 layer->set_offset_to_transform_parent(offset_to_transform_parent_); | 1151 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
1151 layer->SetDrawsContent(DrawsContent()); | 1152 layer->SetDrawsContent(DrawsContent()); |
1152 // subtree_property_changed_ is propagated to all descendants while building | 1153 // subtree_property_changed_ is propagated to all descendants while building |
1153 // property trees. So, it is enough to check it only for the current layer. | 1154 // property trees. So, it is enough to check it only for the current layer. |
1154 if (subtree_property_changed_ || layer_property_changed_) | 1155 if (subtree_property_changed_ || layer_property_changed_) |
1155 layer->NoteLayerPropertyChanged(); | 1156 layer->NoteLayerPropertyChanged(); |
| 1157 layer->set_may_contain_video(may_contain_video_); |
1156 layer->SetMasksToBounds(inputs_.masks_to_bounds); | 1158 layer->SetMasksToBounds(inputs_.masks_to_bounds); |
1157 layer->set_main_thread_scrolling_reasons( | 1159 layer->set_main_thread_scrolling_reasons( |
1158 inputs_.main_thread_scrolling_reasons); | 1160 inputs_.main_thread_scrolling_reasons); |
1159 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); | 1161 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); |
1160 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); | 1162 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); |
1161 layer->SetContentsOpaque(inputs_.contents_opaque); | 1163 layer->SetContentsOpaque(inputs_.contents_opaque); |
1162 layer->SetPosition(inputs_.position); | 1164 layer->SetPosition(inputs_.position); |
1163 layer->set_should_flatten_transform_from_property_tree( | 1165 layer->set_should_flatten_transform_from_property_tree( |
1164 should_flatten_transform_from_property_tree_); | 1166 should_flatten_transform_from_property_tree_); |
1165 layer->set_draw_blend_mode(draw_blend_mode_); | 1167 layer->set_draw_blend_mode(draw_blend_mode_); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. | 1354 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. |
1353 | 1355 |
1354 base->set_transform_free_index(transform_tree_index_); | 1356 base->set_transform_free_index(transform_tree_index_); |
1355 base->set_effect_tree_index(effect_tree_index_); | 1357 base->set_effect_tree_index(effect_tree_index_); |
1356 base->set_clip_tree_index(clip_tree_index_); | 1358 base->set_clip_tree_index(clip_tree_index_); |
1357 base->set_scroll_tree_index(scroll_tree_index_); | 1359 base->set_scroll_tree_index(scroll_tree_index_); |
1358 Vector2dFToProto(offset_to_transform_parent_, | 1360 Vector2dFToProto(offset_to_transform_parent_, |
1359 base->mutable_offset_to_transform_parent()); | 1361 base->mutable_offset_to_transform_parent()); |
1360 base->set_double_sided(inputs_.double_sided); | 1362 base->set_double_sided(inputs_.double_sided); |
1361 base->set_draws_content(draws_content_); | 1363 base->set_draws_content(draws_content_); |
| 1364 base->set_may_contain_video(may_contain_video_); |
1362 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); | 1365 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); |
1363 base->set_subtree_property_changed(subtree_property_changed_); | 1366 base->set_subtree_property_changed(subtree_property_changed_); |
1364 base->set_layer_property_changed(layer_property_changed_); | 1367 base->set_layer_property_changed(layer_property_changed_); |
1365 | 1368 |
1366 // TODO(nyquist): Add support for serializing FilterOperations for | 1369 // TODO(nyquist): Add support for serializing FilterOperations for |
1367 // |filters_| and |background_filters_|. See crbug.com/541321. | 1370 // |filters_| and |background_filters_|. See crbug.com/541321. |
1368 | 1371 |
1369 base->set_masks_to_bounds(inputs_.masks_to_bounds); | 1372 base->set_masks_to_bounds(inputs_.masks_to_bounds); |
1370 base->set_main_thread_scrolling_reasons( | 1373 base->set_main_thread_scrolling_reasons( |
1371 inputs_.main_thread_scrolling_reasons); | 1374 inputs_.main_thread_scrolling_reasons); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 inputs_.bounds = ProtoToSize(base.bounds()); | 1445 inputs_.bounds = ProtoToSize(base.bounds()); |
1443 | 1446 |
1444 transform_tree_index_ = base.transform_free_index(); | 1447 transform_tree_index_ = base.transform_free_index(); |
1445 effect_tree_index_ = base.effect_tree_index(); | 1448 effect_tree_index_ = base.effect_tree_index(); |
1446 clip_tree_index_ = base.clip_tree_index(); | 1449 clip_tree_index_ = base.clip_tree_index(); |
1447 scroll_tree_index_ = base.scroll_tree_index(); | 1450 scroll_tree_index_ = base.scroll_tree_index(); |
1448 offset_to_transform_parent_ = | 1451 offset_to_transform_parent_ = |
1449 ProtoToVector2dF(base.offset_to_transform_parent()); | 1452 ProtoToVector2dF(base.offset_to_transform_parent()); |
1450 inputs_.double_sided = base.double_sided(); | 1453 inputs_.double_sided = base.double_sided(); |
1451 draws_content_ = base.draws_content(); | 1454 draws_content_ = base.draws_content(); |
| 1455 may_contain_video_ = base.may_contain_video(); |
1452 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); | 1456 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); |
1453 subtree_property_changed_ = base.subtree_property_changed(); | 1457 subtree_property_changed_ = base.subtree_property_changed(); |
1454 layer_property_changed_ = base.layer_property_changed(); | 1458 layer_property_changed_ = base.layer_property_changed(); |
1455 inputs_.masks_to_bounds = base.masks_to_bounds(); | 1459 inputs_.masks_to_bounds = base.masks_to_bounds(); |
1456 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); | 1460 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); |
1457 inputs_.non_fast_scrollable_region = | 1461 inputs_.non_fast_scrollable_region = |
1458 RegionFromProto(base.non_fast_scrollable_region()); | 1462 RegionFromProto(base.non_fast_scrollable_region()); |
1459 inputs_.touch_event_handler_region = | 1463 inputs_.touch_event_handler_region = |
1460 RegionFromProto(base.touch_event_handler_region()); | 1464 RegionFromProto(base.touch_event_handler_region()); |
1461 inputs_.contents_opaque = base.contents_opaque(); | 1465 inputs_.contents_opaque = base.contents_opaque(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 SetNeedsPushProperties(); | 1603 SetNeedsPushProperties(); |
1600 } | 1604 } |
1601 | 1605 |
1602 void Layer::SetLayerPropertyChanged() { | 1606 void Layer::SetLayerPropertyChanged() { |
1603 if (layer_property_changed_) | 1607 if (layer_property_changed_) |
1604 return; | 1608 return; |
1605 layer_property_changed_ = true; | 1609 layer_property_changed_ = true; |
1606 SetNeedsPushProperties(); | 1610 SetNeedsPushProperties(); |
1607 } | 1611 } |
1608 | 1612 |
| 1613 void Layer::SetMayContainVideo(bool yes) { |
| 1614 if (may_contain_video_ == yes) |
| 1615 return; |
| 1616 may_contain_video_ = yes; |
| 1617 SetNeedsPushProperties(); |
| 1618 } |
| 1619 |
1609 bool Layer::FilterIsAnimating() const { | 1620 bool Layer::FilterIsAnimating() const { |
1610 return GetAnimationHost()->IsAnimatingFilterProperty( | 1621 return GetAnimationHost()->IsAnimatingFilterProperty( |
1611 element_id(), GetElementTypeForAnimation()); | 1622 element_id(), GetElementTypeForAnimation()); |
1612 } | 1623 } |
1613 | 1624 |
1614 bool Layer::TransformIsAnimating() const { | 1625 bool Layer::TransformIsAnimating() const { |
1615 return GetAnimationHost()->IsAnimatingTransformProperty( | 1626 return GetAnimationHost()->IsAnimatingTransformProperty( |
1616 element_id(), GetElementTypeForAnimation()); | 1627 element_id(), GetElementTypeForAnimation()); |
1617 } | 1628 } |
1618 | 1629 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 ->num_copy_requests_in_subtree; | 1881 ->num_copy_requests_in_subtree; |
1871 } | 1882 } |
1872 | 1883 |
1873 gfx::Transform Layer::screen_space_transform() const { | 1884 gfx::Transform Layer::screen_space_transform() const { |
1874 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1885 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
1875 return draw_property_utils::ScreenSpaceTransform( | 1886 return draw_property_utils::ScreenSpaceTransform( |
1876 this, layer_tree_host_->property_trees()->transform_tree); | 1887 this, layer_tree_host_->property_trees()->transform_tree); |
1877 } | 1888 } |
1878 | 1889 |
1879 } // namespace cc | 1890 } // namespace cc |
OLD | NEW |