aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-12-19 09:29:22 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-19 14:58:56 +0000
commit58d564881657b2c434fa20a9801f874feada0ad0 (patch)
treec3cd9742c7d9620d38c24a87aa4a257f6a112d41 /src/sksl
parent1ad81981b0027e96ef0cecd78661ab2c22bdc4aa (diff)
fixed a couple of SkSL ushort issues
This fixes SkSL omitting the 'u' literal on ushort values, and ushorts can now implicitly coerce to ints. Bug: skia: Change-Id: I21e5dc06d34e09a4fc1aa4d746e6e75c0d2d8c7e Reviewed-on: https://skia-review.googlesource.com/85960 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/sksl')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp4
-rw-r--r--src/sksl/ir/SkSLType.cpp3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index f7d6a8444c..4223a4114b 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -602,7 +602,9 @@ void GLSLCodeGenerator::writeBoolLiteral(const BoolLiteral& b) {
void GLSLCodeGenerator::writeIntLiteral(const IntLiteral& i) {
if (i.fType == *fContext.fUInt_Type) {
this->write(to_string(i.fValue & 0xffffffff) + "u");
- } else {
+ } else if (i.fType == *fContext.fUShort_Type) {
+ this->write(to_string(i.fValue & 0xffff) + "u");
+ } else {
this->write(to_string((int32_t) i.fValue));
}
}
diff --git a/src/sksl/ir/SkSLType.cpp b/src/sksl/ir/SkSLType.cpp
index 19bc58e2f0..4310229d84 100644
--- a/src/sksl/ir/SkSLType.cpp
+++ b/src/sksl/ir/SkSLType.cpp
@@ -35,6 +35,9 @@ int Type::coercionCost(const Type& other) const {
if (this->isUnsigned() && other.isUnsigned()) {
return 1;
}
+ if (this->isUnsigned() && other.isSigned() && other.priority() > priority()) {
+ return 1;
+ }
for (size_t i = 0; i < fCoercibleTypes.size(); i++) {
if (*fCoercibleTypes[i] == other) {
return (int) i + 1;