aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/animator/SkOperand2.h
blob: f482e669b9e0326d2fcd9838399af24c2054f85f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef SkOperand2_DEFINED
#define SkOperand2_DEFINED

#include "SkScalar.h"

class SkOpArray;
class SkString;

union SkOperand2 {
	enum OpType {
		kNoType,
		kS32 = 1,
		kScalar = 2,
		kString = 4,
		kArray = 8,
		kObject = 16
	};
	SkOpArray* fArray;
	void* fObject;
	size_t fReference;
	int32_t fS32;
	SkScalar fScalar;
	SkString* fString;
};

struct SkScriptValue2 {
	enum IsConstant {
		kConstant,
		kVariable
	};
	enum IsWritten {
		kUnwritten,
		kWritten
	};
	SkOperand2 fOperand;
	SkOperand2::OpType fType : 8;
	IsConstant fIsConstant : 8;
	IsWritten fIsWritten : 8;
	SkOpArray* getArray() { SkASSERT(fType == SkOperand2::kArray); return fOperand.fArray; }
	void* getObject() { SkASSERT(fType == SkOperand2::kObject); return fOperand.fObject; }
	int32_t getS32() { SkASSERT(fType == SkOperand2::kS32); return fOperand.fS32; }
	SkScalar getScalar() { SkASSERT(fType == SkOperand2::kScalar); return fOperand.fScalar; }
	SkString* getString() { SkASSERT(fType == SkOperand2::kString); return fOperand.fString; }
        bool isConstant() const { return fIsConstant == kConstant; }
};

#endif // SkOperand2_DEFINED