diff options
Diffstat (limited to 'src/sksl/SkSLUtil.h')
-rw-r--r-- | src/sksl/SkSLUtil.h | 207 |
1 files changed, 46 insertions, 161 deletions
diff --git a/src/sksl/SkSLUtil.h b/src/sksl/SkSLUtil.h index d1af9bb3c7..678241d205 100644 --- a/src/sksl/SkSLUtil.h +++ b/src/sksl/SkSLUtil.h @@ -4,159 +4,22 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_UTIL #define SKSL_UTIL -#include <cstdarg> -#include <memory> #include "stdlib.h" -#include "string.h" #include "assert.h" -#include "SkSLString.h" -#include "SkSLStringStream.h" - -#ifndef SKSL_STANDALONE +#include "SkOpts.h" +#include "SkRefCnt.h" +#include "SkStream.h" +#include "SkString.h" +#include "SkTypes.h" #include "GrContextOptions.h" #include "GrShaderCaps.h" -#endif - -#ifdef SKSL_STANDALONE -#if defined(_WIN32) || defined(__SYMBIAN32__) -#define SKSL_BUILD_FOR_WIN -#endif -#else -#ifdef SK_BUILD_FOR_WIN -#define SKSL_BUILD_FOR_WIN -#endif // SK_BUILD_FOR_WIN -#endif // SKSL_STANDALONE namespace SkSL { -#ifdef SKSL_STANDALONE - -// we're being compiled standalone, so we don't have access to caps... -enum GrGLSLGeneration { - k110_GrGLSLGeneration, - k130_GrGLSLGeneration, - k140_GrGLSLGeneration, - k150_GrGLSLGeneration, - k330_GrGLSLGeneration, - k400_GrGLSLGeneration, - k420_GrGLSLGeneration, - k310es_GrGLSLGeneration, - k320es_GrGLSLGeneration, -}; - -#define SKSL_CAPS_CLASS StandaloneShaderCaps -class StandaloneShaderCaps { -public: - GrGLSLGeneration generation() const { - return k400_GrGLSLGeneration; - } - - bool canUseMinAndAbsTogether() const { - return true; - } - - bool mustForceNegatedAtanParamToFloat() const { - return false; - } - - bool shaderDerivativeSupport() const { - return true; - } - - bool usesPrecisionModifiers() const { - return true; - } - - bool mustDeclareFragmentShaderOutput() const { - return true; - } - - bool fbFetchSupport() const { - return true; - } - - bool fbFetchNeedsCustomOutput() const { - return false; - } - - bool bindlessTextureSupport() const { - return false; - } - - bool dropsTileOnZeroDivide() const { - return false; - } - - bool flatInterpolationSupport() const { - return true; - } - - bool noperspectiveInterpolationSupport() const { - return true; - } - - bool multisampleInterpolationSupport() const { - return true; - } - - bool sampleVariablesSupport() const { - return true; - } - - bool sampleMaskOverrideCoverageSupport() const { - return true; - } - - bool externalTextureSupport() const { - return true; - } - - bool texelFetchSupport() const { - return true; - } - - bool imageLoadStoreSupport() const { - return true; - } - - bool mustEnableAdvBlendEqs() const { - return false; - } - - bool mustEnableSpecificAdvBlendEqs() const { - return false; - } - - bool canUseAnyFunctionInShader() const { - return false; - } - - const char* shaderDerivativeExtensionString() const { - return nullptr; - } - - const char* fragCoordConventionsExtensionString() const { - return nullptr; - } - - const char* imageLoadStoreExtensionString() const { - return nullptr; - } - - const char* versionDeclString() const { - return ""; - } -}; - -extern StandaloneShaderCaps standaloneCaps; - -#else - -#define SKSL_CAPS_CLASS GrShaderCaps // Various sets of caps for use in tests class ShaderCapsFactory { public: @@ -235,38 +98,60 @@ public: return result; } }; -#endif -void write_stringstream(const StringStream& d, OutputStream& out); +void write_data(const SkData& d, SkWStream& out); + +SkString operator+(const SkString& s, const char* c); + +SkString operator+(const char* c, const SkString& s); + +SkString operator+(const SkString& s1, const SkString& s2); + +bool operator==(const SkString& s1, const char* s2); + +bool operator!=(const SkString& s1, const char* s2); + +bool operator!=(const char* s1, const SkString& s2); + +SkString to_string(double value); + +SkString to_string(int32_t value); + +SkString to_string(uint32_t value); + +SkString to_string(int64_t value); + +SkString to_string(uint64_t value); #if _MSC_VER #define NORETURN __declspec(noreturn) #else #define NORETURN __attribute__((__noreturn__)) #endif +int stoi(SkString s); + +double stod(SkString s); + +long stol(SkString s); NORETURN void sksl_abort(); } // namespace -#ifdef SKSL_STANDALONE -#define ASSERT(x) (void)((x) || (ABORT("failed assert(%s): %s:%d\n", #x, __FILE__, __LINE__), 0)) -#define ASSERT_RESULT(x) ASSERT(x) -#define SKSL_DEBUGCODE(x) x -#else -#define ASSERT SkASSERT -#define ASSERT_RESULT(x) SkAssertResult(x) -#define SKSL_DEBUGCODE(x) SkDEBUGCODE(x) -#endif +#define ASSERT(x) SkASSERT(x) +#define ASSERT_RESULT(x) SkAssertResult(x); -#define SKSL_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) - -#if defined(__clang__) || defined(__GNUC__) -#define SKSL_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) +#ifdef SKIA +#define ABORT(...) { SkDebugf(__VA_ARGS__); sksl_abort(); } #else -#define SKSL_PRINTF_LIKE(A, B) +#define ABORT(...) { sksl_abort(); } #endif -#define ABORT(...) (printf(__VA_ARGS__), sksl_abort()) - +namespace std { + template<> struct hash<SkString> { + size_t operator()(const SkString& s) const { + return SkOpts::hash_fn(s.c_str(), s.size(), 0); + } + }; +} #endif |