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

Unified Diff: src/sksl/ir/SkSLLayout.h

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixed CMake build 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/ir/SkSLInterfaceBlock.h ('k') | src/sksl/ir/SkSLModifiers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/ir/SkSLLayout.h
diff --git a/src/sksl/ir/SkSLLayout.h b/src/sksl/ir/SkSLLayout.h
new file mode 100644
index 0000000000000000000000000000000000000000..bab2f0e0dbd0457d16405572e5746045fd7ecdd3
--- /dev/null
+++ b/src/sksl/ir/SkSLLayout.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SKSL_LAYOUT
+#define SKSL_LAYOUT
+
+namespace SkSL {
+
+/**
+ * Represents a layout block appearing before a variable declaration, as in:
+ *
+ * layout (location = 0) int x;
+ */
+struct Layout {
+ Layout(const ASTLayout& layout)
+ : fLocation(layout.fLocation)
+ , fBinding(layout.fBinding)
+ , fIndex(layout.fIndex)
+ , fSet(layout.fSet)
+ , fBuiltin(layout.fBuiltin) {}
+
+ Layout(int location, int binding, int index, int set, int builtin)
+ : fLocation(location)
+ , fBinding(binding)
+ , fIndex(index)
+ , fSet(set)
+ , fBuiltin(builtin) {}
+
+ std::string description() const {
+ std::string result;
+ std::string separator;
+ if (fLocation >= 0) {
+ result += separator + "location = " + to_string(fLocation);
+ separator = ", ";
+ }
+ if (fBinding >= 0) {
+ result += separator + "binding = " + to_string(fBinding);
+ separator = ", ";
+ }
+ if (fIndex >= 0) {
+ result += separator + "index = " + to_string(fIndex);
+ separator = ", ";
+ }
+ if (fSet >= 0) {
+ result += separator + "set = " + to_string(fSet);
+ separator = ", ";
+ }
+ if (fBuiltin >= 0) {
+ result += separator + "builtin = " + to_string(fBuiltin);
+ separator = ", ";
+ }
+ if (result.length() > 0) {
+ result = "layout (" + result + ")";
+ }
+ return result;
+ }
+
+ bool operator==(const Layout& other) const {
+ return fLocation == other.fLocation &&
+ fBinding == other.fBinding &&
+ fIndex == other.fIndex &&
+ fSet == other.fSet &&
+ fBuiltin == other.fBuiltin;
+ }
+
+ bool operator!=(const Layout& other) const {
+ return !(*this == other);
+ }
+
+ const int fLocation;
+ const int fBinding;
+ const int fIndex;
+ const int fSet;
+ const int fBuiltin;
+};
+
+} // namespace
+
+#endif
« no previous file with comments | « src/sksl/ir/SkSLInterfaceBlock.h ('k') | src/sksl/ir/SkSLModifiers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698