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 all 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) | 23 ASTLayout(int location, int binding, int index, int set, int builtin, bool o
riginUpperLeft) |
24 : fLocation(location) | 24 : fLocation(location) |
25 , fBinding(binding) | 25 , fBinding(binding) |
26 , fIndex(index) | 26 , fIndex(index) |
27 , fSet(set) | 27 , fSet(set) |
28 , fBuiltin(builtin) {} | 28 , fBuiltin(builtin) |
| 29 , fOriginUpperLeft(originUpperLeft) {} |
29 | 30 |
30 std::string description() const { | 31 std::string description() const { |
31 std::string result; | 32 std::string result; |
32 std::string separator; | 33 std::string separator; |
33 if (fLocation >= 0) { | 34 if (fLocation >= 0) { |
34 result += separator + "location = " + to_string(fLocation); | 35 result += separator + "location = " + to_string(fLocation); |
35 separator = ", "; | 36 separator = ", "; |
36 } | 37 } |
37 if (fBinding >= 0) { | 38 if (fBinding >= 0) { |
38 result += separator + "binding = " + to_string(fBinding); | 39 result += separator + "binding = " + to_string(fBinding); |
39 separator = ", "; | 40 separator = ", "; |
40 } | 41 } |
41 if (fIndex >= 0) { | 42 if (fIndex >= 0) { |
42 result += separator + "index = " + to_string(fIndex); | 43 result += separator + "index = " + to_string(fIndex); |
43 separator = ", "; | 44 separator = ", "; |
44 } | 45 } |
45 if (fSet >= 0) { | 46 if (fSet >= 0) { |
46 result += separator + "set = " + to_string(fSet); | 47 result += separator + "set = " + to_string(fSet); |
47 separator = ", "; | 48 separator = ", "; |
48 } | 49 } |
49 if (fBuiltin >= 0) { | 50 if (fBuiltin >= 0) { |
50 result += separator + "builtin = " + to_string(fBuiltin); | 51 result += separator + "builtin = " + to_string(fBuiltin); |
51 separator = ", "; | 52 separator = ", "; |
52 } | 53 } |
| 54 if (fOriginUpperLeft) { |
| 55 result += separator + "origin_upper_left"; |
| 56 separator = ", "; |
| 57 } |
53 if (result.length() > 0) { | 58 if (result.length() > 0) { |
54 result = "layout (" + result + ")"; | 59 result = "layout (" + result + ")"; |
55 } | 60 } |
56 return result; | 61 return result; |
57 } | 62 } |
58 | 63 |
59 const int fLocation; | 64 const int fLocation; |
60 const int fBinding; | 65 const int fBinding; |
61 const int fIndex; | 66 const int fIndex; |
62 const int fSet; | 67 const int fSet; |
63 const int fBuiltin; | 68 const int fBuiltin; |
| 69 const bool fOriginUpperLeft; |
64 }; | 70 }; |
65 | 71 |
66 } // namespace | 72 } // namespace |
67 | 73 |
68 #endif | 74 #endif |
OLD | NEW |