| 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 effect_tree_index_(EffectTree::kInvalidNodeId), | 88 effect_tree_index_(EffectTree::kInvalidNodeId), |
| 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), | |
| 99 may_contain_video_(false), | 98 may_contain_video_(false), |
| 100 safe_opaque_background_color_(0), | 99 safe_opaque_background_color_(0), |
| 101 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 100 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
| 102 num_unclipped_descendants_(0) {} | 101 num_unclipped_descendants_(0) {} |
| 103 | 102 |
| 104 Layer::~Layer() { | 103 Layer::~Layer() { |
| 105 // 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 |
| 106 // 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. |
| 107 DCHECK(!parent()); | 106 DCHECK(!parent()); |
| 108 // 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 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 inputs_.filters = filters; | 465 inputs_.filters = filters; |
| 467 SetSubtreePropertyChanged(); | 466 SetSubtreePropertyChanged(); |
| 468 SetNeedsCommit(); | 467 SetNeedsCommit(); |
| 469 } | 468 } |
| 470 | 469 |
| 471 void Layer::SetBackgroundFilters(const FilterOperations& filters) { | 470 void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
| 472 DCHECK(IsPropertyChangeAllowed()); | 471 DCHECK(IsPropertyChangeAllowed()); |
| 473 if (inputs_.background_filters == filters) | 472 if (inputs_.background_filters == filters) |
| 474 return; | 473 return; |
| 475 inputs_.background_filters = filters; | 474 inputs_.background_filters = filters; |
| 476 SetLayerPropertyChanged(); | 475 SetSubtreePropertyChanged(); |
| 477 SetNeedsCommit(); | 476 SetNeedsCommit(); |
| 478 } | 477 } |
| 479 | 478 |
| 480 void Layer::SetFiltersOrigin(const gfx::PointF& filters_origin) { | 479 void Layer::SetFiltersOrigin(const gfx::PointF& filters_origin) { |
| 481 DCHECK(IsPropertyChangeAllowed()); | 480 DCHECK(IsPropertyChangeAllowed()); |
| 482 if (inputs_.filters_origin == filters_origin) | 481 if (inputs_.filters_origin == filters_origin) |
| 483 return; | 482 return; |
| 484 inputs_.filters_origin = filters_origin; | 483 inputs_.filters_origin = filters_origin; |
| 485 SetSubtreePropertyChanged(); | 484 SetSubtreePropertyChanged(); |
| 486 SetNeedsCommit(); | 485 SetNeedsCommit(); |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 #endif | 1164 #endif |
| 1166 | 1165 |
| 1167 layer->SetTransformTreeIndex(transform_tree_index()); | 1166 layer->SetTransformTreeIndex(transform_tree_index()); |
| 1168 layer->SetEffectTreeIndex(effect_tree_index()); | 1167 layer->SetEffectTreeIndex(effect_tree_index()); |
| 1169 layer->SetClipTreeIndex(clip_tree_index()); | 1168 layer->SetClipTreeIndex(clip_tree_index()); |
| 1170 layer->SetScrollTreeIndex(scroll_tree_index()); | 1169 layer->SetScrollTreeIndex(scroll_tree_index()); |
| 1171 layer->set_offset_to_transform_parent(offset_to_transform_parent_); | 1170 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
| 1172 layer->SetDrawsContent(DrawsContent()); | 1171 layer->SetDrawsContent(DrawsContent()); |
| 1173 // subtree_property_changed_ is propagated to all descendants while building | 1172 // subtree_property_changed_ is propagated to all descendants while building |
| 1174 // property trees. So, it is enough to check it only for the current layer. | 1173 // property trees. So, it is enough to check it only for the current layer. |
| 1175 if (subtree_property_changed_ || layer_property_changed_) | 1174 if (subtree_property_changed_) |
| 1176 layer->NoteLayerPropertyChanged(); | 1175 layer->NoteLayerPropertyChanged(); |
| 1177 layer->set_may_contain_video(may_contain_video_); | 1176 layer->set_may_contain_video(may_contain_video_); |
| 1178 layer->SetMasksToBounds(inputs_.masks_to_bounds); | 1177 layer->SetMasksToBounds(inputs_.masks_to_bounds); |
| 1179 layer->set_main_thread_scrolling_reasons( | 1178 layer->set_main_thread_scrolling_reasons( |
| 1180 inputs_.main_thread_scrolling_reasons); | 1179 inputs_.main_thread_scrolling_reasons); |
| 1181 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); | 1180 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); |
| 1182 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); | 1181 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); |
| 1183 layer->SetContentsOpaque(inputs_.contents_opaque); | 1182 layer->SetContentsOpaque(inputs_.contents_opaque); |
| 1184 layer->SetPosition(inputs_.position); | 1183 layer->SetPosition(inputs_.position); |
| 1185 layer->set_should_flatten_transform_from_property_tree( | 1184 layer->set_should_flatten_transform_from_property_tree( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1210 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1209 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1211 // union) any update changes that have occurred on the main thread. | 1210 // union) any update changes that have occurred on the main thread. |
| 1212 inputs_.update_rect.Union(layer->update_rect()); | 1211 inputs_.update_rect.Union(layer->update_rect()); |
| 1213 layer->SetUpdateRect(inputs_.update_rect); | 1212 layer->SetUpdateRect(inputs_.update_rect); |
| 1214 | 1213 |
| 1215 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); | 1214 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 1216 layer->SetNeedsPushProperties(); | 1215 layer->SetNeedsPushProperties(); |
| 1217 | 1216 |
| 1218 // Reset any state that should be cleared for the next update. | 1217 // Reset any state that should be cleared for the next update. |
| 1219 subtree_property_changed_ = false; | 1218 subtree_property_changed_ = false; |
| 1220 layer_property_changed_ = false; | |
| 1221 inputs_.update_rect = gfx::Rect(); | 1219 inputs_.update_rect = gfx::Rect(); |
| 1222 | 1220 |
| 1223 layer_tree_->RemoveLayerShouldPushProperties(this); | 1221 layer_tree_->RemoveLayerShouldPushProperties(this); |
| 1224 } | 1222 } |
| 1225 | 1223 |
| 1226 void Layer::TakeCopyRequests( | 1224 void Layer::TakeCopyRequests( |
| 1227 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { | 1225 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { |
| 1228 for (auto& it : inputs_.copy_requests) { | 1226 for (auto& it : inputs_.copy_requests) { |
| 1229 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1227 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1230 layer_tree_host()->GetTaskRunnerProvider()->MainThreadTaskRunner(); | 1228 layer_tree_host()->GetTaskRunnerProvider()->MainThreadTaskRunner(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 base->set_effect_tree_index(effect_tree_index_); | 1375 base->set_effect_tree_index(effect_tree_index_); |
| 1378 base->set_clip_tree_index(clip_tree_index_); | 1376 base->set_clip_tree_index(clip_tree_index_); |
| 1379 base->set_scroll_tree_index(scroll_tree_index_); | 1377 base->set_scroll_tree_index(scroll_tree_index_); |
| 1380 Vector2dFToProto(offset_to_transform_parent_, | 1378 Vector2dFToProto(offset_to_transform_parent_, |
| 1381 base->mutable_offset_to_transform_parent()); | 1379 base->mutable_offset_to_transform_parent()); |
| 1382 base->set_double_sided(inputs_.double_sided); | 1380 base->set_double_sided(inputs_.double_sided); |
| 1383 base->set_draws_content(draws_content_); | 1381 base->set_draws_content(draws_content_); |
| 1384 base->set_may_contain_video(may_contain_video_); | 1382 base->set_may_contain_video(may_contain_video_); |
| 1385 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); | 1383 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); |
| 1386 base->set_subtree_property_changed(subtree_property_changed_); | 1384 base->set_subtree_property_changed(subtree_property_changed_); |
| 1387 base->set_layer_property_changed(layer_property_changed_); | |
| 1388 | 1385 |
| 1389 // TODO(nyquist): Add support for serializing FilterOperations for | 1386 // TODO(nyquist): Add support for serializing FilterOperations for |
| 1390 // |filters_| and |background_filters_|. See crbug.com/541321. | 1387 // |filters_| and |background_filters_|. See crbug.com/541321. |
| 1391 | 1388 |
| 1392 base->set_masks_to_bounds(inputs_.masks_to_bounds); | 1389 base->set_masks_to_bounds(inputs_.masks_to_bounds); |
| 1393 base->set_main_thread_scrolling_reasons( | 1390 base->set_main_thread_scrolling_reasons( |
| 1394 inputs_.main_thread_scrolling_reasons); | 1391 inputs_.main_thread_scrolling_reasons); |
| 1395 RegionToProto(inputs_.non_fast_scrollable_region, | 1392 RegionToProto(inputs_.non_fast_scrollable_region, |
| 1396 base->mutable_non_fast_scrollable_region()); | 1393 base->mutable_non_fast_scrollable_region()); |
| 1397 RegionToProto(inputs_.touch_event_handler_region, | 1394 RegionToProto(inputs_.touch_event_handler_region, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 effect_tree_index_ = base.effect_tree_index(); | 1465 effect_tree_index_ = base.effect_tree_index(); |
| 1469 clip_tree_index_ = base.clip_tree_index(); | 1466 clip_tree_index_ = base.clip_tree_index(); |
| 1470 scroll_tree_index_ = base.scroll_tree_index(); | 1467 scroll_tree_index_ = base.scroll_tree_index(); |
| 1471 offset_to_transform_parent_ = | 1468 offset_to_transform_parent_ = |
| 1472 ProtoToVector2dF(base.offset_to_transform_parent()); | 1469 ProtoToVector2dF(base.offset_to_transform_parent()); |
| 1473 inputs_.double_sided = base.double_sided(); | 1470 inputs_.double_sided = base.double_sided(); |
| 1474 draws_content_ = base.draws_content(); | 1471 draws_content_ = base.draws_content(); |
| 1475 may_contain_video_ = base.may_contain_video(); | 1472 may_contain_video_ = base.may_contain_video(); |
| 1476 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); | 1473 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); |
| 1477 subtree_property_changed_ = base.subtree_property_changed(); | 1474 subtree_property_changed_ = base.subtree_property_changed(); |
| 1478 layer_property_changed_ = base.layer_property_changed(); | |
| 1479 inputs_.masks_to_bounds = base.masks_to_bounds(); | 1475 inputs_.masks_to_bounds = base.masks_to_bounds(); |
| 1480 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); | 1476 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); |
| 1481 inputs_.non_fast_scrollable_region = | 1477 inputs_.non_fast_scrollable_region = |
| 1482 RegionFromProto(base.non_fast_scrollable_region()); | 1478 RegionFromProto(base.non_fast_scrollable_region()); |
| 1483 inputs_.touch_event_handler_region = | 1479 inputs_.touch_event_handler_region = |
| 1484 RegionFromProto(base.touch_event_handler_region()); | 1480 RegionFromProto(base.touch_event_handler_region()); |
| 1485 inputs_.contents_opaque = base.contents_opaque(); | 1481 inputs_.contents_opaque = base.contents_opaque(); |
| 1486 inputs_.opacity = base.opacity(); | 1482 inputs_.opacity = base.opacity(); |
| 1487 inputs_.blend_mode = SkXfermodeModeFromProto(base.blend_mode()); | 1483 inputs_.blend_mode = SkXfermodeModeFromProto(base.blend_mode()); |
| 1488 inputs_.is_root_for_isolated_group = base.is_root_for_isolated_group(); | 1484 inputs_.is_root_for_isolated_group = base.is_root_for_isolated_group(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 inputs_.client->didUpdateMainThreadScrollingReasons(); | 1609 inputs_.client->didUpdateMainThreadScrollingReasons(); |
| 1614 } | 1610 } |
| 1615 | 1611 |
| 1616 void Layer::SetSubtreePropertyChanged() { | 1612 void Layer::SetSubtreePropertyChanged() { |
| 1617 if (subtree_property_changed_) | 1613 if (subtree_property_changed_) |
| 1618 return; | 1614 return; |
| 1619 subtree_property_changed_ = true; | 1615 subtree_property_changed_ = true; |
| 1620 SetNeedsPushProperties(); | 1616 SetNeedsPushProperties(); |
| 1621 } | 1617 } |
| 1622 | 1618 |
| 1623 void Layer::SetLayerPropertyChanged() { | |
| 1624 if (layer_property_changed_) | |
| 1625 return; | |
| 1626 layer_property_changed_ = true; | |
| 1627 SetNeedsPushProperties(); | |
| 1628 } | |
| 1629 | |
| 1630 void Layer::SetMayContainVideo(bool yes) { | 1619 void Layer::SetMayContainVideo(bool yes) { |
| 1631 if (may_contain_video_ == yes) | 1620 if (may_contain_video_ == yes) |
| 1632 return; | 1621 return; |
| 1633 may_contain_video_ = yes; | 1622 may_contain_video_ = yes; |
| 1634 SetNeedsPushProperties(); | 1623 SetNeedsPushProperties(); |
| 1635 } | 1624 } |
| 1636 | 1625 |
| 1637 bool Layer::FilterIsAnimating() const { | 1626 bool Layer::FilterIsAnimating() const { |
| 1638 return GetAnimationHost()->IsAnimatingFilterProperty( | 1627 return GetAnimationHost()->IsAnimatingFilterProperty( |
| 1639 element_id(), GetElementTypeForAnimation()); | 1628 element_id(), GetElementTypeForAnimation()); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1888 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1900 return draw_property_utils::ScreenSpaceTransform( | 1889 return draw_property_utils::ScreenSpaceTransform( |
| 1901 this, layer_tree_->property_trees()->transform_tree); | 1890 this, layer_tree_->property_trees()->transform_tree); |
| 1902 } | 1891 } |
| 1903 | 1892 |
| 1904 LayerTree* Layer::GetLayerTree() const { | 1893 LayerTree* Layer::GetLayerTree() const { |
| 1905 return layer_tree_; | 1894 return layer_tree_; |
| 1906 } | 1895 } |
| 1907 | 1896 |
| 1908 } // namespace cc | 1897 } // namespace cc |
| OLD | NEW |