blob: 82b658f7bed0eec77a394a6ef054d41736d73025 [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#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
robertphillips@google.com706f6212012-05-14 17:51:23 +000034#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
reed@android.com8a1c16f2008-12-17 15:59:43 +000041bool 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}
robertphillips@google.com706f6212012-05-14 17:51:23 +000067
68#if defined _WIN32
69#pragma warning ( pop )
caryclark@google.com16230cb2012-06-06 12:11:55 +000070#endif