/* * Copyright 2023 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkRasterPipelineContextUtils_DEFINED #define SkRasterPipelineContextUtils_DEFINED #include "src/base/SkArenaAlloc.h" #include "src/base/SkUtils.h" #include <cstring> #include <type_traits> namespace SkRPCtxUtils { UnpackedType; /** * SkRPCtxUtils::Pack will check if the passed-in struct is small enough to fit directly in the * context field. If so, it will return the data bit-casted into a void pointer. If not, it * allocates a copy of the struct inside the alloc and then returns a pointer to the copy. */ template <typename T> [[maybe_unused]] static void* Pack(const T& ctx, SkArenaAlloc* alloc) { … } /** * SkRPCtxUtils::Unpack performs the reverse operation: either un-bitcasting the object back to its * original form, or returning the pointer as-is, depending on the size of the type. */ template <typename T> [[maybe_unused]] static UnpackedType<T> Unpack(const T* ctx) { … } } // namespace SkRPCtxUtils #endif // SkRasterPipelineContextUtils_DEFINED