diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h index 8e6ce497bf..8feae72301 100644 --- a/include/core/SkPostConfig.h +++ b/include/core/SkPostConfig.h @@ -88,6 +88,9 @@ #ifndef SK_SCALAR_SLOW_COMPARES #define SK_SCALAR_SLOW_COMPARES #endif + #ifndef SK_USE_FLOATBITS + #define SK_USE_FLOATBITS + #endif #endif #ifdef SK_BUILD_FOR_WIN @@ -152,6 +155,21 @@ #define sk_strnequal(s, t, n) (!sk_strncmp(s, t, n)) #endif +////////////////////////////////////////////////////////////////////// + +#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC) + #ifndef SkLONGLONG + #ifdef SK_BUILD_FOR_WIN32 + #define SkLONGLONG __int64 + #else + #define SkLONGLONG long long + #endif + #endif +#endif + +// experimental for now +#define SK_SUPPORT_MIPMAP + ////////////////////////////////////////////////////////////////////////////////////////////// #ifndef SK_BUILD_FOR_WINCE #include diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h index b8c91b2ad6..05f3d43fda 100644 --- a/include/core/SkPreConfig.h +++ b/include/core/SkPreConfig.h @@ -17,11 +17,6 @@ #ifndef SkPreConfig_DEFINED #define SkPreConfig_DEFINED -#ifdef ANDROID - #define SK_BUILD_FOR_UNIX - #define SkLONGLONG int64_t -#endif - ////////////////////////////////////////////////////////////////////// #if !defined(SK_BUILD_FOR_PALM) && !defined(SK_BUILD_FOR_WINCE) && !defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_SYMBIAN) && !defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUILD_FOR_MAC) @@ -54,26 +49,15 @@ ////////////////////////////////////////////////////////////////////// -// define to blank or change this in SkUserConfig.h as needed -#define SK_RESTRICT __restrict__ +#if !defined(SK_RESTRICT) + #define SK_RESTRICT __restrict__ +#endif ////////////////////////////////////////////////////////////////////// -#if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC) - #ifndef SK_CAN_USE_FLOAT - #define SK_CAN_USE_FLOAT - #endif - #if !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT) - #define SK_SCALAR_IS_FIXED - #endif - - #ifndef SkLONGLONG - #ifdef SK_BUILD_FOR_WIN32 - #define SkLONGLONG __int64 - #else - #define SkLONGLONG long long - #endif - #endif +#if !defined(SK_SCALAR_IS_FLOAT) && !defined(SK_SCALAR_IS_FIXED) + #define SK_SCALAR_IS_FLOAT + #define SK_CAN_USE_FLOAT #endif ////////////////////////////////////////////////////////////////////// @@ -93,12 +77,5 @@ #define SK_CPU_HAS_CONDITIONAL_INSTR #endif -////////////////////////////////////////////////////////////////////// -// Conditional features based on build target - -#ifdef SK_BUILD_FOR_SYMBIAN - #define SK_USE_RUNTIME_GLOBALS -#endif - #endif diff --git a/include/core/SkUserConfig.h b/include/core/SkUserConfig.h index 85cda1cb58..a3c34a3ba7 100644 --- a/include/core/SkUserConfig.h +++ b/include/core/SkUserConfig.h @@ -17,87 +17,108 @@ #ifndef SkUserConfig_DEFINED #define SkUserConfig_DEFINED -// for floats -#ifdef SK_SCALAR_IS_FIXED -#undef SK_SCALAR_IS_FIXED -#endif -#define SK_SCALAR_IS_FLOAT +/* SkTypes.h, the root of the public header files, does the following trick: + + #include "SkPreConfig.h" + #include "SkUserConfig.h" + #include "SkPostConfig.h" + + SkPreConfig.h runs first, and it is responsible for initializing certain + skia defines. + + SkPostConfig.h runs last, and its job is to just check that the final + defines are consistent (i.e. that we don't have mutually conflicting + defines). + + SkUserConfig.h (this file) runs in the middle. It gets to change or augment + the list of flags initially set in preconfig, and then postconfig checks + that everything still makes sense. -// remove the x if you want to force us into SK_DEBUG mode -#ifdef SK_RELEASE - #undef SK_RELEASE - #define SK_DEBUG -#endif + Below are optional defines that add, subtract, or change default behavior + in Skia. Your port can locally edit this file to enable/disable flags as + you choose, or these can be delared on your command line (i.e. -Dfoo). -// remove the x if you want to force us into SK_RELEASE mode -#ifdef SK_DEBUGx - #undef SK_DEBUG - #define SK_RELEASE -#endif - -#ifdef ANDROID - #include - #include - - #define SK_CRASH() *(int *)(uintptr_t)0 = 0 -// #define SK_CRASH() assert(0) - -#if 0 - // force fixed - #define SK_SCALAR_IS_FIXED - #undef SK_SCALAR_IS_FLOAT -#else - // force floats - #ifdef SK_SCALAR_IS_FIXED - #undef SK_SCALAR_IS_FIXED - #endif - #define SK_SCALAR_IS_FLOAT -#endif - - #define SK_CAN_USE_FLOAT - #define SK_SOFTWARE_FLOAT - #define SkLONGLONG int64_t - - // replace some sw float routines (floor, ceil, etc.) - #define SK_USE_FLOATBITS - - #if __BYTE_ORDER == __BIG_ENDIAN - #define SK_CPU_BENDIAN - #undef SK_CPU_LENDIAN - #else - #define SK_CPU_LENDIAN - #undef SK_CPU_BENDIAN - #endif - - // define SkDebugf to record file/line - #define SkDebugf(...) Android_SkDebugf(__FILE__, __LINE__, \ - __FUNCTION__, __VA_ARGS__) - void Android_SkDebugf(const char* file, int line, - const char* function, const char* format, ...); -#endif - -/* This file is included before all other headers, except for SkPreConfig.h. - That file uses various heuristics to make a "best guess" at settings for - the following build defines. - - However, in this file you can override any of those decisions by either - defining new symbols, or #undef symbols that were already set. + By default, this include file will always default to having all of the flags + commented out, so including it will have no effect. */ -// experimental for now -#define SK_SUPPORT_MIPMAP +/////////////////////////////////////////////////////////////////////////////// +/* Scalars (the fractional value type in skia) can be implemented either as + floats or 16.16 integers (fixed). Exactly one of these two symbols must be + defined. +*/ +//#define SK_SCALAR_IS_FLOAT +//#define SK_SCALAR_IS_FIXED + + +/* Somewhat independent of how SkScalar is implemented, Skia also wants to know + if it can use floats at all. Naturally, if SK_SCALAR_IS_FLOAT is defined, + then so muse SK_CAN_USE_FLOAT, but if scalars are fixed, SK_CAN_USE_FLOAT + can go either way. + */ +//#define SK_CAN_USE_FLOAT + +/* For some performance-critical scalar operations, skia will optionally work + around the standard float operators if it knows that the CPU does not have + native support for floats. If your environment uses software floating point, + define this flag. + */ +//#define SK_SOFTWARE_FLOAT + + +/* Skia has lots of debug-only code. Often this is just null checks or other + parameter checking, but sometimes it can be quite intrusive (e.g. check that + each 32bit pixel is in premultiplied form). This code can be very useful + during development, but will slow things down in a shipping product. + + By default, these mutually exclusive flags are defined in SkPreConfig.h, + based on the presence or absence of NDEBUG, but that decision can be changed + here. + */ +//#define SK_DEBUG +//#define SK_RELEASE + + +/* If, in debugging mode, Skia needs to stop (presumably to invoke a debugger) + it will call SK_CRASH(). If this is not defined it, it is defined in + SkPostConfig.h to write to an illegal address + */ +//#define SK_CRASH() *(int *)(uintptr_t)0 = 0 + + +/* preconfig will have attempted to determine the endianness of the system, + but you can change these mutually exclusive flags here. + */ +//#define SK_CPU_BENDIAN +//#define SK_CPU_LENDIAN + + +/* Some compilers don't support long long for 64bit integers. If yours does + not, define this to the appropriate type. + */ +//#define SkLONGLONG int64_t + + +/* Some envorinments do not suport writable globals (eek!). If yours does not, + define this flag. + */ +//#define SK_USE_RUNTIME_GLOBALS + + +/* To write debug messages to a console, skia will call SkDebugf(...) following + printf conventions (e.g. const char* format, ...). If you want to redirect + this to something other than printf, define yours here + */ +//#define SkDebugf(...) MyFunction(__VA_ARGS__) + + +/* If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST + which will run additional self-tests at startup. These can take a long time, + so this flag is optional. + */ #ifdef SK_DEBUG - #define SK_SUPPORT_UNITTEST - /* Define SK_SIMULATE_FAILED_MALLOC to have - * sk_malloc throw an exception. Use this to - * detect unhandled memory leaks. */ - //#define SK_SIMULATE_FAILED_MALLOC - //#define SK_FIND_MEMORY_LEAKS -#endif - -#ifdef SK_BUILD_FOR_BREW - #include "SkBrewUserConfig.h" +//#define SK_SUPPORT_UNITTEST #endif #endif diff --git a/src/xml/SkParseColor.cpp b/src/xml/SkParseColor.cpp index eca2e382d4..c451253edd 100644 --- a/src/xml/SkParseColor.cpp +++ b/src/xml/SkParseColor.cpp @@ -500,7 +500,7 @@ const char* SkParse::FindColor(const char* value, SkColor* colorPtr) { return FindNamedColor(value, strlen(value), colorPtr); } -#ifdef SK_DEBUG +#ifdef SK_SUPPORT_UNITTEST void SkParse::TestColor() { if (false) CreateTable(); // regenerates data table in the output window diff --git a/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj b/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj index f288c8781a..1df5c61f0e 100644 --- a/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj +++ b/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj @@ -548,7 +548,7 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 01E2163A09EDAC6600E66AF8 /* Development */ = { + 01E2163A09EDAC6600E66AF8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; @@ -568,9 +568,9 @@ WRAPPER_EXTENSION = app; ZERO_LINK = YES; }; - name = Development; + name = Debug; }; - 01E2163B09EDAC6600E66AF8 /* Deployment */ = { + 01E2163B09EDAC6600E66AF8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; @@ -588,25 +588,9 @@ WRAPPER_EXTENSION = app; ZERO_LINK = NO; }; - name = Deployment; + name = Release; }; - 01E2163C09EDAC6600E66AF8 /* Default */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = CICarbonSample_Prefix.pch; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Applications"; - PRODUCT_NAME = CICarbonSample; - SKIP_INSTALL = YES; - WRAPPER_EXTENSION = app; - }; - name = Default; - }; - 01E2163E09EDAC6600E66AF8 /* Development */ = { + 01E2163E09EDAC6600E66AF8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_ENABLE_CPP_EXCEPTIONS = NO; @@ -619,9 +603,9 @@ SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; USER_HEADER_SEARCH_PATHS = "../../include/**"; }; - name = Development; + name = Debug; }; - 01E2163F09EDAC6600E66AF8 /* Deployment */ = { + 01E2163F09EDAC6600E66AF8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { GCC_ENABLE_CPP_EXCEPTIONS = NO; @@ -634,18 +618,7 @@ SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; USER_HEADER_SEARCH_PATHS = "../../include/**"; }; - name = Deployment; - }; - 01E2164009EDAC6600E66AF8 /* Default */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_ENABLE_CPP_EXCEPTIONS = NO; - GCC_ENABLE_CPP_RTTI = NO; - GCC_THREADSAFE_STATICS = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; - USER_HEADER_SEARCH_PATHS = "../../include/**"; - }; - name = Default; + name = Release; }; /* End XCBuildConfiguration section */ @@ -653,22 +626,20 @@ 01E2163909EDAC6600E66AF8 /* Build configuration list for PBXNativeTarget "CICarbonSample" */ = { isa = XCConfigurationList; buildConfigurations = ( - 01E2163A09EDAC6600E66AF8 /* Development */, - 01E2163B09EDAC6600E66AF8 /* Deployment */, - 01E2163C09EDAC6600E66AF8 /* Default */, + 01E2163A09EDAC6600E66AF8 /* Debug */, + 01E2163B09EDAC6600E66AF8 /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Default; + defaultConfigurationName = Debug; }; 01E2163D09EDAC6600E66AF8 /* Build configuration list for PBXProject "SampleApp" */ = { isa = XCConfigurationList; buildConfigurations = ( - 01E2163E09EDAC6600E66AF8 /* Development */, - 01E2163F09EDAC6600E66AF8 /* Deployment */, - 01E2164009EDAC6600E66AF8 /* Default */, + 01E2163E09EDAC6600E66AF8 /* Debug */, + 01E2163F09EDAC6600E66AF8 /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Default; + defaultConfigurationName = Debug; }; /* End XCConfigurationList section */ };