blob: e51e3d11d095e9eea80ce70177eafb5949f77c80 [file] [log] [blame] [edit]
/*
* 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 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 {
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(SkPackedGlyphID packedGlyphID, MaskFormat format);
private:
struct HashTraits {
static const GlyphEntryKey& GetKey(const GlyphEntry* glyph);
static uint32_t Hash(GlyphEntryKey key);
};
skia_private::THashTable<GlyphEntry*, GlyphEntryKey, HashTraits> fCache;
friend class sktext::gpu::StrikeCache;
};
} // namespace skgpu::graphite
#endif // skgpu_graphite_TextStrike_DEFINED