blob: 7bc3e2ec85288b0221cb7a18ed9e8c55c3f3f558 [file]
/*
* Copyright 2025 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_TextStrike_DEFINED
#define skgpu_graphite_TextStrike_DEFINED
#include "include/core/SkRefCnt.h"
#include "src/core/SkTHash.h"
#include "src/gpu/MaskFormat.h"
#include "src/text/gpu/StrikeCache.h"
struct SkPackedGlyphID;
class SkStrikeSpec;
namespace sktext::gpu {
struct PackedGPUGlyphID;
}
namespace skgpu::graphite {
struct GlyphEntry;
struct GlyphEntryKey;
/**
* Graphite-specific text strike cache.
*
* TextStrike manages a cache of Glyph objects for a specific font strike.
*/
class TextStrike final : public sktext::gpu::TextStrikeBase {
using PackedGPUGlyphID = sktext::gpu::PackedGPUGlyphID;
public:
TextStrike(sktext::gpu::StrikeCache* strikeCache, const SkStrikeSpec& strikeSpec);
// Find or create a TextStrike for the given strikeSpec
static sk_sp<TextStrike> GetOrCreate(sktext::gpu::StrikeCache* strikeCache,
const SkStrikeSpec& strikeSpec);
GlyphEntry* getGlyph(PackedGPUGlyphID packedGlyphID);
private:
struct HashTraits {
static const PackedGPUGlyphID& GetKey(const GlyphEntry* glyph);
static uint32_t Hash(PackedGPUGlyphID key);
};
skia_private::THashTable<GlyphEntry*, PackedGPUGlyphID, HashTraits> fCache;
friend class sktext::gpu::StrikeCache;
};
} // namespace skgpu::graphite
#endif // skgpu_graphite_TextStrike_DEFINED