Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkKnownRuntimeEffects.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
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 SkKnownRuntimeEffects_DEFINED
9#define SkKnownRuntimeEffects_DEFINED
10
12#include <cstdint>
13
14class SkRuntimeEffect;
15
16namespace SkKnownRuntimeEffects {
17
18// We allocate the keys in blocks in the order:
19// Skia builtins
20// Skia known runtime effects
21// Android known runtime effects
22// Chrome known runtime effects
23// unknown runtime effects (on a first come, first served basis -> unstable)
24//
25// WARNING: If any of these values are changed, UniqueKeys that have stably-keyed effects
26// will need to be invalidated.
27// TODO(b/238759147): add a revision number that can drive the invalidation.
28static constexpr int kSkiaBuiltInReservedCnt = 500;
29static constexpr int kSkiaKnownRuntimeEffectsReservedCnt = 500;
30static constexpr int kAndroidKnownRuntimeEffectsReservedCnt = 100;
31static constexpr int kChromeKnownRuntimeEffectsReservedCnt = 100;
32
36
40
44
46
47// All six 1DBlur* stable keys must be consecutive after 1DBlurBase and
48// there is no 1DBlur24 bc for large kernels we bin by a multiple of eight.
49// Similarly, all six 2DBlur* stable keys must be consecutive after 2DBlurBase and
50// there is no 2DBlur24 bc for large kernels we bin by a multiple of eight.
51// As for the macros:
52// M(X) is for standard entries
53// M1(X) is for helper values that should be skipped in a switch statement
54// M2(X,Y) is for entries that have an initializer (Y)
55#define SK_ALL_STABLEKEYS(M, M1, M2) \
56 M2(Invalid, Start) \
57 M1(1DBlurBase) \
58 M2(1DBlur4, 1DBlurBase) \
59 M(1DBlur8) \
60 M(1DBlur12) \
61 M(1DBlur16) \
62 M(1DBlur20) \
63 M(1DBlur28) \
64 M1(2DBlurBase) \
65 M2(2DBlur4, 2DBlurBase) \
66 M(2DBlur8) \
67 M(2DBlur12) \
68 M(2DBlur16) \
69 M(2DBlur20) \
70 M(2DBlur28) \
71 M(Blend) \
72 M(Decal) \
73 M(Displacement) \
74 M(Lighting) \
75 M(LinearMorphology) \
76 M(Magnifier) \
77 M(Normal) \
78 M(SparseMorphology) \
79 M(Arithmetic) \
80 M(HighContrast) \
81 M(Lerp) \
82 M(Luma) \
83 M(Overdraw)
84
85// WARNING: If any of the existing values are changed, UniqueKeys that have stably-keyed effects
86// will need to be invalidated. (Adding new values to the end of the enum should be fine though.)
87// TODO(b/238759147): add a revision number that can drive the invalidation
88enum class StableKey : uint32_t {
90
91#define M(type) k##type,
92#define M1(type) k##type,
93#define M2(type, initializer) k##type = k##initializer,
95#undef M2
96#undef M1
97#undef M
98
99 kLast = kOverdraw,
100};
101
102static const int kStableKeyCnt = static_cast<int>(StableKey::kLast) -
103 static_cast<int>(StableKey::kStart) + 1;
104
105static_assert(static_cast<int>(StableKey::kLast) < kSkiaKnownRuntimeEffectsEnd);
106
108
109static_assert(static_cast<int>(StableKey::kInvalid) == static_cast<int>(StableKey::kStart));
110
111static_assert(static_cast<int>(StableKey::k1DBlur4) == static_cast<int>(StableKey::k1DBlurBase));
112static_assert(static_cast<int>(StableKey::k1DBlur8) == static_cast<int>(StableKey::k1DBlurBase)+1);
113static_assert(static_cast<int>(StableKey::k1DBlur12) == static_cast<int>(StableKey::k1DBlurBase)+2);
114static_assert(static_cast<int>(StableKey::k1DBlur16) == static_cast<int>(StableKey::k1DBlurBase)+3);
115static_assert(static_cast<int>(StableKey::k1DBlur20) == static_cast<int>(StableKey::k1DBlurBase)+4);
116static_assert(static_cast<int>(StableKey::k1DBlur28) == static_cast<int>(StableKey::k1DBlurBase)+5);
117
118static_assert(static_cast<int>(StableKey::k2DBlur4) == static_cast<int>(StableKey::k2DBlurBase));
119static_assert(static_cast<int>(StableKey::k2DBlur8) == static_cast<int>(StableKey::k2DBlurBase)+1);
120static_assert(static_cast<int>(StableKey::k2DBlur12) == static_cast<int>(StableKey::k2DBlurBase)+2);
121static_assert(static_cast<int>(StableKey::k2DBlur16) == static_cast<int>(StableKey::k2DBlurBase)+3);
122static_assert(static_cast<int>(StableKey::k2DBlur20) == static_cast<int>(StableKey::k2DBlurBase)+4);
123static_assert(static_cast<int>(StableKey::k2DBlur28) == static_cast<int>(StableKey::k2DBlurBase)+5);
124
125} // namespace SkKnownRuntimeEffects
126
127#endif // SkKnownRuntimeEffects_DEFINED
#define SK_ALL_STABLEKEYS(M, M1, M2)
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
static constexpr int kSkiaKnownRuntimeEffectsReservedCnt
static constexpr int kUnknownRuntimeEffectIDStart
static constexpr int kAndroidKnownRuntimeEffectsStart
static constexpr int kAndroidKnownRuntimeEffectsEnd
static constexpr int kSkiaKnownRuntimeEffectsEnd
static constexpr int kChromeKnownRuntimeEffectsStart
static constexpr int kAndroidKnownRuntimeEffectsReservedCnt
static constexpr int kSkiaBuiltInReservedCnt
static constexpr int kSkiaKnownRuntimeEffectsStart
static constexpr int kChromeKnownRuntimeEffectsReservedCnt
static constexpr int kChromeKnownRuntimeEffectsEnd