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

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

Issue 2236193002: WIP: Implement CSS transitions on top of InterpolationTypes instead of AnimatableValues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_environmentStyle
Patch Set: Created 4 years, 4 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 return result; 54 return result;
55 } 55 }
56 56
57 void KeyframeEffectModelBase::setFrames(KeyframeVector& keyframes) 57 void KeyframeEffectModelBase::setFrames(KeyframeVector& keyframes)
58 { 58 {
59 // TODO(samli): Should also notify/invalidate the animation 59 // TODO(samli): Should also notify/invalidate the animation
60 m_keyframes = keyframes; 60 m_keyframes = keyframes;
61 m_keyframeGroups = nullptr; 61 m_keyframeGroups = nullptr;
62 m_interpolationEffect.clear(); 62 m_interpolationEffect.clear();
63 m_lastFraction = std::numeric_limits<double>::quiet_NaN(); 63 clearLastFraction();
64 } 64 }
65 65
66 bool KeyframeEffectModelBase::sample(int iteration, double fraction, double iter ationDuration, Vector<RefPtr<Interpolation>>& result) const 66 void KeyframeEffectModelBase::sampleImpl(int iteration, double fraction, double iterationDuration, Vector<RefPtr<Interpolation>>& result) const
67 { 67 {
68 ASSERT(iteration >= 0);
69 ASSERT(!isNull(fraction));
70 ensureKeyframeGroups(); 68 ensureKeyframeGroups();
71 ensureInterpolationEffectPopulated(); 69 ensureInterpolationEffectPopulated();
72
73 bool changed = iteration != m_lastIteration || fraction != m_lastFraction || iterationDuration != m_lastIterationDuration;
74 m_lastIteration = iteration;
75 m_lastFraction = fraction;
76 m_lastIterationDuration = iterationDuration;
77 m_interpolationEffect.getActiveInterpolations(fraction, iterationDuration, r esult); 70 m_interpolationEffect.getActiveInterpolations(fraction, iterationDuration, r esult);
78 return changed;
79 } 71 }
80 72
81 bool KeyframeEffectModelBase::snapshotNeutralCompositorKeyframes(Element& elemen t, const ComputedStyle& oldStyle, const ComputedStyle& newStyle, const ComputedS tyle* parentStyle) const 73 bool KeyframeEffectModelBase::snapshotNeutralCompositorKeyframes(Element& elemen t, const ComputedStyle& oldStyle, const ComputedStyle& newStyle, const ComputedS tyle* parentStyle) const
82 { 74 {
83 bool updated = false; 75 bool updated = false;
84 ensureKeyframeGroups(); 76 ensureKeyframeGroups();
85 for (CSSPropertyID property : CompositorAnimations::compositableProperties) { 77 for (CSSPropertyID property : CompositorAnimations::compositableProperties) {
86 if (CSSPropertyEquality::propertiesEqual(property, oldStyle, newStyle)) 78 if (CSSPropertyEquality::propertiesEqual(property, oldStyle, newStyle))
87 continue; 79 continue;
88 PropertySpecificKeyframeGroup* keyframeGroup = m_keyframeGroups->get(Pro pertyHandle(property)); 80 PropertySpecificKeyframeGroup* keyframeGroup = m_keyframeGroups->get(Pro pertyHandle(property));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 for (size_t j = 1; j < i - lastIndex; ++j) 137 for (size_t j = 1; j < i - lastIndex; ++j)
146 result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffs et) * j / (i - lastIndex)); 138 result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffs et) * j / (i - lastIndex));
147 lastIndex = i; 139 lastIndex = i;
148 lastOffset = offset; 140 lastOffset = offset;
149 } 141 }
150 } 142 }
151 143
152 return result; 144 return result;
153 } 145 }
154 146
155 bool KeyframeEffectModelBase::isTransformRelatedEffect() const
156 {
157 return affects(PropertyHandle(CSSPropertyTransform))
158 || affects(PropertyHandle(CSSPropertyRotate))
159 || affects(PropertyHandle(CSSPropertyScale))
160 || affects(PropertyHandle(CSSPropertyTranslate));
161 }
162
163 void KeyframeEffectModelBase::ensureKeyframeGroups() const 147 void KeyframeEffectModelBase::ensureKeyframeGroups() const
164 { 148 {
165 if (m_keyframeGroups) 149 if (m_keyframeGroups)
166 return; 150 return;
167 151
168 m_keyframeGroups = wrapUnique(new KeyframeGroupMap); 152 m_keyframeGroups = wrapUnique(new KeyframeGroupMap);
169 RefPtr<TimingFunction> zeroOffsetEasing = m_defaultKeyframeEasing; 153 RefPtr<TimingFunction> zeroOffsetEasing = m_defaultKeyframeEasing;
170 for (const auto& keyframe : normalizedKeyframes(getFrames())) { 154 for (const auto& keyframe : normalizedKeyframes(getFrames())) {
171 if (keyframe->offset() == 0) 155 if (keyframe->offset() == 0)
172 zeroOffsetEasing = &keyframe->easing(); 156 zeroOffsetEasing = &keyframe->easing();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 275 }
292 if (m_keyframes.last()->offset() != 1.0) { 276 if (m_keyframes.last()->offset() != 1.0) {
293 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, nullptr)); 277 appendKeyframe(m_keyframes.last()->neutralKeyframe(1, nullptr));
294 addedSyntheticKeyframe = true; 278 addedSyntheticKeyframe = true;
295 } 279 }
296 280
297 return addedSyntheticKeyframe; 281 return addedSyntheticKeyframe;
298 } 282 }
299 283
300 } // namespace blink 284 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698