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

Side by Side Diff: src/sksl/ir/SkSLModifiers.h

Issue 2185393003: added initial GLSL support to skslc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixed gn build Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/sksl/ir/SkSLLayout.h ('k') | src/sksl/ir/SkSLTypeReference.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MODIFIERS 8 #ifndef SKSL_MODIFIERS
9 #define SKSL_MODIFIERS 9 #define SKSL_MODIFIERS
10 10
11 #include "../ast/SkSLASTModifiers.h" 11 #include "../ast/SkSLASTModifiers.h"
12 #include "SkSLLayout.h" 12 #include "SkSLLayout.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 Modifiers { 19 struct Modifiers {
20 enum Flag { 20 enum Flag {
21 kNo_Flag = ASTModifiers::kNo_Flag, 21 kNo_Flag = ASTModifiers::kNo_Flag,
22 kConst_Flag = ASTModifiers::kConst_Flag, 22 kConst_Flag = ASTModifiers::kConst_Flag,
23 kIn_Flag = ASTModifiers::kIn_Flag, 23 kIn_Flag = ASTModifiers::kIn_Flag,
24 kOut_Flag = ASTModifiers::kOut_Flag, 24 kOut_Flag = ASTModifiers::kOut_Flag,
25 kLowp_Flag = ASTModifiers::kLowp_Flag, 25 kLowp_Flag = ASTModifiers::kLowp_Flag,
26 kMediump_Flag = ASTModifiers::kMediump_Flag, 26 kMediump_Flag = ASTModifiers::kMediump_Flag,
27 kHighp_Flag = ASTModifiers::kHighp_Flag, 27 kHighp_Flag = ASTModifiers::kHighp_Flag,
28 kUniform_Flag = ASTModifiers::kUniform_Flag 28 kUniform_Flag = ASTModifiers::kUniform_Flag,
29 kFlat_Flag = ASTModifiers::kFlat_Flag,
30 kNoPerspective_Flag = ASTModifiers::kNoPerspective_Flag
29 }; 31 };
30 32
31 Modifiers(const ASTModifiers& modifiers) 33 Modifiers(const ASTModifiers& modifiers)
32 : fLayout(modifiers.fLayout) 34 : fLayout(modifiers.fLayout)
33 , fFlags(modifiers.fFlags) {} 35 , fFlags(modifiers.fFlags) {}
34 36
35 Modifiers(Layout& layout, int flags) 37 Modifiers(Layout& layout, int flags)
36 : fLayout(layout) 38 : fLayout(layout)
37 , fFlags(flags) {} 39 , fFlags(flags) {}
38 40
39 std::string description() const { 41 std::string description() const {
40 std::string result = fLayout.description(); 42 std::string result = fLayout.description();
41 if (fFlags & kUniform_Flag) { 43 if (fFlags & kUniform_Flag) {
42 result += "uniform "; 44 result += "uniform ";
43 } 45 }
44 if (fFlags & kConst_Flag) { 46 if (fFlags & kConst_Flag) {
45 result += "const "; 47 result += "const ";
46 } 48 }
47 if (fFlags & kLowp_Flag) { 49 if (fFlags & kLowp_Flag) {
48 result += "lowp "; 50 result += "lowp ";
49 } 51 }
50 if (fFlags & kMediump_Flag) { 52 if (fFlags & kMediump_Flag) {
51 result += "mediump "; 53 result += "mediump ";
52 } 54 }
53 if (fFlags & kHighp_Flag) { 55 if (fFlags & kHighp_Flag) {
54 result += "highp "; 56 result += "highp ";
55 } 57 }
58 if (fFlags & kFlat_Flag) {
59 result += "flat ";
60 }
61 if (fFlags & kNoPerspective_Flag) {
62 result += "noperspective ";
63 }
56 64
57 if ((fFlags & kIn_Flag) && (fFlags & kOut_Flag)) { 65 if ((fFlags & kIn_Flag) && (fFlags & kOut_Flag)) {
58 result += "inout "; 66 result += "inout ";
59 } else if (fFlags & kIn_Flag) { 67 } else if (fFlags & kIn_Flag) {
60 result += "in "; 68 result += "in ";
61 } else if (fFlags & kOut_Flag) { 69 } else if (fFlags & kOut_Flag) {
62 result += "out "; 70 result += "out ";
63 } 71 }
64 72
65 return result; 73 return result;
66 } 74 }
67 75
68 bool operator==(const Modifiers& other) const { 76 bool operator==(const Modifiers& other) const {
69 return fLayout == other.fLayout && fFlags == other.fFlags; 77 return fLayout == other.fLayout && fFlags == other.fFlags;
70 } 78 }
71 79
72 bool operator!=(const Modifiers& other) const { 80 bool operator!=(const Modifiers& other) const {
73 return !(*this == other); 81 return !(*this == other);
74 } 82 }
75 83
76 const Layout fLayout; 84 Layout fLayout;
77 const int fFlags; 85 int fFlags;
78 }; 86 };
79 87
80 } // namespace 88 } // namespace
81 89
82 #endif 90 #endif
OLDNEW
« no previous file with comments | « src/sksl/ir/SkSLLayout.h ('k') | src/sksl/ir/SkSLTypeReference.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698