efde90d973
This modifier is currently allowed on built-in functions only. The presence of this modifier will be used to indicate intrinsics which are ES3-specific (and therefore, not allowed in user code under typical circumstances). Change-Id: Ice6be8d9d1b2bf0c8f07f2a89f335bb2f90f6681 Bug: skia:12202 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439057 Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
116 lines
2.8 KiB
C++
116 lines
2.8 KiB
C++
/*
|
|
* 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 "include/private/SkSLLayout.h"
|
|
|
|
#include <vector>
|
|
|
|
namespace SkSL {
|
|
|
|
/**
|
|
* A set of modifier keywords (in, out, uniform, etc.) appearing before a declaration.
|
|
*/
|
|
struct Modifiers {
|
|
enum Flag {
|
|
kNo_Flag = 0,
|
|
kConst_Flag = 1 << 0,
|
|
kIn_Flag = 1 << 1,
|
|
kOut_Flag = 1 << 2,
|
|
kUniform_Flag = 1 << 3,
|
|
kFlat_Flag = 1 << 4,
|
|
kNoPerspective_Flag = 1 << 5,
|
|
kHasSideEffects_Flag = 1 << 6,
|
|
kHighp_Flag = 1 << 7,
|
|
kMediump_Flag = 1 << 8,
|
|
kLowp_Flag = 1 << 9,
|
|
kInline_Flag = 1 << 10,
|
|
kNoInline_Flag = 1 << 11,
|
|
kES3_Flag = 1 << 12,
|
|
};
|
|
|
|
Modifiers()
|
|
: fLayout(Layout())
|
|
, fFlags(0) {}
|
|
|
|
Modifiers(const Layout& layout, int flags)
|
|
: fLayout(layout)
|
|
, fFlags(flags) {}
|
|
|
|
String description() const {
|
|
String result = fLayout.description();
|
|
if (fFlags & kES3_Flag) {
|
|
result += "$es3 ";
|
|
}
|
|
if (fFlags & kUniform_Flag) {
|
|
result += "uniform ";
|
|
}
|
|
if (fFlags & kConst_Flag) {
|
|
result += "const ";
|
|
}
|
|
if (fFlags & kFlat_Flag) {
|
|
result += "flat ";
|
|
}
|
|
if (fFlags & kNoPerspective_Flag) {
|
|
result += "noperspective ";
|
|
}
|
|
if (fFlags & kHasSideEffects_Flag) {
|
|
result += "sk_has_side_effects ";
|
|
}
|
|
if (fFlags & kNoInline_Flag) {
|
|
result += "noinline ";
|
|
}
|
|
if (fFlags & kHighp_Flag) {
|
|
result += "highp ";
|
|
}
|
|
if (fFlags & kMediump_Flag) {
|
|
result += "mediump ";
|
|
}
|
|
if (fFlags & kLowp_Flag) {
|
|
result += "lowp ";
|
|
}
|
|
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;
|
|
}
|
|
|
|
bool operator==(const Modifiers& other) const {
|
|
return fLayout == other.fLayout && fFlags == other.fFlags;
|
|
}
|
|
|
|
bool operator!=(const Modifiers& other) const {
|
|
return !(*this == other);
|
|
}
|
|
|
|
Layout fLayout;
|
|
int fFlags;
|
|
};
|
|
|
|
} // namespace SkSL
|
|
|
|
namespace std {
|
|
|
|
template <>
|
|
struct hash<SkSL::Modifiers> {
|
|
size_t operator()(const SkSL::Modifiers& key) const {
|
|
return (size_t) key.fFlags ^ ((size_t) key.fLayout.fFlags << 8) ^
|
|
((size_t) key.fLayout.fBuiltin << 16);
|
|
}
|
|
};
|
|
|
|
} // namespace std
|
|
|
|
#endif
|