Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: src/sksl/SkSLGLSLCodeGenerator.cpp

Issue 2312233002: refactored SkSL VarDeclaration handling (Closed)
Patch Set: fixed nits Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/SkSLGLSLCodeGenerator.h ('k') | src/sksl/SkSLIRGenerator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/SkSLGLSLCodeGenerator.cpp
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 20a39cf729e2b3700be036191a5bfa6501e8ec17..da0bcb903cf3508826e8a311f6f98338ba06f0a1 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -313,24 +313,24 @@ void GLSLCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
this->writeLine("};");
}
-void GLSLCodeGenerator::writeVarDeclaration(const VarDeclaration& decl) {
+void GLSLCodeGenerator::writeVarDeclarations(const VarDeclarations& decl) {
ASSERT(decl.fVars.size() > 0);
- this->writeModifiers(decl.fVars[0]->fModifiers);
+ this->writeModifiers(decl.fVars[0].fVar->fModifiers);
this->writeType(decl.fBaseType);
std::string separator = " ";
- for (size_t i = 0; i < decl.fVars.size(); i++) {
- ASSERT(decl.fVars[i]->fModifiers == decl.fVars[0]->fModifiers);
+ for (const auto& var : decl.fVars) {
+ ASSERT(var.fVar->fModifiers == decl.fVars[0].fVar->fModifiers);
this->write(separator);
separator = ", ";
- this->write(decl.fVars[i]->fName);
- for (const auto& size : decl.fSizes[i]) {
+ this->write(var.fVar->fName);
+ for (const auto& size : var.fSizes) {
this->write("[");
this->writeExpression(*size, kTopLevel_Precedence);
this->write("]");
}
- if (decl.fValues[i]) {
+ if (var.fValue) {
this->write(" = ");
- this->writeExpression(*decl.fValues[i], kTopLevel_Precedence);
+ this->writeExpression(*var.fValue, kTopLevel_Precedence);
}
}
this->write(";");
@@ -348,8 +348,8 @@ void GLSLCodeGenerator::writeStatement(const Statement& s) {
case Statement::kReturn_Kind:
this->writeReturnStatement((ReturnStatement&) s);
break;
- case Statement::kVarDeclaration_Kind:
- this->writeVarDeclaration(*((VarDeclarationStatement&) s).fDeclaration);
+ case Statement::kVarDeclarations_Kind:
+ this->writeVarDeclarations(*((VarDeclarationsStatement&) s).fDeclaration);
break;
case Statement::kIf_Kind:
this->writeIfStatement((IfStatement&) s);
@@ -455,9 +455,10 @@ void GLSLCodeGenerator::generateCode(const Program& program, std::ostream& out)
this->writeExtension((Extension&) *e);
break;
case ProgramElement::kVar_Kind: {
- VarDeclaration& decl = (VarDeclaration&) *e;
- if (decl.fVars.size() > 0 && decl.fVars[0]->fModifiers.fLayout.fBuiltin == -1) {
- this->writeVarDeclaration(decl);
+ VarDeclarations& decl = (VarDeclarations&) *e;
+ if (decl.fVars.size() > 0 &&
+ decl.fVars[0].fVar->fModifiers.fLayout.fBuiltin == -1) {
+ this->writeVarDeclarations(decl);
this->writeLine();
}
break;
« no previous file with comments | « src/sksl/SkSLGLSLCodeGenerator.h ('k') | src/sksl/SkSLIRGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698