Skip to content

Instantly share code, notes, and snippets.

@vddvss
Last active February 8, 2020 17:49
Show Gist options
  • Save vddvss/159f203c32bea41f0e8e496ef57e722b to your computer and use it in GitHub Desktop.
Save vddvss/159f203c32bea41f0e8e496ef57e722b to your computer and use it in GitHub Desktop.
gl bug workaround
--- chromium-80.0.3987.87.orig/third_party/angle/src/compiler/translator/InfoSink.h
+++ chromium-80.0.3987.87/third_party/angle/src/compiler/translator/InfoSink.h
@@ -92,7 +92,16 @@ class TInfoSinkBase
stream.precision(8);
stream << f;
}
- sink.append(stream.str());
+
+ // Hack to work around a bug where negative floating point values
+ // are rendered like '.0.5' instead of '-0.5'
+ std::string res(stream.str());
+
+ if (signbit(f)) { // test if f is negative
+ res[0] = '-';
+ }
+
+ sink.append(res);
return *this;
}
// Write boolean values as their names instead of integral value.
--- chromium-80.0.3987.87.orig/third_party/skia/src/sksl/SkSLString.cpp
+++ chromium-80.0.3987.87/third_party/skia/src/sksl/SkSLString.cpp
@@ -240,7 +240,12 @@ String to_string(double value) {
if (needsDotZero) {
buffer << ".0";
}
- return String(buffer.str().c_str());
+
+ std::string ret(buffer.str());
+ if (signbit(value) && ret[0] == '.') {
+ ret[0] = '-';
+ }
+ return String(ret.c_str());
}
SKSL_INT stoi(const String& s) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment