michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkDisplayNumber.h" michael@0: michael@0: enum SkDisplayNumber_Properties { michael@0: SK_PROPERTY(MAX_VALUE), michael@0: SK_PROPERTY(MIN_VALUE), michael@0: SK_PROPERTY(NEGATIVE_INFINITY), michael@0: SK_PROPERTY(NaN), michael@0: SK_PROPERTY(POSITIVE_INFINITY) michael@0: }; michael@0: michael@0: #if SK_USE_CONDENSED_INFO == 0 michael@0: michael@0: const SkMemberInfo SkDisplayNumber::fInfo[] = { michael@0: SK_MEMBER_PROPERTY(MAX_VALUE, Float), michael@0: SK_MEMBER_PROPERTY(MIN_VALUE, Float), michael@0: SK_MEMBER_PROPERTY(NEGATIVE_INFINITY, Float), michael@0: SK_MEMBER_PROPERTY(NaN, Float), michael@0: SK_MEMBER_PROPERTY(POSITIVE_INFINITY, Float) michael@0: }; michael@0: michael@0: #endif michael@0: michael@0: DEFINE_GET_MEMBER(SkDisplayNumber); michael@0: michael@0: #if defined _WIN32 michael@0: #pragma warning ( push ) michael@0: // we are intentionally causing an overflow here michael@0: // (warning C4756: overflow in constant arithmetic) michael@0: #pragma warning ( disable : 4756 ) michael@0: #endif michael@0: michael@0: bool SkDisplayNumber::getProperty(int index, SkScriptValue* value) const { michael@0: SkScalar constant; michael@0: switch (index) { michael@0: case SK_PROPERTY(MAX_VALUE): michael@0: constant = SK_ScalarMax; michael@0: break; michael@0: case SK_PROPERTY(MIN_VALUE): michael@0: constant = SK_ScalarMin; michael@0: break; michael@0: case SK_PROPERTY(NEGATIVE_INFINITY): michael@0: constant = -SK_ScalarInfinity; michael@0: break; michael@0: case SK_PROPERTY(NaN): michael@0: constant = SK_ScalarNaN; michael@0: break; michael@0: case SK_PROPERTY(POSITIVE_INFINITY): michael@0: constant = SK_ScalarInfinity; michael@0: break; michael@0: default: michael@0: SkASSERT(0); michael@0: return false; michael@0: } michael@0: value->fOperand.fScalar = constant; michael@0: value->fType = SkType_Float; michael@0: return true; michael@0: } michael@0: michael@0: #if defined _WIN32 michael@0: #pragma warning ( pop ) michael@0: #endif