epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #ifndef SkOperand2_DEFINED |
| 9 | #define SkOperand2_DEFINED |
| 10 | |
| 11 | #include "SkScalar.h" |
| 12 | |
| 13 | class SkOpArray; |
| 14 | class SkString; |
| 15 | |
| 16 | union SkOperand2 { |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 17 | enum OpType { |
| 18 | kNoType, |
| 19 | kS32 = 1, |
| 20 | kScalar = 2, |
| 21 | kString = 4, |
| 22 | kArray = 8, |
| 23 | kObject = 16 |
| 24 | }; |
| 25 | SkOpArray* fArray; |
| 26 | void* fObject; |
| 27 | size_t fReference; |
| 28 | int32_t fS32; |
| 29 | SkScalar fScalar; |
| 30 | SkString* fString; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | struct SkScriptValue2 { |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 34 | enum IsConstant { |
| 35 | kConstant, |
| 36 | kVariable |
| 37 | }; |
| 38 | enum IsWritten { |
| 39 | kUnwritten, |
| 40 | kWritten |
| 41 | }; |
| 42 | SkOperand2 fOperand; |
| 43 | SkOperand2::OpType fType : 8; |
| 44 | IsConstant fIsConstant : 8; |
| 45 | IsWritten fIsWritten : 8; |
| 46 | SkOpArray* getArray() { SkASSERT(fType == SkOperand2::kArray); return fOperand.fArray; } |
| 47 | void* getObject() { SkASSERT(fType == SkOperand2::kObject); return fOperand.fObject; } |
| 48 | int32_t getS32() { SkASSERT(fType == SkOperand2::kS32); return fOperand.fS32; } |
| 49 | SkScalar getScalar() { SkASSERT(fType == SkOperand2::kScalar); return fOperand.fScalar; } |
| 50 | SkString* getString() { SkASSERT(fType == SkOperand2::kString); return fOperand.fString; } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 51 | bool isConstant() const { return fIsConstant == kConstant; } |
| 52 | }; |
| 53 | |
| 54 | #endif // SkOperand2_DEFINED |