Chromium Code Reviews| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 clip_tree_index_(ClipTree::kInvalidNodeId), | 90 clip_tree_index_(ClipTree::kInvalidNodeId), |
| 91 scroll_tree_index_(ScrollTree::kInvalidNodeId), | 91 scroll_tree_index_(ScrollTree::kInvalidNodeId), |
| 92 property_tree_sequence_number_(-1), | 92 property_tree_sequence_number_(-1), |
| 93 should_flatten_transform_from_property_tree_(false), | 93 should_flatten_transform_from_property_tree_(false), |
| 94 draws_content_(false), | 94 draws_content_(false), |
| 95 use_local_transform_for_backface_visibility_(false), | 95 use_local_transform_for_backface_visibility_(false), |
| 96 should_check_backface_visibility_(false), | 96 should_check_backface_visibility_(false), |
| 97 force_render_surface_for_testing_(false), | 97 force_render_surface_for_testing_(false), |
| 98 subtree_property_changed_(false), | 98 subtree_property_changed_(false), |
| 99 may_contain_video_(false), | 99 may_contain_video_(false), |
| 100 scrollbars_hidden_(false), | |
|
aelias_OOO_until_Jul13
2016/10/26 19:01:03
This state is redundant with the one in Scrollable
bokan
2016/10/27 20:56:46
Done.
| |
| 100 safe_opaque_background_color_(0), | 101 safe_opaque_background_color_(0), |
| 101 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 102 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
| 102 num_unclipped_descendants_(0) {} | 103 num_unclipped_descendants_(0) {} |
| 103 | 104 |
| 104 Layer::~Layer() { | 105 Layer::~Layer() { |
| 105 // Our parent should be holding a reference to us so there should be no | 106 // 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. | 107 // way for us to be destroyed while we still have a parent. |
| 107 DCHECK(!parent()); | 108 DCHECK(!parent()); |
| 108 // Similarly we shouldn't have a layer tree host since it also keeps a | 109 // Similarly we shouldn't have a layer tree host since it also keeps a |
| 109 // reference to us. | 110 // reference to us. |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 transform_node->needs_local_transform_update = true; | 819 transform_node->needs_local_transform_update = true; |
| 819 property_trees->transform_tree.set_needs_update(true); | 820 property_trees->transform_tree.set_needs_update(true); |
| 820 needs_rebuild = false; | 821 needs_rebuild = false; |
| 821 } | 822 } |
| 822 | 823 |
| 823 if (needs_rebuild) | 824 if (needs_rebuild) |
| 824 property_trees->needs_rebuild = true; | 825 property_trees->needs_rebuild = true; |
| 825 | 826 |
| 826 if (!inputs_.did_scroll_callback.is_null()) | 827 if (!inputs_.did_scroll_callback.is_null()) |
| 827 inputs_.did_scroll_callback.Run(); | 828 inputs_.did_scroll_callback.Run(); |
| 829 | |
|
aelias_OOO_until_Jul13
2016/10/26 19:01:03
nit: unnecessary newline
bokan
2016/10/27 20:56:46
Done.
| |
| 828 // The callback could potentially change the layer structure: | 830 // The callback could potentially change the layer structure: |
| 829 // "this" may have been destroyed during the process. | 831 // "this" may have been destroyed during the process. |
| 830 } | 832 } |
| 831 | 833 |
| 832 void Layer::SetScrollClipLayerId(int clip_layer_id) { | 834 void Layer::SetScrollClipLayerId(int clip_layer_id) { |
| 833 DCHECK(IsPropertyChangeAllowed()); | 835 DCHECK(IsPropertyChangeAllowed()); |
| 834 if (inputs_.scroll_clip_layer_id == clip_layer_id) | 836 if (inputs_.scroll_clip_layer_id == clip_layer_id) |
| 835 return; | 837 return; |
| 836 inputs_.scroll_clip_layer_id = clip_layer_id; | 838 inputs_.scroll_clip_layer_id = clip_layer_id; |
| 837 SetNeedsCommit(); | 839 SetNeedsCommit(); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1384 base->set_safe_opaque_background_color(safe_opaque_background_color_); | 1386 base->set_safe_opaque_background_color(safe_opaque_background_color_); |
| 1385 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. | 1387 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. |
| 1386 base->set_transform_free_index(transform_tree_index_); | 1388 base->set_transform_free_index(transform_tree_index_); |
| 1387 base->set_effect_tree_index(effect_tree_index_); | 1389 base->set_effect_tree_index(effect_tree_index_); |
| 1388 base->set_clip_tree_index(clip_tree_index_); | 1390 base->set_clip_tree_index(clip_tree_index_); |
| 1389 base->set_scroll_tree_index(scroll_tree_index_); | 1391 base->set_scroll_tree_index(scroll_tree_index_); |
| 1390 Vector2dFToProto(offset_to_transform_parent_, | 1392 Vector2dFToProto(offset_to_transform_parent_, |
| 1391 base->mutable_offset_to_transform_parent()); | 1393 base->mutable_offset_to_transform_parent()); |
| 1392 base->set_draws_content(draws_content_); | 1394 base->set_draws_content(draws_content_); |
| 1393 base->set_may_contain_video(may_contain_video_); | 1395 base->set_may_contain_video(may_contain_video_); |
| 1396 // TODO(bokan): Should we serialize the scrollbars_enabled flag? | |
| 1394 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); | 1397 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); |
| 1395 base->set_subtree_property_changed(subtree_property_changed_); | 1398 base->set_subtree_property_changed(subtree_property_changed_); |
| 1396 | 1399 |
| 1397 // TODO(nyquist): Add support for serializing FilterOperations for | 1400 // TODO(nyquist): Add support for serializing FilterOperations for |
| 1398 // |filters_| and |background_filters_|. See crbug.com/541321. | 1401 // |filters_| and |background_filters_|. See crbug.com/541321. |
| 1399 | 1402 |
| 1400 base->set_masks_to_bounds(inputs_.masks_to_bounds); | 1403 base->set_masks_to_bounds(inputs_.masks_to_bounds); |
| 1401 base->set_main_thread_scrolling_reasons( | 1404 base->set_main_thread_scrolling_reasons( |
| 1402 inputs_.main_thread_scrolling_reasons); | 1405 inputs_.main_thread_scrolling_reasons); |
| 1403 RegionToProto(inputs_.non_fast_scrollable_region, | 1406 RegionToProto(inputs_.non_fast_scrollable_region, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1447 | 1450 |
| 1448 transform_tree_index_ = base.transform_free_index(); | 1451 transform_tree_index_ = base.transform_free_index(); |
| 1449 effect_tree_index_ = base.effect_tree_index(); | 1452 effect_tree_index_ = base.effect_tree_index(); |
| 1450 clip_tree_index_ = base.clip_tree_index(); | 1453 clip_tree_index_ = base.clip_tree_index(); |
| 1451 scroll_tree_index_ = base.scroll_tree_index(); | 1454 scroll_tree_index_ = base.scroll_tree_index(); |
| 1452 offset_to_transform_parent_ = | 1455 offset_to_transform_parent_ = |
| 1453 ProtoToVector2dF(base.offset_to_transform_parent()); | 1456 ProtoToVector2dF(base.offset_to_transform_parent()); |
| 1454 inputs_.double_sided = base.double_sided(); | 1457 inputs_.double_sided = base.double_sided(); |
| 1455 draws_content_ = base.draws_content(); | 1458 draws_content_ = base.draws_content(); |
| 1456 may_contain_video_ = base.may_contain_video(); | 1459 may_contain_video_ = base.may_contain_video(); |
| 1460 // TODO(bokan): scrollbars_hidden_ | |
| 1457 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); | 1461 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); |
| 1458 subtree_property_changed_ = base.subtree_property_changed(); | 1462 subtree_property_changed_ = base.subtree_property_changed(); |
| 1459 inputs_.masks_to_bounds = base.masks_to_bounds(); | 1463 inputs_.masks_to_bounds = base.masks_to_bounds(); |
| 1460 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); | 1464 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); |
| 1461 inputs_.non_fast_scrollable_region = | 1465 inputs_.non_fast_scrollable_region = |
| 1462 RegionFromProto(base.non_fast_scrollable_region()); | 1466 RegionFromProto(base.non_fast_scrollable_region()); |
| 1463 inputs_.touch_event_handler_region = | 1467 inputs_.touch_event_handler_region = |
| 1464 RegionFromProto(base.touch_event_handler_region()); | 1468 RegionFromProto(base.touch_event_handler_region()); |
| 1465 inputs_.contents_opaque = base.contents_opaque(); | 1469 inputs_.contents_opaque = base.contents_opaque(); |
| 1466 inputs_.opacity = base.opacity(); | 1470 inputs_.opacity = base.opacity(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1600 SetNeedsPushProperties(); | 1604 SetNeedsPushProperties(); |
| 1601 } | 1605 } |
| 1602 | 1606 |
| 1603 void Layer::SetMayContainVideo(bool yes) { | 1607 void Layer::SetMayContainVideo(bool yes) { |
| 1604 if (may_contain_video_ == yes) | 1608 if (may_contain_video_ == yes) |
| 1605 return; | 1609 return; |
| 1606 may_contain_video_ = yes; | 1610 may_contain_video_ = yes; |
| 1607 SetNeedsPushProperties(); | 1611 SetNeedsPushProperties(); |
| 1608 } | 1612 } |
| 1609 | 1613 |
| 1614 void Layer::SetScrollbarsHiddenFromImplSide(bool hidden) { | |
| 1615 if (scrollbars_hidden_ == hidden) | |
| 1616 return; | |
| 1617 | |
| 1618 scrollbars_hidden_ = hidden; | |
| 1619 if (inputs_.client) | |
| 1620 inputs_.client->didChangeScrollbarsHidden(hidden); | |
| 1621 } | |
| 1622 | |
| 1610 bool Layer::FilterIsAnimating() const { | 1623 bool Layer::FilterIsAnimating() const { |
| 1611 return GetAnimationHost()->IsAnimatingFilterProperty( | 1624 return GetAnimationHost()->IsAnimatingFilterProperty( |
| 1612 element_id(), GetElementTypeForAnimation()); | 1625 element_id(), GetElementTypeForAnimation()); |
| 1613 } | 1626 } |
| 1614 | 1627 |
| 1615 bool Layer::TransformIsAnimating() const { | 1628 bool Layer::TransformIsAnimating() const { |
| 1616 return GetAnimationHost()->IsAnimatingTransformProperty( | 1629 return GetAnimationHost()->IsAnimatingTransformProperty( |
| 1617 element_id(), GetElementTypeForAnimation()); | 1630 element_id(), GetElementTypeForAnimation()); |
| 1618 } | 1631 } |
| 1619 | 1632 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1885 | 1898 |
| 1886 LayerTree* Layer::GetLayerTree() const { | 1899 LayerTree* Layer::GetLayerTree() const { |
| 1887 return layer_tree_; | 1900 return layer_tree_; |
| 1888 } | 1901 } |
| 1889 | 1902 |
| 1890 void Layer::SetLayerIdForTesting(int id) { | 1903 void Layer::SetLayerIdForTesting(int id) { |
| 1891 inputs_.layer_id = id; | 1904 inputs_.layer_id = id; |
| 1892 } | 1905 } |
| 1893 | 1906 |
| 1894 } // namespace cc | 1907 } // namespace cc |
| OLD | NEW |