Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 2130053002: cc: Clean up Layer and LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@start_minor_layer_cleanup
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 10 #include <algorithm>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/numerics/safe_conversions.h" 15 #include "base/numerics/safe_conversions.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "base/trace_event/trace_event_argument.h" 18 #include "base/trace_event/trace_event_argument.h"
19 #include "cc/animation/animation_host.h"
19 #include "cc/animation/mutable_properties.h" 20 #include "cc/animation/mutable_properties.h"
20 #include "cc/base/math_util.h" 21 #include "cc/base/math_util.h"
21 #include "cc/base/simple_enclosed_region.h" 22 #include "cc/base/simple_enclosed_region.h"
22 #include "cc/debug/debug_colors.h" 23 #include "cc/debug/debug_colors.h"
23 #include "cc/debug/layer_tree_debug_state.h" 24 #include "cc/debug/layer_tree_debug_state.h"
24 #include "cc/debug/micro_benchmark_impl.h" 25 #include "cc/debug/micro_benchmark_impl.h"
25 #include "cc/debug/traced_value.h" 26 #include "cc/debug/traced_value.h"
26 #include "cc/input/main_thread_scrolling_reason.h" 27 #include "cc/input/main_thread_scrolling_reason.h"
27 #include "cc/input/scroll_state.h" 28 #include "cc/input/scroll_state.h"
28 #include "cc/layers/layer.h" 29 #include "cc/layers/layer.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 layer_tree_impl_->RemoveFromElementMap(this); 101 layer_tree_impl_->RemoveFromElementMap(this);
101 102
102 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 103 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
103 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); 104 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this);
104 } 105 }
105 106
106 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) { 107 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) {
107 has_will_change_transform_hint_ = has_will_change; 108 has_will_change_transform_hint_ = has_will_change;
108 } 109 }
109 110
111 AnimationHost* LayerImpl::GetAnimationHost() const {
112 return layer_tree_impl_ ? layer_tree_impl_->animation_host() : nullptr;
113 }
114
115 ElementListType LayerImpl::GetElementTypeForAnimation() const {
116 return IsActive() ? ElementListType::ACTIVE : ElementListType::PENDING;
117 }
118
110 void LayerImpl::SetDebugInfo( 119 void LayerImpl::SetDebugInfo(
111 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) { 120 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) {
112 owned_debug_info_ = std::move(debug_info); 121 owned_debug_info_ = std::move(debug_info);
113 debug_info_ = owned_debug_info_.get(); 122 debug_info_ = owned_debug_info_.get();
114 SetNeedsPushProperties(); 123 SetNeedsPushProperties();
115 } 124 }
116 125
117 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { 126 void LayerImpl::DistributeScroll(ScrollState* scroll_state) {
118 DCHECK(scroll_state); 127 DCHECK(scroll_state);
119 if (scroll_state->FullyConsumed()) 128 if (scroll_state->FullyConsumed())
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 if (SkColorGetA(color) == 255) 775 if (SkColorGetA(color) == 255)
767 color = SK_ColorTRANSPARENT; 776 color = SK_ColorTRANSPARENT;
768 return color; 777 return color;
769 } 778 }
770 779
771 void LayerImpl::SetFilters(const FilterOperations& filters) { 780 void LayerImpl::SetFilters(const FilterOperations& filters) {
772 filters_ = filters; 781 filters_ = filters;
773 } 782 }
774 783
775 bool LayerImpl::FilterIsAnimating() const { 784 bool LayerImpl::FilterIsAnimating() const {
776 return layer_tree_impl_->IsAnimatingFilterProperty(this); 785 return GetAnimationHost()->IsAnimatingFilterProperty(
786 element_id(), GetElementTypeForAnimation());
777 } 787 }
778 788
779 bool LayerImpl::HasPotentiallyRunningFilterAnimation() const { 789 bool LayerImpl::HasPotentiallyRunningFilterAnimation() const {
780 return layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this); 790 return GetAnimationHost()->HasPotentiallyRunningFilterAnimation(
791 element_id(), GetElementTypeForAnimation());
781 } 792 }
782 793
783 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) { 794 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) {
784 masks_to_bounds_ = masks_to_bounds; 795 masks_to_bounds_ = masks_to_bounds;
785 } 796 }
786 797
787 void LayerImpl::SetContentsOpaque(bool opaque) { 798 void LayerImpl::SetContentsOpaque(bool opaque) {
788 contents_opaque_ = opaque; 799 contents_opaque_ = opaque;
789 } 800 }
790 801
791 float LayerImpl::Opacity() const { 802 float LayerImpl::Opacity() const {
792 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 803 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
793 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 804 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
794 return 1.f; 805 return 1.f;
795 EffectNode* node = property_trees->effect_tree.Node( 806 EffectNode* node = property_trees->effect_tree.Node(
796 property_trees->effect_id_to_index_map[id()]); 807 property_trees->effect_id_to_index_map[id()]);
797 return node->opacity; 808 return node->opacity;
798 } 809 }
799 810
800 bool LayerImpl::OpacityIsAnimating() const {
801 return layer_tree_impl_->IsAnimatingOpacityProperty(this);
802 }
803
804 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const {
805 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this);
806 }
807
808 void LayerImpl::SetElementId(ElementId element_id) { 811 void LayerImpl::SetElementId(ElementId element_id) {
809 if (element_id == element_id_) 812 if (element_id == element_id_)
810 return; 813 return;
811 814
812 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 815 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
813 "LayerImpl::SetElementId", "element", 816 "LayerImpl::SetElementId", "element",
814 element_id.AsValue().release()); 817 element_id.AsValue().release());
815 818
816 layer_tree_impl_->RemoveFromElementMap(this); 819 layer_tree_impl_->RemoveFromElementMap(this);
817 element_id_ = element_id; 820 element_id_ = element_id;
(...skipping 24 matching lines...) Expand all
842 845
843 void LayerImpl::Set3dSortingContextId(int id) { 846 void LayerImpl::Set3dSortingContextId(int id) {
844 sorting_context_id_ = id; 847 sorting_context_id_ = id;
845 } 848 }
846 849
847 void LayerImpl::SetTransform(const gfx::Transform& transform) { 850 void LayerImpl::SetTransform(const gfx::Transform& transform) {
848 transform_ = transform; 851 transform_ = transform;
849 } 852 }
850 853
851 bool LayerImpl::TransformIsAnimating() const { 854 bool LayerImpl::TransformIsAnimating() const {
852 return layer_tree_impl_->IsAnimatingTransformProperty(this); 855 return GetAnimationHost()->IsAnimatingTransformProperty(
856 element_id(), GetElementTypeForAnimation());
853 } 857 }
854 858
855 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { 859 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const {
856 return layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); 860 return GetAnimationHost()->HasPotentiallyRunningTransformAnimation(
861 element_id(), GetElementTypeForAnimation());
857 } 862 }
858 863
859 bool LayerImpl::HasOnlyTranslationTransforms() const { 864 bool LayerImpl::HasOnlyTranslationTransforms() const {
860 return layer_tree_impl_->HasOnlyTranslationTransforms(this); 865 return GetAnimationHost()->HasOnlyTranslationTransforms(
861 } 866 element_id(), GetElementTypeForAnimation());
862
863 bool LayerImpl::AnimationsPreserveAxisAlignment() const {
864 return layer_tree_impl_->AnimationsPreserveAxisAlignment(this);
865 }
866
867 bool LayerImpl::MaximumTargetScale(float* max_scale) const {
868 return layer_tree_impl_->MaximumTargetScale(this, max_scale);
869 }
870
871 bool LayerImpl::AnimationStartScale(float* start_scale) const {
872 return layer_tree_impl_->AnimationStartScale(this, start_scale);
873 } 867 }
874 868
875 bool LayerImpl::HasAnyAnimationTargetingProperty( 869 bool LayerImpl::HasAnyAnimationTargetingProperty(
876 TargetProperty::Type property) const { 870 TargetProperty::Type property) const {
877 return layer_tree_impl_->HasAnyAnimationTargetingProperty(this, property); 871 return GetAnimationHost()->HasAnyAnimationTargetingProperty(element_id(),
872 property);
878 } 873 }
879 874
880 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const { 875 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const {
881 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this); 876 return GetAnimationHost()->HasFilterAnimationThatInflatesBounds(element_id());
882 } 877 }
883 878
884 bool LayerImpl::HasTransformAnimationThatInflatesBounds() const { 879 bool LayerImpl::HasTransformAnimationThatInflatesBounds() const {
885 return layer_tree_impl_->HasTransformAnimationThatInflatesBounds(this); 880 return GetAnimationHost()->HasTransformAnimationThatInflatesBounds(
881 element_id());
886 } 882 }
887 883
888 bool LayerImpl::HasAnimationThatInflatesBounds() const { 884 bool LayerImpl::HasAnimationThatInflatesBounds() const {
889 return layer_tree_impl_->HasAnimationThatInflatesBounds(this); 885 return GetAnimationHost()->HasAnimationThatInflatesBounds(element_id());
890 } 886 }
891 887
892 bool LayerImpl::FilterAnimationBoundsForBox(const gfx::BoxF& box, 888 bool LayerImpl::FilterAnimationBoundsForBox(const gfx::BoxF& box,
893 gfx::BoxF* bounds) const { 889 gfx::BoxF* bounds) const {
894 return layer_tree_impl_->FilterAnimationBoundsForBox(this, box, bounds); 890 return GetAnimationHost()->FilterAnimationBoundsForBox(element_id(), box,
891 bounds);
895 } 892 }
896 893
897 bool LayerImpl::TransformAnimationBoundsForBox(const gfx::BoxF& box, 894 bool LayerImpl::TransformAnimationBoundsForBox(const gfx::BoxF& box,
898 gfx::BoxF* bounds) const { 895 gfx::BoxF* bounds) const {
899 return layer_tree_impl_->TransformAnimationBoundsForBox(this, box, bounds); 896 return GetAnimationHost()->TransformAnimationBoundsForBox(element_id(), box,
897 bounds);
900 } 898 }
901 899
902 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) { 900 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) {
903 update_rect_ = update_rect; 901 update_rect_ = update_rect;
904 SetNeedsPushProperties(); 902 SetNeedsPushProperties();
905 } 903 }
906 904
907 void LayerImpl::AddDamageRect(const gfx::Rect& damage_rect) { 905 void LayerImpl::AddDamageRect(const gfx::Rect& damage_rect) {
908 damage_rect_.Union(damage_rect); 906 damage_rect_.Union(damage_rect);
909 } 907 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 } 1018 }
1021 if (!non_fast_scrollable_region_.IsEmpty()) { 1019 if (!non_fast_scrollable_region_.IsEmpty()) {
1022 state->BeginArray("non_fast_scrollable_region"); 1020 state->BeginArray("non_fast_scrollable_region");
1023 non_fast_scrollable_region_.AsValueInto(state); 1021 non_fast_scrollable_region_.AsValueInto(state);
1024 state->EndArray(); 1022 state->EndArray();
1025 } 1023 }
1026 1024
1027 state->SetBoolean("can_use_lcd_text", CanUseLCDText()); 1025 state->SetBoolean("can_use_lcd_text", CanUseLCDText());
1028 state->SetBoolean("contents_opaque", contents_opaque()); 1026 state->SetBoolean("contents_opaque", contents_opaque());
1029 1027
1030 state->SetBoolean("has_animation_bounds", 1028 state->SetBoolean("has_animation_bounds", HasAnimationThatInflatesBounds());
1031 layer_tree_impl_->HasAnimationThatInflatesBounds(this));
1032 1029
1033 state->SetBoolean("has_will_change_transform_hint", 1030 state->SetBoolean("has_will_change_transform_hint",
1034 has_will_change_transform_hint()); 1031 has_will_change_transform_hint());
1035 1032
1036 gfx::BoxF box; 1033 gfx::BoxF box;
1037 if (LayerUtils::GetAnimationBounds(*this, &box)) 1034 if (LayerUtils::GetAnimationBounds(*this, &box))
1038 MathUtil::AddToTracedValue("animation_bounds", box, state); 1035 MathUtil::AddToTracedValue("animation_bounds", box, state);
1039 1036
1040 if (debug_info_) { 1037 if (debug_info_) {
1041 std::string str; 1038 std::string str;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 .layer_transforms_should_scale_layer_contents) { 1195 .layer_transforms_should_scale_layer_contents) {
1199 return default_scale; 1196 return default_scale;
1200 } 1197 }
1201 1198
1202 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1199 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1203 ScreenSpaceTransform(), default_scale); 1200 ScreenSpaceTransform(), default_scale);
1204 return std::max(transform_scales.x(), transform_scales.y()); 1201 return std::max(transform_scales.x(), transform_scales.y());
1205 } 1202 }
1206 1203
1207 } // namespace cc 1204 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698