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; getArraySkScriptValue239 SkOpArray* getArray() { SkASSERT(fType == SkOperand2::kArray); return fOperand.fArray; } getObjectSkScriptValue240 void* getObject() { SkASSERT(fType == SkOperand2::kObject); return fOperand.fObject; } getS32SkScriptValue241 int32_t getS32() { SkASSERT(fType == SkOperand2::kS32); return fOperand.fS32; } getScalarSkScriptValue242 SkScalar getScalar() { SkASSERT(fType == SkOperand2::kScalar); return fOperand.fScalar; } getStringSkScriptValue243 SkString* getString() { SkASSERT(fType == SkOperand2::kString); return fOperand.fString; } isConstantSkScriptValue244 bool isConstant() const { return fIsConstant == kConstant; } 45 }; 46 47 #endif // SkOperand2_DEFINED 48