1
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
9
10#include "SkDisplayNumber.h"
11
12enum SkDisplayNumber_Properties {
13    SK_PROPERTY(MAX_VALUE),
14    SK_PROPERTY(MIN_VALUE),
15    SK_PROPERTY(NEGATIVE_INFINITY),
16    SK_PROPERTY(NaN),
17    SK_PROPERTY(POSITIVE_INFINITY)
18};
19
20#if SK_USE_CONDENSED_INFO == 0
21
22const SkMemberInfo SkDisplayNumber::fInfo[] = {
23    SK_MEMBER_PROPERTY(MAX_VALUE, Float),
24    SK_MEMBER_PROPERTY(MIN_VALUE, Float),
25    SK_MEMBER_PROPERTY(NEGATIVE_INFINITY, Float),
26    SK_MEMBER_PROPERTY(NaN, Float),
27    SK_MEMBER_PROPERTY(POSITIVE_INFINITY, Float)
28};
29
30#endif
31
32DEFINE_GET_MEMBER(SkDisplayNumber);
33
34#if defined _WIN32
35#pragma warning ( push )
36// we are intentionally causing an overflow here
37//      (warning C4756: overflow in constant arithmetic)
38#pragma warning ( disable : 4756 )
39#endif
40
41bool SkDisplayNumber::getProperty(int index, SkScriptValue* value) const {
42    SkScalar constant;
43    switch (index) {
44        case SK_PROPERTY(MAX_VALUE):
45            constant = SK_ScalarMax;
46        break;
47        case SK_PROPERTY(MIN_VALUE):
48            constant = SK_ScalarMin;
49        break;
50        case SK_PROPERTY(NEGATIVE_INFINITY):
51            constant = -SK_ScalarInfinity;
52        break;
53        case SK_PROPERTY(NaN):
54            constant = SK_ScalarNaN;
55        break;
56        case SK_PROPERTY(POSITIVE_INFINITY):
57            constant = SK_ScalarInfinity;
58        break;
59        default:
60            SkASSERT(0);
61            return false;
62    }
63    value->fOperand.fScalar = constant;
64    value->fType = SkType_Float;
65    return true;
66}
67
68#if defined _WIN32
69#pragma warning ( pop )
70#endif
71