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

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

Issue 1010663002: CC Animations: Redirect all compositor animation requests to AnimationHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@introduce
Patch Set: Rebase and fix conflicts (HasPotentiallyRunningTransformAnimation) Created 5 years, 7 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/layers/layer_utils.cc » ('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 "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 clip_tree_index_(-1), 78 clip_tree_index_(-1),
79 draw_depth_(0.f), 79 draw_depth_(0.f),
80 needs_push_properties_(false), 80 needs_push_properties_(false),
81 num_dependents_need_push_properties_(0), 81 num_dependents_need_push_properties_(0),
82 sorting_context_id_(0), 82 sorting_context_id_(0),
83 current_draw_mode_(DRAW_MODE_NONE), 83 current_draw_mode_(DRAW_MODE_NONE),
84 frame_timing_requests_dirty_(false) { 84 frame_timing_requests_dirty_(false) {
85 DCHECK_GT(layer_id_, 0); 85 DCHECK_GT(layer_id_, 0);
86 DCHECK(layer_tree_impl_); 86 DCHECK(layer_tree_impl_);
87 layer_tree_impl_->RegisterLayer(this); 87 layer_tree_impl_->RegisterLayer(this);
88 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); 88
89 layer_animation_controller_ = 89 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) {
90 registrar->GetAnimationControllerForId(layer_id_); 90 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar();
91 layer_animation_controller_->AddValueObserver(this); 91 layer_animation_controller_ =
92 if (IsActive()) { 92 registrar->GetAnimationControllerForId(layer_id_);
93 layer_animation_controller_->set_value_provider(this); 93 layer_animation_controller_->AddValueObserver(this);
94 layer_animation_controller_->set_layer_animation_delegate(this); 94 if (IsActive()) {
95 layer_animation_controller_->set_value_provider(this);
96 layer_animation_controller_->set_layer_animation_delegate(this);
97 }
95 } 98 }
96 SetNeedsPushProperties(); 99 SetNeedsPushProperties();
97 } 100 }
98 101
99 LayerImpl::~LayerImpl() { 102 LayerImpl::~LayerImpl() {
100 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 103 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
101 104
102 layer_animation_controller_->RemoveValueObserver(this); 105 if (layer_animation_controller_) {
103 layer_animation_controller_->remove_value_provider(this); 106 layer_animation_controller_->RemoveValueObserver(this);
104 layer_animation_controller_->remove_layer_animation_delegate(this); 107 layer_animation_controller_->remove_value_provider(this);
108 layer_animation_controller_->remove_layer_animation_delegate(this);
109 }
105 110
106 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) 111 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree())
107 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); 112 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
108 layer_tree_impl_->UnregisterLayer(this); 113 layer_tree_impl_->UnregisterLayer(this);
109 114
110 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 115 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
111 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); 116 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this);
112 } 117 }
113 118
114 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { 119 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) {
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 967
963 void LayerImpl::SetFilters(const FilterOperations& filters) { 968 void LayerImpl::SetFilters(const FilterOperations& filters) {
964 if (filters_ == filters) 969 if (filters_ == filters)
965 return; 970 return;
966 971
967 filters_ = filters; 972 filters_ = filters;
968 NoteLayerPropertyChangedForSubtree(); 973 NoteLayerPropertyChangedForSubtree();
969 } 974 }
970 975
971 bool LayerImpl::FilterIsAnimating() const { 976 bool LayerImpl::FilterIsAnimating() const {
972 return layer_animation_controller_->IsAnimatingProperty(Animation::FILTER); 977 return layer_animation_controller_
978 ? layer_animation_controller_->IsAnimatingProperty(
979 Animation::FILTER)
980 : layer_tree_impl_->IsAnimatingFilterProperty(this);
973 } 981 }
974 982
975 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { 983 bool LayerImpl::FilterIsAnimatingOnImplOnly() const {
984 if (!layer_animation_controller_)
985 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this);
986
976 Animation* filter_animation = 987 Animation* filter_animation =
977 layer_animation_controller_->GetAnimation(Animation::FILTER); 988 layer_animation_controller_->GetAnimation(Animation::FILTER);
978 return filter_animation && filter_animation->is_impl_only(); 989 return filter_animation && filter_animation->is_impl_only();
979 } 990 }
980 991
981 void LayerImpl::SetBackgroundFilters( 992 void LayerImpl::SetBackgroundFilters(
982 const FilterOperations& filters) { 993 const FilterOperations& filters) {
983 if (background_filters_ == filters) 994 if (background_filters_ == filters)
984 return; 995 return;
985 996
(...skipping 19 matching lines...) Expand all
1005 1016
1006 void LayerImpl::SetOpacity(float opacity) { 1017 void LayerImpl::SetOpacity(float opacity) {
1007 if (opacity_ == opacity) 1018 if (opacity_ == opacity)
1008 return; 1019 return;
1009 1020
1010 opacity_ = opacity; 1021 opacity_ = opacity;
1011 NoteLayerPropertyChangedForSubtree(); 1022 NoteLayerPropertyChangedForSubtree();
1012 } 1023 }
1013 1024
1014 bool LayerImpl::OpacityIsAnimating() const { 1025 bool LayerImpl::OpacityIsAnimating() const {
1015 return layer_animation_controller_->IsAnimatingProperty(Animation::OPACITY); 1026 return layer_animation_controller_
1027 ? layer_animation_controller_->IsAnimatingProperty(
1028 Animation::OPACITY)
1029 : layer_tree_impl_->IsAnimatingOpacityProperty(this);
1030 }
1031
1032 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const {
1033 if (layer_animation_controller_) {
1034 if (Animation* animation =
1035 layer_animation_controller()->GetAnimation(Animation::OPACITY)) {
1036 return !animation->is_finished();
1037 }
1038 return false;
1039 } else {
1040 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this);
1041 }
1016 } 1042 }
1017 1043
1018 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 1044 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
1045 if (!layer_animation_controller_)
1046 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1047
1019 Animation* opacity_animation = 1048 Animation* opacity_animation =
1020 layer_animation_controller_->GetAnimation(Animation::OPACITY); 1049 layer_animation_controller_->GetAnimation(Animation::OPACITY);
1021 return opacity_animation && opacity_animation->is_impl_only(); 1050 return opacity_animation && opacity_animation->is_impl_only();
1022 } 1051 }
1023 1052
1024 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { 1053 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
1025 if (blend_mode_ == blend_mode) 1054 if (blend_mode_ == blend_mode)
1026 return; 1055 return;
1027 1056
1028 blend_mode_ = blend_mode; 1057 blend_mode_ = blend_mode;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 DCHECK(transform_is_invertible_ == transform_is_invertible) 1116 DCHECK(transform_is_invertible_ == transform_is_invertible)
1088 << "Can't change invertibility if transform is unchanged"; 1117 << "Can't change invertibility if transform is unchanged";
1089 return; 1118 return;
1090 } 1119 }
1091 transform_ = transform; 1120 transform_ = transform;
1092 transform_is_invertible_ = transform_is_invertible; 1121 transform_is_invertible_ = transform_is_invertible;
1093 NoteLayerPropertyChangedForSubtree(); 1122 NoteLayerPropertyChangedForSubtree();
1094 } 1123 }
1095 1124
1096 bool LayerImpl::TransformIsAnimating() const { 1125 bool LayerImpl::TransformIsAnimating() const {
1097 return layer_animation_controller_->IsAnimatingProperty(Animation::TRANSFORM); 1126 return layer_animation_controller_
1127 ? layer_animation_controller_->IsAnimatingProperty(
1128 Animation::TRANSFORM)
1129 : layer_tree_impl_->IsAnimatingTransformProperty(this);
1130 }
1131
1132 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const {
1133 if (layer_animation_controller_) {
1134 if (Animation* animation =
1135 layer_animation_controller()->GetAnimation(Animation::TRANSFORM)) {
1136 return !animation->is_finished();
1137 }
1138 return false;
1139 } else {
1140 return layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this);
1141 }
1098 } 1142 }
1099 1143
1100 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { 1144 bool LayerImpl::TransformIsAnimatingOnImplOnly() const {
1145 if (!layer_animation_controller_)
1146 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this);
1147
1101 Animation* transform_animation = 1148 Animation* transform_animation =
1102 layer_animation_controller_->GetAnimation(Animation::TRANSFORM); 1149 layer_animation_controller_->GetAnimation(Animation::TRANSFORM);
1103 return transform_animation && transform_animation->is_impl_only(); 1150 return transform_animation && transform_animation->is_impl_only();
1104 } 1151 }
1105 1152
1153 bool LayerImpl::HasOnlyTranslationTransforms() const {
1154 if (!layer_animation_controller_)
1155 return layer_tree_impl_->HasOnlyTranslationTransforms(this);
1156
1157 return layer_animation_controller_->HasOnlyTranslationTransforms();
1158 }
1159
1160 bool LayerImpl::MaximumTargetScale(float* max_scale) const {
1161 if (!layer_animation_controller_)
1162 return layer_tree_impl_->MaximumTargetScale(this, max_scale);
1163
1164 return layer_animation_controller_->MaximumTargetScale(max_scale);
1165 }
1166
1167 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const {
1168 if (!layer_animation_controller_)
1169 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this);
1170
1171 return layer_animation_controller_->HasFilterAnimationThatInflatesBounds();
1172 }
1173
1174 bool LayerImpl::HasTransformAnimationThatInflatesBounds() const {
1175 if (!layer_animation_controller_)
1176 return layer_tree_impl_->HasTransformAnimationThatInflatesBounds(this);
1177
1178 return layer_animation_controller_->HasTransformAnimationThatInflatesBounds();
1179 }
1180
1181 bool LayerImpl::HasAnimationThatInflatesBounds() const {
1182 if (!layer_animation_controller_)
1183 return layer_tree_impl_->HasAnimationThatInflatesBounds(this);
1184
1185 return layer_animation_controller_->HasAnimationThatInflatesBounds();
1186 }
1187
1188 bool LayerImpl::FilterAnimationBoundsForBox(const gfx::BoxF& box,
1189 gfx::BoxF* bounds) const {
1190 if (!layer_animation_controller_)
1191 return layer_tree_impl_->FilterAnimationBoundsForBox(this, box, bounds);
1192
1193 return layer_animation_controller_->FilterAnimationBoundsForBox(box, bounds);
1194 }
1195
1196 bool LayerImpl::TransformAnimationBoundsForBox(const gfx::BoxF& box,
1197 gfx::BoxF* bounds) const {
1198 if (!layer_animation_controller_)
1199 return layer_tree_impl_->TransformAnimationBoundsForBox(this, box, bounds);
1200
1201 return layer_animation_controller_->TransformAnimationBoundsForBox(box,
1202 bounds);
1203 }
1204
1106 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) { 1205 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) {
1107 update_rect_ = update_rect; 1206 update_rect_ = update_rect;
1108 SetNeedsPushProperties(); 1207 SetNeedsPushProperties();
1109 } 1208 }
1110 1209
1111 void LayerImpl::AddDamageRect(const gfx::RectF& damage_rect) { 1210 void LayerImpl::AddDamageRect(const gfx::RectF& damage_rect) {
1112 damage_rect_ = gfx::UnionRects(damage_rect_, damage_rect); 1211 damage_rect_ = gfx::UnionRects(damage_rect_, damage_rect);
1113 } 1212 }
1114 1213
1115 void LayerImpl::SetContentBounds(const gfx::Size& content_bounds) { 1214 void LayerImpl::SetContentBounds(const gfx::Size& content_bounds) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 state->SetInteger("scroll_parent", scroll_parent_->id()); 1639 state->SetInteger("scroll_parent", scroll_parent_->id());
1541 1640
1542 if (clip_parent_) 1641 if (clip_parent_)
1543 state->SetInteger("clip_parent", clip_parent_->id()); 1642 state->SetInteger("clip_parent", clip_parent_->id());
1544 1643
1545 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); 1644 state->SetBoolean("can_use_lcd_text", can_use_lcd_text());
1546 state->SetBoolean("contents_opaque", contents_opaque()); 1645 state->SetBoolean("contents_opaque", contents_opaque());
1547 1646
1548 state->SetBoolean( 1647 state->SetBoolean(
1549 "has_animation_bounds", 1648 "has_animation_bounds",
1550 layer_animation_controller()->HasAnimationThatInflatesBounds()); 1649 layer_animation_controller_
1650 ? layer_animation_controller_->HasAnimationThatInflatesBounds()
1651 : layer_tree_impl_->HasAnimationThatInflatesBounds(this));
1551 1652
1552 gfx::BoxF box; 1653 gfx::BoxF box;
1553 if (LayerUtils::GetAnimationBounds(*this, &box)) 1654 if (LayerUtils::GetAnimationBounds(*this, &box))
1554 MathUtil::AddToTracedValue("animation_bounds", box, state); 1655 MathUtil::AddToTracedValue("animation_bounds", box, state);
1555 1656
1556 if (debug_info_.get()) { 1657 if (debug_info_.get()) {
1557 std::string str; 1658 std::string str;
1558 debug_info_->AppendAsTraceFormat(&str); 1659 debug_info_->AppendAsTraceFormat(&str);
1559 base::JSONReader json_reader; 1660 base::JSONReader json_reader;
1560 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); 1661 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 gfx::Transform scaled_draw_transform = 1736 gfx::Transform scaled_draw_transform =
1636 draw_properties_.target_space_transform; 1737 draw_properties_.target_space_transform;
1637 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); 1738 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
1638 gfx::Size scaled_content_bounds = 1739 gfx::Size scaled_content_bounds =
1639 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale)); 1740 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale));
1640 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, 1741 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform,
1641 gfx::Rect(scaled_content_bounds)); 1742 gfx::Rect(scaled_content_bounds));
1642 } 1743 }
1643 1744
1644 } // namespace cc 1745 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698