Bug 1125455 patch 6 - Only search the properties list of the animation once when adding animations to the compositor. r=birtles

This removes the duplication where AddAnimationsForProperty calls
HasAnimationOfProperty which goes over the list once, and then
AddAnimationForProperty searches the list again and skips all but the
item found before.

It also makes it easier, in patch 7, to perform additional tests on the
item that we found.
This commit is contained in:
L. David Baron 2015-03-19 21:10:00 -07:00
Родитель 40bd226b51
Коммит 92c8f10ebf
1 изменённых файлов: 36 добавлений и 39 удалений

Просмотреть файл

@ -332,7 +332,7 @@ static void AddTransformFunctions(nsCSSValueList* aList,
} }
static TimingFunction static TimingFunction
ToTimingFunction(ComputedTimingFunction& aCTF) ToTimingFunction(const ComputedTimingFunction& aCTF)
{ {
if (aCTF.GetType() == nsTimingFunction::Function) { if (aCTF.GetType() == nsTimingFunction::Function) {
const nsSMILKeySpline* spline = aCTF.GetFunction(); const nsSMILKeySpline* spline = aCTF.GetFunction();
@ -345,7 +345,7 @@ ToTimingFunction(ComputedTimingFunction& aCTF)
} }
static void static void
AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
AnimationPlayer* aPlayer, Layer* aLayer, AnimationPlayer* aPlayer, Layer* aLayer,
AnimationData& aData, bool aPending) AnimationData& aData, bool aPending)
{ {
@ -373,44 +373,33 @@ AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
animation->duration() = timing.mIterationDuration; animation->duration() = timing.mIterationDuration;
animation->iterationCount() = timing.mIterationCount; animation->iterationCount() = timing.mIterationCount;
animation->direction() = timing.mDirection; animation->direction() = timing.mDirection;
animation->property() = aProperty; animation->property() = aProperty.mProperty;
animation->data() = aData; animation->data() = aData;
dom::Animation* anim = aPlayer->GetSource(); for (uint32_t segIdx = 0; segIdx < aProperty.mSegments.Length(); segIdx++) {
for (size_t propIdx = 0; const AnimationPropertySegment& segment = aProperty.mSegments[segIdx];
propIdx < anim->Properties().Length();
propIdx++) {
AnimationProperty& property = anim->Properties()[propIdx];
if (aProperty != property.mProperty) { AnimationSegment* animSegment = animation->segments().AppendElement();
continue; if (aProperty.mProperty == eCSSProperty_transform) {
animSegment->startState() = InfallibleTArray<TransformFunction>();
animSegment->endState() = InfallibleTArray<TransformFunction>();
nsCSSValueSharedList* list =
segment.mFromValue.GetCSSValueSharedListValue();
AddTransformFunctions(list->mHead, styleContext, presContext, bounds,
animSegment->startState().get_ArrayOfTransformFunction());
list = segment.mToValue.GetCSSValueSharedListValue();
AddTransformFunctions(list->mHead, styleContext, presContext, bounds,
animSegment->endState().get_ArrayOfTransformFunction());
} else if (aProperty.mProperty == eCSSProperty_opacity) {
animSegment->startState() = segment.mFromValue.GetFloatValue();
animSegment->endState() = segment.mToValue.GetFloatValue();
} }
for (uint32_t segIdx = 0; segIdx < property.mSegments.Length(); segIdx++) { animSegment->startPortion() = segment.mFromKey;
AnimationPropertySegment& segment = property.mSegments[segIdx]; animSegment->endPortion() = segment.mToKey;
animSegment->sampleFn() = ToTimingFunction(segment.mTimingFunction);
AnimationSegment* animSegment = animation->segments().AppendElement();
if (aProperty == eCSSProperty_transform) {
animSegment->startState() = InfallibleTArray<TransformFunction>();
animSegment->endState() = InfallibleTArray<TransformFunction>();
nsCSSValueSharedList* list =
segment.mFromValue.GetCSSValueSharedListValue();
AddTransformFunctions(list->mHead, styleContext, presContext, bounds,
animSegment->startState().get_ArrayOfTransformFunction());
list = segment.mToValue.GetCSSValueSharedListValue();
AddTransformFunctions(list->mHead, styleContext, presContext, bounds,
animSegment->endState().get_ArrayOfTransformFunction());
} else if (aProperty == eCSSProperty_opacity) {
animSegment->startState() = segment.mFromValue.GetFloatValue();
animSegment->endState() = segment.mToValue.GetFloatValue();
}
animSegment->startPortion() = segment.mFromKey;
animSegment->endPortion() = segment.mToKey;
animSegment->sampleFn() = ToTimingFunction(segment.mTimingFunction);
}
} }
} }
@ -418,12 +407,20 @@ static void
AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
AnimationPlayerPtrArray& aPlayers, AnimationPlayerPtrArray& aPlayers,
Layer* aLayer, AnimationData& aData, Layer* aLayer, AnimationData& aData,
bool aPending) { bool aPending)
{
for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) { for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) {
AnimationPlayer* player = aPlayers[playerIdx]; AnimationPlayer* player = aPlayers[playerIdx];
if (!player->IsRunning()) {
continue;
}
dom::Animation* anim = player->GetSource(); dom::Animation* anim = player->GetSource();
if (!(anim && anim->HasAnimationOfProperty(aProperty) && if (!anim) {
player->IsRunning())) { continue;
}
const AnimationProperty* property =
anim->GetAnimationOfProperty(aProperty);
if (!property) {
continue; continue;
} }
@ -443,7 +440,7 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
} }
} }
AddAnimationForProperty(aFrame, aProperty, player, aLayer, aData, aPending); AddAnimationForProperty(aFrame, *property, player, aLayer, aData, aPending);
player->SetIsRunningOnCompositor(); player->SetIsRunningOnCompositor();
} }
} }