aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/animator/SkOperand2.h
blob: f844b6b4c9861635d79c87d53c981acd8d30f67a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SkOperand2_DEFINED
#define SkOperand2_DEFINED

#include "SkScalar.h"

class SkOpArray;
class SkString;

union SkOperand2 {
    enum OpType {
        kNoType,
        kS32 = 1,
        kScalar = 2,
        kString = 4,
        kArray = 8,
        kObject = 16
    };
    SkOpArray* fArray;
    void* fObject;
    size_t fReference;
    int32_t fS32;
    SkScalar fScalar;
    SkString* fString;
};

struct SkScriptValue2 {
    enum IsConstant {
        kConstant,
        kVariable
    };
    enum IsWritten {
        kUnwritten,
        kWritten
    };
    SkOperand2 fOperand;
    SkOperand2::OpType fType : 8;
    IsConstant fIsConstant : 8;
    IsWritten fIsWritten : 8;
    SkOpArray* getArray() { SkASSERT(fType == SkOperand2::kArray); return fOperand.fArray; }
    void* getObject() { SkASSERT(fType == SkOperand2::kObject); return fOperand.fObject; }
    int32_t getS32() { SkASSERT(fType == SkOperand2::kS32); return fOperand.fS32; }
    SkScalar getScalar() { SkASSERT(fType == SkOperand2::kScalar); return fOperand.fScalar; }
    SkString* getString() { SkASSERT(fType == SkOperand2::kString); return fOperand.fString; }
        bool isConstant() const { return fIsConstant == kConstant; }
};

#endif // SkOperand2_DEFINED