Flutter Engine
The Flutter Engine
GlyphVector.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef sktext_gpu_GlyphVector_DEFINED
9#define sktext_gpu_GlyphVector_DEFINED
10
12#include "include/core/SkSpan.h"
13#include "src/core/SkGlyph.h"
14#include "src/gpu/AtlasTypes.h"
17
18#include <cstddef>
19#include <cstdint>
20#include <optional>
21#include <tuple>
22
23class SkReadBuffer;
24class SkStrikeClient;
25class SkWriteBuffer;
26
28namespace skgpu::ganesh { class AtlasTextOp; }
29namespace skgpu::graphite {
30class Device;
31class Recorder;
32}
33
34namespace sktext::gpu {
35class Glyph;
36class SubRunAllocator;
37
38// -- GlyphVector ----------------------------------------------------------------------------------
39// GlyphVector provides a way to delay the lookup of Glyphs until the code is running on the GPU
40// in single threaded mode. The GlyphVector is created in a multi-threaded environment, but the
41// StrikeCache is only single threaded (and must be single threaded because of the atlas).
43public:
44 union Variant {
45 // Initially, filled with packed id, but changed to Glyph* in the onPrepare stage.
48 // Add ctors to help SkArenaAlloc create arrays.
49 Variant() : glyph{nullptr} {}
51 };
52
54
55 static GlyphVector Make(SkStrikePromise&& promise,
57 SubRunAllocator* alloc);
58
60
61 static std::optional<GlyphVector> MakeFromBuffer(SkReadBuffer& buffer,
62 const SkStrikeClient* strikeClient,
63 SubRunAllocator* alloc);
64 void flatten(SkWriteBuffer& buffer) const;
65
66 // This doesn't need to include sizeof(GlyphVector) because this is embedded in each of
67 // the sub runs.
68 int unflattenSize() const { return GlyphVectorSize(fGlyphs.size()); }
69
71
72 static size_t GlyphVectorSize(size_t count) {
73 return sizeof(Variant) * count;
74 }
75
76private:
78 friend class ::skgpu::graphite::Device;
79 friend class ::skgpu::ganesh::AtlasTextOp;
80
81 // This function is implemented in ganesh/text/GrAtlasManager.cpp, and should only be called
82 // from AtlasTextOp or linking issues may occur.
83 std::tuple<bool, int> regenerateAtlasForGanesh(
84 int begin, int end,
85 skgpu::MaskFormat maskFormat,
86 int srcPadding,
88
89 // This function is implemented in graphite/text/AtlasManager.cpp, and should only be called
90 // from graphite::Device or linking issues may occur.
91 std::tuple<bool, int> regenerateAtlasForGraphite(
92 int begin, int end,
93 skgpu::MaskFormat maskFormat,
94 int srcPadding,
96
97 SkStrikePromise fStrikePromise;
98 SkSpan<Variant> fGlyphs;
99 sk_sp<TextStrike> fTextStrike{nullptr};
100 uint64_t fAtlasGeneration{skgpu::AtlasGenerationCounter::kInvalidGeneration};
101 skgpu::BulkUsePlotUpdater fBulkUseUpdater;
102};
103} // namespace sktext::gpu
104#endif // sktext_gpu_GlyphVector_DEFINED
int count
Definition: FontMgrTest.cpp:50
static constexpr uint64_t kInvalidGeneration
Definition: AtlasTypes.h:139
GlyphVector(SkStrikePromise &&strikePromise, SkSpan< Variant > glyphs)
Definition: GlyphVector.cpp:32
static GlyphVector Make(SkStrikePromise &&promise, SkSpan< const SkPackedGlyphID > glyphs, SubRunAllocator *alloc)
Definition: GlyphVector.cpp:38
void flatten(SkWriteBuffer &buffer) const
Definition: GlyphVector.cpp:84
SkSpan< const Glyph * > glyphs() const
Definition: GlyphVector.cpp:96
void packedGlyphIDToGlyph(StrikeCache *cache)
static size_t GlyphVectorSize(size_t count)
Definition: GlyphVector.h:72
int unflattenSize() const
Definition: GlyphVector.h:68
static std::optional< GlyphVector > MakeFromBuffer(SkReadBuffer &buffer, const SkStrikeClient *strikeClient, SubRunAllocator *alloc)
Definition: GlyphVector.cpp:50
static const char * begin(const StringSlice &s)
Definition: editor.cpp:252
glong glong end
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
MaskFormat
Definition: AtlasTypes.h:98
const uintptr_t id
Variant(SkPackedGlyphID id)
Definition: GlyphVector.h:50