OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkSLGLSLCodeGenerator.h" | 8 #include "SkSLGLSLCodeGenerator.h" |
9 | 9 |
10 #include "string.h" | 10 #include "string.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 this->write(type.name()); | 61 this->write(type.name()); |
62 return; | 62 return; |
63 } | 63 } |
64 } | 64 } |
65 fWrittenStructs.push_back(&type); | 65 fWrittenStructs.push_back(&type); |
66 this->writeLine("struct " + type.name() + " {"); | 66 this->writeLine("struct " + type.name() + " {"); |
67 fIndentation++; | 67 fIndentation++; |
68 for (const auto& f : type.fields()) { | 68 for (const auto& f : type.fields()) { |
69 this->writeModifiers(f.fModifiers); | 69 this->writeModifiers(f.fModifiers); |
70 // sizes (which must be static in structs) are part of the type name
here | 70 // sizes (which must be static in structs) are part of the type name
here |
71 this->writeType(f.fType); | 71 this->writeType(*f.fType); |
72 this->writeLine(" " + f.fName + ";"); | 72 this->writeLine(" " + f.fName + ";"); |
73 } | 73 } |
74 fIndentation--; | 74 fIndentation--; |
75 this->writeLine("}"); | 75 this->writeLine("}"); |
76 } else { | 76 } else { |
77 this->write(type.name()); | 77 this->write(type.name()); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 void GLSLCodeGenerator::writeExpression(const Expression& expr, Precedence paren
tPrecedence) { | 81 void GLSLCodeGenerator::writeExpression(const Expression& expr, Precedence paren
tPrecedence) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 void GLSLCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) { | 300 void GLSLCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) { |
301 if (intf.fVariable.fName == "gl_PerVertex") { | 301 if (intf.fVariable.fName == "gl_PerVertex") { |
302 return; | 302 return; |
303 } | 303 } |
304 this->writeModifiers(intf.fVariable.fModifiers); | 304 this->writeModifiers(intf.fVariable.fModifiers); |
305 this->writeLine(intf.fVariable.fType.name() + " {"); | 305 this->writeLine(intf.fVariable.fType.name() + " {"); |
306 fIndentation++; | 306 fIndentation++; |
307 for (const auto& f : intf.fVariable.fType.fields()) { | 307 for (const auto& f : intf.fVariable.fType.fields()) { |
308 this->writeModifiers(f.fModifiers); | 308 this->writeModifiers(f.fModifiers); |
309 this->writeType(f.fType); | 309 this->writeType(*f.fType); |
310 this->writeLine(" " + f.fName + ";"); | 310 this->writeLine(" " + f.fName + ";"); |
311 } | 311 } |
312 fIndentation--; | 312 fIndentation--; |
313 this->writeLine("};"); | 313 this->writeLine("};"); |
314 } | 314 } |
315 | 315 |
316 void GLSLCodeGenerator::writeVarDeclaration(const VarDeclaration& decl) { | 316 void GLSLCodeGenerator::writeVarDeclaration(const VarDeclaration& decl) { |
317 ASSERT(decl.fVars.size() > 0); | 317 ASSERT(decl.fVars.size() > 0); |
318 this->writeModifiers(decl.fVars[0]->fModifiers); | 318 this->writeModifiers(decl.fVars[0]->fModifiers); |
319 this->writeType(decl.fBaseType); | 319 this->writeType(decl.fBaseType); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 break; | 470 break; |
471 default: | 471 default: |
472 printf("%s\n", e->description().c_str()); | 472 printf("%s\n", e->description().c_str()); |
473 ABORT("unsupported program element"); | 473 ABORT("unsupported program element"); |
474 } | 474 } |
475 } | 475 } |
476 fOut = nullptr; | 476 fOut = nullptr; |
477 } | 477 } |
478 | 478 |
479 } | 479 } |
OLD | NEW |