1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/core/SkPreConfig.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,241 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkPreConfig_DEFINED 1.14 +#define SkPreConfig_DEFINED 1.15 + 1.16 +#ifdef WEBKIT_VERSION_MIN_REQUIRED 1.17 + #include "config.h" 1.18 +#endif 1.19 + 1.20 +// Allows embedders that want to disable macros that take arguments to just 1.21 +// define that symbol to be one of these 1.22 +// 1.23 +#define SK_NOTHING_ARG1(arg1) 1.24 +#define SK_NOTHING_ARG2(arg1, arg2) 1.25 +#define SK_NOTHING_ARG3(arg1, arg2, arg3) 1.26 + 1.27 +////////////////////////////////////////////////////////////////////// 1.28 + 1.29 +#if !defined(SK_BUILD_FOR_ANDROID) && !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) && !defined(SK_BUILD_FOR_NACL) 1.30 + 1.31 + #ifdef __APPLE__ 1.32 + #include "TargetConditionals.h" 1.33 + #endif 1.34 + 1.35 + #if defined(PALMOS_SDK_VERSION) 1.36 + #define SK_BUILD_FOR_PALM 1.37 + #elif defined(UNDER_CE) 1.38 + #define SK_BUILD_FOR_WINCE 1.39 + #elif defined(WIN32) 1.40 + #define SK_BUILD_FOR_WIN32 1.41 + #elif defined(__SYMBIAN32__) 1.42 + #define SK_BUILD_FOR_WIN32 1.43 + #elif defined(ANDROID) 1.44 + #define SK_BUILD_FOR_ANDROID 1.45 + #elif defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ 1.46 + defined(__sun) || defined(__NetBSD__) || defined(__DragonFly__) || \ 1.47 + defined(__GLIBC__) || defined(__GNU__) 1.48 + #define SK_BUILD_FOR_UNIX 1.49 + #elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR 1.50 + #define SK_BUILD_FOR_IOS 1.51 + #else 1.52 + #define SK_BUILD_FOR_MAC 1.53 + #endif 1.54 + 1.55 +#endif 1.56 + 1.57 +/* Even if the user only defined the framework variant we still need to build 1.58 + * the default (NDK-compliant) Android code. Therefore, when attempting to 1.59 + * include/exclude something from the framework variant check first that we are 1.60 + * building for Android then check the status of the framework define. 1.61 + */ 1.62 +#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && !defined(SK_BUILD_FOR_ANDROID) 1.63 + #define SK_BUILD_FOR_ANDROID 1.64 +#endif 1.65 + 1.66 +////////////////////////////////////////////////////////////////////// 1.67 + 1.68 +#if !defined(SK_DEBUG) && !defined(SK_RELEASE) 1.69 + #ifdef NDEBUG 1.70 + #define SK_RELEASE 1.71 + #else 1.72 + #define SK_DEBUG 1.73 + #endif 1.74 +#endif 1.75 + 1.76 +#ifdef SK_BUILD_FOR_WIN32 1.77 + #if !defined(SK_RESTRICT) 1.78 + #define SK_RESTRICT __restrict 1.79 + #endif 1.80 + #if !defined(SK_WARN_UNUSED_RESULT) 1.81 + #define SK_WARN_UNUSED_RESULT 1.82 + #endif 1.83 +#endif 1.84 + 1.85 +////////////////////////////////////////////////////////////////////// 1.86 + 1.87 +#if !defined(SK_RESTRICT) 1.88 + #define SK_RESTRICT __restrict__ 1.89 +#endif 1.90 + 1.91 +#if !defined(SK_WARN_UNUSED_RESULT) 1.92 + #define SK_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 1.93 +#endif 1.94 + 1.95 +////////////////////////////////////////////////////////////////////// 1.96 + 1.97 +#if !defined(SK_CPU_BENDIAN) && !defined(SK_CPU_LENDIAN) 1.98 + #if defined (__ppc__) || defined(__PPC__) || defined(__ppc64__) \ 1.99 + || defined(__PPC64__) 1.100 + #define SK_CPU_BENDIAN 1.101 + #else 1.102 + #define SK_CPU_LENDIAN 1.103 + #endif 1.104 +#endif 1.105 + 1.106 +////////////////////////////////////////////////////////////////////// 1.107 + 1.108 +/** 1.109 + * SK_CPU_SSE_LEVEL 1.110 + * 1.111 + * If defined, SK_CPU_SSE_LEVEL should be set to the highest supported level. 1.112 + * On non-intel CPU this should be undefined. 1.113 + */ 1.114 + 1.115 +#define SK_CPU_SSE_LEVEL_SSE1 10 1.116 +#define SK_CPU_SSE_LEVEL_SSE2 20 1.117 +#define SK_CPU_SSE_LEVEL_SSE3 30 1.118 +#define SK_CPU_SSE_LEVEL_SSSE3 31 1.119 + 1.120 +// Are we in GCC? 1.121 +#ifndef SK_CPU_SSE_LEVEL 1.122 + // These checks must be done in descending order to ensure we set the highest 1.123 + // available SSE level. 1.124 + #if defined(__SSSE3__) 1.125 + #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSSE3 1.126 + #elif defined(__SSE3__) 1.127 + #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSE3 1.128 + #elif defined(__SSE2__) 1.129 + #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSE2 1.130 + #endif 1.131 +#endif 1.132 + 1.133 +// Are we in VisualStudio? 1.134 +#ifndef SK_CPU_SSE_LEVEL 1.135 + // These checks must be done in descending order to ensure we set the highest 1.136 + // available SSE level. 1.137 + #if defined (_M_IX86_FP) 1.138 + #if _M_IX86_FP >= 2 1.139 + #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSE2 1.140 + #elif _M_IX86_FP == 1 1.141 + #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSE1 1.142 + #endif 1.143 + #endif 1.144 +#endif 1.145 + 1.146 +////////////////////////////////////////////////////////////////////// 1.147 +// ARM defines 1.148 + 1.149 +#if defined(__arm__) && (!defined(__APPLE__) || !TARGET_IPHONE_SIMULATOR) 1.150 + #define SK_CPU_ARM 1.151 + 1.152 + #if defined(__GNUC__) 1.153 + #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ 1.154 + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ 1.155 + || defined(__ARM_ARCH_7EM__) || defined(_ARM_ARCH_7) 1.156 + #define SK_ARM_ARCH 7 1.157 + #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ 1.158 + || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ 1.159 + || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \ 1.160 + || defined(__ARM_ARCH_6M__) || defined(_ARM_ARCH_6) 1.161 + #define SK_ARM_ARCH 6 1.162 + #elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \ 1.163 + || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \ 1.164 + || defined(__ARM_ARCH_5TEJ__) || defined(_ARM_ARCH_5) 1.165 + #define SK_ARM_ARCH 5 1.166 + #elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || defined(_ARM_ARCH_4) 1.167 + #define SK_ARM_ARCH 4 1.168 + #else 1.169 + #define SK_ARM_ARCH 3 1.170 + #endif 1.171 + 1.172 + #if defined(__thumb2__) && (SK_ARM_ARCH >= 6) \ 1.173 + || !defined(__thumb__) && ((SK_ARM_ARCH > 5) || defined(__ARM_ARCH_5E__) \ 1.174 + || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)) 1.175 + #define SK_ARM_HAS_EDSP 1.176 + #endif 1.177 + #endif 1.178 +#endif 1.179 + 1.180 +////////////////////////////////////////////////////////////////////// 1.181 + 1.182 +#if !defined(SKIA_IMPLEMENTATION) 1.183 + #define SKIA_IMPLEMENTATION 0 1.184 +#endif 1.185 + 1.186 +#if defined(SKIA_DLL) 1.187 + #if defined(WIN32) 1.188 + #if SKIA_IMPLEMENTATION 1.189 + #define SK_API __declspec(dllexport) 1.190 + #else 1.191 + #define SK_API __declspec(dllimport) 1.192 + #endif 1.193 + #else 1.194 + #define SK_API __attribute__((visibility("default"))) 1.195 + #endif 1.196 +#else 1.197 + #define SK_API 1.198 +#endif 1.199 + 1.200 +////////////////////////////////////////////////////////////////////// 1.201 + 1.202 +/** 1.203 + * Use SK_PURE_FUNC as an attribute to indicate that a function's 1.204 + * return value only depends on the value of its parameters. This 1.205 + * can help the compiler optimize out successive calls. 1.206 + * 1.207 + * Usage: 1.208 + * void function(int params) SK_PURE_FUNC; 1.209 + */ 1.210 +#if defined(__GNUC__) 1.211 +# define SK_PURE_FUNC __attribute__((pure)) 1.212 +#else 1.213 +# define SK_PURE_FUNC /* nothing */ 1.214 +#endif 1.215 + 1.216 +////////////////////////////////////////////////////////////////////// 1.217 + 1.218 +/** 1.219 + * SK_HAS_ATTRIBUTE(<name>) should return true iff the compiler 1.220 + * supports __attribute__((<name>)). Mostly important because 1.221 + * Clang doesn't support all of GCC attributes. 1.222 + */ 1.223 +#if defined(__has_attribute) 1.224 +# define SK_HAS_ATTRIBUTE(x) __has_attribute(x) 1.225 +#elif defined(__GNUC__) 1.226 +# define SK_HAS_ATTRIBUTE(x) 1 1.227 +#else 1.228 +# define SK_HAS_ATTRIBUTE(x) 0 1.229 +#endif 1.230 + 1.231 +/** 1.232 + * SK_ATTRIBUTE_OPTIMIZE_O1 can be used as a function attribute 1.233 + * to specify individual optimization level of -O1, if the compiler 1.234 + * supports it. 1.235 + * 1.236 + * NOTE: Clang/ARM (r161757) does not support the 'optimize' attribute. 1.237 + */ 1.238 +#if SK_HAS_ATTRIBUTE(optimize) 1.239 +# define SK_ATTRIBUTE_OPTIMIZE_O1 __attribute__((optimize("O1"))) 1.240 +#else 1.241 +# define SK_ATTRIBUTE_OPTIMIZE_O1 /* nothing */ 1.242 +#endif 1.243 + 1.244 +#endif