Flutter Engine
The Flutter Engine
SkSLModifierFlags.h
Go to the documentation of this file.
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
13
14#include <string>
15
16namespace SkSL {
17
18class Context;
19class Position;
20
21enum 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
50
51namespace SkSL {
52
53class ModifierFlags : public SkEnumBitMask<SkSL::ModifierFlag> {
54public:
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,
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};
83
84} // namespace SkSL
85
86#endif
SkPoint pos
SK_MAKE_BITMASK_OPS(SkSL::ModifierFlag)
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
SK_ALWAYS_INLINE constexpr SkEnumBitMask(SkSL::ModifierFlag e)
Definition: SkEnumBitMask.h:36
ModifierFlags(SkEnumBitMask< SkSL::ModifierFlag > that)
bool isWorkgroup() const
std::string paddedDescription() const
std::string description() const
bool checkPermittedFlags(const Context &context, Position pos, ModifierFlags permittedModifierFlags) const
bool isPixelLocal() const
bool isWriteOnly() const