gfx/skia/trunk/include/gpu/GrConfig.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 /*
michael@0 3 * Copyright 2010 Google Inc.
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10
michael@0 11 #ifndef GrConfig_DEFINED
michael@0 12 #define GrConfig_DEFINED
michael@0 13
michael@0 14 #include "SkTypes.h"
michael@0 15
michael@0 16 ///////////////////////////////////////////////////////////////////////////////
michael@0 17 // preconfig section:
michael@0 18 //
michael@0 19 // All the work before including GrUserConfig.h should center around guessing
michael@0 20 // what platform we're on, and defining low-level symbols based on that.
michael@0 21 //
michael@0 22 // A build environment may have already defined symbols, so we first check
michael@0 23 // for that
michael@0 24 //
michael@0 25
michael@0 26 // hack to ensure we know what sort of Apple platform we're on
michael@0 27 #if defined(__APPLE_CPP__) || defined(__APPLE_CC__)
michael@0 28 #include <TargetConditionals.h>
michael@0 29 #endif
michael@0 30
michael@0 31 /**
michael@0 32 * Gr defines are set to 0 or 1, rather than being undefined or defined
michael@0 33 */
michael@0 34
michael@0 35 #if !defined(GR_CACHE_STATS)
michael@0 36 #define GR_CACHE_STATS 0
michael@0 37 #endif
michael@0 38
michael@0 39 ///////////////////////////////////////////////////////////////////////////////
michael@0 40 ///////////////////////////////////////////////////////////////////////////////
michael@0 41
michael@0 42 #if defined(SK_BUILD_FOR_WIN32)
michael@0 43 // VC8 doesn't support stdint.h, so we define those types here.
michael@0 44 typedef signed char int8_t;
michael@0 45 typedef unsigned char uint8_t;
michael@0 46 typedef short int16_t;
michael@0 47 typedef unsigned short uint16_t;
michael@0 48 typedef int int32_t;
michael@0 49 typedef unsigned uint32_t;
michael@0 50 typedef __int64 int64_t;
michael@0 51 typedef unsigned __int64 uint64_t;
michael@0 52 #else
michael@0 53 /*
michael@0 54 * Include stdint.h with defines that trigger declaration of C99 limit/const
michael@0 55 * macros here before anyone else has a chance to include stdint.h without
michael@0 56 * these.
michael@0 57 */
michael@0 58 #ifndef __STDC_LIMIT_MACROS
michael@0 59 #define __STDC_LIMIT_MACROS
michael@0 60 #endif
michael@0 61 #ifndef __STDC_CONSTANT_MACROS
michael@0 62 #define __STDC_CONSTANT_MACROS
michael@0 63 #endif
michael@0 64 #include <stdint.h>
michael@0 65 #endif
michael@0 66
michael@0 67 /*
michael@0 68 * The "user config" file can be empty, and everything should work. It is
michael@0 69 * meant to store a given platform/client's overrides of our guess-work.
michael@0 70 *
michael@0 71 * A alternate user config file can be specified by defining
michael@0 72 * GR_USER_CONFIG_FILE. It should be defined relative to GrConfig.h
michael@0 73 *
michael@0 74 * e.g. it can change the BUILD target or supply its own defines for anything
michael@0 75 * else (e.g. GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT)
michael@0 76 */
michael@0 77 #if !defined(GR_USER_CONFIG_FILE)
michael@0 78 #include "GrUserConfig.h"
michael@0 79 #else
michael@0 80 #include GR_USER_CONFIG_FILE
michael@0 81 #endif
michael@0 82
michael@0 83
michael@0 84 ///////////////////////////////////////////////////////////////////////////////
michael@0 85 ///////////////////////////////////////////////////////////////////////////////
michael@0 86 // postconfig section:
michael@0 87 //
michael@0 88
michael@0 89 // By now we must have a GR_..._BUILD symbol set to 1, and a decision about
michael@0 90 // debug -vs- release
michael@0 91 //
michael@0 92
michael@0 93 #define GrPrintf SkDebugf
michael@0 94
michael@0 95 /**
michael@0 96 * GR_STRING makes a string of X where X is expanded before conversion to a string
michael@0 97 * if X itself contains macros.
michael@0 98 */
michael@0 99 #define GR_STRING(X) GR_STRING_IMPL(X)
michael@0 100 #define GR_STRING_IMPL(X) #X
michael@0 101
michael@0 102 /**
michael@0 103 * GR_CONCAT concatenates X and Y where each is expanded before
michael@0 104 * contanenation if either contains macros.
michael@0 105 */
michael@0 106 #define GR_CONCAT(X,Y) GR_CONCAT_IMPL(X,Y)
michael@0 107 #define GR_CONCAT_IMPL(X,Y) X##Y
michael@0 108
michael@0 109 /**
michael@0 110 * Creates a string of the form "<filename>(<linenumber>) : "
michael@0 111 */
michael@0 112 #define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : "
michael@0 113
michael@0 114 /**
michael@0 115 * Compilers have different ways of issuing warnings. This macro
michael@0 116 * attempts to abstract them, but may need to be specialized for your
michael@0 117 * particular compiler.
michael@0 118 * To insert compiler warnings use "#pragma message GR_WARN(<string>)"
michael@0 119 */
michael@0 120 #if defined(_MSC_VER) && _MSC_VER
michael@0 121 #define GR_WARN(MSG) (GR_FILE_AND_LINE_STR "WARNING: " MSG)
michael@0 122 #else//__GNUC__ - may need other defines for different compilers
michael@0 123 #define GR_WARN(MSG) ("WARNING: " MSG)
michael@0 124 #endif
michael@0 125
michael@0 126 /**
michael@0 127 * GR_ALWAYSBREAK is an unconditional break in all builds.
michael@0 128 */
michael@0 129 #if !defined(GR_ALWAYSBREAK)
michael@0 130 #if defined(SK_BUILD_FOR_WIN32)
michael@0 131 #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); __debugbreak()
michael@0 132 #else
michael@0 133 // TODO: do other platforms really not have continuable breakpoints?
michael@0 134 // sign extend for 64bit architectures to be sure this is
michael@0 135 // in the high address range
michael@0 136 #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xbeefcafe) = 0;
michael@0 137 #endif
michael@0 138 #endif
michael@0 139
michael@0 140 /**
michael@0 141 * GR_DEBUGBREAK is an unconditional break in debug builds.
michael@0 142 */
michael@0 143 #if !defined(GR_DEBUGBREAK)
michael@0 144 #ifdef SK_DEBUG
michael@0 145 #define GR_DEBUGBREAK GR_ALWAYSBREAK
michael@0 146 #else
michael@0 147 #define GR_DEBUGBREAK
michael@0 148 #endif
michael@0 149 #endif
michael@0 150
michael@0 151 /**
michael@0 152 * GR_ALWAYSASSERT is an assertion in all builds.
michael@0 153 */
michael@0 154 #if !defined(GR_ALWAYSASSERT)
michael@0 155 #define GR_ALWAYSASSERT(COND) \
michael@0 156 do { \
michael@0 157 if (!(COND)) { \
michael@0 158 GrPrintf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \
michael@0 159 GR_ALWAYSBREAK; \
michael@0 160 } \
michael@0 161 } while (false)
michael@0 162 #endif
michael@0 163
michael@0 164 /**
michael@0 165 * GR_DEBUGASSERT is an assertion in debug builds only.
michael@0 166 */
michael@0 167 #if !defined(GR_DEBUGASSERT)
michael@0 168 #ifdef SK_DEBUG
michael@0 169 #define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND)
michael@0 170 #else
michael@0 171 #define GR_DEBUGASSERT(COND)
michael@0 172 #endif
michael@0 173 #endif
michael@0 174
michael@0 175 /**
michael@0 176 * Prettier forms of the above macros.
michael@0 177 */
michael@0 178 #define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND)
michael@0 179
michael@0 180 /**
michael@0 181 * Crash from unrecoverable condition, optionally with a message. The debug variants only
michael@0 182 * crash in a debug build. The message versions print the message regardless of release vs debug.
michael@0 183 */
michael@0 184 inline void GrCrash() { GrAlwaysAssert(false); }
michael@0 185 inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); }
michael@0 186 inline void GrDebugCrash() { SkASSERT(false); }
michael@0 187 inline void GrDebugCrash(const char* msg) { GrPrintf(msg); SkASSERT(false); }
michael@0 188
michael@0 189 /**
michael@0 190 * GR_STATIC_ASSERT is a compile time assertion. Depending on the platform
michael@0 191 * it may print the message in the compiler log. Obviously, the condition must
michael@0 192 * be evaluatable at compile time.
michael@0 193 */
michael@0 194 // VS 2010 and GCC compiled with c++0x or gnu++0x support the new
michael@0 195 // static_assert.
michael@0 196 #if !defined(GR_STATIC_ASSERT)
michael@0 197 #if (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)
michael@0 198 #define GR_STATIC_ASSERT(CONDITION) static_assert(CONDITION, "bug")
michael@0 199 #else
michael@0 200 template <bool> class GR_STATIC_ASSERT_FAILURE;
michael@0 201 template <> class GR_STATIC_ASSERT_FAILURE<true> {};
michael@0 202 #define GR_STATIC_ASSERT(CONDITION) \
michael@0 203 enum {GR_CONCAT(X,__LINE__) = \
michael@0 204 sizeof(GR_STATIC_ASSERT_FAILURE<CONDITION>)}
michael@0 205 #endif
michael@0 206 #endif
michael@0 207
michael@0 208 /**
michael@0 209 * GR_GEOM_BUFFER_LOCK_THRESHOLD gives a threshold (in bytes) for when Gr should
michael@0 210 * lock a GrGeometryBuffer to update its contents. It will use lock() if the
michael@0 211 * size of the updated region is greater than the threshold. Otherwise it will
michael@0 212 * use updateData().
michael@0 213 */
michael@0 214 #if !defined(GR_GEOM_BUFFER_LOCK_THRESHOLD)
michael@0 215 #define GR_GEOM_BUFFER_LOCK_THRESHOLD (1 << 15)
michael@0 216 #endif
michael@0 217
michael@0 218 /**
michael@0 219 * GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT gives a threshold (in megabytes) for the
michael@0 220 * maximum size of the texture cache in vram. The value is only a default and
michael@0 221 * can be overridden at runtime.
michael@0 222 */
michael@0 223 #if !defined(GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT)
michael@0 224 #define GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT 96
michael@0 225 #endif
michael@0 226
michael@0 227 /**
michael@0 228 * GR_DEFAULT_RESOURCE_CACHE_COUNT_LIMIT specifies the maximum number of
michael@0 229 * textures the texture cache can hold in vram. The value is only a default and
michael@0 230 * can be overridden at runtime.
michael@0 231 */
michael@0 232 #if !defined(GR_DEFAULT_RESOURCE_CACHE_COUNT_LIMIT)
michael@0 233 #define GR_DEFAULT_RESOURCE_CACHE_COUNT_LIMIT 2048
michael@0 234 #endif
michael@0 235
michael@0 236 /**
michael@0 237 * GR_STROKE_PATH_RENDERING controls whether or not the GrStrokePathRenderer can be selected
michael@0 238 * as a path renderer. GrStrokePathRenderer is currently an experimental path renderer.
michael@0 239 */
michael@0 240 #if !defined(GR_STROKE_PATH_RENDERING)
michael@0 241 #define GR_STROKE_PATH_RENDERING 0
michael@0 242 #endif
michael@0 243
michael@0 244 #endif

mercurial