Home | History | Annotate | Download | only in animator
      1 /* libs/graphics/animator/SkOperand.h
      2 **
      3 ** Copyright 2006, The Android Open Source Project
      4 **
      5 ** Licensed under the Apache License, Version 2.0 (the "License");
      6 ** you may not use this file except in compliance with the License.
      7 ** You may obtain a copy of the License at
      8 **
      9 **     http://www.apache.org/licenses/LICENSE-2.0
     10 **
     11 ** Unless required by applicable law or agreed to in writing, software
     12 ** distributed under the License is distributed on an "AS IS" BASIS,
     13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 ** See the License for the specific language governing permissions and
     15 ** limitations under the License.
     16 */
     17 
     18 #ifndef SkOperand_DEFINED
     19 #define SkOperand_DEFINED
     20 
     21 #include "SkDisplayType.h"
     22 
     23 class SkTypedArray;
     24 class SkDisplayable;
     25 class SkDrawable;
     26 class SkString;
     27 
     28 union SkOperand {
     29 //  SkOperand() {}
     30 //  SkOperand(SkScalar scalar) : fScalar(scalar) {}
     31     SkTypedArray* fArray;
     32     SkDisplayable* fDisplayable;
     33     SkDrawable* fDrawable;
     34     void* fObject;
     35     int32_t fS32;
     36     SkMSec fMSec;
     37     SkScalar fScalar;
     38     SkString* fString;
     39 };
     40 
     41 struct SkScriptValue {
     42     SkOperand fOperand;
     43     SkDisplayTypes fType;
     44     SkTypedArray* getArray() { SkASSERT(fType == SkType_Array); return fOperand.fArray; }
     45     SkDisplayable* getDisplayable() { SkASSERT(fType == SkType_Displayable); return fOperand.fDisplayable; }
     46     SkDrawable* getDrawable() { SkASSERT(fType == SkType_Drawable); return fOperand.fDrawable; }
     47     int32_t getS32(SkAnimateMaker* maker) { SkASSERT(fType == SkType_Int || fType == SkType_Boolean ||
     48         SkDisplayType::IsEnum(maker, fType)); return fOperand.fS32; }
     49     SkMSec getMSec() { SkASSERT(fType == SkType_MSec); return fOperand.fMSec; }
     50     SkScalar getScalar() { SkASSERT(fType == SkType_Float); return fOperand.fScalar; }
     51     SkString* getString() { SkASSERT(fType == SkType_String); return fOperand.fString; }
     52 };
     53 
     54 #endif // SkOperand_DEFINED
     55