1 // [Blend2D] 2 // 2D Vector Graphics Powered by a JIT Compiler. 3 // 4 // [License] 5 // ZLIB - See LICENSE.md file in the package. 6 7 // This is an internal header file that is always included first by each source 8 // file. This means that any macros we might need to define to build 'blend2d' 9 // can be defined here instead of passing them to the compiler through command 10 // line. 11 12 #ifndef BLEND2D_API_BUILD_P_H 13 #define BLEND2D_API_BUILD_P_H 14 15 // ============================================================================ 16 // [Build - Configuration] 17 // ============================================================================ 18 19 // ---------------------------------------------------------------------------- 20 // Disable most of compiler intrinsics used by Blend2D. Disabling them is only 21 // useful for testing fallback functions as these intrinsics improve performance 22 // in general. 23 // 24 // #define BL_BUILD_NO_INTRINSICS 25 // ---------------------------------------------------------------------------- 26 27 // ---------------------------------------------------------------------------- 28 // Disable built-in statistics that is used to trace `BLFont`, `BLImage`, 29 // and `BLPath`, in addition to allocations that are normally available in 30 // `BLRuntimeMemoryInfo` and can be queried through `BLRuntime`. These statistics 31 // use atomic operations so there shouldn't be reason to disable them. 32 // 33 // #define BL_BUILD_NO_STATISTICS 34 // ---------------------------------------------------------------------------- 35 36 // Blend2D provides traces that can be enabled during development. Traces can 37 // help to understand how certain things work and can be used to track bugs. 38 39 // #define BL_TRACE_OT_ALL // Trace OpenType features (all). 40 // #define BL_TRACE_OT_CFF // Trace OpenType CFF|CFF2 ('CFF ', 'CFF2). 41 // #define BL_TRACE_OT_CORE // Trace OpenType core ('OS/2', 'head', 'maxp', 'post'). 42 // #define BL_TRACE_OT_KERN // Trace OpenType kerning ('kern'). 43 // #define BL_TRACE_OT_LAYOUT // Trace OpenType layout ('BASE', 'GDEF', 'GPOS', 'GSUB', 'JSTF'). 44 // #define BL_TRACE_OT_NAME // Trace OpenType name ('name'). 45 46 // ============================================================================ 47 // [Build - Requirements] 48 // ============================================================================ 49 50 //! \cond NEVER 51 52 // Turn off deprecation warnings when building 'blend2d'. Required as <blend2d.h> 53 // and other headers include some essential C headers that could in some cases 54 // warn about using functions such as `snprintf()`, which we use correctly. 55 #ifdef _MSC_VER 56 #if !defined(_CRT_SECURE_NO_DEPRECATE) 57 #define _CRT_SECURE_NO_DEPRECATE 58 #endif 59 #if !defined(_CRT_SECURE_NO_WARNINGS) 60 #define _CRT_SECURE_NO_WARNINGS 61 #endif 62 #endif 63 64 #if defined(_WIN32) && !defined(_WIN32_WINNT) 65 #define _WIN32_WINNT 0x0600 66 #endif 67 68 // The FileSystem API works fully with 64-bit file sizes and offsets, 69 // however, this feature must be enabled before including any header. 70 #if !defined(_WIN32) && !defined(_LARGEFILE64_SOURCE) 71 #define _LARGEFILE64_SOURCE 1 72 #endif 73 74 // The FileSystem API supports extensions offered by Linux. 75 #if defined(__linux__) && !defined(_GNU_SOURCE) 76 #define _GNU_SOURCE 77 #endif 78 79 //! \endcond 80 81 // ============================================================================ 82 // [Build - Compiler Diagnostics] 83 // ============================================================================ 84 85 //! \cond NEVER 86 87 #if defined(__INTEL_COMPILER) 88 // Not regularly tested. 89 #elif defined(_MSC_VER) 90 #pragma warning(disable: 4102) // unreferenced label 91 #pragma warning(disable: 4127) // conditional expression is constant 92 #pragma warning(disable: 4201) // nameless struct/union 93 #pragma warning(disable: 4251) // struct needs to have dll-interface 94 #pragma warning(disable: 4275) // non dll-interface struct ... used 95 #pragma warning(disable: 4324) // structure was padded due to alignment specifier 96 #pragma warning(disable: 4355) // this used in base member-init list 97 #pragma warning(disable: 4480) // specifying underlying type for enum 98 #pragma warning(disable: 4505) // unreferenced local function has been removed 99 #pragma warning(disable: 4800) // forcing value to bool true or false 100 #elif defined(__clang__) 101 #pragma clang diagnostic ignored "-Wconstant-logical-operand" 102 #pragma clang diagnostic ignored "-Wunnamed-type-template-args" 103 #pragma clang diagnostic ignored "-Wunused-function" 104 #pragma clang diagnostic ignored "-Wswitch" 105 #pragma clang diagnostic warning "-Wattributes" 106 #elif defined(__GNUC__) 107 #pragma GCC diagnostic ignored "-Wenum-compare" 108 #pragma GCC diagnostic ignored "-Wunused-function" 109 #pragma GCC diagnostic ignored "-Wswitch" 110 #pragma GCC diagnostic warning "-Wattributes" 111 #if (__GNUC__ == 4) 112 // GCC 4 has kinda broken diagnostic in this case, GCC 5+ is okay. 113 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" 114 #endif 115 #if (__GNUC__ >= 7) 116 #pragma GCC diagnostic ignored "-Wint-in-bool-context" 117 #endif 118 #if (__GNUC__ >= 8) 119 #pragma GCC diagnostic ignored "-Wclass-memaccess" 120 #endif 121 #endif 122 123 //! \endcond 124 125 // ============================================================================ 126 // [Build - Target Architecture & Optimizations] 127 // ============================================================================ 128 129 //! \cond INTERNAL 130 //! \addtogroup blend2d_internal 131 //! \{ 132 133 #if defined(_M_X64) || defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) 134 #define BL_TARGET_ARCH_X86 64 135 #elif defined(_M_IX86) || defined(__i386) || defined(__i386__) 136 #define BL_TARGET_ARCH_X86 32 137 #else 138 #define BL_TARGET_ARCH_X86 0 139 #endif 140 141 #if defined(__ARM64__) || defined(__aarch64__) 142 #define BL_TARGET_ARCH_ARM 64 143 #elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__) || defined(__thumb2__) 144 #define BL_TARGET_ARCH_ARM 32 145 #else 146 #define BL_TARGET_ARCH_ARM 0 147 #endif 148 149 #if defined(_MIPS_ARCH_MIPS64) || defined(__mips64) 150 #define BL_TARGET_ARCH_MIPS 64 151 #elif defined(_MIPS_ARCH_MIPS32) || defined(_M_MRX000) || defined(__mips) || defined(__mips__) 152 #define BL_TARGET_ARCH_MIPS 32 153 #else 154 #define BL_TARGET_ARCH_MIPS 0 155 #endif 156 157 #define BL_TARGET_ARCH_BITS (BL_TARGET_ARCH_X86 | BL_TARGET_ARCH_ARM | BL_TARGET_ARCH_MIPS) 158 #if BL_TARGET_ARCH_BITS == 0 159 #undef BL_TARGET_ARCH_BITS 160 #if defined (__LP64__) || defined(_LP64) 161 #define BL_TARGET_ARCH_BITS 64 162 #else 163 #define BL_TARGET_ARCH_BITS 32 164 #endif 165 #endif 166 167 // Build optimizations control compile-time optimizations to be used by Blend2D 168 // and C++ compiler. These optimizations are not related to the code-generator 169 // optimizations (JIT) that are always auto-detected at runtime. 170 #if defined(BL_BUILD_OPT_AVX2) && !defined(BL_BUILD_OPT_AVX) 171 #define BL_BUILD_OPT_AVX 172 #endif 173 #if defined(BL_BUILD_OPT_AVX) && !defined(BL_BUILD_OPT_SSE4_2) 174 #define BL_BUILD_OPT_SSE4_2 175 #endif 176 #if defined(BL_BUILD_OPT_SSE4_2) && !defined(BL_BUILD_OPT_SSE4_1) 177 #define BL_BUILD_OPT_SSE4_1 178 #endif 179 #if defined(BL_BUILD_OPT_SSE4_1) && !defined(BL_BUILD_OPT_SSSE3) 180 #define BL_BUILD_OPT_SSSE3 181 #endif 182 #if defined(BL_BUILD_OPT_SSSE3) && !defined(BL_BUILD_OPT_SSE3) 183 #define BL_BUILD_OPT_SSE3 184 #endif 185 #if defined(BL_BUILD_OPT_SSE3) && !defined(BL_BUILD_OPT_SSE2) 186 #define BL_BUILD_OPT_SSE2 187 #endif 188 189 #if defined(__AVX2__) 190 #define BL_TARGET_OPT_AVX2 191 #endif 192 #if defined(BL_TARGET_OPT_AVX2) || defined(__AVX__) 193 #define BL_TARGET_OPT_AVX 194 #endif 195 #if defined(BL_TARGET_OPT_AVX) || defined(__SSE4_2__) 196 #define BL_TARGET_OPT_SSE4_2 197 #endif 198 #if defined(BL_TARGET_OPT_SSE4_2) || defined(__SSE4_1__) 199 #define BL_TARGET_OPT_SSE4_1 200 #endif 201 #if defined(BL_TARGET_OPT_SSE4_1) || defined(__SSSE3__) 202 #define BL_TARGET_OPT_SSSE3 203 #endif 204 #if defined(BL_TARGET_OPT_SSSE3) || defined(__SSE3__) 205 #define BL_TARGET_OPT_SSE3 206 #endif 207 #if defined(BL_TARGET_OPT_SSE3) || (BL_TARGET_ARCH_X86 == 64 || defined(__SSE2__) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2)) 208 #define BL_TARGET_OPT_SSE2 209 #endif 210 #if defined(BL_TARGET_OPT_SSE2) || (BL_TARGET_ARCH_X86 == 64 || defined(__SSE__) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1)) 211 #define BL_TARGET_OPT_SSE 212 #endif 213 214 #if defined(BL_TARGET_OPT_SSE4_2) || defined(__POPCNT__) 215 #define BL_TARGET_OPT_POPCNT 216 #endif 217 218 #if BL_TARGET_ARCH_ARM && defined(__ARM_NEON__) 219 #define BL_TARGET_OPT_NEON 220 #endif 221 222 // ============================================================================ 223 // [Build - Configuration Autodetection] 224 // ============================================================================ 225 226 // Don't build PipeGen at all if the host architecture doesn't support 227 // instruction sets required. 228 #if !defined(BL_BUILD_NO_PIPEGEN) && BL_TARGET_ARCH_X86 == 0 229 #define BL_BUILD_NO_PIPEGEN 230 #endif 231 232 // Make sure we build either PipeGen or FixedPipe, but not both. 233 #if defined(BL_BUILD_NO_PIPEGEN) 234 #if defined(BL_BUILD_NO_FIXED_PIPE) 235 #undef BL_BUILD_NO_FIXED_PIPE 236 #endif 237 #else 238 #if !defined(BL_BUILD_NO_FIXED_PIPE) 239 #define BL_BUILD_NO_FIXED_PIPE 240 #endif 241 #endif 242 243 // ============================================================================ 244 // [Build - Tests] 245 // ============================================================================ 246 247 //! \cond NEVER 248 249 // Make sure '#ifdef'ed unit tests are not disabled by IDE. 250 #ifndef BL_TEST 251 #if defined(__INTELLISENSE__) 252 #define BL_TEST 253 #endif 254 #endif 255 256 // Include a unit testing package if this is a `blend2d_test_unit` build. 257 #if defined(BL_TEST) 258 #include "../../test/broken.h" 259 #endif 260 261 //! \endcond 262 263 // ============================================================================ 264 // [Build - Export] 265 // ============================================================================ 266 267 //! \cond INTERNAL 268 269 //! Export mode is on when `BL_BUILD_EXPORT` is defined - this MUST be defined 270 //! before including any other header as "blapi.h" uses `BL_BUILD_EXPORT` to 271 //! define a proper `BL_API` decorator that is used by all exported functions 272 //! and variables. 273 #define BL_BUILD_EXPORT 274 275 //! \endcond 276 277 // ============================================================================ 278 // [Dependencies] 279 // ============================================================================ 280 281 #include "./api.h" 282 #include "./api-impl.h" 283 #include "./api-internal_p.h" 284 285 #endif // BLEND2D_API_BUILD_P_H 286