/* * Copyright 2022 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef skgpu_graphite_PaintParamsKey_DEFINED #define skgpu_graphite_PaintParamsKey_DEFINED #include "include/core/SkSpan.h" #include "include/core/SkTypes.h" #include "include/private/base/SkMacros.h" #include "include/private/base/SkTArray.h" #include "src/core/SkChecksum.h" #include "src/gpu/graphite/BuiltInCodeSnippetID.h" #include <limits> #include <cstring> // for memcmp class SkArenaAlloc; struct SkSamplingOptions; enum class SkTileMode; namespace skgpu::graphite { class Caps; class ShaderCodeDictionary; class ShaderNode; class TextureProxy; class UniquePaintParamsID; // This class is a compact representation of the shader needed to implement a given // PaintParams. Its structure is a series of nodes where each node consists of: // 4 bytes: code-snippet ID // N child nodes, where N is the constant number of children defined by the ShaderCodeDictionary // for the node's snippet ID. // // All children of a child node are stored in the key before the next child is encoded in the key, // e.g. iterating the data in a key is a depth-first traversal of the node tree. class PaintParamsKey { … }; // The PaintParamsKeyBuilder and the PaintParamsKeys snapped from it share the same // underlying block of memory. When an PaintParamsKey is snapped from the builder it 'locks' // the memory and 'unlocks' it in its destructor. Because of this relationship, the builder // can only have one extant key and that key must be destroyed before the builder can be reused // to create another one. // // This arrangement is intended to improve performance in the expected case, where a builder is // being used in a tight loop to generate keys which can be recycled once they've been used to // find the dictionary's matching uniqueID. We don't expect the cost of copying the key's memory // into the dictionary to be prohibitive since that should be infrequent. class PaintParamsKeyBuilder { … }; class AutoLockBuilderAsKey { … }; } // namespace skgpu::graphite #endif // skgpu_graphite_PaintParamsKey_DEFINED