Flutter Engine
The Flutter Engine
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(MatrixConvUniforms) \
78 M(MatrixConvTexSm) \
79 M(MatrixConvTexLg) \
80 M(Normal) \
81 M(SparseMorphology) \
82 M(Arithmetic) \
83 M(HighContrast) \
84 M(Lerp) \
85 M(Luma) \
86 M(Overdraw)
87
88// WARNING: If any of the existing values are changed, UniqueKeys that have stably-keyed effects
89// will need to be invalidated. (Adding new values to the end of the enum should be fine though.)
90// TODO(b/238759147): add a revision number that can drive the invalidation
91enum class StableKey : uint32_t {
93
94#define M(type) k##type,
95#define M1(type) k##type,
96#define M2(type, initializer) k##type = k##initializer,
97 SK_ALL_STABLEKEYS(M, M1, M2)
98#undef M2
99#undef M1
100#undef M
101
102 kLast = kOverdraw,
103};
104
105static const int kStableKeyCnt = static_cast<int>(StableKey::kLast) -
106 static_cast<int>(StableKey::kStart) + 1;
107
108static_assert(static_cast<int>(StableKey::kLast) < kSkiaKnownRuntimeEffectsEnd);
109
111
112static_assert(static_cast<int>(StableKey::kInvalid) == static_cast<int>(StableKey::kStart));
113
114static_assert(static_cast<int>(StableKey::k1DBlur4) == static_cast<int>(StableKey::k1DBlurBase));
115static_assert(static_cast<int>(StableKey::k1DBlur8) == static_cast<int>(StableKey::k1DBlurBase)+1);
116static_assert(static_cast<int>(StableKey::k1DBlur12) == static_cast<int>(StableKey::k1DBlurBase)+2);
117static_assert(static_cast<int>(StableKey::k1DBlur16) == static_cast<int>(StableKey::k1DBlurBase)+3);
118static_assert(static_cast<int>(StableKey::k1DBlur20) == static_cast<int>(StableKey::k1DBlurBase)+4);
119static_assert(static_cast<int>(StableKey::k1DBlur28) == static_cast<int>(StableKey::k1DBlurBase)+5);
120
121static_assert(static_cast<int>(StableKey::k2DBlur4) == static_cast<int>(StableKey::k2DBlurBase));
122static_assert(static_cast<int>(StableKey::k2DBlur8) == static_cast<int>(StableKey::k2DBlurBase)+1);
123static_assert(static_cast<int>(StableKey::k2DBlur12) == static_cast<int>(StableKey::k2DBlurBase)+2);
124static_assert(static_cast<int>(StableKey::k2DBlur16) == static_cast<int>(StableKey::k2DBlurBase)+3);
125static_assert(static_cast<int>(StableKey::k2DBlur20) == static_cast<int>(StableKey::k2DBlurBase)+4);
126static_assert(static_cast<int>(StableKey::k2DBlur28) == static_cast<int>(StableKey::k2DBlurBase)+5);
127
128} // namespace SkKnownRuntimeEffects
129
130#endif // SkKnownRuntimeEffects_DEFINED
@ kInvalid
#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 const int kStableKeyCnt
static constexpr int kChromeKnownRuntimeEffectsEnd