Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/animation/animation_player.h" | 9 #include "cc/animation/animation_player.h" |
| 10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
| 11 #include "cc/animation/animation_timeline.h" | 11 #include "cc/animation/animation_timeline.h" |
| 12 #include "cc/trees/layer_tree_mutators_client.h" | 12 #include "cc/trees/layer_tree_mutators_client.h" |
| 13 #include "ui/gfx/geometry/box_f.h" | |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 scoped_ptr<AnimationHost> AnimationHost::Create(bool is_impl_instance) { | 17 scoped_ptr<AnimationHost> AnimationHost::Create(bool is_impl_instance) { |
| 17 return make_scoped_ptr(new AnimationHost(is_impl_instance)); | 18 return make_scoped_ptr(new AnimationHost(is_impl_instance)); |
| 18 } | 19 } |
| 19 | 20 |
| 20 AnimationHost::AnimationHost(bool is_impl_instance) | 21 AnimationHost::AnimationHost(bool is_impl_instance) |
| 21 : animation_registrar_(AnimationRegistrar::Create()), | 22 : animation_registrar_(AnimationRegistrar::Create()), |
| 22 layer_tree_mutators_client_(), | 23 layer_tree_mutators_client_(), |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 timeline->PushPropertiesTo(timeline_impl); | 147 timeline->PushPropertiesTo(timeline_impl); |
| 147 } | 148 } |
| 148 } | 149 } |
| 149 | 150 |
| 150 AnimationPlayer* AnimationHost::GetPlayerForLayerId(int layer_id) const { | 151 AnimationPlayer* AnimationHost::GetPlayerForLayerId(int layer_id) const { |
| 151 DCHECK(layer_id); | 152 DCHECK(layer_id); |
| 152 auto iter = layer_to_player_map_.find(layer_id); | 153 auto iter = layer_to_player_map_.find(layer_id); |
| 153 return iter == layer_to_player_map_.end() ? nullptr : iter->second; | 154 return iter == layer_to_player_map_.end() ? nullptr : iter->second; |
| 154 } | 155 } |
| 155 | 156 |
| 157 void AnimationHost::SetSupportsScrollAnimations( | |
| 158 bool supports_scroll_animations) { | |
| 159 animation_registrar_->set_supports_scroll_animations( | |
| 160 supports_scroll_animations); | |
| 161 } | |
| 162 | |
| 163 bool AnimationHost::GetSupportsScrollAnimations() const { | |
|
ajuma
2015/04/21 17:57:57
Nit: s/GetSupportsScrollAnimations/SupportsScrollA
loyso (OOO)
2015/04/22 01:08:11
Acknowledged.
| |
| 164 return animation_registrar_->supports_scroll_animations(); | |
| 165 } | |
| 166 | |
| 167 bool AnimationHost::NeedsAnimateLayers() const { | |
| 168 return animation_registrar_->needs_animate_layers(); | |
| 169 } | |
| 170 | |
| 171 bool AnimationHost::ActivateAnimations() { | |
| 172 return animation_registrar_->ActivateAnimations(); | |
| 173 } | |
| 174 | |
| 175 bool AnimationHost::AnimateLayers(base::TimeTicks monotonic_time) { | |
| 176 return animation_registrar_->AnimateLayers(monotonic_time); | |
| 177 } | |
| 178 | |
| 179 bool AnimationHost::UpdateAnimationState(bool start_ready_animations, | |
| 180 AnimationEventsVector* events) { | |
| 181 return animation_registrar_->UpdateAnimationState(start_ready_animations, | |
| 182 events); | |
| 183 } | |
| 184 | |
| 185 scoped_ptr<AnimationEventsVector> AnimationHost::CreateEvents() { | |
| 186 return animation_registrar_->CreateEvents(); | |
| 187 } | |
| 188 | |
| 189 void AnimationHost::SetAnimationEvents( | |
| 190 scoped_ptr<AnimationEventsVector> events) { | |
| 191 return animation_registrar_->SetAnimationEvents(events.Pass()); | |
| 192 } | |
| 193 | |
| 194 bool AnimationHost::IsAnimatingFilterProperty(int layer_id) const { | |
| 195 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
|
loyso (OOO)
2015/04/22 01:27:30
We have a hash look-up for such a request. The num
| |
| 196 return player | |
| 197 ? player->layer_animation_controller()->IsAnimatingProperty( | |
| 198 Animation::FILTER) | |
| 199 : false; | |
| 200 } | |
| 201 | |
| 202 bool AnimationHost::IsAnimatingOpacityProperty(int layer_id) const { | |
| 203 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 204 return player | |
| 205 ? player->layer_animation_controller()->IsAnimatingProperty( | |
| 206 Animation::OPACITY) | |
| 207 : false; | |
| 208 } | |
| 209 | |
| 210 bool AnimationHost::IsAnimatingTransformProperty(int layer_id) const { | |
| 211 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 212 return player | |
| 213 ? player->layer_animation_controller()->IsAnimatingProperty( | |
| 214 Animation::TRANSFORM) | |
| 215 : false; | |
| 216 } | |
| 217 | |
| 218 bool AnimationHost::FilterIsAnimatingOnImplOnly(int layer_id) const { | |
| 219 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 220 if (!player) | |
| 221 return false; | |
| 222 | |
| 223 Animation* animation = | |
| 224 player->layer_animation_controller()->GetAnimation(Animation::FILTER); | |
| 225 return animation && animation->is_impl_only(); | |
| 226 } | |
| 227 | |
| 228 bool AnimationHost::OpacityIsAnimatingOnImplOnly(int layer_id) const { | |
| 229 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 230 if (!player) | |
| 231 return false; | |
| 232 | |
| 233 Animation* animation = | |
| 234 player->layer_animation_controller()->GetAnimation(Animation::OPACITY); | |
| 235 return animation && animation->is_impl_only(); | |
| 236 } | |
| 237 | |
| 238 bool AnimationHost::TransformIsAnimatingOnImplOnly(int layer_id) const { | |
| 239 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 240 if (!player) | |
| 241 return false; | |
| 242 | |
| 243 Animation* animation = | |
| 244 player->layer_animation_controller()->GetAnimation(Animation::TRANSFORM); | |
| 245 return animation && animation->is_impl_only(); | |
| 246 } | |
| 247 | |
| 248 bool AnimationHost::HasFilterAnimationThatInflatesBounds(int layer_id) const { | |
| 249 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 250 return player | |
| 251 ? player->layer_animation_controller() | |
| 252 ->HasFilterAnimationThatInflatesBounds() | |
| 253 : false; | |
| 254 } | |
| 255 | |
| 256 bool AnimationHost::HasTransformAnimationThatInflatesBounds( | |
| 257 int layer_id) const { | |
| 258 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 259 return player | |
| 260 ? player->layer_animation_controller() | |
| 261 ->HasTransformAnimationThatInflatesBounds() | |
| 262 : false; | |
| 263 } | |
| 264 | |
| 265 bool AnimationHost::HasAnimationThatInflatesBounds(int layer_id) const { | |
| 266 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 267 return player | |
| 268 ? player->layer_animation_controller() | |
| 269 ->HasAnimationThatInflatesBounds() | |
| 270 : false; | |
| 271 } | |
| 272 | |
| 273 bool AnimationHost::FilterAnimationBoundsForBox(int layer_id, | |
| 274 const gfx::BoxF& box, | |
| 275 gfx::BoxF* bounds) const { | |
| 276 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 277 return player | |
| 278 ? player->layer_animation_controller() | |
| 279 ->FilterAnimationBoundsForBox(box, bounds) | |
| 280 : false; | |
| 281 } | |
| 282 | |
| 283 bool AnimationHost::TransformAnimationBoundsForBox(int layer_id, | |
| 284 const gfx::BoxF& box, | |
| 285 gfx::BoxF* bounds) const { | |
| 286 *bounds = gfx::BoxF(); | |
| 287 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 288 return player | |
| 289 ? player->layer_animation_controller() | |
| 290 ->TransformAnimationBoundsForBox(box, bounds) | |
| 291 : true; | |
| 292 } | |
| 293 | |
| 294 bool AnimationHost::HasOnlyTranslationTransforms(int layer_id) const { | |
| 295 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 296 return player | |
| 297 ? player->layer_animation_controller() | |
| 298 ->HasOnlyTranslationTransforms() | |
| 299 : true; | |
| 300 } | |
| 301 | |
| 302 bool AnimationHost::AnimationsPreserveAxisAlignment(int layer_id) const { | |
| 303 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 304 return player | |
| 305 ? player->layer_animation_controller() | |
| 306 ->AnimationsPreserveAxisAlignment() | |
| 307 : true; | |
| 308 } | |
| 309 | |
| 310 bool AnimationHost::MaximumTargetScale(int layer_id, float* max_scale) const { | |
| 311 *max_scale = 0.f; | |
| 312 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 313 return player | |
| 314 ? player->layer_animation_controller()->MaximumTargetScale( | |
| 315 max_scale) | |
| 316 : true; | |
| 317 } | |
| 318 | |
| 319 bool AnimationHost::HasAnyAnimation(int layer_id) const { | |
| 320 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 321 return player ? player->layer_animation_controller()->has_any_animation() | |
| 322 : false; | |
| 323 } | |
| 324 | |
| 325 bool AnimationHost::HasActiveAnimation(int layer_id) const { | |
| 326 AnimationPlayer* player = GetPlayerForLayerId(layer_id); | |
| 327 return player ? player->layer_animation_controller()->HasActiveAnimation() | |
| 328 : false; | |
| 329 } | |
| 330 | |
| 156 } // namespace cc | 331 } // namespace cc |
| OLD | NEW |