Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "LayerAnimationUtils.h"
8 : #include "mozilla/ComputedTimingFunction.h" // For ComputedTimingFunction
9 : #include "mozilla/layers/LayersMessages.h" // For TimingFunction etc.
10 :
11 : namespace mozilla {
12 : namespace layers {
13 :
14 : /* static */ Maybe<ComputedTimingFunction>
15 0 : AnimationUtils::TimingFunctionToComputedTimingFunction(
16 : const TimingFunction& aTimingFunction)
17 : {
18 0 : switch (aTimingFunction.type()) {
19 : case TimingFunction::Tnull_t:
20 0 : return Nothing();
21 : case TimingFunction::TCubicBezierFunction: {
22 0 : CubicBezierFunction cbf = aTimingFunction.get_CubicBezierFunction();
23 0 : return Some(ComputedTimingFunction::CubicBezier(cbf.x1(), cbf.y1(),
24 0 : cbf.x2(), cbf.y2()));
25 : }
26 : case TimingFunction::TStepFunction: {
27 0 : StepFunction sf = aTimingFunction.get_StepFunction();
28 0 : nsTimingFunction::Type type = sf.type() == 1 ?
29 : nsTimingFunction::Type::StepStart :
30 0 : nsTimingFunction::Type::StepEnd;
31 0 : return Some(ComputedTimingFunction::Steps(type, sf.steps()));
32 : }
33 : case TimingFunction::TFramesFunction: {
34 0 : FramesFunction ff = aTimingFunction.get_FramesFunction();
35 0 : return Some(ComputedTimingFunction::Frames(ff.frames()));
36 : }
37 : default:
38 0 : MOZ_ASSERT_UNREACHABLE(
39 : "Function must be null, bezier, step or frames");
40 : break;
41 : }
42 : return Nothing();
43 : }
44 :
45 : } // namespace layers
46 : } // namespace mozilla
|