aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLUtil.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2016-11-21 10:39:35 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-21 17:14:43 +0000
commit9e1138d56665d13641f8805cd72ae81adc255f79 (patch)
tree1c94ded7cff10f5f62233d1de83c3d30ad0a2893 /src/sksl/SkSLUtil.h
parente54d4cefb7864a575c01894b2e5e0df16978c6e6 (diff)
re-land of switched skslc from std::string to SkString
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5084 Change-Id: Ib21c30afc0d8483392b417e660b7fecfcc30e617 Reviewed-on: https://skia-review.googlesource.com/5084 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLUtil.h')
-rw-r--r--src/sksl/SkSLUtil.h52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/sksl/SkSLUtil.h b/src/sksl/SkSLUtil.h
index ede21830e5..ad8287e39f 100644
--- a/src/sksl/SkSLUtil.h
+++ b/src/sksl/SkSLUtil.h
@@ -8,12 +8,12 @@
#ifndef SKSL_UTIL
#define SKSL_UTIL
-#include <iomanip>
-#include <string>
-#include <sstream>
#include "stdlib.h"
#include "assert.h"
+#include "SkOpts.h"
#include "SkRefCnt.h"
+#include "SkStream.h"
+#include "SkString.h"
#include "SkTypes.h"
#include "glsl/GrGLSLCaps.h"
#include "GrContextOptions.h"
@@ -73,40 +73,47 @@ public:
}
};
-// our own definitions of certain std:: functions, because they are not always present on Android
+void write_data(const SkData& d, SkWStream& out);
-std::string to_string(double value);
+SkString operator+(const SkString& s, const char* c);
-std::string to_string(int32_t value);
+SkString operator+(const char* c, const SkString& s);
-std::string to_string(uint32_t value);
+SkString operator+(const SkString& s1, const SkString& s2);
-std::string to_string(int64_t value);
+bool operator==(const SkString& s1, const char* s2);
-std::string to_string(uint64_t value);
+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(std::string s);
+int stoi(SkString s);
-double stod(std::string s);
+double stod(SkString s);
-long stol(std::string s);
+long stol(SkString s);
NORETURN void sksl_abort();
} // namespace
-#ifdef DEBUG
-#define ASSERT(x) assert(x)
-#define ASSERT_RESULT(x) ASSERT(x);
-#else
-#define ASSERT(x)
-#define ASSERT_RESULT(x) x
-#endif
+#define ASSERT(x) SkASSERT(x)
+#define ASSERT_RESULT(x) SkAssertResult(x);
#ifdef SKIA
#define ABORT(...) { SkDebugf(__VA_ARGS__); sksl_abort(); }
@@ -114,4 +121,11 @@ NORETURN void sksl_abort();
#define ABORT(...) { sksl_abort(); }
#endif
+namespace std {
+ template<> struct hash<SkString> {
+ size_t operator()(const SkString& s) const {
+ return SkOpts::hash_fn(s.c_str(), s.size(), 0);
+ }
+ };
+}
#endif