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

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

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: more 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_LAYOUT
9 #define SKSL_LAYOUT
10
11 namespace SkSL {
12
13 /**
14 * Represents a layout block appearing before a variable declaration, as in:
15 *
16 * layout (location = 0) int x;
17 */
18 struct Layout {
19 Layout(const ASTLayout& layout)
20 : fLocation(layout.fLocation)
21 , fBinding(layout.fBinding)
22 , fIndex(layout.fIndex)
23 , fSet(layout.fSet)
24 , fBuiltin(layout.fBuiltin) {}
25
26 Layout(int location, int binding, int index, int set, int builtin)
27 : fLocation(location)
28 , fBinding(binding)
29 , fIndex(index)
30 , fSet(set)
31 , fBuiltin(builtin) {}
32
33 std::string description() const {
34 std::string result;
35 std::string separator;
36 if (fLocation >= 0) {
37 result += separator + "location = " + to_string(fLocation);
38 separator = ", ";
39 }
40 if (fBinding >= 0) {
41 result += separator + "binding = " + to_string(fBinding);
42 separator = ", ";
43 }
44 if (fIndex >= 0) {
45 result += separator + "index = " + to_string(fIndex);
46 separator = ", ";
47 }
48 if (fSet >= 0) {
49 result += separator + "set = " + to_string(fSet);
50 separator = ", ";
51 }
52 if (fBuiltin >= 0) {
53 result += separator + "builtin = " + to_string(fBuiltin);
54 separator = ", ";
55 }
56 if (result.length() > 0) {
57 result = "layout (" + result + ")";
dogben 2016/06/22 17:43:57 nit: just return?
ethannicholas 2016/06/24 21:23:10 It's a stylistic point for me -- I'm certainly wil
58 }
59 return result;
60 }
61
62 const int fLocation;
63 const int fBinding;
64 const int fIndex;
65 const int fSet;
66 const int fBuiltin;
67 };
68
69 } // namespace
70
71 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698