File indexing completed on 2024-05-12 15:38:39

0001 /*
0002  * Copyright (C) 2007 Apple Inc.  All rights reserved.
0003  *
0004  * Redistribution and use in source and binary forms, with or without
0005  * modification, are permitted provided that the following conditions
0006  * are met:
0007  *
0008  * 1.  Redistributions of source code must retain the above copyright
0009  *     notice, this list of conditions and the following disclaimer.
0010  * 2.  Redistributions in binary form must reproduce the above copyright
0011  *     notice, this list of conditions and the following disclaimer in the
0012  *     documentation and/or other materials provided with the distribution.
0013  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
0014  *     its contributors may be used to endorse or promote products derived
0015  *     from this software without specific prior written permission.
0016  *
0017  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
0018  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0019  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0020  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
0021  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0022  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0023  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0024  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifndef FloatConversion_h
0030 #define FloatConversion_h
0031 
0032 #include <wtf/Platform.h>
0033 #if PLATFORM(CG)
0034 #include <CoreGraphics/CGBase.h>
0035 #endif
0036 
0037 namespace WebCore
0038 {
0039 
0040 template<typename T>
0041 float narrowPrecisionToFloat(T);
0042 
0043 template<>
0044 inline float narrowPrecisionToFloat(double number)
0045 {
0046     return static_cast<float>(number);
0047 }
0048 
0049 #if PLATFORM(CG)
0050 template<typename T>
0051 CGFloat narrowPrecisionToCGFloat(T);
0052 
0053 template<>
0054 inline CGFloat narrowPrecisionToCGFloat(double number)
0055 {
0056     return static_cast<CGFloat>(number);
0057 }
0058 #endif
0059 
0060 } // namespace WebCore
0061 
0062 #endif // FloatConversion_h