diff options
author | 2017-10-26 09:30:08 -0400 | |
---|---|---|
committer | 2017-10-26 14:58:27 +0000 | |
commit | d608c09ac5d862568962d63e62e693d22c58f95c (patch) | |
tree | 7a5dd9bc7a97dea7fa7720c73e7f9bdf1dac51c9 /src/sksl/SkSLHCodeGenerator.cpp | |
parent | d4e9ec86cf934107cc441f651ee2429078188d02 (diff) |
Re-land "converted OverdrawColorFilter to SkSL"
This reverts commit 2d3cac58fcc8f2d398a421b0341c36479a6ba324.
Bug: skia:
Change-Id: I6607d419f6b30c3e17b52ec5ce67d489bd1ad1dc
Reviewed-on: https://skia-review.googlesource.com/64080
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLHCodeGenerator.cpp')
-rw-r--r-- | src/sksl/SkSLHCodeGenerator.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/sksl/SkSLHCodeGenerator.cpp b/src/sksl/SkSLHCodeGenerator.cpp index 21f4f2842c..da67126baf 100644 --- a/src/sksl/SkSLHCodeGenerator.cpp +++ b/src/sksl/SkSLHCodeGenerator.cpp @@ -23,8 +23,11 @@ HCodeGenerator::HCodeGenerator(const Context* context, const Program* program, , fFullName(String::printf("Gr%s", fName.c_str())) , fSectionAndParameterHelper(*program, *errors) {} -String HCodeGenerator::ParameterType(const Context& context, const Type& type) { - if (type == *context.fFloat_Type || type == *context.fHalf_Type) { +String HCodeGenerator::ParameterType(const Context& context, const Type& type, + const Layout& layout) { + if (layout.fCType != "") { + return layout.fCType; + } else if (type == *context.fFloat_Type || type == *context.fHalf_Type) { return "float"; } else if (type == *context.fFloat2_Type || type == *context.fHalf2_Type) { return "SkPoint"; @@ -42,7 +45,8 @@ String HCodeGenerator::ParameterType(const Context& context, const Type& type) { return type.name(); } -String HCodeGenerator::FieldType(const Context& context, const Type& type) { +String HCodeGenerator::FieldType(const Context& context, const Type& type, + const Layout& layout) { if (type.kind() == Type::kSampler_Kind) { return "TextureSampler"; } else if (type == *context.fFragmentProcessor_Type) { @@ -51,7 +55,7 @@ String HCodeGenerator::FieldType(const Context& context, const Type& type) { ASSERT(false); return "<error>"; } - return ParameterType(context, type); + return ParameterType(context, type, layout); } void HCodeGenerator::writef(const char* s, va_list va) { @@ -134,7 +138,8 @@ void HCodeGenerator::writeMake() { this->writef(" static std::unique_ptr<GrFragmentProcessor> Make("); separator = ""; for (const auto& param : fSectionAndParameterHelper.getParameters()) { - this->writef("%s%s %s", separator, ParameterType(fContext, param->fType).c_str(), + this->writef("%s%s %s", separator, ParameterType(fContext, param->fType, + param->fModifiers.fLayout).c_str(), String(param->fName).c_str()); separator = ", "; } @@ -176,7 +181,8 @@ void HCodeGenerator::writeConstructor() { this->writef(" %s(", fFullName.c_str()); const char* separator = ""; for (const auto& param : fSectionAndParameterHelper.getParameters()) { - this->writef("%s%s %s", separator, ParameterType(fContext, param->fType).c_str(), + this->writef("%s%s %s", separator, ParameterType(fContext, param->fType, + param->fModifiers.fLayout).c_str(), String(param->fName).c_str()); separator = ", "; } @@ -235,7 +241,8 @@ void HCodeGenerator::writeFields() { if (param->fType == *fContext.fFragmentProcessor_Type) { continue; } - this->writef(" %s %s;\n", FieldType(fContext, param->fType).c_str(), + this->writef(" %s %s;\n", FieldType(fContext, param->fType, + param->fModifiers.fLayout).c_str(), FieldName(String(param->fName).c_str()).c_str()); } for (const Section* s : fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION)) { @@ -267,7 +274,8 @@ bool HCodeGenerator::generateCode() { String nameString(param->fName); const char* name = nameString.c_str(); this->writef(" %s %s() const { return %s; }\n", - FieldType(fContext, param->fType).c_str(), name, FieldName(name).c_str()); + FieldType(fContext, param->fType, param->fModifiers.fLayout).c_str(), name, + FieldName(name).c_str()); } this->writeMake(); this->writef(" %s(const %s& src);\n" |