summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/utils/mac/SkCGBase.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/skia/skia/src/utils/mac/SkCGBase.h')
-rw-r--r--gfx/skia/skia/src/utils/mac/SkCGBase.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/utils/mac/SkCGBase.h b/gfx/skia/skia/src/utils/mac/SkCGBase.h
new file mode 100644
index 0000000000..a7b0ed06d0
--- /dev/null
+++ b/gfx/skia/skia/src/utils/mac/SkCGBase.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCGBase_DEFINED
+#define SkCGBase_DEFINED
+
+#include "include/core/SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
+#ifdef SK_BUILD_FOR_MAC
+#import <ApplicationServices/ApplicationServices.h>
+#endif
+
+#ifdef SK_BUILD_FOR_IOS
+#include <CoreGraphics/CoreGraphics.h>
+#endif
+
+// Skia extensions for types in CGBase.h
+
+static inline CGFloat SkScalarToCGFloat(SkScalar scalar) {
+ return CGFLOAT_IS_DOUBLE ? SkScalarToDouble(scalar) : SkScalarToFloat(scalar);
+}
+
+static inline SkScalar SkScalarFromCGFloat(CGFloat cgFloat) {
+ return CGFLOAT_IS_DOUBLE ? SkDoubleToScalar(cgFloat) : SkFloatToScalar(cgFloat);
+}
+
+static inline float SkFloatFromCGFloat(CGFloat cgFloat) {
+ return CGFLOAT_IS_DOUBLE ? static_cast<float>(cgFloat) : cgFloat;
+}
+
+#endif
+#endif //SkCGBase_DEFINED