• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 enum 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 
22 const 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 
32 DEFINE_GET_MEMBER(SkDisplayNumber);
33 
getProperty(int index,SkScriptValue * value) const34 bool SkDisplayNumber::getProperty(int index, SkScriptValue* value) const {
35     SkScalar constant;
36     switch (index) {
37         case SK_PROPERTY(MAX_VALUE):
38             constant = SK_ScalarMax;
39         break;
40         case SK_PROPERTY(MIN_VALUE):
41             constant = SK_ScalarMin;
42         break;
43         case SK_PROPERTY(NEGATIVE_INFINITY):
44             constant = -SK_ScalarInfinity;
45         break;
46         case SK_PROPERTY(NaN):
47             constant = SK_ScalarNaN;
48         break;
49         case SK_PROPERTY(POSITIVE_INFINITY):
50             constant = SK_ScalarInfinity;
51         break;
52         default:
53             SkASSERT(0);
54             return false;
55     }
56     value->fOperand.fScalar = constant;
57     value->fType = SkType_Float;
58     return true;
59 }
60