blob: adbe69f167bddba04c027309af93276ef9306f70 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#ifndef SkOperandInterpolator_DEFINED
11#define SkOperandInterpolator_DEFINED
12
13#include "SkDisplayType.h"
14#include "SkInterpolator.h"
15#include "SkOperand.h"
16
17class SkOperandInterpolator : public SkInterpolatorBase {
18public:
19 SkOperandInterpolator();
20 SkOperandInterpolator(int elemCount, int frameCount, SkDisplayTypes type);
21 SkOperand* getValues() { return fValues; }
22 int getValuesCount() { return fFrameCount * fElemCount; }
23 void reset(int elemCount, int frameCount, SkDisplayTypes type);
24
25 /** Add or replace a key frame, copying the values[] data into the interpolator.
26 @param index The index of this frame (frames must be ordered by time)
27 @param time The millisecond time for this frame
28 @param values The array of values [elemCount] for this frame. The data is copied
29 into the interpolator.
30 @param blend A positive scalar specifying how to blend between this and the next key frame.
31 [0...1) is a cubic lag/log/lag blend (slow to change at the beginning and end)
32 1 is a linear blend (default)
33 (1...inf) is a cubic log/lag/log blend (fast to change at the beginning and end)
34 */
35 bool setKeyFrame(int index, SkMSec time, const SkOperand values[], SkScalar blend = SK_Scalar1);
36 Result timeToValues(SkMSec time, SkOperand values[]) const;
37 SkDEBUGCODE(static void UnitTest();)
38private:
39 SkDisplayTypes fType;
40 SkOperand* fValues; // pointer into fStorage
41#ifdef SK_DEBUG
42 SkOperand(* fValuesArray)[10];
43#endif
44 typedef SkInterpolatorBase INHERITED;
45};
46
47#endif // SkOperandInterpolator_DEFINED