diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-03-31 16:04:34 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-31 16:04:41 +0000 |
commit | 9bd301d640ff63c280b202c7dd00bc00a3315ff4 (patch) | |
tree | 176fcfe46fb17a8c50c145196705f4ef42a950fa /src/sksl/SkSLUtil.h | |
parent | 92d7ccafdf896cf19764e025873d13315a76842d (diff) |
Revert "skslc can now be compiled with no Skia dependencies, in preparation for its eventual"
This reverts commit f3333c89bf05fc602d9bf8e1e24547668c660383.
Reason for revert: breaking the bots
Original change's description:
> skslc can now be compiled with no Skia dependencies, in preparation for its eventual
> role in Skia's build process.
>
> This reverts commit bcf35f86d50b784b165de703b404998dd4299f6a.
>
> BUG=skia:
>
> Change-Id: Id0a12dfc4d804d69a3c6bf60fed37e89ee130f02
> Reviewed-on: https://skia-review.googlesource.com/10802
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
>
TBR=benjaminwagner@google.com,ethannicholas@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Change-Id: Ic7b50d391d25b3870acffa9764cbafc7f5c3be89
Reviewed-on: https://skia-review.googlesource.com/10962
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
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 |