| 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 #ifndef SKSL_ASTLAYOUT | 8 #ifndef SKSL_ASTLAYOUT |
| 9 #define SKSL_ASTLAYOUT | 9 #define SKSL_ASTLAYOUT |
| 10 | 10 |
| 11 #include "SkSLASTNode.h" | 11 #include "SkSLASTNode.h" |
| 12 #include "SkSLUtil.h" | 12 #include "SkSLUtil.h" |
| 13 | 13 |
| 14 namespace SkSL { | 14 namespace SkSL { |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Represents a layout block appearing before a variable declaration, as in: | 17 * Represents a layout block appearing before a variable declaration, as in: |
| 18 * | 18 * |
| 19 * layout (location = 0) int x; | 19 * layout (location = 0) int x; |
| 20 */ | 20 */ |
| 21 struct ASTLayout : public ASTNode { | 21 struct ASTLayout : public ASTNode { |
| 22 // For int parameters, a -1 means no value | 22 // For all parameters, a -1 means no value |
| 23 ASTLayout(int location, int binding, int index, int set, int builtin, bool o
riginUpperLeft, | 23 ASTLayout(int location, int binding, int index, int set, int builtin, bool o
riginUpperLeft, |
| 24 bool overrideCoverage, bool blendSupportAllEquations, bool pushCon
stant) | 24 bool overrideCoverage, bool blendSupportAllEquations) |
| 25 : fLocation(location) | 25 : fLocation(location) |
| 26 , fBinding(binding) | 26 , fBinding(binding) |
| 27 , fIndex(index) | 27 , fIndex(index) |
| 28 , fSet(set) | 28 , fSet(set) |
| 29 , fBuiltin(builtin) | 29 , fBuiltin(builtin) |
| 30 , fOriginUpperLeft(originUpperLeft) | 30 , fOriginUpperLeft(originUpperLeft) |
| 31 , fOverrideCoverage(overrideCoverage) | 31 , fOverrideCoverage(overrideCoverage) |
| 32 , fBlendSupportAllEquations(blendSupportAllEquations) | 32 , fBlendSupportAllEquations(blendSupportAllEquations) {} |
| 33 , fPushConstant(pushConstant) {} | |
| 34 | 33 |
| 35 std::string description() const { | 34 std::string description() const { |
| 36 std::string result; | 35 std::string result; |
| 37 std::string separator; | 36 std::string separator; |
| 38 if (fLocation >= 0) { | 37 if (fLocation >= 0) { |
| 39 result += separator + "location = " + to_string(fLocation); | 38 result += separator + "location = " + to_string(fLocation); |
| 40 separator = ", "; | 39 separator = ", "; |
| 41 } | 40 } |
| 42 if (fBinding >= 0) { | 41 if (fBinding >= 0) { |
| 43 result += separator + "binding = " + to_string(fBinding); | 42 result += separator + "binding = " + to_string(fBinding); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 60 separator = ", "; | 59 separator = ", "; |
| 61 } | 60 } |
| 62 if (fOverrideCoverage) { | 61 if (fOverrideCoverage) { |
| 63 result += separator + "override_coverage"; | 62 result += separator + "override_coverage"; |
| 64 separator = ", "; | 63 separator = ", "; |
| 65 } | 64 } |
| 66 if (fBlendSupportAllEquations) { | 65 if (fBlendSupportAllEquations) { |
| 67 result += separator + "blend_support_all_equations"; | 66 result += separator + "blend_support_all_equations"; |
| 68 separator = ", "; | 67 separator = ", "; |
| 69 } | 68 } |
| 70 if (fPushConstant) { | |
| 71 result += separator + "push_constant"; | |
| 72 separator = ", "; | |
| 73 } | |
| 74 if (result.length() > 0) { | 69 if (result.length() > 0) { |
| 75 result = "layout (" + result + ")"; | 70 result = "layout (" + result + ")"; |
| 76 } | 71 } |
| 77 return result; | 72 return result; |
| 78 } | 73 } |
| 79 | 74 |
| 80 const int fLocation; | 75 const int fLocation; |
| 81 const int fBinding; | 76 const int fBinding; |
| 82 const int fIndex; | 77 const int fIndex; |
| 83 const int fSet; | 78 const int fSet; |
| 84 const int fBuiltin; | 79 const int fBuiltin; |
| 85 const bool fOriginUpperLeft; | 80 const bool fOriginUpperLeft; |
| 86 const bool fOverrideCoverage; | 81 const bool fOverrideCoverage; |
| 87 const bool fBlendSupportAllEquations; | 82 const bool fBlendSupportAllEquations; |
| 88 const bool fPushConstant; | |
| 89 }; | 83 }; |
| 90 | 84 |
| 91 } // namespace | 85 } // namespace |
| 92 | 86 |
| 93 #endif | 87 #endif |
| OLD | NEW |