1 #ifndef SkOperand2_DEFINED 2 #define SkOperand2_DEFINED 3 4 #include "SkScalar.h" 5 6 class SkOpArray; 7 class SkString; 8 9 union SkOperand2 { 10 enum OpType { 11 kNoType, 12 kS32 = 1, 13 kScalar = 2, 14 kString = 4, 15 kArray = 8, 16 kObject = 16 17 }; 18 SkOpArray* fArray; 19 void* fObject; 20 size_t fReference; 21 int32_t fS32; 22 SkScalar fScalar; 23 SkString* fString; 24 }; 25 26 struct SkScriptValue2 { 27 enum IsConstant { 28 kConstant, 29 kVariable 30 }; 31 enum IsWritten { 32 kUnwritten, 33 kWritten 34 }; 35 SkOperand2 fOperand; 36 SkOperand2::OpType fType : 8; 37 IsConstant fIsConstant : 8; 38 IsWritten fIsWritten : 8; 39 SkOpArray* getArray() { SkASSERT(fType == SkOperand2::kArray); return fOperand.fArray; } 40 void* getObject() { SkASSERT(fType == SkOperand2::kObject); return fOperand.fObject; } 41 int32_t getS32() { SkASSERT(fType == SkOperand2::kS32); return fOperand.fS32; } 42 SkScalar getScalar() { SkASSERT(fType == SkOperand2::kScalar); return fOperand.fScalar; } 43 SkString* getString() { SkASSERT(fType == SkOperand2::kString); return fOperand.fString; } 44 bool isConstant() const { return fIsConstant == kConstant; } 45 }; 46 47 #endif // SkOperand2_DEFINED 48