OLD | NEW |
(Empty) | |
| 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 #ifndef SKSL_MODIFIERS |
| 9 #define SKSL_MODIFIERS |
| 10 |
| 11 #include "../ast/SkSLASTModifiers.h" |
| 12 #include "SkSLLayout.h" |
| 13 |
| 14 namespace SkSL { |
| 15 |
| 16 /** |
| 17 * A set of modifier keywords (in, out, uniform, etc.) appearing before a declar
ation. |
| 18 */ |
| 19 struct Modifiers { |
| 20 enum Flag { |
| 21 kNo_Flag = ASTModifiers::kNo_Flag, |
| 22 kConst_Flag = ASTModifiers::kConst_Flag, |
| 23 kIn_Flag = ASTModifiers::kIn_Flag, |
| 24 kOut_Flag = ASTModifiers::kOut_Flag, |
| 25 kLowp_Flag = ASTModifiers::kLowp_Flag, |
| 26 kMediump_Flag = ASTModifiers::kMediump_Flag, |
| 27 kHighp_Flag = ASTModifiers::kHighp_Flag, |
| 28 kUniform_Flag = ASTModifiers::kUniform_Flag |
| 29 }; |
| 30 |
| 31 Modifiers(const ASTModifiers& modifiers) |
| 32 : fLayout(modifiers.fLayout) |
| 33 , fFlags(modifiers.fFlags) {} |
| 34 |
| 35 Modifiers(Layout& layout, int flags) |
| 36 : fLayout(layout) |
| 37 , fFlags(flags) {} |
| 38 |
| 39 std::string description() const { |
| 40 std::string result = fLayout.description(); |
| 41 if (fFlags & kUniform_Flag) { |
| 42 result += "uniform "; |
| 43 } |
| 44 if (fFlags & kConst_Flag) { |
| 45 result += "const "; |
| 46 } |
| 47 if (fFlags & kLowp_Flag) { |
| 48 result += "lowp "; |
| 49 } |
| 50 if (fFlags & kMediump_Flag) { |
| 51 result += "mediump "; |
| 52 } |
| 53 if (fFlags & kHighp_Flag) { |
| 54 result += "highp "; |
| 55 } |
| 56 |
| 57 if ((fFlags & kIn_Flag) && (fFlags & kOut_Flag)) { |
| 58 result += "inout "; |
| 59 } else if (fFlags & kIn_Flag) { |
| 60 result += "in "; |
| 61 } else if (fFlags & kOut_Flag) { |
| 62 result += "out "; |
| 63 } |
| 64 |
| 65 return result; |
| 66 } |
| 67 |
| 68 bool operator==(const Modifiers& other) const { |
| 69 return fLayout == other.fLayout && fFlags == other.fFlags; |
| 70 } |
| 71 |
| 72 bool operator!=(const Modifiers& other) const { |
| 73 return !(*this == other); |
| 74 } |
| 75 |
| 76 const Layout fLayout; |
| 77 const int fFlags; |
| 78 }; |
| 79 |
| 80 } // namespace |
| 81 |
| 82 #endif |
OLD | NEW |