michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkOperand_DEFINED michael@0: #define SkOperand_DEFINED michael@0: michael@0: #include "SkDisplayType.h" michael@0: michael@0: class SkTypedArray; michael@0: class SkDisplayable; michael@0: class SkDrawable; michael@0: class SkString; michael@0: michael@0: union SkOperand { michael@0: // SkOperand() {} michael@0: // SkOperand(SkScalar scalar) : fScalar(scalar) {} michael@0: SkTypedArray* fArray; michael@0: SkDisplayable* fDisplayable; michael@0: SkDrawable* fDrawable; michael@0: void* fObject; michael@0: int32_t fS32; michael@0: SkMSec fMSec; michael@0: SkScalar fScalar; michael@0: SkString* fString; michael@0: }; michael@0: michael@0: struct SkScriptValue { michael@0: SkOperand fOperand; michael@0: SkDisplayTypes fType; michael@0: SkTypedArray* getArray() { SkASSERT(fType == SkType_Array); return fOperand.fArray; } michael@0: SkDisplayable* getDisplayable() { SkASSERT(fType == SkType_Displayable); return fOperand.fDisplayable; } michael@0: SkDrawable* getDrawable() { SkASSERT(fType == SkType_Drawable); return fOperand.fDrawable; } michael@0: int32_t getS32(SkAnimateMaker* maker) { SkASSERT(fType == SkType_Int || fType == SkType_Boolean || michael@0: SkDisplayType::IsEnum(maker, fType)); return fOperand.fS32; } michael@0: SkMSec getMSec() { SkASSERT(fType == SkType_MSec); return fOperand.fMSec; } michael@0: SkScalar getScalar() { SkASSERT(fType == SkType_Float); return fOperand.fScalar; } michael@0: SkString* getString() { SkASSERT(fType == SkType_String); return fOperand.fString; } michael@0: }; michael@0: michael@0: #endif // SkOperand_DEFINED