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