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