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

Side by Side Diff: third_party/WebKit/Source/core/animation/CompositorAnimations.cpp

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address reviewer feedback Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #include "core/animation/CompositorAnimations.h" 31 #include "core/animation/CompositorAnimations.h"
32 32
33 #include "core/animation/AnimationEffect.h" 33 #include "core/animation/AnimationEffect.h"
34 #include "core/animation/ElementAnimations.h" 34 #include "core/animation/ElementAnimations.h"
35 #include "core/animation/KeyframeEffectModel.h" 35 #include "core/animation/KeyframeEffectModel.h"
36 #include "core/animation/animatable/AnimatableDouble.h" 36 #include "core/animation/animatable/AnimatableDouble.h"
37 #include "core/animation/animatable/AnimatableFilterOperations.h" 37 #include "core/animation/animatable/AnimatableFilterOperations.h"
38 #include "core/animation/animatable/AnimatableTransform.h" 38 #include "core/animation/animatable/AnimatableTransform.h"
39 #include "core/animation/animatable/AnimatableValue.h" 39 #include "core/animation/animatable/AnimatableValue.h"
40 #include "core/dom/DOMNodeIds.h"
40 #include "core/layout/LayoutBoxModelObject.h" 41 #include "core/layout/LayoutBoxModelObject.h"
41 #include "core/layout/LayoutObject.h" 42 #include "core/layout/LayoutObject.h"
42 #include "core/layout/compositing/CompositedLayerMapping.h" 43 #include "core/layout/compositing/CompositedLayerMapping.h"
43 #include "core/paint/PaintLayer.h" 44 #include "core/paint/PaintLayer.h"
44 #include "platform/animation/AnimationTranslationUtil.h" 45 #include "platform/animation/AnimationTranslationUtil.h"
45 #include "platform/animation/CompositorAnimation.h" 46 #include "platform/animation/CompositorAnimation.h"
46 #include "platform/animation/CompositorAnimationPlayer.h" 47 #include "platform/animation/CompositorAnimationPlayer.h"
47 #include "platform/animation/CompositorFilterAnimationCurve.h" 48 #include "platform/animation/CompositorFilterAnimationCurve.h"
48 #include "platform/animation/CompositorFilterKeyframe.h" 49 #include "platform/animation/CompositorFilterKeyframe.h"
49 #include "platform/animation/CompositorFloatAnimationCurve.h" 50 #include "platform/animation/CompositorFloatAnimationCurve.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 370
370 if (!canStartAnimationOnCompositor(element)) { 371 if (!canStartAnimationOnCompositor(element)) {
371 ASSERT_NOT_REACHED(); 372 ASSERT_NOT_REACHED();
372 return; 373 return;
373 } 374 }
374 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer(); 375 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
375 ASSERT(compositorPlayer); 376 ASSERT(compositorPlayer);
376 compositorPlayer->pauseAnimation(id, pauseTime); 377 compositorPlayer->pauseAnimation(id, pauseTime);
377 } 378 }
378 379
379 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con st Animation& animation) 380 void CompositorAnimations::attachCompositedLayers(Element& element, const Animat ion& animation)
380 { 381 {
381 if (!animation.compositorPlayer()) 382 if (!animation.compositorPlayer())
382 return false; 383 return;
383
384 if (!element.layoutObject() || !element.layoutObject()->isBoxModelObject())
385 return false;
386
387 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
388
389 if (!layer || !layer->isAllowedToQueryCompositingState()
390 || !layer->compositedLayerMapping()
391 || !layer->compositedLayerMapping()->mainGraphicsLayer())
392 return false;
393
394 if (!layer->compositedLayerMapping()->mainGraphicsLayer()->platformLayer())
395 return false;
396
397 return true;
398 }
399
400 void CompositorAnimations::attachCompositedLayers(const Element& element, const Animation& animation)
401 {
402 ASSERT(element.layoutObject());
403
404 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
405 ASSERT(layer);
406 384
407 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer(); 385 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
408 ASSERT(compositorPlayer); 386 compositorPlayer->attachElement(createCompositorElementId(DOMNodeIds::idForN ode(&element), CompositorSubElementId::Primary));
409
410 ASSERT(layer->compositedLayerMapping());
411 compositorPlayer->attachLayer(layer->compositedLayerMapping()->mainGraphicsL ayer()->platformLayer());
412 } 387 }
413 388
414 bool CompositorAnimations::convertTimingForCompositor(const Timing& timing, doub le timeOffset, CompositorTiming& out, double animationPlaybackRate) 389 bool CompositorAnimations::convertTimingForCompositor(const Timing& timing, doub le timeOffset, CompositorTiming& out, double animationPlaybackRate)
415 { 390 {
416 timing.assertValid(); 391 timing.assertValid();
417 392
418 // FIXME: Compositor does not know anything about endDelay. 393 // FIXME: Compositor does not know anything about endDelay.
419 if (timing.endDelay != 0) 394 if (timing.endDelay != 0)
420 return false; 395 return false;
421 396
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 break; 631 break;
657 default: 632 default:
658 ASSERT_NOT_REACHED(); 633 ASSERT_NOT_REACHED();
659 } 634 }
660 animations.append(std::move(animation)); 635 animations.append(std::move(animation));
661 } 636 }
662 ASSERT(!animations.isEmpty()); 637 ASSERT(!animations.isEmpty());
663 } 638 }
664 639
665 } // namespace blink 640 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698