diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-10-25 15:55:58 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-25 20:19:18 +0000 |
commit | 8aa4dc9052a64d84cfd0a4330910057bd37b6bf7 (patch) | |
tree | 5b8c084ed43b6f10e6014a2fc2959e84c4be3c5b /src/sksl/SkSLHCodeGenerator.cpp | |
parent | 4cbb6e6d551e8bea2c040b1aa9dce253cffb9af0 (diff) |
converted OverdrawColorFilter to SkSL
Bug: skia:
Change-Id: Idcc0502758df1e60ed131a168b5c9a65a4d834a1
Reviewed-on: https://skia-review.googlesource.com/63840
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@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" |