1 /* 2 * Copyright 2020 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkCGBase_DEFINED 9 #define SkCGBase_DEFINED 10 11 #include "include/core/SkTypes.h" 12 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) 13 14 #ifdef SK_BUILD_FOR_MAC 15 #import <ApplicationServices/ApplicationServices.h> 16 #endif 17 18 #ifdef SK_BUILD_FOR_IOS 19 #include <CoreGraphics/CoreGraphics.h> 20 #endif 21 22 // Skia extensions for types in CGBase.h 23 SkScalarToCGFloat(SkScalar scalar)24static inline CGFloat SkScalarToCGFloat(SkScalar scalar) { 25 return CGFLOAT_IS_DOUBLE ? SkScalarToDouble(scalar) : SkScalarToFloat(scalar); 26 } 27 SkScalarFromCGFloat(CGFloat cgFloat)28static inline SkScalar SkScalarFromCGFloat(CGFloat cgFloat) { 29 return CGFLOAT_IS_DOUBLE ? SkDoubleToScalar(cgFloat) : SkFloatToScalar(cgFloat); 30 } 31 SkFloatFromCGFloat(CGFloat cgFloat)32static inline float SkFloatFromCGFloat(CGFloat cgFloat) { 33 return CGFLOAT_IS_DOUBLE ? static_cast<float>(cgFloat) : cgFloat; 34 } 35 36 #endif 37 #endif //SkCGBase_DEFINED 38