aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLUtil.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-03-30 18:42:48 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-30 18:42:59 +0000
commitbcf35f86d50b784b165de703b404998dd4299f6a (patch)
tree9fcd85326b1a5dbda864da9431a878bb62f65191 /src/sksl/SkSLUtil.h
parent7833466da45bfa1e078427c4a6db94d41c5c1535 (diff)
Revert "skslc can now be compiled with no Skia dependencies, in preparation for"
This reverts commit 7833466da45bfa1e078427c4a6db94d41c5c1535. Reason for revert: Vulkan assertion failure Original change's description: > skslc can now be compiled with no Skia dependencies, in preparation for > its eventual role in Skia's build process. > > Bug: skia: > Change-Id: Iaa9933f4fc4a64bec60aa897c509a3513f457a78 > Reviewed-on: https://skia-review.googlesource.com/10282 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Ben Wagner <benjaminwagner@google.com> > TBR=egdaniel@google.com,benjaminwagner@google.com,ethannicholas@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ic64cac2395abb406116885ddd725f74a434c8c49 Reviewed-on: https://skia-review.googlesource.com/10758 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.h207
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