SkPreConfig.h revision fbfcd5602128ec010c82cb733c9cdc0a3254f9f3
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_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          defined(__GLIBC__) || defined(__GNU__)
40        #define SK_BUILD_FOR_UNIX
41    #elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
42        #define SK_BUILD_FOR_IOS
43    #else
44        #define SK_BUILD_FOR_MAC
45    #endif
46
47#endif
48
49/* Even if the user only defined the NDK variant we still need to build
50 * the default Android code. Therefore, when attempting to include/exclude
51 * something from the NDK variant check first that we are building for
52 * Android then check the status of the NDK define.
53 */
54#if defined(SK_BUILD_FOR_ANDROID_NDK) && !defined(SK_BUILD_FOR_ANDROID)
55    #define SK_BUILD_FOR_ANDROID
56#endif
57
58//////////////////////////////////////////////////////////////////////
59
60#if !defined(SK_DEBUG) && !defined(SK_RELEASE)
61    #ifdef NDEBUG
62        #define SK_RELEASE
63    #else
64        #define SK_DEBUG
65    #endif
66#endif
67
68#ifdef SK_BUILD_FOR_WIN32
69    #if !defined(SK_RESTRICT)
70        #define SK_RESTRICT __restrict
71    #endif
72    #if !defined(SK_WARN_UNUSED_RESULT)
73        #define SK_WARN_UNUSED_RESULT
74    #endif
75    #include "sk_stdint.h"
76#endif
77
78//////////////////////////////////////////////////////////////////////
79
80#if !defined(SK_RESTRICT)
81    #define SK_RESTRICT __restrict__
82#endif
83
84#if !defined(SK_WARN_UNUSED_RESULT)
85    #define SK_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
86#endif
87
88//////////////////////////////////////////////////////////////////////
89
90#if !defined(SK_SCALAR_IS_FLOAT) && !defined(SK_SCALAR_IS_FIXED)
91    #define SK_SCALAR_IS_FLOAT
92#endif
93
94//////////////////////////////////////////////////////////////////////
95
96#if !defined(SK_CPU_BENDIAN) && !defined(SK_CPU_LENDIAN)
97    #if defined (__ppc__) || defined(__ppc64__)
98        #define SK_CPU_BENDIAN
99    #else
100        #define SK_CPU_LENDIAN
101    #endif
102#endif
103
104//////////////////////////////////////////////////////////////////////
105
106/**
107 *  SK_CPU_SSE_LEVEL
108 *
109 *  If defined, SK_CPU_SSE_LEVEL should be set to the highest supported level.
110 *  On non-intel CPU this should be undefined.
111 */
112
113#define SK_CPU_SSE_LEVEL_SSE1     10
114#define SK_CPU_SSE_LEVEL_SSE2     20
115#define SK_CPU_SSE_LEVEL_SSE3     30
116#define SK_CPU_SSE_LEVEL_SSSE3    31
117
118// Are we in GCC?
119#ifndef SK_CPU_SSE_LEVEL
120    #if defined(__SSE2__)
121        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE2
122    #elif defined(__SSE3__)
123        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE3
124    #elif defined(__SSSE3__)
125        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSSE3
126    #endif
127#endif
128
129// Are we in VisualStudio?
130#ifndef SK_CPU_SSE_LEVEL
131    #if _M_IX86_FP == 1
132        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE1
133    #elif _M_IX86_FP >= 2
134        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE2
135    #endif
136#endif
137
138// 64bit intel guarantees at least SSE2
139#if defined(__x86_64__) || defined(_WIN64)
140    #if !defined(SK_CPU_SSE_LEVEL) || (SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SSE2)
141        #undef SK_CPU_SSE_LEVEL
142        #define SK_CPU_SSE_LEVEL    SK_CPU_SSE_LEVEL_SSE2
143    #endif
144#endif
145
146//////////////////////////////////////////////////////////////////////
147
148/**
149 *  THUMB is the only known config where we avoid small branches in
150 *  favor of more complex math.
151 */
152#if !(defined(__arm__) && defined(__thumb__))
153    #define SK_CPU_HAS_CONDITIONAL_INSTR
154#endif
155
156//////////////////////////////////////////////////////////////////////
157
158#if !defined(SKIA_IMPLEMENTATION)
159    #define SKIA_IMPLEMENTATION 0
160#endif
161
162#if defined(SKIA_DLL)
163    #if defined(WIN32)
164        #if SKIA_IMPLEMENTATION
165            #define SK_API __declspec(dllexport)
166        #else
167            #define SK_API __declspec(dllimport)
168        #endif
169    #else
170        #define SK_API __attribute__((visibility("default")))
171    #endif
172#else
173    #define SK_API
174#endif
175
176//////////////////////////////////////////////////////////////////////
177
178/**
179 * Use SK_PURE_FUNC as an attribute to indicate that a function's
180 * return value only depends on the value of its parameters. This
181 * can help the compiler optimize out successive calls.
182 *
183 * Usage:
184 *      void  function(int params)  SK_PURE_FUNC;
185 */
186#if defined(__GNUC__)
187#  define  SK_PURE_FUNC  __attribute__((pure))
188#else
189#  define  SK_PURE_FUNC  /* nothing */
190#endif
191
192#endif
193
194