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

Unified Diff: src/sksl/ir/SkSLModifiers.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 side-by-side diff with in-line comments
Download patch
Index: src/sksl/ir/SkSLModifiers.h
diff --git a/src/sksl/ir/SkSLModifiers.h b/src/sksl/ir/SkSLModifiers.h
new file mode 100644
index 0000000000000000000000000000000000000000..2c05969a1a1af6d81ca2a8508edc30c9b6b21315
--- /dev/null
+++ b/src/sksl/ir/SkSLModifiers.h
@@ -0,0 +1,74 @@
+/*
+ * 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_MODIFIERS
+#define SKSL_MODIFIERS
+
+#include "../ast/SkSLASTModifiers.h"
+#include "SkSLLayout.h"
+
+namespace SkSL {
+
+/**
+ * A set of modifier keywords (in, out, uniform, etc.) appearing before a declaration.
+ */
+struct Modifiers {
+ enum Flag {
+ kNo_Flag = ASTModifiers::kNo_Flag,
+ kConst_Flag = ASTModifiers::kConst_Flag,
+ kIn_Flag = ASTModifiers::kIn_Flag,
+ kOut_Flag = ASTModifiers::kOut_Flag,
+ kLowp_Flag = ASTModifiers::kLowp_Flag,
+ kMediump_Flag = ASTModifiers::kMediump_Flag,
+ kHighp_Flag = ASTModifiers::kHighp_Flag,
+ kUniform_Flag = ASTModifiers::kUniform_Flag
+ };
+
+ Modifiers(const ASTModifiers& modifiers)
+ : fLayout(modifiers.fLayout)
+ , fFlags(modifiers.fFlags) {}
+
+ Modifiers(Layout& layout, int flags)
+ : fLayout(layout)
+ , fFlags(flags) {}
+
+ std::string description() const {
+ std::string result = fLayout.description();
+ if (fFlags & kUniform_Flag) {
+ result += "uniform ";
+ }
+ if (fFlags & kConst_Flag) {
+ result += "const ";
+ }
+ if (fFlags & kLowp_Flag) {
+ result += "lowp ";
+ }
+ if (fFlags & kMediump_Flag) {
+ result += "mediump ";
+ }
+ if (fFlags & kHighp_Flag) {
+ result += "highp ";
+ }
+
+ if ((fFlags & kIn_Flag) && (fFlags & kOut_Flag)) {
+ result += "inout ";
+ } else if (fFlags & kIn_Flag) {
+ result += "in ";
+ } else if (fFlags & kOut_Flag) {
+ result += "out ";
+ }
+
+ return result;
+ }
+
+ const Layout fLayout;
+ const int fFlags;
+};
+
+} // namespace
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698