gfx/skia/trunk/include/core/SkPostConfig.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2006 The Android Open Source Project
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkPostConfig_DEFINED
michael@0 9 #define SkPostConfig_DEFINED
michael@0 10
michael@0 11 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE)
michael@0 12 # define SK_BUILD_FOR_WIN
michael@0 13 #endif
michael@0 14
michael@0 15 #if defined(SK_DEBUG) && defined(SK_RELEASE)
michael@0 16 # error "cannot define both SK_DEBUG and SK_RELEASE"
michael@0 17 #elif !defined(SK_DEBUG) && !defined(SK_RELEASE)
michael@0 18 # error "must define either SK_DEBUG or SK_RELEASE"
michael@0 19 #endif
michael@0 20
michael@0 21 #if defined(SK_SUPPORT_UNITTEST) && !defined(SK_DEBUG)
michael@0 22 # error "can't have unittests without debug"
michael@0 23 #endif
michael@0 24
michael@0 25 /**
michael@0 26 * Matrix calculations may be float or double.
michael@0 27 * The default is double, as that is faster given our impl uses doubles
michael@0 28 * for intermediate calculations.
michael@0 29 */
michael@0 30 #if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT)
michael@0 31 # error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT"
michael@0 32 #elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT)
michael@0 33 # define SK_MSCALAR_IS_DOUBLE
michael@0 34 #endif
michael@0 35
michael@0 36 #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
michael@0 37 # error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
michael@0 38 #elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
michael@0 39 # error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
michael@0 40 #endif
michael@0 41
michael@0 42 /**
michael@0 43 * Ensure the port has defined all of SK_X32_SHIFT, or none of them.
michael@0 44 */
michael@0 45 #ifdef SK_A32_SHIFT
michael@0 46 # if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT)
michael@0 47 # error "all or none of the 32bit SHIFT amounts must be defined"
michael@0 48 # endif
michael@0 49 #else
michael@0 50 # if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT)
michael@0 51 # error "all or none of the 32bit SHIFT amounts must be defined"
michael@0 52 # endif
michael@0 53 #endif
michael@0 54
michael@0 55 #if !defined(SK_HAS_COMPILER_FEATURE)
michael@0 56 # if defined(__has_feature)
michael@0 57 # define SK_HAS_COMPILER_FEATURE(x) __has_feature(x)
michael@0 58 # else
michael@0 59 # define SK_HAS_COMPILER_FEATURE(x) 0
michael@0 60 # endif
michael@0 61 #endif
michael@0 62
michael@0 63 #if !defined(SK_ATTRIBUTE)
michael@0 64 # if defined(__clang__) || defined(__GNUC__)
michael@0 65 # define SK_ATTRIBUTE(attr) __attribute__((attr))
michael@0 66 # else
michael@0 67 # define SK_ATTRIBUTE(attr)
michael@0 68 # endif
michael@0 69 #endif
michael@0 70
michael@0 71 #if !defined(SK_SUPPORT_GPU)
michael@0 72 # define SK_SUPPORT_GPU 1
michael@0 73 #endif
michael@0 74
michael@0 75 /**
michael@0 76 * The clang static analyzer likes to know that when the program is not
michael@0 77 * expected to continue (crash, assertion failure, etc). It will notice that
michael@0 78 * some combination of parameters lead to a function call that does not return.
michael@0 79 * It can then make appropriate assumptions about the parameters in code
michael@0 80 * executed only if the non-returning function was *not* called.
michael@0 81 */
michael@0 82 #if !defined(SkNO_RETURN_HINT)
michael@0 83 # if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn)
michael@0 84 static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn));
michael@0 85 static inline void SkNO_RETURN_HINT() {}
michael@0 86 # else
michael@0 87 # define SkNO_RETURN_HINT() do {} while (false)
michael@0 88 # endif
michael@0 89 #endif
michael@0 90
michael@0 91 #if defined(SK_ZLIB_INCLUDE) && defined(SK_SYSTEM_ZLIB)
michael@0 92 # error "cannot define both SK_ZLIB_INCLUDE and SK_SYSTEM_ZLIB"
michael@0 93 #elif defined(SK_ZLIB_INCLUDE) || defined(SK_SYSTEM_ZLIB)
michael@0 94 # define SK_HAS_ZLIB
michael@0 95 #endif
michael@0 96
michael@0 97 ///////////////////////////////////////////////////////////////////////////////
michael@0 98
michael@0 99 #ifndef SkNEW
michael@0 100 # define SkNEW(type_name) (new type_name)
michael@0 101 # define SkNEW_ARGS(type_name, args) (new type_name args)
michael@0 102 # define SkNEW_ARRAY(type_name, count) (new type_name[(count)])
michael@0 103 # define SkNEW_PLACEMENT(buf, type_name) (new (buf) type_name)
michael@0 104 # define SkNEW_PLACEMENT_ARGS(buf, type_name, args) (new (buf) type_name args)
michael@0 105 # define SkDELETE(obj) (delete (obj))
michael@0 106 # define SkDELETE_ARRAY(array) (delete[] (array))
michael@0 107 #endif
michael@0 108
michael@0 109 #ifndef SK_CRASH
michael@0 110 # if 1 // set to 0 for infinite loop, which can help connecting gdb
michael@0 111 # define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false)
michael@0 112 # else
michael@0 113 # define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true)
michael@0 114 # endif
michael@0 115 #endif
michael@0 116
michael@0 117 ///////////////////////////////////////////////////////////////////////////////
michael@0 118
michael@0 119 /**
michael@0 120 * SK_ENABLE_INST_COUNT controlls printing how many reference counted objects
michael@0 121 * are still held on exit.
michael@0 122 * Defaults to 1 in DEBUG and 0 in RELEASE.
michael@0 123 */
michael@0 124 #ifndef SK_ENABLE_INST_COUNT
michael@0 125 # ifdef SK_DEBUG
michael@0 126 // Only enabled for static builds, because instance counting relies on static
michael@0 127 // variables in functions defined in header files.
michael@0 128 # define SK_ENABLE_INST_COUNT !defined(SKIA_DLL)
michael@0 129 # else
michael@0 130 # define SK_ENABLE_INST_COUNT 0
michael@0 131 # endif
michael@0 132 #endif
michael@0 133
michael@0 134 ///////////////////////////////////////////////////////////////////////////////
michael@0 135
michael@0 136 #ifdef SK_BUILD_FOR_WIN
michael@0 137 # ifndef WIN32_LEAN_AND_MEAN
michael@0 138 # define WIN32_LEAN_AND_MEAN
michael@0 139 # define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
michael@0 140 # endif
michael@0 141 # ifndef NOMINMAX
michael@0 142 # define NOMINMAX
michael@0 143 # define NOMINMAX_WAS_LOCALLY_DEFINED
michael@0 144 # endif
michael@0 145 #
michael@0 146 # include <windows.h>
michael@0 147 #
michael@0 148 # ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
michael@0 149 # undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
michael@0 150 # undef WIN32_LEAN_AND_MEAN
michael@0 151 # endif
michael@0 152 # ifdef NOMINMAX_WAS_LOCALLY_DEFINED
michael@0 153 # undef NOMINMAX_WAS_LOCALLY_DEFINED
michael@0 154 # undef NOMINMAX
michael@0 155 # endif
michael@0 156 #
michael@0 157 # ifndef SK_DEBUGBREAK
michael@0 158 # define SK_DEBUGBREAK(p) do { if (!(p)) { SkNO_RETURN_HINT(); __debugbreak(); }} while (false)
michael@0 159 # endif
michael@0 160 #
michael@0 161 # ifndef SK_A32_SHIFT
michael@0 162 # define SK_A32_SHIFT 24
michael@0 163 # define SK_R32_SHIFT 16
michael@0 164 # define SK_G32_SHIFT 8
michael@0 165 # define SK_B32_SHIFT 0
michael@0 166 # endif
michael@0 167 #
michael@0 168 #else
michael@0 169 # ifdef SK_DEBUG
michael@0 170 # include <stdio.h>
michael@0 171 # ifndef SK_DEBUGBREAK
michael@0 172 # define SK_DEBUGBREAK(cond) do { if (cond) break; \
michael@0 173 SkDebugf("%s:%d: failed assertion \"%s\"\n", \
michael@0 174 __FILE__, __LINE__, #cond); SK_CRASH(); } while (false)
michael@0 175 # endif
michael@0 176 # endif
michael@0 177 #endif
michael@0 178
michael@0 179 /**
michael@0 180 * We check to see if the SHIFT value has already been defined.
michael@0 181 * if not, we define it ourself to some default values. We default to OpenGL
michael@0 182 * order (in memory: r,g,b,a)
michael@0 183 */
michael@0 184 #ifndef SK_A32_SHIFT
michael@0 185 # ifdef SK_CPU_BENDIAN
michael@0 186 # define SK_R32_SHIFT 24
michael@0 187 # define SK_G32_SHIFT 16
michael@0 188 # define SK_B32_SHIFT 8
michael@0 189 # define SK_A32_SHIFT 0
michael@0 190 # else
michael@0 191 # define SK_R32_SHIFT 0
michael@0 192 # define SK_G32_SHIFT 8
michael@0 193 # define SK_B32_SHIFT 16
michael@0 194 # define SK_A32_SHIFT 24
michael@0 195 # endif
michael@0 196 #endif
michael@0 197
michael@0 198 /**
michael@0 199 * SkColor has well defined shift values, but SkPMColor is configurable. This
michael@0 200 * macro is a convenience that returns true if the shift values are equal while
michael@0 201 * ignoring the machine's endianness.
michael@0 202 */
michael@0 203 #define SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER \
michael@0 204 (SK_A32_SHIFT == 24 && SK_R32_SHIFT == 16 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 0)
michael@0 205
michael@0 206 /**
michael@0 207 * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time. The
michael@0 208 * relationship between the byte order and shift values depends on machine endianness. If the shift
michael@0 209 * order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R channel on a little
michael@0 210 * endian machine and the A channel on a big endian machine. Thus, given those shifts values,
michael@0 211 * SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and
michael@0 212 * SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine.
michael@0 213 */
michael@0 214 #ifdef SK_CPU_BENDIAN
michael@0 215 # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
michael@0 216 (SK_ ## C3 ## 32_SHIFT == 0 && \
michael@0 217 SK_ ## C2 ## 32_SHIFT == 8 && \
michael@0 218 SK_ ## C1 ## 32_SHIFT == 16 && \
michael@0 219 SK_ ## C0 ## 32_SHIFT == 24)
michael@0 220 #else
michael@0 221 # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
michael@0 222 (SK_ ## C0 ## 32_SHIFT == 0 && \
michael@0 223 SK_ ## C1 ## 32_SHIFT == 8 && \
michael@0 224 SK_ ## C2 ## 32_SHIFT == 16 && \
michael@0 225 SK_ ## C3 ## 32_SHIFT == 24)
michael@0 226 #endif
michael@0 227
michael@0 228 //////////////////////////////////////////////////////////////////////
michael@0 229
michael@0 230 // TODO: rebaseline as needed so we can remove this flag entirely.
michael@0 231 // - all platforms have int64_t now
michael@0 232 // - we have slightly different fixed math results because of this check
michael@0 233 // since we don't define this for linux/android
michael@0 234 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC)
michael@0 235 # ifndef SkLONGLONG
michael@0 236 # define SkLONGLONG int64_t
michael@0 237 # endif
michael@0 238 #endif
michael@0 239
michael@0 240 //////////////////////////////////////////////////////////////////////////////////////////////
michael@0 241 #ifndef SK_BUILD_FOR_WINCE
michael@0 242 # include <string.h>
michael@0 243 # include <stdlib.h>
michael@0 244 #else
michael@0 245 # define _CMNINTRIN_DECLARE_ONLY
michael@0 246 # include "cmnintrin.h"
michael@0 247 #endif
michael@0 248
michael@0 249 #if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32
michael@0 250 # ifdef free
michael@0 251 # undef free
michael@0 252 # endif
michael@0 253 # include <crtdbg.h>
michael@0 254 # undef free
michael@0 255 #
michael@0 256 # ifdef SK_DEBUGx
michael@0 257 # if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus)
michael@0 258 void * operator new(
michael@0 259 size_t cb,
michael@0 260 int nBlockUse,
michael@0 261 const char * szFileName,
michael@0 262 int nLine,
michael@0 263 int foo
michael@0 264 );
michael@0 265 void * operator new[](
michael@0 266 size_t cb,
michael@0 267 int nBlockUse,
michael@0 268 const char * szFileName,
michael@0 269 int nLine,
michael@0 270 int foo
michael@0 271 );
michael@0 272 void operator delete(
michael@0 273 void *pUserData,
michael@0 274 int, const char*, int, int
michael@0 275 );
michael@0 276 void operator delete(
michael@0 277 void *pUserData
michael@0 278 );
michael@0 279 void operator delete[]( void * p );
michael@0 280 # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
michael@0 281 # else
michael@0 282 # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
michael@0 283 # endif
michael@0 284 # define new DEBUG_CLIENTBLOCK
michael@0 285 # else
michael@0 286 # define DEBUG_CLIENTBLOCK
michael@0 287 # endif
michael@0 288 #endif
michael@0 289
michael@0 290 //////////////////////////////////////////////////////////////////////
michael@0 291
michael@0 292 #ifndef SK_OVERRIDE
michael@0 293 # if defined(_MSC_VER)
michael@0 294 # define SK_OVERRIDE override
michael@0 295 # elif defined(__clang__)
michael@0 296 // Using __attribute__((override)) on clang does not appear to always work.
michael@0 297 // Clang defaults to C++03 and warns about using override. Squelch that. Intentionally no
michael@0 298 // push/pop here so all users of SK_OVERRIDE ignore the warning too. This is like passing
michael@0 299 // -Wno-c++11-extensions, except that GCC won't die (because it won't see this pragma).
michael@0 300 # pragma clang diagnostic ignored "-Wc++11-extensions"
michael@0 301 #
michael@0 302 # if __has_feature(cxx_override_control)
michael@0 303 # define SK_OVERRIDE override
michael@0 304 # elif defined(__has_extension) && __has_extension(cxx_override_control)
michael@0 305 # define SK_OVERRIDE override
michael@0 306 # endif
michael@0 307 # endif
michael@0 308 # ifndef SK_OVERRIDE
michael@0 309 # define SK_OVERRIDE
michael@0 310 # endif
michael@0 311 #endif
michael@0 312
michael@0 313 //////////////////////////////////////////////////////////////////////
michael@0 314
michael@0 315 #if !defined(SK_UNUSED)
michael@0 316 # define SK_UNUSED SK_ATTRIBUTE(unused)
michael@0 317 #endif
michael@0 318
michael@0 319 #if !defined(SK_ATTR_DEPRECATED)
michael@0 320 // FIXME: we ignore msg for now...
michael@0 321 # define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated)
michael@0 322 #endif
michael@0 323
michael@0 324 /**
michael@0 325 * If your judgment is better than the compiler's (i.e. you've profiled it),
michael@0 326 * you can use SK_ALWAYS_INLINE to force inlining. E.g.
michael@0 327 * inline void someMethod() { ... } // may not be inlined
michael@0 328 * SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined
michael@0 329 */
michael@0 330 #if !defined(SK_ALWAYS_INLINE)
michael@0 331 # if defined(SK_BUILD_FOR_WIN)
michael@0 332 # define SK_ALWAYS_INLINE __forceinline
michael@0 333 # else
michael@0 334 # define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline
michael@0 335 # endif
michael@0 336 #endif
michael@0 337
michael@0 338 //////////////////////////////////////////////////////////////////////
michael@0 339
michael@0 340 #if defined(__clang__) || defined(__GNUC__)
michael@0 341 # define SK_PREFETCH(ptr) __builtin_prefetch(ptr)
michael@0 342 # define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1)
michael@0 343 #else
michael@0 344 # define SK_PREFETCH(ptr)
michael@0 345 # define SK_WRITE_PREFETCH(ptr)
michael@0 346 #endif
michael@0 347
michael@0 348 //////////////////////////////////////////////////////////////////////
michael@0 349
michael@0 350 #ifndef SK_PRINTF_LIKE
michael@0 351 # if defined(__clang__) || defined(__GNUC__)
michael@0 352 # define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
michael@0 353 # else
michael@0 354 # define SK_PRINTF_LIKE(A, B)
michael@0 355 # endif
michael@0 356 #endif
michael@0 357
michael@0 358 //////////////////////////////////////////////////////////////////////
michael@0 359
michael@0 360 #ifndef SK_SIZE_T_SPECIFIER
michael@0 361 # if defined(_MSC_VER)
michael@0 362 # define SK_SIZE_T_SPECIFIER "%Iu"
michael@0 363 # else
michael@0 364 # define SK_SIZE_T_SPECIFIER "%zu"
michael@0 365 # endif
michael@0 366 #endif
michael@0 367
michael@0 368 //////////////////////////////////////////////////////////////////////
michael@0 369
michael@0 370 #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
michael@0 371 # define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
michael@0 372 #endif
michael@0 373
michael@0 374 //////////////////////////////////////////////////////////////////////
michael@0 375
michael@0 376 #ifndef SK_ATOMICS_PLATFORM_H
michael@0 377 # if defined(_MSC_VER)
michael@0 378 # define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_win.h"
michael@0 379 # elif defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
michael@0 380 # define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_android.h"
michael@0 381 # else
michael@0 382 # define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_sync.h"
michael@0 383 # endif
michael@0 384 #endif
michael@0 385
michael@0 386 #ifndef SK_MUTEX_PLATFORM_H
michael@0 387 # if defined(SK_BUILD_FOR_WIN)
michael@0 388 # define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_win.h"
michael@0 389 # else
michael@0 390 # define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_pthread.h"
michael@0 391 # endif
michael@0 392 #endif
michael@0 393
michael@0 394 #endif // SkPostConfig_DEFINED

mercurial