Bug 1216842 - Part 1: Add null_t into TimingFunction to skip calculation of linear timing function. r=cam

This is a patch for compositor side to represent linear function as null_t/Nothing().

Also the first argument of ToTimingFunction changes to a Maybe<ComputedTimingFunction>.
As a result of this change we can also use ToTimingFunction for animation
effect's timing function.
This commit is contained in:
Hiroyuki Ikezoe 2016-01-26 21:14:00 +01:00
parent 1a086bb8f8
commit 52d846dacd
2 changed files with 11 additions and 6 deletions

View File

@ -93,6 +93,7 @@ struct StepFunction {
};
union TimingFunction {
null_t;
CubicBezierFunction;
StepFunction;
};

View File

@ -347,16 +347,20 @@ static void AddTransformFunctions(nsCSSValueList* aList,
}
static TimingFunction
ToTimingFunction(const ComputedTimingFunction& aCTF)
ToTimingFunction(Maybe<ComputedTimingFunction> aCTF)
{
if (aCTF.HasSpline()) {
const nsSMILKeySpline* spline = aCTF.GetFunction();
if (aCTF.isNothing()) {
return TimingFunction(null_t());
}
if (aCTF->HasSpline()) {
const nsSMILKeySpline* spline = aCTF->GetFunction();
return TimingFunction(CubicBezierFunction(spline->X1(), spline->Y1(),
spline->X2(), spline->Y2()));
}
uint32_t type = aCTF.GetType() == nsTimingFunction::Type::StepStart ? 1 : 2;
return TimingFunction(StepFunction(aCTF.GetSteps(), type));
uint32_t type = aCTF->GetType() == nsTimingFunction::Type::StepStart ? 1 : 2;
return TimingFunction(StepFunction(aCTF->GetSteps(), type));
}
static void
@ -421,7 +425,7 @@ AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
animSegment->startPortion() = segment.mFromKey;
animSegment->endPortion() = segment.mToKey;
animSegment->sampleFn() = ToTimingFunction(segment.mTimingFunction);
animSegment->sampleFn() = ToTimingFunction(Some(segment.mTimingFunction));
}
}