Flutter Engine
The Flutter Engine
SkTypeface_remote.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 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
9
15#include "src/core/SkGlyph.h"
19
20#include <optional>
21#include <utility>
22
23class SkArenaAlloc;
24class SkDescriptor;
25class SkPath;
26
28 const SkScalerContextEffects& effects,
29 const SkDescriptor* desc,
31 : SkScalerContext{std::move(tf), effects, desc}
32 , fDiscardableManager{std::move(manager)} {}
33
35 SkArenaAlloc*) {
36 TRACE_EVENT1("skia", "generateMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
37 if (this->getProxyTypeface()->isLogging()) {
38 SkDebugf("GlyphCacheMiss generateMetrics looking for glyph: %x\n generateMetrics: %s\n",
39 glyph.getPackedID().value(), this->getRec().dump().c_str());
40 }
41
42 fDiscardableManager->notifyCacheMiss(
43 SkStrikeClient::CacheMissType::kGlyphMetrics, fRec.fTextSize);
44
45 return {glyph.maskFormat()};
46}
47
49 TRACE_EVENT1("skia", "generateImage", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
50 if (this->getProxyTypeface()->isLogging()) {
51 SkDebugf("GlyphCacheMiss generateImage: %s\n", this->getRec().dump().c_str());
52 }
53
54 // There is no desperation search here, because if there was an image to be found it was
55 // copied over with the metrics search.
56 fDiscardableManager->notifyCacheMiss(
57 SkStrikeClient::CacheMissType::kGlyphImage, fRec.fTextSize);
58}
59
61 TRACE_EVENT1("skia", "generatePath", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
62 if (this->getProxyTypeface()->isLogging()) {
63 SkDebugf("GlyphCacheMiss generatePath: %s\n", this->getRec().dump().c_str());
64 }
65
66 fDiscardableManager->notifyCacheMiss(
67 SkStrikeClient::CacheMissType::kGlyphPath, fRec.fTextSize);
68 return false;
69}
70
72 TRACE_EVENT1("skia", "generateDrawable", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
73 if (this->getProxyTypeface()->isLogging()) {
74 SkDebugf("GlyphCacheMiss generateDrawable: %s\n", this->getRec().dump().c_str());
75 }
76
77 fDiscardableManager->notifyCacheMiss(
78 SkStrikeClient::CacheMissType::kGlyphDrawable, fRec.fTextSize);
79 return nullptr;
80}
81
84 "skia", "generateFontMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
85 if (this->getProxyTypeface()->isLogging()) {
86 SkDebugf("GlyphCacheMiss generateFontMetrics: %s\n", this->getRec().dump().c_str());
87 }
88
89 // Font metrics aren't really used for render, so just zero out the data and return.
90 fDiscardableManager->notifyCacheMiss(
91 SkStrikeClient::CacheMissType::kFontMetrics, fRec.fTextSize);
92 sk_bzero(metrics, sizeof(*metrics));
93}
94
95std::optional<SkTypefaceProxyPrototype>
97 SkASSERT(buffer.isValid());
98 const SkTypefaceID typefaceID = buffer.readUInt();
99 const int glyphCount = buffer.readInt();
100 const int32_t styleValue = buffer.read32();
101 const bool isFixedPitch = buffer.readBool();
102 const bool glyphMaskNeedsCurrentColor = buffer.readBool();
103
104 if (buffer.isValid()) {
106 typefaceID, glyphCount, styleValue, isFixedPitch, glyphMaskNeedsCurrentColor};
107 }
108
109 return std::nullopt;
110}
111
113 : fServerTypefaceID{typeface.uniqueID()}
114 , fGlyphCount{typeface.countGlyphs()}
115 , fStyleValue{typeface.fontStyle().fValue}
116 , fIsFixedPitch{typeface.isFixedPitch()}
117 , fGlyphMaskNeedsCurrentColor{typeface.glyphMaskNeedsCurrentColor()} {}
118
120 int32_t styleValue, bool isFixedPitch,
121 bool glyphMaskNeedsCurrentColor)
122 : fServerTypefaceID {typefaceID}
123 , fGlyphCount{glyphCount}
124 , fStyleValue{styleValue}
125 , fIsFixedPitch{isFixedPitch}
126 , fGlyphMaskNeedsCurrentColor{glyphMaskNeedsCurrentColor} {}
127
129 buffer.writeUInt(fServerTypefaceID);
130 buffer.writeInt(fGlyphCount);
131 buffer.write32(fStyleValue);
132 buffer.writeBool(fIsFixedPitch);
133 buffer.writeBool(fGlyphMaskNeedsCurrentColor);
134}
135
136
139 bool isLogging)
140 : SkTypeface{prototype.style(), prototype.fIsFixedPitch}
141 , fTypefaceID{prototype.fServerTypefaceID}
142 , fGlyphCount{prototype.fGlyphCount}
143 , fIsLogging{isLogging}
144 , fGlyphMaskNeedsCurrentColor{prototype.fGlyphMaskNeedsCurrentColor}
145 , fDiscardableManager{std::move(manager)} {}
146
148 int glyphCount,
149 const SkFontStyle& style,
150 bool isFixedPitch,
151 bool glyphMaskNeedsCurrentColor,
153 bool isLogging)
154 : SkTypeface{style, isFixedPitch}
155 , fTypefaceID{typefaceID}
156 , fGlyphCount{glyphCount}
157 , fIsLogging{isLogging}
158 , fGlyphMaskNeedsCurrentColor(glyphMaskNeedsCurrentColor)
159 , fDiscardableManager{std::move(manager)} {}
160
162 return (SkTypefaceProxy*)this->getTypeface();
163}
sk_bzero(glyphs, sizeof(glyphs))
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define TRACE_STR_COPY(str)
Definition: SkTraceEvent.h:63
uint32_t SkTypefaceID
Definition: SkTypeface.h:38
static void dump(const float m[20], SkYUVColorSpace cs, bool rgb2yuv)
Definition: SkYUVMath.cpp:629
SkMask::Format maskFormat() const
Definition: SkGlyph.h:500
SkPackedGlyphID getPackedID() const
Definition: SkGlyph.h:430
Definition: SkPath.h:59
SkScalerContextProxy(sk_sp< SkTypeface > tf, const SkScalerContextEffects &effects, const SkDescriptor *desc, sk_sp< SkStrikeClient::DiscardableHandleManager > manager)
void generateFontMetrics(SkFontMetrics *metrics) override
sk_sp< SkDrawable > generateDrawable(const SkGlyph &) override
bool generatePath(const SkGlyph &glyph, SkPath *path) override
SkTypefaceProxy * getProxyTypeface() const
void generateImage(const SkGlyph &, void *) override
GlyphMetrics generateMetrics(const SkGlyph &, SkArenaAlloc *) override
SkScalerContextRec fRec
SkTypeface * getTypeface() const
const SkScalerContextRec & getRec() const
virtual void notifyCacheMiss(CacheMissType type, int fontSize)=0
void flatten(SkWriteBuffer &buffer) const
static std::optional< SkTypefaceProxyPrototype > MakeFromBuffer(SkReadBuffer &buffer)
SkTypefaceProxyPrototype(const SkTypeface &typeface)
SkTypefaceProxy(const SkTypefaceProxyPrototype &prototype, sk_sp< SkStrikeClient::DiscardableHandleManager > manager, bool isLogging=true)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
Definition: switches.h:218
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
Definition: switches.h:57
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
Definition: ref_ptr.h:256
uint32_t value() const
Definition: SkGlyph.h:110
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
Definition: trace_event.h:141