SkPreConfig.h revision 00aad94f01a9078d26363db3116f8005d84440f2
1
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef SkPreConfig_DEFINED
11#define SkPreConfig_DEFINED
12
13#ifdef WEBKIT_VERSION_MIN_REQUIRED
14    #include "config.h"
15#endif
16
17//////////////////////////////////////////////////////////////////////
18
19#if !defined(SK_BUILD_FOR_ANDROID) && !defined(SK_BUILD_FOR_ANDROID_NDK) && !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_PALM) && !defined(SK_BUILD_FOR_WINCE) && !defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_SYMBIAN) && !defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_SDL) && !defined(SK_BUILD_FOR_BREW)
20
21    #ifdef __APPLE__
22        #include "TargetConditionals.h"
23    #endif
24
25    #if defined(PALMOS_SDK_VERSION)
26        #define SK_BUILD_FOR_PALM
27    #elif defined(UNDER_CE)
28        #define SK_BUILD_FOR_WINCE
29    #elif defined(WIN32)
30        #define SK_BUILD_FOR_WIN32
31    #elif defined(__SYMBIAN32__)
32        #define SK_BUILD_FOR_WIN32
33    #elif defined(ANDROID_NDK)
34        #define SK_BUILD_FOR_ANDROID_NDK
35    #elif defined(ANDROID)
36        #define SK_BUILD_FOR_ANDROID
37    #elif defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
38          defined(__sun) || defined(__NetBSD__) || defined(__DragonFly__)
39        #define SK_BUILD_FOR_UNIX
40    #elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
41        #define SK_BUILD_FOR_IOS
42    #else
43        #define SK_BUILD_FOR_MAC
44    #endif
45
46#endif
47
48/* Even if the user only defined the NDK variant we still need to build
49 * the default Android code. Therefore, when attempting to include/exclude
50 * something from the NDK variant check first that we are building for
51 * Android then check the status of the NDK define.
52 */
53#if defined(SK_BUILD_FOR_ANDROID_NDK) && !defined(SK_BUILD_FOR_ANDROID)
54    #define SK_BUILD_FOR_ANDROID
55#endif
56
57//////////////////////////////////////////////////////////////////////
58
59#if !defined(SK_DEBUG) && !defined(SK_RELEASE)
60    #ifdef NDEBUG
61        #define SK_RELEASE
62    #else
63        #define SK_DEBUG
64    #endif
65#endif
66
67#ifdef SK_BUILD_FOR_WIN32
68    #if !defined(SK_RESTRICT)
69        #define SK_RESTRICT __restrict
70    #endif
71    #if !defined(SK_WARN_UNUSED_RESULT)
72        #define SK_WARN_UNUSED_RESULT
73    #endif
74    #include "sk_stdint.h"
75#endif
76
77//////////////////////////////////////////////////////////////////////
78
79#if !defined(SK_RESTRICT)
80    #define SK_RESTRICT __restrict__
81#endif
82
83#if !defined(SK_WARN_UNUSED_RESULT)
84    #define SK_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
85#endif
86
87//////////////////////////////////////////////////////////////////////
88
89#if !defined(SK_SCALAR_IS_FLOAT) && !defined(SK_SCALAR_IS_FIXED)
90    #define SK_SCALAR_IS_FLOAT
91#endif
92
93//////////////////////////////////////////////////////////////////////
94
95#if !defined(SK_CPU_BENDIAN) && !defined(SK_CPU_LENDIAN)
96    #if defined (__ppc__) || defined(__ppc64__)
97        #define SK_CPU_BENDIAN
98    #else
99        #define SK_CPU_LENDIAN
100    #endif
101#endif
102
103//////////////////////////////////////////////////////////////////////
104
105/**
106 *  SK_CPU_SSE_LEVEL
107 *
108 *  If defined, SK_CPU_SSE_LEVEL should be set to the highest supported level.
109 *  On non-intel CPU this should be undefined.
110 */
111
112#define SK_CPU_SSE_LEVEL_SSE1     10
113#define SK_CPU_SSE_LEVEL_SSE2     20
114#define SK_CPU_SSE_LEVEL_SSE3     30
115#define SK_CPU_SSE_LEVEL_SSSE3    31
116
117// Are we in GCC?
118#ifndef SK_CPU_SSE_LEVEL
119    #if defined(__SSE2__)
120        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE2
121    #elif defined(__SSE3__)
122        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE3
123    #elif defined(__SSSE3__)
124        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSSE3
125    #endif
126#endif
127
128// Are we in VisualStudio?
129#ifndef SK_CPU_SSE_LEVEL
130    #if _M_IX86_FP == 1
131        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE1
132    #elif _M_IX86_FP >= 2
133        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE2
134    #endif
135#endif
136
137// 64bit intel guarantees at least SSE2
138#if defined(__x86_64__) || defined(_WIN64)
139    #if !defined(SK_CPU_SSE_LEVEL) || (SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SSE2)
140        #undef SK_CPU_SSE_LEVEL
141        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE2
142    #endif
143#endif
144
145//////////////////////////////////////////////////////////////////////
146
147#if (defined(__arm__) && !defined(__thumb__)) || defined(SK_BUILD_FOR_WINCE) || (defined(SK_BUILD_FOR_SYMBIAN) && !defined(__MARM_THUMB__))
148    /* e.g. the ARM instructions have conditional execution, making tiny branches cheap */
149    #define SK_CPU_HAS_CONDITIONAL_INSTR
150#endif
151
152//////////////////////////////////////////////////////////////////////
153
154#if !defined(SKIA_IMPLEMENTATION)
155    #define SKIA_IMPLEMENTATION 0
156#endif
157
158#if defined(SKIA_DLL)
159    #if defined(WIN32)
160        #if SKIA_IMPLEMENTATION
161            #define SK_API __declspec(dllexport)
162        #else
163            #define SK_API __declspec(dllimport)
164        #endif
165    #else
166        #define SK_API __attribute__((visibility("default")))
167    #endif
168#else
169    #define SK_API
170#endif
171
172#endif
173
174