OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 num_dependents_need_push_properties_(0), | 91 num_dependents_need_push_properties_(0), |
92 sorting_context_id_(0), | 92 sorting_context_id_(0), |
93 current_draw_mode_(DRAW_MODE_NONE), | 93 current_draw_mode_(DRAW_MODE_NONE), |
94 element_id_(0), | 94 element_id_(0), |
95 mutable_properties_(kMutablePropertyNone), | 95 mutable_properties_(kMutablePropertyNone), |
96 force_render_surface_(false), | 96 force_render_surface_(false), |
97 frame_timing_requests_dirty_(false), | 97 frame_timing_requests_dirty_(false), |
98 visited_(false), | 98 visited_(false), |
99 layer_or_descendant_is_drawn_(false), | 99 layer_or_descendant_is_drawn_(false), |
100 layer_or_descendant_has_input_handler_(false), | 100 layer_or_descendant_has_input_handler_(false), |
101 sorted_for_recursion_(false), | 101 sorted_for_recursion_(false) { |
102 is_hidden_from_property_trees_(false) { | |
103 DCHECK_GT(layer_id_, 0); | 102 DCHECK_GT(layer_id_, 0); |
104 DCHECK(layer_tree_impl_); | 103 DCHECK(layer_tree_impl_); |
105 layer_tree_impl_->RegisterLayer(this); | 104 layer_tree_impl_->RegisterLayer(this); |
106 | 105 |
107 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { | 106 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { |
108 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); | 107 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); |
109 layer_animation_controller_ = | 108 layer_animation_controller_ = |
110 registrar->GetAnimationControllerForId(layer_id_); | 109 registrar->GetAnimationControllerForId(layer_id_); |
111 layer_animation_controller_->AddValueObserver(this); | 110 layer_animation_controller_->AddValueObserver(this); |
112 if (IsActive()) { | 111 if (IsActive()) { |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
646 | 645 |
647 layer->PushScrollOffset(nullptr); | 646 layer->PushScrollOffset(nullptr); |
648 | 647 |
649 layer->Set3dSortingContextId(sorting_context_id_); | 648 layer->Set3dSortingContextId(sorting_context_id_); |
650 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 649 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
651 | 650 |
652 layer->SetTransformTreeIndex(transform_tree_index_); | 651 layer->SetTransformTreeIndex(transform_tree_index_); |
653 layer->SetClipTreeIndex(clip_tree_index_); | 652 layer->SetClipTreeIndex(clip_tree_index_); |
654 layer->SetEffectTreeIndex(effect_tree_index_); | 653 layer->SetEffectTreeIndex(effect_tree_index_); |
655 layer->set_offset_to_transform_parent(offset_to_transform_parent_); | 654 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
656 layer->set_is_hidden_from_property_trees(is_hidden_from_property_trees_); | |
657 | 655 |
658 LayerImpl* scroll_parent = nullptr; | 656 LayerImpl* scroll_parent = nullptr; |
659 if (scroll_parent_) { | 657 if (scroll_parent_) { |
660 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 658 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
661 DCHECK(scroll_parent); | 659 DCHECK(scroll_parent); |
662 } | 660 } |
663 | 661 |
664 layer->SetScrollParent(scroll_parent); | 662 layer->SetScrollParent(scroll_parent); |
665 if (scroll_children_) { | 663 if (scroll_children_) { |
666 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 664 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
978 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { | 976 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { |
979 return CurrentScrollOffset(); | 977 return CurrentScrollOffset(); |
980 } | 978 } |
981 | 979 |
982 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) { | 980 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) { |
983 SetFilters(filters); | 981 SetFilters(filters); |
984 } | 982 } |
985 | 983 |
986 void LayerImpl::OnOpacityAnimated(float opacity) { | 984 void LayerImpl::OnOpacityAnimated(float opacity) { |
987 SetOpacity(opacity); | 985 SetOpacity(opacity); |
988 UpdatePropertyTreeOpacity(); | 986 UpdatePropertyTreeOpacity(); |
jaydasika
2016/01/21 00:53:09
Question : Do we need to update property tree opac
ajuma
2016/01/21 14:38:04
Yes, you're right that Opacity() won't change in t
| |
989 } | 987 } |
990 | 988 |
991 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) { | 989 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) { |
992 SetTransform(transform); | 990 SetTransform(transform); |
993 UpdatePropertyTreeTransform(); | 991 UpdatePropertyTreeTransform(); |
994 was_ever_ready_since_last_transform_animation_ = false; | 992 was_ever_ready_since_last_transform_animation_ = false; |
995 } | 993 } |
996 | 994 |
997 void LayerImpl::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { | 995 void LayerImpl::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { |
998 // Only layers in the active tree should need to do anything here, since | 996 // Only layers in the active tree should need to do anything here, since |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1910 } | 1908 } |
1911 | 1909 |
1912 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { | 1910 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { |
1913 gfx::Transform scaled_draw_transform = DrawTransform(); | 1911 gfx::Transform scaled_draw_transform = DrawTransform(); |
1914 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); | 1912 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); |
1915 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale); | 1913 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale); |
1916 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, | 1914 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, |
1917 gfx::Rect(scaled_bounds)); | 1915 gfx::Rect(scaled_bounds)); |
1918 } | 1916 } |
1919 | 1917 |
1920 bool LayerImpl::LayerIsHidden() const { | 1918 bool LayerImpl::IsHidden() const { |
1921 if (layer_tree_impl()->settings().use_property_trees) { | 1919 if (layer_tree_impl()->settings().use_property_trees) { |
1922 return is_hidden_from_property_trees_; | 1920 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree; |
1921 EffectNode* node = effect_tree.Node(effect_tree_index_); | |
1922 return node->data.screen_space_opacity == 0.f; | |
1923 } else { | 1923 } else { |
1924 return hide_layer_and_subtree_ || (parent() && parent()->LayerIsHidden()); | 1924 return opacity() == 0.f || (parent() && parent()->IsHidden()); |
1925 } | 1925 } |
1926 } | 1926 } |
1927 | 1927 |
1928 float LayerImpl::GetIdealContentsScale() const { | 1928 float LayerImpl::GetIdealContentsScale() const { |
1929 float page_scale = IsAffectedByPageScale() | 1929 float page_scale = IsAffectedByPageScale() |
1930 ? layer_tree_impl()->current_page_scale_factor() | 1930 ? layer_tree_impl()->current_page_scale_factor() |
1931 : 1.f; | 1931 : 1.f; |
1932 float device_scale = layer_tree_impl()->device_scale_factor(); | 1932 float device_scale = layer_tree_impl()->device_scale_factor(); |
1933 | 1933 |
1934 float default_scale = page_scale * device_scale; | 1934 float default_scale = page_scale * device_scale; |
1935 if (!layer_tree_impl() | 1935 if (!layer_tree_impl() |
1936 ->settings() | 1936 ->settings() |
1937 .layer_transforms_should_scale_layer_contents) { | 1937 .layer_transforms_should_scale_layer_contents) { |
1938 return default_scale; | 1938 return default_scale; |
1939 } | 1939 } |
1940 | 1940 |
1941 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1941 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1942 DrawTransform(), default_scale); | 1942 DrawTransform(), default_scale); |
1943 return std::max(transform_scales.x(), transform_scales.y()); | 1943 return std::max(transform_scales.x(), transform_scales.y()); |
1944 } | 1944 } |
1945 | 1945 |
1946 } // namespace cc | 1946 } // namespace cc |
OLD | NEW |