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

Side by Side Diff: cc/animation/animation_host.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. Created 5 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/animation/animation_host.h ('k') | cc/cc_tests.gyp » ('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 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/animation/element_animations.h" 12 #include "cc/animation/element_animations.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( 17 scoped_ptr<AnimationHost> AnimationHost::Create(
17 ThreadInstance thread_instance) { 18 ThreadInstance thread_instance) {
18 return make_scoped_ptr(new AnimationHost(thread_instance)); 19 return make_scoped_ptr(new AnimationHost(thread_instance));
19 } 20 }
20 21
21 AnimationHost::AnimationHost(ThreadInstance thread_instance) 22 AnimationHost::AnimationHost(ThreadInstance thread_instance)
22 : animation_registrar_(AnimationRegistrar::Create()), 23 : animation_registrar_(AnimationRegistrar::Create()),
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 196 }
196 197
197 ElementAnimations* AnimationHost::GetElementAnimationsForLayerId( 198 ElementAnimations* AnimationHost::GetElementAnimationsForLayerId(
198 int layer_id) const { 199 int layer_id) const {
199 DCHECK(layer_id); 200 DCHECK(layer_id);
200 auto iter = layer_to_element_animations_map_.find(layer_id); 201 auto iter = layer_to_element_animations_map_.find(layer_id);
201 return iter == layer_to_element_animations_map_.end() ? nullptr 202 return iter == layer_to_element_animations_map_.end() ? nullptr
202 : iter->second; 203 : iter->second;
203 } 204 }
204 205
206 void AnimationHost::SetSupportsScrollAnimations(
207 bool supports_scroll_animations) {
208 animation_registrar_->set_supports_scroll_animations(
209 supports_scroll_animations);
210 }
211
212 bool AnimationHost::SupportsScrollAnimations() const {
213 return animation_registrar_->supports_scroll_animations();
214 }
215
216 bool AnimationHost::NeedsAnimateLayers() const {
217 return animation_registrar_->needs_animate_layers();
218 }
219
220 bool AnimationHost::ActivateAnimations() {
221 return animation_registrar_->ActivateAnimations();
222 }
223
224 bool AnimationHost::AnimateLayers(base::TimeTicks monotonic_time) {
225 return animation_registrar_->AnimateLayers(monotonic_time);
226 }
227
228 bool AnimationHost::UpdateAnimationState(bool start_ready_animations,
229 AnimationEventsVector* events) {
230 return animation_registrar_->UpdateAnimationState(start_ready_animations,
231 events);
232 }
233
234 scoped_ptr<AnimationEventsVector> AnimationHost::CreateEvents() {
235 return animation_registrar_->CreateEvents();
236 }
237
238 void AnimationHost::SetAnimationEvents(
239 scoped_ptr<AnimationEventsVector> events) {
240 return animation_registrar_->SetAnimationEvents(events.Pass());
241 }
242
243 bool AnimationHost::ScrollOffsetAnimationWasInterrupted(int layer_id) const {
244 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
245 return controller ? controller->scroll_offset_animation_was_interrupted()
246 : false;
247 }
248
249 bool AnimationHost::IsAnimatingFilterProperty(int layer_id) const {
250 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
251 return controller ? controller->IsAnimatingProperty(Animation::FILTER)
252 : false;
253 }
254
255 bool AnimationHost::IsAnimatingOpacityProperty(int layer_id) const {
256 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
257 return controller ? controller->IsAnimatingProperty(Animation::OPACITY)
258 : false;
259 }
260
261 bool AnimationHost::IsAnimatingTransformProperty(int layer_id) const {
262 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
263 return controller ? controller->IsAnimatingProperty(Animation::TRANSFORM)
264 : false;
265 }
266
267 bool AnimationHost::HasPotentiallyRunningOpacityAnimation(int layer_id) const {
268 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
269 if (!controller)
270 return false;
271
272 Animation* animation = controller->GetAnimation(Animation::OPACITY);
273 return animation && !animation->is_finished();
274 }
275
276 bool AnimationHost::HasPotentiallyRunningTransformAnimation(
277 int layer_id) const {
278 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
279 if (!controller)
280 return false;
281
282 Animation* animation = controller->GetAnimation(Animation::TRANSFORM);
283 return animation && !animation->is_finished();
284 }
285
286 bool AnimationHost::FilterIsAnimatingOnImplOnly(int layer_id) const {
287 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
288 if (!controller)
289 return false;
290
291 Animation* animation = controller->GetAnimation(Animation::FILTER);
292 return animation && animation->is_impl_only();
293 }
294
295 bool AnimationHost::OpacityIsAnimatingOnImplOnly(int layer_id) const {
296 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
297 if (!controller)
298 return false;
299
300 Animation* animation = controller->GetAnimation(Animation::OPACITY);
301 return animation && animation->is_impl_only();
302 }
303
304 bool AnimationHost::TransformIsAnimatingOnImplOnly(int layer_id) const {
305 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
306 if (!controller)
307 return false;
308
309 Animation* animation = controller->GetAnimation(Animation::TRANSFORM);
310 return animation && animation->is_impl_only();
311 }
312
313 bool AnimationHost::HasFilterAnimationThatInflatesBounds(int layer_id) const {
314 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
315 return controller ? controller->HasFilterAnimationThatInflatesBounds()
316 : false;
317 }
318
319 bool AnimationHost::HasTransformAnimationThatInflatesBounds(
320 int layer_id) const {
321 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
322 return controller ? controller->HasTransformAnimationThatInflatesBounds()
323 : false;
324 }
325
326 bool AnimationHost::HasAnimationThatInflatesBounds(int layer_id) const {
327 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
328 return controller ? controller->HasAnimationThatInflatesBounds() : false;
329 }
330
331 bool AnimationHost::FilterAnimationBoundsForBox(int layer_id,
332 const gfx::BoxF& box,
333 gfx::BoxF* bounds) const {
334 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
335 return controller ? controller->FilterAnimationBoundsForBox(box, bounds)
336 : false;
337 }
338
339 bool AnimationHost::TransformAnimationBoundsForBox(int layer_id,
340 const gfx::BoxF& box,
341 gfx::BoxF* bounds) const {
342 *bounds = gfx::BoxF();
343 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
344 return controller ? controller->TransformAnimationBoundsForBox(box, bounds)
345 : true;
346 }
347
348 bool AnimationHost::HasOnlyTranslationTransforms(int layer_id) const {
349 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
350 return controller ? controller->HasOnlyTranslationTransforms() : true;
351 }
352
353 bool AnimationHost::AnimationsPreserveAxisAlignment(int layer_id) const {
354 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
355 return controller ? controller->AnimationsPreserveAxisAlignment() : true;
356 }
357
358 bool AnimationHost::MaximumTargetScale(int layer_id, float* max_scale) const {
359 *max_scale = 0.f;
360 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
361 return controller ? controller->MaximumTargetScale(max_scale) : true;
362 }
363
364 bool AnimationHost::AnimationStartScale(int layer_id,
365 float* start_scale) const {
366 *start_scale = 0.f;
367 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
368 return controller ? controller->AnimationStartScale(start_scale) : true;
369 }
370
371 bool AnimationHost::HasAnyAnimation(int layer_id) const {
372 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
373 return controller ? controller->has_any_animation() : false;
374 }
375
376 bool AnimationHost::HasActiveAnimation(int layer_id) const {
377 LayerAnimationController* controller = GetControllerForLayerId(layer_id);
378 return controller ? controller->HasActiveAnimation() : false;
379 }
380
205 } // namespace cc 381 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_host.h ('k') | cc/cc_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698