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

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

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: documentation and cleanups Created 4 years, 6 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
OLDNEW
(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 static const int kNo_Bit = ASTModifiers::kNo_Bit;
21 static const int kConst_Bit = ASTModifiers::kConst_Bit;
22 static const int kIn_Bit = ASTModifiers::kIn_Bit;
23 static const int kOut_Bit = ASTModifiers::kOut_Bit;
24 static const int kLowp_Bit = ASTModifiers::kLowp_Bit;
25 static const int kMediump_Bit = ASTModifiers::kMediump_Bit;
26 static const int kHighp_Bit = ASTModifiers::kHighp_Bit;
27 static const int kUniform_Bit = ASTModifiers::kUniform_Bit;
28
29 Modifiers(const ASTModifiers& modifiers)
30 : fLayout(modifiers.fLayout)
31 , fBits(modifiers.fBits) {}
32
33 Modifiers(Layout& layout, int bits)
34 : fLayout(layout)
35 , fBits(bits) {}
36
37 std::string description() const {
38 std::string result = fLayout.description();
39 if (fBits & kUniform_Bit) {
40 result += "uniform ";
41 }
42 if (fBits & kConst_Bit) {
43 result += "const ";
44 }
45 if (fBits & kLowp_Bit) {
46 result += "lowp ";
47 }
48 if (fBits & kMediump_Bit) {
49 result += "mediump ";
50 }
51 if (fBits & kHighp_Bit) {
52 result += "highp ";
53 }
54
55 if ((fBits & kIn_Bit) && (fBits & kOut_Bit)) {
56 result += "inout ";
57 } else if (fBits & kIn_Bit) {
58 result += "in ";
59 } else if (fBits & kOut_Bit) {
60 result += "out ";
61 }
62
63 return result;
64 }
65
66 const Layout fLayout;
67 const int fBits;
68 };
69
70 } // namespace
71
72 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698