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

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

Issue 1602343002: compositor-worker: cc->blink mutation plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor-worker-ian-patch
Patch Set: Use animation machinery instead of updating inline style Created 4 years, 10 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "CompositorMutationAnimations.h"
6
7 #include "core/animation/Animation.h"
8 #include "core/animation/AnimationTimeline.h"
9 #include "core/animation/KeyframeEffect.h"
10 #include "core/animation/KeyframeEffectModel.h"
11 #include "core/animation/animatable/AnimatableDouble.h"
12 #include "core/animation/animatable/AnimatableTransform.h"
13 #include "core/animation/animatable/AnimatableValue.h"
14 #include "platform/TraceEvent.h"
15 #include "platform/graphics/CompositorMutation.h"
16 #include "platform/transforms/Matrix3DTransformOperation.h"
17 #include "platform/transforms/MatrixTransformOperation.h"
18 #include "platform/transforms/TransformOperations.h"
19
20 namespace blink {
21
22 namespace {
23
24 // Create animation with zero duration, fill mode forward, and two key frame s
25 // with same value. This animation is always running and by updating the
26 // key frames we are able to control the applied value.
27 static KeyframeEffect* createInfiniteKeyFrameEffect(Element& element, CSSPro pertyID propertyId, PassRefPtr<AnimatableValue> value)
esprehn 2016/02/17 01:32:36 don't indent namespace code
majidvp 2016/02/22 17:59:48 Done.
28 {
29 AnimatableValueKeyframeVector keyframes(2);
30 keyframes[0] = AnimatableValueKeyframe::create();
31 keyframes[0]->setOffset(0.0);
32 keyframes[0]->setPropertyValue(propertyId, value.get());
33 keyframes[1] = AnimatableValueKeyframe::create();
34 keyframes[1]->setOffset(1.0);
35 keyframes[1]->setPropertyValue(propertyId, value.get());
36 keyframes[1]->setComposite(EffectModel::CompositeReplace);
37
38 Timing timing;
39 timing.iterationDuration = 0;
40 timing.fillMode = Timing::FillModeForwards;
41
42 AnimatableValueKeyframeEffectModel* effectModel = AnimatableValueKeyfram eEffectModel::create(keyframes);
43 return KeyframeEffect::create(&element, effectModel, timing);
44 }
45
46 static Animation* createOrUpdateAnimation(Animation* animation, Element& ele ment, CSSPropertyID propertyId, PassRefPtr<AnimatableValue> newValue)
47 {
48 if (!animation) {
49 KeyframeEffect* keyframeEffect = createInfiniteKeyFrameEffect(elemen t, propertyId, newValue);
50 return element.document().timeline().play(keyframeEffect);
51 }
52
53 KeyframeEffect* keyframeEffect = toKeyframeEffect(animation->effect());
54 auto effectModel = toAnimatableValueKeyframeEffectModel(keyframeEffect-> model());
55 const KeyframeVector& frames = effectModel->getFrames();
56 KeyframeVector newFrames(2);
57 newFrames[0] = toAnimatableValueKeyframe(frames[0]->clone().get());
58 newFrames[1] = toAnimatableValueKeyframe(frames[1]->clone().get());
59 toAnimatableValueKeyframe(newFrames[1].get())->setPropertyValue(property Id, newValue);
60 effectModel->setFrames(newFrames);
61 return animation;
62 }
63
64 } // namespace
65
66 void CompositorMutationAnimations::applyUpdate(Element& element, const Composito rMutation& mutation)
67 {
68 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositorMuta tionAnimations::applyUpdate");
69
70 if (mutation.isOpacityMutated()) {
71 RefPtr<AnimatableValue> animatableValue = AnimatableDouble::create(mutat ion.opacity());
72 m_opacityAnimation = createOrUpdateAnimation(m_opacityAnimation, element , CSSPropertyOpacity, animatableValue.release());
73 }
74 if (mutation.isTransformMutated()) {
75 TransformOperations ops;
76 ops.operations().append(Matrix3DTransformOperation::create(Transformatio nMatrix(mutation.transform())));
77 RefPtr<AnimatableValue> animatableValue = AnimatableTransform::create(op s, 1);
78 m_transformAnimation = createOrUpdateAnimation(m_transformAnimation, ele ment, CSSPropertyTransform, animatableValue.release());
79 }
80 }
81
82 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698