/* * Copyright 2024 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkKnownRuntimeEffects_DEFINED #define SkKnownRuntimeEffects_DEFINED #include "include/core/SkTypes.h" #include <cstdint> class SkRuntimeEffect; namespace SkKnownRuntimeEffects { // We allocate the keys in blocks in the order: // Skia builtins // Skia known runtime effects // Android known runtime effects // Chrome known runtime effects // unknown runtime effects (on a first come, first served basis -> unstable) // // WARNING: If any of these values are changed, UniqueKeys that have stably-keyed effects // will need to be invalidated. // TODO(b/238759147): add a revision number that can drive the invalidation. static constexpr int kSkiaBuiltInReservedCnt = …; static constexpr int kSkiaKnownRuntimeEffectsReservedCnt = …; static constexpr int kAndroidKnownRuntimeEffectsReservedCnt = …; static constexpr int kChromeKnownRuntimeEffectsReservedCnt = …; static constexpr int kSkiaKnownRuntimeEffectsStart = …; static constexpr int kSkiaKnownRuntimeEffectsEnd = …; static constexpr int kAndroidKnownRuntimeEffectsStart = …; static constexpr int kAndroidKnownRuntimeEffectsEnd = …; static constexpr int kChromeKnownRuntimeEffectsStart = …; static constexpr int kChromeKnownRuntimeEffectsEnd = …; static constexpr int kUnknownRuntimeEffectIDStart = …; // All six 1DBlur* stable keys must be consecutive after 1DBlurBase and // there is no 1DBlur24 bc for large kernels we bin by a multiple of eight. // Similarly, all six 2DBlur* stable keys must be consecutive after 2DBlurBase and // there is no 2DBlur24 bc for large kernels we bin by a multiple of eight. // As for the macros: // M(X) is for standard entries // M1(X) is for helper values that should be skipped in a switch statement // M2(X,Y) is for entries that have an initializer (Y) #define SK_ALL_STABLEKEYS(M, M1, M2) … // WARNING: If any of the existing values are changed, UniqueKeys that have stably-keyed effects // will need to be invalidated. (Adding new values to the end of the enum should be fine though.) // TODO(b/238759147): add a revision number that can drive the invalidation enum class StableKey : uint32_t { … }; static const int kStableKeyCnt = …; static_assert …; const SkRuntimeEffect* GetKnownRuntimeEffect(StableKey); static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; } // namespace SkKnownRuntimeEffects #endif // SkKnownRuntimeEffects_DEFINED