blob: f1552762ada19b963bfb34fc11e75c789170ef1b [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/* libs/graphics/animator/SkOperandInterpolator.h
2**
3** Copyright 2006, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef SkOperandInterpolator_DEFINED
19#define SkOperandInterpolator_DEFINED
20
21#include "SkDisplayType.h"
22#include "SkInterpolator.h"
23#include "SkOperand.h"
24
25class SkOperandInterpolator : public SkInterpolatorBase {
26public:
27 SkOperandInterpolator();
28 SkOperandInterpolator(int elemCount, int frameCount, SkDisplayTypes type);
29 SkOperand* getValues() { return fValues; }
30 int getValuesCount() { return fFrameCount * fElemCount; }
31 void reset(int elemCount, int frameCount, SkDisplayTypes type);
32
33 /** Add or replace a key frame, copying the values[] data into the interpolator.
34 @param index The index of this frame (frames must be ordered by time)
35 @param time The millisecond time for this frame
36 @param values The array of values [elemCount] for this frame. The data is copied
37 into the interpolator.
38 @param blend A positive scalar specifying how to blend between this and the next key frame.
39 [0...1) is a cubic lag/log/lag blend (slow to change at the beginning and end)
40 1 is a linear blend (default)
41 (1...inf) is a cubic log/lag/log blend (fast to change at the beginning and end)
42 */
43 bool setKeyFrame(int index, SkMSec time, const SkOperand values[], SkScalar blend = SK_Scalar1);
44 Result timeToValues(SkMSec time, SkOperand values[]) const;
45 SkDEBUGCODE(static void UnitTest();)
46private:
47 SkDisplayTypes fType;
48 SkOperand* fValues; // pointer into fStorage
49#ifdef SK_DEBUG
50 SkOperand(* fValuesArray)[10];
51#endif
52 typedef SkInterpolatorBase INHERITED;
53};
54
55#endif // SkOperandInterpolator_DEFINED
56