2010-12-22 21:39:39 +00:00
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2010-12-22 21:39:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
#ifndef GrConfig_DEFINED
|
|
|
|
#define GrConfig_DEFINED
|
|
|
|
|
2012-08-31 13:07:37 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// preconfig section:
|
|
|
|
//
|
|
|
|
// All the work before including GrUserConfig.h should center around guessing
|
|
|
|
// what platform we're on, and defining low-level symbols based on that.
|
|
|
|
//
|
|
|
|
// A build environment may have already defined symbols, so we first check
|
|
|
|
// for that
|
|
|
|
//
|
|
|
|
|
|
|
|
// hack to ensure we know what sort of Apple platform we're on
|
|
|
|
#if defined(__APPLE_CPP__) || defined(__APPLE_CC__)
|
|
|
|
#include <TargetConditionals.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gr defines are set to 0 or 1, rather than being undefined or defined
|
|
|
|
*/
|
|
|
|
|
2012-08-31 13:07:37 +00:00
|
|
|
#if !defined(GR_CACHE_STATS)
|
2016-04-28 15:12:55 +00:00
|
|
|
#if defined(SK_DEVELOPER) || defined(SK_DEBUG) || defined(SK_DUMP_STATS)
|
2014-10-24 16:34:41 +00:00
|
|
|
#define GR_CACHE_STATS 1
|
|
|
|
#else
|
|
|
|
#define GR_CACHE_STATS 0
|
|
|
|
#endif
|
2012-08-31 13:07:37 +00:00
|
|
|
#endif
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2014-09-18 20:52:08 +00:00
|
|
|
#if !defined(GR_GPU_STATS)
|
2016-04-28 15:12:55 +00:00
|
|
|
#if defined(SK_DEVELOPER) || defined(SK_DEBUG) || defined(SK_DUMP_STATS)
|
2014-10-24 16:34:41 +00:00
|
|
|
#define GR_GPU_STATS 1
|
|
|
|
#else
|
|
|
|
#define GR_GPU_STATS 0
|
|
|
|
#endif
|
2014-09-18 20:52:08 +00:00
|
|
|
#endif
|
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-09-25 20:57:51 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN32)
|
2011-03-28 20:47:09 +00:00
|
|
|
// VC8 doesn't support stdint.h, so we define those types here.
|
|
|
|
typedef signed char int8_t;
|
|
|
|
typedef unsigned char uint8_t;
|
|
|
|
typedef short int16_t;
|
|
|
|
typedef unsigned short uint16_t;
|
|
|
|
typedef int int32_t;
|
|
|
|
typedef unsigned uint32_t;
|
2011-04-19 21:15:09 +00:00
|
|
|
typedef __int64 int64_t;
|
|
|
|
typedef unsigned __int64 uint64_t;
|
2011-03-28 20:47:09 +00:00
|
|
|
#else
|
2010-12-22 21:39:39 +00:00
|
|
|
/*
|
2011-03-21 19:51:57 +00:00
|
|
|
* Include stdint.h with defines that trigger declaration of C99 limit/const
|
2012-08-23 18:09:54 +00:00
|
|
|
* macros here before anyone else has a chance to include stdint.h without
|
2011-03-21 19:51:57 +00:00
|
|
|
* these.
|
2010-12-22 21:39:39 +00:00
|
|
|
*/
|
2012-11-06 18:36:33 +00:00
|
|
|
#ifndef __STDC_LIMIT_MACROS
|
2010-12-22 21:39:39 +00:00
|
|
|
#define __STDC_LIMIT_MACROS
|
2012-11-06 18:36:33 +00:00
|
|
|
#endif
|
|
|
|
#ifndef __STDC_CONSTANT_MACROS
|
2010-12-22 21:39:39 +00:00
|
|
|
#define __STDC_CONSTANT_MACROS
|
2012-11-06 18:36:33 +00:00
|
|
|
#endif
|
2010-12-22 21:39:39 +00:00
|
|
|
#include <stdint.h>
|
2011-03-28 20:47:09 +00:00
|
|
|
#endif
|
2010-12-22 21:39:39 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// postconfig section:
|
|
|
|
//
|
2011-03-21 19:51:57 +00:00
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
/**
|
|
|
|
* GR_STRING makes a string of X where X is expanded before conversion to a string
|
|
|
|
* if X itself contains macros.
|
|
|
|
*/
|
|
|
|
#define GR_STRING(X) GR_STRING_IMPL(X)
|
|
|
|
#define GR_STRING_IMPL(X) #X
|
|
|
|
|
|
|
|
/**
|
2011-02-14 16:51:21 +00:00
|
|
|
* GR_CONCAT concatenates X and Y where each is expanded before
|
2010-12-22 21:39:39 +00:00
|
|
|
* contanenation if either contains macros.
|
|
|
|
*/
|
|
|
|
#define GR_CONCAT(X,Y) GR_CONCAT_IMPL(X,Y)
|
|
|
|
#define GR_CONCAT_IMPL(X,Y) X##Y
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a string of the form "<filename>(<linenumber>) : "
|
|
|
|
*/
|
|
|
|
#define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : "
|
|
|
|
|
|
|
|
/**
|
2011-02-14 16:51:21 +00:00
|
|
|
* Compilers have different ways of issuing warnings. This macro
|
|
|
|
* attempts to abstract them, but may need to be specialized for your
|
2010-12-22 21:39:39 +00:00
|
|
|
* particular compiler.
|
|
|
|
* To insert compiler warnings use "#pragma message GR_WARN(<string>)"
|
|
|
|
*/
|
2016-03-10 19:14:40 +00:00
|
|
|
#if defined(_MSC_VER)
|
2010-12-22 21:39:39 +00:00
|
|
|
#define GR_WARN(MSG) (GR_FILE_AND_LINE_STR "WARNING: " MSG)
|
|
|
|
#else//__GNUC__ - may need other defines for different compilers
|
|
|
|
#define GR_WARN(MSG) ("WARNING: " MSG)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GR_ALWAYSBREAK is an unconditional break in all builds.
|
|
|
|
*/
|
|
|
|
#if !defined(GR_ALWAYSBREAK)
|
2013-09-25 20:57:51 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN32)
|
2011-11-23 21:25:35 +00:00
|
|
|
#define GR_ALWAYSBREAK SkNO_RETURN_HINT(); __debugbreak()
|
2011-02-14 16:51:21 +00:00
|
|
|
#else
|
2010-12-22 21:39:39 +00:00
|
|
|
// TODO: do other platforms really not have continuable breakpoints?
|
2011-02-14 16:51:21 +00:00
|
|
|
// sign extend for 64bit architectures to be sure this is
|
2010-12-22 21:39:39 +00:00
|
|
|
// in the high address range
|
2011-11-23 21:25:35 +00:00
|
|
|
#define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xbeefcafe) = 0;
|
2010-12-22 21:39:39 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GR_DEBUGBREAK is an unconditional break in debug builds.
|
|
|
|
*/
|
|
|
|
#if !defined(GR_DEBUGBREAK)
|
2013-08-28 14:17:03 +00:00
|
|
|
#ifdef SK_DEBUG
|
2010-12-22 21:39:39 +00:00
|
|
|
#define GR_DEBUGBREAK GR_ALWAYSBREAK
|
|
|
|
#else
|
|
|
|
#define GR_DEBUGBREAK
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GR_ALWAYSASSERT is an assertion in all builds.
|
|
|
|
*/
|
|
|
|
#if !defined(GR_ALWAYSASSERT)
|
|
|
|
#define GR_ALWAYSASSERT(COND) \
|
|
|
|
do { \
|
|
|
|
if (!(COND)) { \
|
2014-10-31 14:11:12 +00:00
|
|
|
SkDebugf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \
|
2010-12-22 21:39:39 +00:00
|
|
|
GR_ALWAYSBREAK; \
|
|
|
|
} \
|
|
|
|
} while (false)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GR_DEBUGASSERT is an assertion in debug builds only.
|
|
|
|
*/
|
|
|
|
#if !defined(GR_DEBUGASSERT)
|
2013-08-28 14:17:03 +00:00
|
|
|
#ifdef SK_DEBUG
|
2010-12-22 21:39:39 +00:00
|
|
|
#define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND)
|
|
|
|
#else
|
|
|
|
#define GR_DEBUGASSERT(COND)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prettier forms of the above macros.
|
|
|
|
*/
|
|
|
|
#define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GR_STATIC_ASSERT is a compile time assertion. Depending on the platform
|
|
|
|
* it may print the message in the compiler log. Obviously, the condition must
|
|
|
|
* be evaluatable at compile time.
|
|
|
|
*/
|
2016-03-10 19:14:40 +00:00
|
|
|
#define GR_STATIC_ASSERT(CONDITION) static_assert(CONDITION, "bug")
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2016-01-30 17:59:10 +00:00
|
|
|
/**
|
|
|
|
* Set to 1 to enable pixel local storage path rendering on supported devices.
|
|
|
|
*/
|
|
|
|
#if !defined(GR_ENABLE_PLS_PATH_RENDERING)
|
|
|
|
#define GR_ENABLE_PLS_PATH_RENDERING 0
|
|
|
|
#endif
|
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
#endif
|