Home | History | Annotate | Download | only in animator
      1 /* libs/graphics/animator/SkDisplayNumber.cpp
      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 #include "SkDisplayNumber.h"
     19 
     20 enum SkDisplayNumber_Properties {
     21     SK_PROPERTY(MAX_VALUE),
     22     SK_PROPERTY(MIN_VALUE),
     23     SK_PROPERTY(NEGATIVE_INFINITY),
     24     SK_PROPERTY(NaN),
     25     SK_PROPERTY(POSITIVE_INFINITY)
     26 };
     27 
     28 #if SK_USE_CONDENSED_INFO == 0
     29 
     30 const SkMemberInfo SkDisplayNumber::fInfo[] = {
     31     SK_MEMBER_PROPERTY(MAX_VALUE, Float),
     32     SK_MEMBER_PROPERTY(MIN_VALUE, Float),
     33     SK_MEMBER_PROPERTY(NEGATIVE_INFINITY, Float),
     34     SK_MEMBER_PROPERTY(NaN, Float),
     35     SK_MEMBER_PROPERTY(POSITIVE_INFINITY, Float)
     36 };
     37 
     38 #endif
     39 
     40 DEFINE_GET_MEMBER(SkDisplayNumber);
     41 
     42 bool SkDisplayNumber::getProperty(int index, SkScriptValue* value) const {
     43     SkScalar constant;
     44     switch (index) {
     45         case SK_PROPERTY(MAX_VALUE):
     46             constant = SK_ScalarMax;
     47         break;
     48         case SK_PROPERTY(MIN_VALUE):
     49             constant = SK_ScalarMin;
     50         break;
     51         case SK_PROPERTY(NEGATIVE_INFINITY):
     52             constant = -SK_ScalarInfinity;
     53         break;
     54         case SK_PROPERTY(NaN):
     55             constant = SK_ScalarNaN;
     56         break;
     57         case SK_PROPERTY(POSITIVE_INFINITY):
     58             constant = SK_ScalarInfinity;
     59         break;
     60         default:
     61             SkASSERT(0);
     62             return false;
     63     }
     64     value->fOperand.fScalar = constant;
     65     value->fType = SkType_Float;
     66     return true;
     67 }
     68