Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkSLHCodeGenerator.h" |
| 9 | |
| 10 | #include "SkSLUtil.h" |
| 11 | #include "ir/SkSLFunctionDeclaration.h" |
| 12 | #include "ir/SkSLFunctionDefinition.h" |
| 13 | #include "ir/SkSLSection.h" |
| 14 | #include "ir/SkSLVarDeclarations.h" |
| 15 | |
| 16 | namespace SkSL { |
| 17 | |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 18 | HCodeGenerator::HCodeGenerator(const Context* context, const Program* program, |
| 19 | ErrorReporter* errors, String name, OutputStream* out) |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 20 | : INHERITED(program, errors, out) |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 21 | , fContext(*context) |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 22 | , fName(std::move(name)) |
| 23 | , fFullName(String::printf("Gr%s", fName.c_str())) |
| 24 | , fSectionAndParameterHelper(*program, *errors) {} |
| 25 | |
Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 26 | String HCodeGenerator::ParameterType(const Context& context, const Type& type, |
| 27 | const Layout& layout) { |
| 28 | if (layout.fCType != "") { |
| 29 | return layout.fCType; |
| 30 | } else if (type == *context.fFloat_Type || type == *context.fHalf_Type) { |
Ethan Nicholas | f7b8820 | 2017-09-18 14:10:39 -0400 | [diff] [blame] | 31 | return "float"; |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 32 | } else if (type == *context.fFloat2_Type || type == *context.fHalf2_Type) { |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 33 | return "SkPoint"; |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 34 | } else if (type == *context.fInt4_Type || type == *context.fShort4_Type) { |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 35 | return "SkIRect"; |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 36 | } else if (type == *context.fFloat4_Type || type == *context.fHalf4_Type) { |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 37 | return "SkRect"; |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 38 | } else if (type == *context.fFloat4x4_Type || type == *context.fHalf4x4_Type) { |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 39 | return "SkMatrix44"; |
| 40 | } else if (type.kind() == Type::kSampler_Kind) { |
| 41 | return "sk_sp<GrTextureProxy>"; |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 42 | } else if (type == *context.fFragmentProcessor_Type) { |
| 43 | return "std::unique_ptr<GrFragmentProcessor>"; |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 44 | } |
| 45 | return type.name(); |
| 46 | } |
| 47 | |
Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 48 | String HCodeGenerator::FieldType(const Context& context, const Type& type, |
| 49 | const Layout& layout) { |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 50 | if (type.kind() == Type::kSampler_Kind) { |
| 51 | return "TextureSampler"; |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 52 | } else if (type == *context.fFragmentProcessor_Type) { |
| 53 | // we don't store fragment processors in fields, they get registered via |
| 54 | // registerChildProcessor instead |
| 55 | ASSERT(false); |
| 56 | return "<error>"; |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 57 | } |
Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 58 | return ParameterType(context, type, layout); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | void HCodeGenerator::writef(const char* s, va_list va) { |
| 62 | static constexpr int BUFFER_SIZE = 1024; |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 63 | va_list copy; |
| 64 | va_copy(copy, va); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 65 | char buffer[BUFFER_SIZE]; |
| 66 | int length = vsnprintf(buffer, BUFFER_SIZE, s, va); |
| 67 | if (length < BUFFER_SIZE) { |
| 68 | fOut->write(buffer, length); |
| 69 | } else { |
| 70 | std::unique_ptr<char[]> heap(new char[length + 1]); |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 71 | vsprintf(heap.get(), s, copy); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 72 | fOut->write(heap.get(), length); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | void HCodeGenerator::writef(const char* s, ...) { |
| 77 | va_list va; |
| 78 | va_start(va, s); |
| 79 | this->writef(s, va); |
| 80 | va_end(va); |
| 81 | } |
| 82 | |
| 83 | bool HCodeGenerator::writeSection(const char* name, const char* prefix) { |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 84 | const Section* s = fSectionAndParameterHelper.getSection(name); |
| 85 | if (s) { |
| 86 | this->writef("%s%s", prefix, s->fText.c_str()); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 87 | return true; |
| 88 | } |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | void HCodeGenerator::writeExtraConstructorParams(const char* separator) { |
| 93 | // super-simple parse, just assume the last token before a comma is the name of a parameter |
| 94 | // (which is true as long as there are no multi-parameter template types involved). Will replace |
| 95 | // this with something more robust if the need arises. |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 96 | const Section* section = fSectionAndParameterHelper.getSection(CONSTRUCTOR_PARAMS_SECTION); |
| 97 | if (section) { |
| 98 | const char* s = section->fText.c_str(); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 99 | #define BUFFER_SIZE 64 |
| 100 | char lastIdentifier[BUFFER_SIZE]; |
| 101 | int lastIdentifierLength = 0; |
| 102 | bool foundBreak = false; |
| 103 | while (*s) { |
| 104 | char c = *s; |
| 105 | ++s; |
| 106 | if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || |
| 107 | c == '_') { |
| 108 | if (foundBreak) { |
| 109 | lastIdentifierLength = 0; |
| 110 | foundBreak = false; |
| 111 | } |
| 112 | ASSERT(lastIdentifierLength < BUFFER_SIZE); |
| 113 | lastIdentifier[lastIdentifierLength] = c; |
| 114 | ++lastIdentifierLength; |
| 115 | } else { |
| 116 | foundBreak = true; |
| 117 | if (c == ',') { |
| 118 | ASSERT(lastIdentifierLength < BUFFER_SIZE); |
| 119 | lastIdentifier[lastIdentifierLength] = 0; |
| 120 | this->writef("%s%s", separator, lastIdentifier); |
| 121 | separator = ", "; |
| 122 | } else if (c != ' ' && c != '\t' && c != '\n' && c != '\r') { |
| 123 | lastIdentifierLength = 0; |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | if (lastIdentifierLength) { |
| 128 | ASSERT(lastIdentifierLength < BUFFER_SIZE); |
| 129 | lastIdentifier[lastIdentifierLength] = 0; |
| 130 | this->writef("%s%s", separator, lastIdentifier); |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | void HCodeGenerator::writeMake() { |
| 136 | const char* separator; |
| 137 | if (!this->writeSection(MAKE_SECTION)) { |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 138 | this->writef(" static std::unique_ptr<GrFragmentProcessor> Make("); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 139 | separator = ""; |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 140 | for (const auto& param : fSectionAndParameterHelper.getParameters()) { |
Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 141 | this->writef("%s%s %s", separator, ParameterType(fContext, param->fType, |
| 142 | param->fModifiers.fLayout).c_str(), |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 143 | String(param->fName).c_str()); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 144 | separator = ", "; |
| 145 | } |
| 146 | this->writeSection(CONSTRUCTOR_PARAMS_SECTION, separator); |
| 147 | this->writef(") {\n" |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 148 | " return std::unique_ptr<GrFragmentProcessor>(new %s(", |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 149 | fFullName.c_str()); |
| 150 | separator = ""; |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 151 | for (const auto& param : fSectionAndParameterHelper.getParameters()) { |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 152 | if (param->fType == *fContext.fFragmentProcessor_Type) { |
Robert Phillips | 7a59f23 | 2017-11-08 15:31:30 -0500 | [diff] [blame^] | 153 | this->writef("%sstd::move(%s)", separator, String(param->fName).c_str()); |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 154 | } else { |
| 155 | this->writef("%s%s", separator, String(param->fName).c_str()); |
| 156 | } |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 157 | separator = ", "; |
| 158 | } |
| 159 | this->writeExtraConstructorParams(separator); |
| 160 | this->writef("));\n" |
| 161 | " }\n"); |
| 162 | } |
| 163 | } |
| 164 | |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 165 | void HCodeGenerator::failOnSection(const char* section, const char* msg) { |
| 166 | std::vector<const Section*> s = fSectionAndParameterHelper.getSections(section); |
| 167 | if (s.size()) { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 168 | fErrors.error(s[0]->fOffset, String("@") + section + " " + msg); |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 172 | void HCodeGenerator::writeConstructor() { |
| 173 | if (this->writeSection(CONSTRUCTOR_SECTION)) { |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 174 | const char* msg = "may not be present when constructor is overridden"; |
| 175 | this->failOnSection(CONSTRUCTOR_CODE_SECTION, msg); |
| 176 | this->failOnSection(CONSTRUCTOR_PARAMS_SECTION, msg); |
| 177 | this->failOnSection(COORD_TRANSFORM_SECTION, msg); |
| 178 | this->failOnSection(INITIALIZERS_SECTION, msg); |
| 179 | this->failOnSection(OPTIMIZATION_FLAGS_SECTION, msg); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 180 | } |
| 181 | this->writef(" %s(", fFullName.c_str()); |
| 182 | const char* separator = ""; |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 183 | for (const auto& param : fSectionAndParameterHelper.getParameters()) { |
Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 184 | this->writef("%s%s %s", separator, ParameterType(fContext, param->fType, |
| 185 | param->fModifiers.fLayout).c_str(), |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 186 | String(param->fName).c_str()); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 187 | separator = ", "; |
| 188 | } |
| 189 | this->writeSection(CONSTRUCTOR_PARAMS_SECTION, separator); |
| 190 | this->writef(")\n" |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 191 | " : INHERITED(k%s_ClassID", fFullName.c_str()); |
| 192 | if (!this->writeSection(OPTIMIZATION_FLAGS_SECTION, ", (OptimizationFlags) ")) { |
| 193 | this->writef(", kNone_OptimizationFlags"); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 194 | } |
| 195 | this->writef(")"); |
| 196 | this->writeSection(INITIALIZERS_SECTION, "\n , "); |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 197 | for (const auto& param : fSectionAndParameterHelper.getParameters()) { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 198 | String nameString(param->fName); |
| 199 | const char* name = nameString.c_str(); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 200 | if (param->fType.kind() == Type::kSampler_Kind) { |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 201 | this->writef("\n , %s(std::move(%s)", FieldName(name).c_str(), name); |
| 202 | for (const Section* s : fSectionAndParameterHelper.getSections( |
| 203 | SAMPLER_PARAMS_SECTION)) { |
| 204 | if (s->fArgument == name) { |
| 205 | this->writef(", %s", s->fText.c_str()); |
| 206 | } |
| 207 | } |
| 208 | this->writef(")"); |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 209 | } else if (param->fType == *fContext.fFragmentProcessor_Type) { |
| 210 | // do nothing |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 211 | } else { |
| 212 | this->writef("\n , %s(%s)", FieldName(name).c_str(), name); |
| 213 | } |
| 214 | } |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 215 | for (const Section* s : fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION)) { |
| 216 | String field = FieldName(s->fArgument.c_str()); |
| 217 | this->writef("\n , %sCoordTransform(%s, %s.proxy())", field.c_str(), s->fText.c_str(), |
| 218 | field.c_str()); |
| 219 | } |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 220 | this->writef(" {\n"); |
| 221 | this->writeSection(CONSTRUCTOR_CODE_SECTION); |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 222 | for (const auto& param : fSectionAndParameterHelper.getParameters()) { |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 223 | if (param->fType.kind() == Type::kSampler_Kind) { |
| 224 | this->writef(" this->addTextureSampler(&%s);\n", |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 225 | FieldName(String(param->fName).c_str()).c_str()); |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 226 | } else if (param->fType == *fContext.fFragmentProcessor_Type) { |
| 227 | this->writef(" this->registerChildProcessor(std::move(%s));", |
| 228 | String(param->fName).c_str()); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 229 | } |
| 230 | } |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 231 | for (const Section* s : fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION)) { |
| 232 | String field = FieldName(s->fArgument.c_str()); |
| 233 | this->writef(" this->addCoordTransform(&%sCoordTransform);\n", field.c_str()); |
| 234 | } |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 235 | this->writef(" }\n"); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | void HCodeGenerator::writeFields() { |
| 239 | this->writeSection(FIELDS_SECTION); |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 240 | for (const auto& param : fSectionAndParameterHelper.getParameters()) { |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 241 | if (param->fType == *fContext.fFragmentProcessor_Type) { |
| 242 | continue; |
| 243 | } |
Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 244 | this->writef(" %s %s;\n", FieldType(fContext, param->fType, |
| 245 | param->fModifiers.fLayout).c_str(), |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 246 | FieldName(String(param->fName).c_str()).c_str()); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 247 | } |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 248 | for (const Section* s : fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION)) { |
| 249 | this->writef(" GrCoordTransform %sCoordTransform;\n", |
| 250 | FieldName(s->fArgument.c_str()).c_str()); |
| 251 | } |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | bool HCodeGenerator::generateCode() { |
| 255 | this->writef(kFragmentProcessorHeader, fFullName.c_str()); |
| 256 | this->writef("#ifndef %s_DEFINED\n" |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 257 | "#define %s_DEFINED\n", |
| 258 | fFullName.c_str(), |
| 259 | fFullName.c_str()); |
Ethan Nicholas | ceb4d48 | 2017-07-10 15:40:20 -0400 | [diff] [blame] | 260 | this->writef("#include \"SkTypes.h\"\n" |
| 261 | "#if SK_SUPPORT_GPU\n"); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 262 | this->writeSection(HEADER_SECTION); |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 263 | this->writef("#include \"GrFragmentProcessor.h\"\n" |
Brian Osman | 1cb4171 | 2017-10-19 12:54:52 -0400 | [diff] [blame] | 264 | "#include \"GrCoordTransform.h\"\n"); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 265 | this->writef("class %s : public GrFragmentProcessor {\n" |
| 266 | "public:\n", |
| 267 | fFullName.c_str()); |
| 268 | this->writeSection(CLASS_SECTION); |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 269 | for (const auto& param : fSectionAndParameterHelper.getParameters()) { |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 270 | if (param->fType.kind() == Type::kSampler_Kind || |
| 271 | param->fType.kind() == Type::kOther_Kind) { |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 272 | continue; |
| 273 | } |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 274 | String nameString(param->fName); |
| 275 | const char* name = nameString.c_str(); |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 276 | this->writef(" %s %s() const { return %s; }\n", |
Ethan Nicholas | d608c09 | 2017-10-26 09:30:08 -0400 | [diff] [blame] | 277 | FieldType(fContext, param->fType, param->fModifiers.fLayout).c_str(), name, |
| 278 | FieldName(name).c_str()); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 279 | } |
| 280 | this->writeMake(); |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 281 | this->writef(" %s(const %s& src);\n" |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 282 | " std::unique_ptr<GrFragmentProcessor> clone() const override;\n" |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 283 | " const char* name() const override { return \"%s\"; }\n" |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 284 | "private:\n", |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 285 | fFullName.c_str(), fFullName.c_str(), fName.c_str()); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 286 | this->writeConstructor(); |
| 287 | this->writef(" GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;\n" |
| 288 | " void onGetGLSLProcessorKey(const GrShaderCaps&," |
| 289 | "GrProcessorKeyBuilder*) const override;\n" |
| 290 | " bool onIsEqual(const GrFragmentProcessor&) const override;\n" |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 291 | " GR_DECLARE_FRAGMENT_PROCESSOR_TEST\n"); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 292 | this->writeFields(); |
| 293 | this->writef(" typedef GrFragmentProcessor INHERITED;\n" |
Ethan Nicholas | 9fb036f | 2017-07-05 16:19:09 -0400 | [diff] [blame] | 294 | "};\n"); |
| 295 | this->writeSection(HEADER_END_SECTION); |
Ethan Nicholas | ceb4d48 | 2017-07-10 15:40:20 -0400 | [diff] [blame] | 296 | this->writef("#endif\n" |
| 297 | "#endif\n"); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 298 | return 0 == fErrors.errorCount(); |
| 299 | } |
| 300 | |
| 301 | } // namespace |