gfx/skia/trunk/include/gpu/GrConfig.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/gpu/GrConfig.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,244 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2010 Google Inc.
     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 +
    1.14 +#ifndef GrConfig_DEFINED
    1.15 +#define GrConfig_DEFINED
    1.16 +
    1.17 +#include "SkTypes.h"
    1.18 +
    1.19 +///////////////////////////////////////////////////////////////////////////////
    1.20 +// preconfig section:
    1.21 +//
    1.22 +// All the work before including GrUserConfig.h should center around guessing
    1.23 +// what platform we're on, and defining low-level symbols based on that.
    1.24 +//
    1.25 +// A build environment may have already defined symbols, so we first check
    1.26 +// for that
    1.27 +//
    1.28 +
    1.29 +// hack to ensure we know what sort of Apple platform we're on
    1.30 +#if defined(__APPLE_CPP__) || defined(__APPLE_CC__)
    1.31 +    #include <TargetConditionals.h>
    1.32 +#endif
    1.33 +
    1.34 +/**
    1.35 + *  Gr defines are set to 0 or 1, rather than being undefined or defined
    1.36 + */
    1.37 +
    1.38 +#if !defined(GR_CACHE_STATS)
    1.39 +    #define GR_CACHE_STATS      0
    1.40 +#endif
    1.41 +
    1.42 +///////////////////////////////////////////////////////////////////////////////
    1.43 +///////////////////////////////////////////////////////////////////////////////
    1.44 +
    1.45 +#if defined(SK_BUILD_FOR_WIN32)
    1.46 +// VC8 doesn't support stdint.h, so we define those types here.
    1.47 +typedef signed char int8_t;
    1.48 +typedef unsigned char uint8_t;
    1.49 +typedef short int16_t;
    1.50 +typedef unsigned short uint16_t;
    1.51 +typedef int int32_t;
    1.52 +typedef unsigned uint32_t;
    1.53 +typedef __int64 int64_t;
    1.54 +typedef unsigned __int64 uint64_t;
    1.55 +#else
    1.56 +/*
    1.57 + *  Include stdint.h with defines that trigger declaration of C99 limit/const
    1.58 + *  macros here before anyone else has a chance to include stdint.h without
    1.59 + *  these.
    1.60 + */
    1.61 +#ifndef __STDC_LIMIT_MACROS
    1.62 +#define __STDC_LIMIT_MACROS
    1.63 +#endif
    1.64 +#ifndef __STDC_CONSTANT_MACROS
    1.65 +#define __STDC_CONSTANT_MACROS
    1.66 +#endif
    1.67 +#include <stdint.h>
    1.68 +#endif
    1.69 +
    1.70 +/*
    1.71 + *  The "user config" file can be empty, and everything should work. It is
    1.72 + *  meant to store a given platform/client's overrides of our guess-work.
    1.73 + *
    1.74 + *  A alternate user config file can be specified by defining
    1.75 + *  GR_USER_CONFIG_FILE. It should be defined relative to GrConfig.h
    1.76 + *
    1.77 + *  e.g. it can change the BUILD target or supply its own defines for anything
    1.78 + *  else (e.g. GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT)
    1.79 + */
    1.80 +#if !defined(GR_USER_CONFIG_FILE)
    1.81 +    #include "GrUserConfig.h"
    1.82 +#else
    1.83 +    #include GR_USER_CONFIG_FILE
    1.84 +#endif
    1.85 +
    1.86 +
    1.87 +///////////////////////////////////////////////////////////////////////////////
    1.88 +///////////////////////////////////////////////////////////////////////////////
    1.89 +// postconfig section:
    1.90 +//
    1.91 +
    1.92 +// By now we must have a GR_..._BUILD symbol set to 1, and a decision about
    1.93 +// debug -vs- release
    1.94 +//
    1.95 +
    1.96 +#define GrPrintf SkDebugf
    1.97 +
    1.98 +/**
    1.99 + *  GR_STRING makes a string of X where X is expanded before conversion to a string
   1.100 + *  if X itself contains macros.
   1.101 + */
   1.102 +#define GR_STRING(X) GR_STRING_IMPL(X)
   1.103 +#define GR_STRING_IMPL(X) #X
   1.104 +
   1.105 +/**
   1.106 + *  GR_CONCAT concatenates X and Y  where each is expanded before
   1.107 + *  contanenation if either contains macros.
   1.108 + */
   1.109 +#define GR_CONCAT(X,Y) GR_CONCAT_IMPL(X,Y)
   1.110 +#define GR_CONCAT_IMPL(X,Y) X##Y
   1.111 +
   1.112 +/**
   1.113 + *  Creates a string of the form "<filename>(<linenumber>) : "
   1.114 + */
   1.115 +#define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : "
   1.116 +
   1.117 +/**
   1.118 + *  Compilers have different ways of issuing warnings. This macro
   1.119 + *  attempts to abstract them, but may need to be specialized for your
   1.120 + *  particular compiler.
   1.121 + *  To insert compiler warnings use "#pragma message GR_WARN(<string>)"
   1.122 + */
   1.123 +#if defined(_MSC_VER) && _MSC_VER
   1.124 +    #define GR_WARN(MSG) (GR_FILE_AND_LINE_STR "WARNING: " MSG)
   1.125 +#else//__GNUC__ - may need other defines for different compilers
   1.126 +    #define GR_WARN(MSG) ("WARNING: " MSG)
   1.127 +#endif
   1.128 +
   1.129 +/**
   1.130 + *  GR_ALWAYSBREAK is an unconditional break in all builds.
   1.131 + */
   1.132 +#if !defined(GR_ALWAYSBREAK)
   1.133 +    #if     defined(SK_BUILD_FOR_WIN32)
   1.134 +        #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); __debugbreak()
   1.135 +    #else
   1.136 +        // TODO: do other platforms really not have continuable breakpoints?
   1.137 +        // sign extend for 64bit architectures to be sure this is
   1.138 +        // in the high address range
   1.139 +        #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xbeefcafe) = 0;
   1.140 +    #endif
   1.141 +#endif
   1.142 +
   1.143 +/**
   1.144 + *  GR_DEBUGBREAK is an unconditional break in debug builds.
   1.145 + */
   1.146 +#if !defined(GR_DEBUGBREAK)
   1.147 +    #ifdef SK_DEBUG
   1.148 +        #define GR_DEBUGBREAK GR_ALWAYSBREAK
   1.149 +    #else
   1.150 +        #define GR_DEBUGBREAK
   1.151 +    #endif
   1.152 +#endif
   1.153 +
   1.154 +/**
   1.155 + *  GR_ALWAYSASSERT is an assertion in all builds.
   1.156 + */
   1.157 +#if !defined(GR_ALWAYSASSERT)
   1.158 +    #define GR_ALWAYSASSERT(COND)                                        \
   1.159 +        do {                                                             \
   1.160 +            if (!(COND)) {                                               \
   1.161 +                GrPrintf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \
   1.162 +                GR_ALWAYSBREAK;                                          \
   1.163 +            }                                                            \
   1.164 +        } while (false)
   1.165 +#endif
   1.166 +
   1.167 +/**
   1.168 + *  GR_DEBUGASSERT is an assertion in debug builds only.
   1.169 + */
   1.170 +#if !defined(GR_DEBUGASSERT)
   1.171 +    #ifdef SK_DEBUG
   1.172 +        #define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND)
   1.173 +    #else
   1.174 +        #define GR_DEBUGASSERT(COND)
   1.175 +    #endif
   1.176 +#endif
   1.177 +
   1.178 +/**
   1.179 + *  Prettier forms of the above macros.
   1.180 + */
   1.181 +#define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND)
   1.182 +
   1.183 +/**
   1.184 + * Crash from unrecoverable condition, optionally with a message. The debug variants only
   1.185 + * crash in a debug build. The message versions print the message regardless of release vs debug.
   1.186 + */
   1.187 +inline void GrCrash() { GrAlwaysAssert(false); }
   1.188 +inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); }
   1.189 +inline void GrDebugCrash() { SkASSERT(false); }
   1.190 +inline void GrDebugCrash(const char* msg) { GrPrintf(msg); SkASSERT(false); }
   1.191 +
   1.192 +/**
   1.193 + *  GR_STATIC_ASSERT is a compile time assertion. Depending on the platform
   1.194 + *  it may print the message in the compiler log. Obviously, the condition must
   1.195 + *  be evaluatable at compile time.
   1.196 + */
   1.197 +// VS 2010 and GCC compiled with c++0x or gnu++0x support the new
   1.198 +// static_assert.
   1.199 +#if !defined(GR_STATIC_ASSERT)
   1.200 +    #if (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)
   1.201 +        #define GR_STATIC_ASSERT(CONDITION) static_assert(CONDITION, "bug")
   1.202 +    #else
   1.203 +        template <bool> class GR_STATIC_ASSERT_FAILURE;
   1.204 +        template <> class GR_STATIC_ASSERT_FAILURE<true> {};
   1.205 +        #define GR_STATIC_ASSERT(CONDITION) \
   1.206 +            enum {GR_CONCAT(X,__LINE__) = \
   1.207 +            sizeof(GR_STATIC_ASSERT_FAILURE<CONDITION>)}
   1.208 +    #endif
   1.209 +#endif
   1.210 +
   1.211 +/**
   1.212 + * GR_GEOM_BUFFER_LOCK_THRESHOLD gives a threshold (in bytes) for when Gr should
   1.213 + * lock a GrGeometryBuffer to update its contents. It will use lock() if the
   1.214 + * size of the updated region is greater than the threshold. Otherwise it will
   1.215 + * use updateData().
   1.216 + */
   1.217 +#if !defined(GR_GEOM_BUFFER_LOCK_THRESHOLD)
   1.218 +    #define GR_GEOM_BUFFER_LOCK_THRESHOLD (1 << 15)
   1.219 +#endif
   1.220 +
   1.221 +/**
   1.222 + * GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT gives a threshold (in megabytes) for the
   1.223 + * maximum size of the texture cache in vram. The value is only a default and
   1.224 + * can be overridden at runtime.
   1.225 + */
   1.226 +#if !defined(GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT)
   1.227 +    #define GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT 96
   1.228 +#endif
   1.229 +
   1.230 +/**
   1.231 + * GR_DEFAULT_RESOURCE_CACHE_COUNT_LIMIT specifies the maximum number of
   1.232 + * textures the texture cache can hold in vram. The value is only a default and
   1.233 + * can be overridden at runtime.
   1.234 + */
   1.235 +#if !defined(GR_DEFAULT_RESOURCE_CACHE_COUNT_LIMIT)
   1.236 +    #define GR_DEFAULT_RESOURCE_CACHE_COUNT_LIMIT 2048
   1.237 +#endif
   1.238 +
   1.239 +/**
   1.240 + * GR_STROKE_PATH_RENDERING controls whether or not the GrStrokePathRenderer can be selected
   1.241 + * as a path renderer. GrStrokePathRenderer is currently an experimental path renderer.
   1.242 + */
   1.243 +#if !defined(GR_STROKE_PATH_RENDERING)
   1.244 +    #define GR_STROKE_PATH_RENDERING                 0
   1.245 +#endif
   1.246 +
   1.247 +#endif

mercurial