1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2011 Google Inc.
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkOperand2_DEFINED
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkOperand2_DEFINED
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalar.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkOpArray;
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkString;
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comunion SkOperand2 {
17d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    enum OpType {
18d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kNoType,
19d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kS32 = 1,
20d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kScalar = 2,
21d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kString = 4,
22d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kArray = 8,
23d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kObject = 16
24d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    };
25d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkOpArray* fArray;
26d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    void* fObject;
27d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    size_t fReference;
28d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    int32_t fS32;
29d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkScalar fScalar;
30d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkString* fString;
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkScriptValue2 {
34d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    enum IsConstant {
35d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kConstant,
36d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kVariable
37d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    };
38d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    enum IsWritten {
39d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kUnwritten,
40d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        kWritten
41d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    };
42d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkOperand2 fOperand;
43d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkOperand2::OpType fType : 8;
44d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    IsConstant fIsConstant : 8;
45d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    IsWritten fIsWritten : 8;
46d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkOpArray* getArray() { SkASSERT(fType == SkOperand2::kArray); return fOperand.fArray; }
47d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    void* getObject() { SkASSERT(fType == SkOperand2::kObject); return fOperand.fObject; }
48d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    int32_t getS32() { SkASSERT(fType == SkOperand2::kS32); return fOperand.fS32; }
49d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkScalar getScalar() { SkASSERT(fType == SkOperand2::kScalar); return fOperand.fScalar; }
50d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    SkString* getString() { SkASSERT(fType == SkOperand2::kString); return fOperand.fString; }
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        bool isConstant() const { return fIsConstant == kConstant; }
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif // SkOperand2_DEFINED
55