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
ToTimingFunction(ComputedTimingFunction& aCTF)
ToTimingFunction(const ComputedTimingFunction& aCTF)
{
if (aCTF.GetType() == nsTimingFunction::Function) {
const nsSMILKeySpline* spline = aCTF.GetFunction();
@ -345,7 +345,7 @@ ToTimingFunction(ComputedTimingFunction& aCTF)
}
static void
AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
AnimationPlayer* aPlayer, Layer* aLayer,
AnimationData& aData, bool aPending)
{
@ -373,44 +373,33 @@ AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
animation->duration() = timing.mIterationDuration;
animation->iterationCount() = timing.mIterationCount;
animation->direction() = timing.mDirection;
animation->property() = aProperty;
animation->property() = aProperty.mProperty;
animation->data() = aData;
dom::Animation* anim = aPlayer->GetSource();
for (size_t propIdx = 0;
propIdx < anim->Properties().Length();
propIdx++) {
AnimationProperty& property = anim->Properties()[propIdx];
for (uint32_t segIdx = 0; segIdx < aProperty.mSegments.Length(); segIdx++) {
const AnimationPropertySegment& segment = aProperty.mSegments[segIdx];
if (aProperty != property.mProperty) {
continue;
AnimationSegment* animSegment = animation->segments().AppendElement();
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++) {
AnimationPropertySegment& segment = property.mSegments[segIdx];
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);
}
animSegment->startPortion() = segment.mFromKey;
animSegment->endPortion() = segment.mToKey;
animSegment->sampleFn() = ToTimingFunction(segment.mTimingFunction);
}
}
@ -418,12 +407,20 @@ static void
AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
AnimationPlayerPtrArray& aPlayers,
Layer* aLayer, AnimationData& aData,
bool aPending) {
bool aPending)
{
for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) {
AnimationPlayer* player = aPlayers[playerIdx];
if (!player->IsRunning()) {
continue;
}
dom::Animation* anim = player->GetSource();
if (!(anim && anim->HasAnimationOfProperty(aProperty) &&
player->IsRunning())) {
if (!anim) {
continue;
}
const AnimationProperty* property =
anim->GetAnimationOfProperty(aProperty);
if (!property) {
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();
}
}