| 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_MODIFIERFLAGS |
| 9 |
#define SKSL_MODIFIERFLAGS |
| 10 |
|
| 11 |
#include "include/private/base/SkTo.h" |
| 12 |
#include "src/base/SkEnumBitMask.h" |
| 13 |
|
| 14 |
#include <string> |
| 15 |
|
| 16 |
namespace SkSL { |
| 17 |
|
| 18 |
class Context; |
| 19 |
class Position; |
| 20 |
|
| 21 |
enum class ModifierFlag : int { |
| 22 |
kNone = 0, |
| 23 |
// Real GLSL modifiers |
| 24 |
kFlat = 1 << 0, |
| 25 |
kNoPerspective = 1 << 1, |
| 26 |
kConst = 1 << 2, |
| 27 |
kUniform = 1 << 3, |
| 28 |
kIn = 1 << 4, |
| 29 |
kOut = 1 << 5, |
| 30 |
kHighp = 1 << 6, |
| 31 |
kMediump = 1 << 7, |
| 32 |
kLowp = 1 << 8, |
| 33 |
kReadOnly = 1 << 9, |
| 34 |
kWriteOnly = 1 << 10, |
| 35 |
kBuffer = 1 << 11, |
| 36 |
kPixelLocal = 1 << 12, |
| 37 |
// Corresponds to the GLSL 'shared' modifier. Only allowed in a compute program. |
| 38 |
kWorkgroup = 1 << 13, |
| 39 |
// SkSL extensions, not present in GLSL |
| 40 |
kExport = 1 << 14, |
| 41 |
kES3 = 1 << 15, |
| 42 |
kPure = 1 << 16, |
| 43 |
kInline = 1 << 17, |
| 44 |
kNoInline = 1 << 18, |
| 45 |
}; |
| 46 |
|
| 47 |
} // namespace SkSL |
| 48 |
|
| 49 |
SK_MAKE_BITMASK_OPS(SkSL::ModifierFlag) |
| 50 |
|
| 51 |
namespace SkSL { |
| 52 |
|
| 53 |
class ModifierFlags : public SkEnumBitMask<SkSL::ModifierFlag> { |
| 54 |
public: |
| 55 |
using SkEnumBitMask<SkSL::ModifierFlag>::SkEnumBitMask; |
| 56 |
ModifierFlags(SkEnumBitMask<SkSL::ModifierFlag> that) |
| 57 |
: SkEnumBitMask<SkSL::ModifierFlag>(that) {} |
| 58 |
|
| 59 |
std::string description() const; |
| 60 |
std::string paddedDescription() const; |
| 61 |
|
| 62 |
/** |
| 63 |
* Verifies that only permitted modifier flags are included. Reports errors and returns false in |
| 64 |
* the event of a violation. |
| 65 |
*/ |
| 66 |
bool checkPermittedFlags(const Context& context, |
| 67 |
Position pos, |
| 68 |
ModifierFlags permittedModifierFlags) const; |
| 69 |
|
| 70 |
bool isConst() const { return SkToBool(*this & ModifierFlag::kConst); } |
| 71 |
bool isUniform() const { return SkToBool(*this & ModifierFlag::kUniform); } |
| 72 |
bool isReadOnly() const { return SkToBool(*this & ModifierFlag::kReadOnly); } |
| 73 |
bool isWriteOnly() const { return SkToBool(*this & ModifierFlag::kWriteOnly); } |
| 74 |
bool isBuffer() const { return SkToBool(*this & ModifierFlag::kBuffer); } |
| 75 |
bool isPixelLocal() const { return SkToBool(*this & ModifierFlag::kPixelLocal); } |
| 76 |
bool isWorkgroup() const { return SkToBool(*this & ModifierFlag::kWorkgroup); } |
| 77 |
bool isExport() const { return SkToBool(*this & ModifierFlag::kExport); } |
| 78 |
bool isES3() const { return SkToBool(*this & ModifierFlag::kES3); } |
| 79 |
bool isPure() const { return SkToBool(*this & ModifierFlag::kPure); } |
| 80 |
bool isInline() const { return SkToBool(*this & ModifierFlag::kInline); } |
| 81 |
bool isNoInline() const { return SkToBool(*this & ModifierFlag::kNoInline); } |
| 82 |
bool isFlat() const { return SkToBool(*this & ModifierFlag::kFlat); } |
| 83 |
bool isNoPerspective() const { return SkToBool(*this & ModifierFlag::kNoPerspective); } |
| 84 |
}; |
| 85 |
|
| 86 |
} // namespace SkSL |
| 87 |
|
| 88 |
#endif |