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

Side by Side Diff: Source/core/animation/AnimationStack.cpp

Issue 863863004: Implemented additive animations for length (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More comprehensive non-negative length layout tests Created 5 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
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 24 matching lines...) Expand all
35 #include "core/animation/StyleInterpolation.h" 35 #include "core/animation/StyleInterpolation.h"
36 #include "core/animation/css/CSSAnimations.h" 36 #include "core/animation/css/CSSAnimations.h"
37 #include "wtf/BitArray.h" 37 #include "wtf/BitArray.h"
38 #include "wtf/NonCopyingSort.h" 38 #include "wtf/NonCopyingSort.h"
39 #include <algorithm> 39 #include <algorithm>
40 40
41 namespace blink { 41 namespace blink {
42 42
43 namespace { 43 namespace {
44 44
45 void copyToActiveInterpolationMap(const WillBeHeapVector<RefPtrWillBeMember<blin k::Interpolation> >& source, WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember <blink::Interpolation> >& target) 45 void copyToActiveInterpolationMap(const WillBeHeapVector<RefPtrWillBeMember<blin k::Interpolation>>& source, InterpolationPipelineMap& target)
46 { 46 {
47 for (const auto& interpolation : source) { 47 for (const auto& interpolation : source) {
48 target.set(toStyleInterpolation(interpolation.get())->id(), interpolatio n.get()); 48 CSSPropertyID property = toStyleInterpolation(interpolation.get())->id() ;
49
50 RefPtrWillBeRawPtr<InterpolationPipelineStage> newStage = InterpolationP ipelineStage::create(interpolation);
51
52 RefPtrWillBeRawPtr<InterpolationPipeline> pipeline = target.get(property );
53 if (!pipeline) {
54 pipeline = InterpolationPipeline::create();
55 target.set(property, pipeline);
56 }
57
58 pipeline->append(newStage);
49 } 59 }
50 } 60 }
51 61
52 bool compareEffects(const OwnPtrWillBeMember<SampledEffect>& effect1, const OwnP trWillBeMember<SampledEffect>& effect2) 62 bool compareEffects(const OwnPtrWillBeMember<SampledEffect>& effect1, const OwnP trWillBeMember<SampledEffect>& effect2)
53 { 63 {
54 ASSERT(effect1 && effect2); 64 ASSERT(effect1 && effect2);
55 return effect1->sequenceNumber() < effect2->sequenceNumber(); 65 return effect1->sequenceNumber() < effect2->sequenceNumber();
56 } 66 }
57 67
58 void copyNewAnimationsToActiveInterpolationMap(const WillBeHeapVector<RawPtrWill BeMember<InertAnimation> >& newAnimations, WillBeHeapHashMap<CSSPropertyID, RefP trWillBeMember<Interpolation> >& result) 68 void copyNewAnimationsToActiveInterpolationMap(const WillBeHeapVector<RawPtrWill BeMember<InertAnimation>>& newAnimations, InterpolationPipelineMap& result)
59 { 69 {
60 for (const auto& newAnimation : newAnimations) { 70 for (const auto& newAnimation : newAnimations) {
61 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> sample = nullptr; 71 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> sample = nullptr;
62 newAnimation->sample(sample); 72 newAnimation->sample(sample);
63 if (sample) 73 if (sample)
64 copyToActiveInterpolationMap(*sample, result); 74 copyToActiveInterpolationMap(*sample, result);
65 } 75 }
66 } 76 }
67 77
68 } // namespace 78 } // namespace
(...skipping 13 matching lines...) Expand all
82 92
83 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st 93 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st
84 { 94 {
85 for (const auto& effect : m_effects) { 95 for (const auto& effect : m_effects) {
86 if (effect->animation() && effect->animation()->hasActiveAnimationsOnCom positor(property)) 96 if (effect->animation() && effect->animation()->hasActiveAnimationsOnCom positor(property))
87 return true; 97 return true;
88 } 98 }
89 return false; 99 return false;
90 } 100 }
91 101
92 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > AnimationSt ack::activeInterpolations(AnimationStack* animationStack, const WillBeHeapVector <RawPtrWillBeMember<InertAnimation> >* newAnimations, const WillBeHeapHashSet<Ra wPtrWillBeMember<const AnimationPlayer> >* suppressedAnimationPlayers, Animation ::Priority priority, double timelineCurrentTime) 102 InterpolationPipelineMap AnimationStack::activeInterpolations(AnimationStack* an imationStack, const WillBeHeapVector<RawPtrWillBeMember<InertAnimation>>* newAni mations, const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>* sup pressedAnimationPlayers, Animation::Priority priority, double timelineCurrentTim e)
93 { 103 {
94 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate. 104 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate.
95 105
96 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result; 106 InterpolationPipelineMap result;
97 107
98 if (animationStack) { 108 if (animationStack) {
99 WillBeHeapVector<OwnPtrWillBeMember<SampledEffect> >& effects = animatio nStack->m_effects; 109 WillBeHeapVector<OwnPtrWillBeMember<SampledEffect>>& effects = animation Stack->m_effects;
100 // std::sort doesn't work with OwnPtrs 110 // std::sort doesn't work with OwnPtrs
101 nonCopyingSort(effects.begin(), effects.end(), compareEffects); 111 nonCopyingSort(effects.begin(), effects.end(), compareEffects);
102 animationStack->simplifyEffects(); 112 animationStack->simplifyEffects();
103 for (const auto& effect : effects) { 113 for (const auto& effect : effects) {
104 if (effect->priority() != priority || (suppressedAnimationPlayers && effect->animation() && suppressedAnimationPlayers->contains(effect->animation() ->player()))) 114 if (effect->priority() != priority || (suppressedAnimationPlayers && effect->animation() && suppressedAnimationPlayers->contains(effect->animation() ->player())))
105 continue; 115 continue;
106 copyToActiveInterpolationMap(effect->interpolations(), result); 116 copyToActiveInterpolationMap(effect->interpolations(), result);
107 } 117 }
108 } 118 }
109 119
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 FloatBox expandingBox(originalBox); 169 FloatBox expandingBox(originalBox);
160 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *anim->effect(), startRange, endRange)) 170 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *anim->effect(), startRange, endRange))
161 return false; 171 return false;
162 box.expandTo(expandingBox); 172 box.expandTo(expandingBox);
163 } 173 }
164 } 174 }
165 return true; 175 return true;
166 } 176 }
167 177
168 } // namespace blink 178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698