blob: 14126fccbfda24fba2675f9f406cd8343cfcc907 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#ifndef SkOperand_DEFINED
11#define SkOperand_DEFINED
12
13#include "SkDisplayType.h"
14
15class SkTypedArray;
16class SkDisplayable;
reed986ca612014-11-26 08:50:45 -080017class SkADrawable;
reed@android.com8a1c16f2008-12-17 15:59:43 +000018class SkString;
19
20union SkOperand {
21// SkOperand() {}
22// SkOperand(SkScalar scalar) : fScalar(scalar) {}
23 SkTypedArray* fArray;
24 SkDisplayable* fDisplayable;
reed986ca612014-11-26 08:50:45 -080025 SkADrawable* fDrawable;
reed@android.com8a1c16f2008-12-17 15:59:43 +000026 void* fObject;
27 int32_t fS32;
28 SkMSec fMSec;
29 SkScalar fScalar;
30 SkString* fString;
31};
32
33struct SkScriptValue {
34 SkOperand fOperand;
35 SkDisplayTypes fType;
36 SkTypedArray* getArray() { SkASSERT(fType == SkType_Array); return fOperand.fArray; }
37 SkDisplayable* getDisplayable() { SkASSERT(fType == SkType_Displayable); return fOperand.fDisplayable; }
reed986ca612014-11-26 08:50:45 -080038 SkADrawable* getDrawable() { SkASSERT(fType == SkType_Drawable); return fOperand.fDrawable; }
reed@android.com8a1c16f2008-12-17 15:59:43 +000039 int32_t getS32(SkAnimateMaker* maker) { SkASSERT(fType == SkType_Int || fType == SkType_Boolean ||
40 SkDisplayType::IsEnum(maker, fType)); return fOperand.fS32; }
41 SkMSec getMSec() { SkASSERT(fType == SkType_MSec); return fOperand.fMSec; }
42 SkScalar getScalar() { SkASSERT(fType == SkType_Float); return fOperand.fScalar; }
43 SkString* getString() { SkASSERT(fType == SkType_String); return fOperand.fString; }
44};
45
46#endif // SkOperand_DEFINED