Flutter Engine
The Flutter Engine
Namespaces | Classes | Functions
sktext Namespace Reference

Namespaces

namespace  gpu
 

Classes

class  GlyphRun
 
class  GlyphRunBuilder
 
class  GlyphRunList
 
union  IDOrDrawable
 
union  IDOrPath
 
class  SkStrikePromise
 
class  StrikeForGPU
 
class  StrikeForGPUCacheInterface
 
class  StrikeMutationMonitor
 

Functions

static SkRect glyphrun_source_bounds (const SkFont &font, const SkPaint &paint, SkZip< const SkGlyphID, const SkPoint > source, SkSpan< const SkVector > scaledRotations)
 
static SkSpan< const SkPointdraw_text_positions (const SkFont &font, SkSpan< const SkGlyphID > glyphIDs, SkPoint origin, SkPoint *buffer)
 

Function Documentation

◆ draw_text_positions()

static SkSpan< const SkPoint > sktext::draw_text_positions ( const SkFont font,
SkSpan< const SkGlyphID glyphIDs,
SkPoint  origin,
SkPoint buffer 
)
static

Definition at line 196 of file GlyphRun.cpp.

197 {
199 SkBulkGlyphMetrics storage{strikeSpec};
200 auto glyphs = storage.glyphs(glyphIDs);
201
202 SkPoint* positionCursor = buffer;
203 SkPoint endOfLastGlyph = origin;
204 for (auto glyph : glyphs) {
205 *positionCursor++ = endOfLastGlyph;
206 endOfLastGlyph += glyph->advanceVector();
207 }
208 return SkSpan(buffer, glyphIDs.size());
209}
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
constexpr size_t size() const
Definition: SkSpan_impl.h:95
static SkStrikeSpec MakeWithNoDevice(const SkFont &font, const SkPaint *paint=nullptr)
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
font
Font Metadata and Metrics.

◆ glyphrun_source_bounds()

static SkRect sktext::glyphrun_source_bounds ( const SkFont font,
const SkPaint paint,
SkZip< const SkGlyphID, const SkPoint source,
SkSpan< const SkVector scaledRotations 
)
static

Definition at line 119 of file GlyphRun.cpp.

123 {
125 const SkRect fontBounds = SkFontPriv::GetFontBounds(font);
126
127 SkSpan<const SkGlyphID> glyphIDs = source.get<0>();
128 SkSpan<const SkPoint> positions = source.get<1>();
129
130 if (fontBounds.isEmpty()) {
131 // Empty font bounds are likely a font bug. TightBounds has a better chance of
132 // producing useful results in this case.
133 auto [strikeSpec, strikeToSourceScale] = SkStrikeSpec::MakeCanonicalized(font, &paint);
134 SkBulkGlyphMetrics metrics{strikeSpec};
135 SkSpan<const SkGlyph*> glyphs = metrics.glyphs(glyphIDs);
136 if (scaledRotations.empty()) {
137 // No RSXForm data - glyphs x/y aligned.
138 auto scaleAndTranslateRect =
139 [scale = strikeToSourceScale](const SkRect& in, const SkPoint& pos) {
140 return SkRect::MakeLTRB(in.left() * scale + pos.x(),
141 in.top() * scale + pos.y(),
142 in.right() * scale + pos.x(),
143 in.bottom() * scale + pos.y());
144 };
145
147 for (auto [pos, glyph] : SkMakeZip(positions, glyphs)) {
148 if (SkRect r = glyph->rect(); !r.isEmpty()) {
149 bounds.join(scaleAndTranslateRect(r, pos));
150 }
151 }
152 return bounds;
153 } else {
154 // RSXForm - glyphs can be any scale or rotation.
156 for (auto [pos, scaleRotate, glyph] : SkMakeZip(positions, scaledRotations, glyphs)) {
157 if (!glyph->rect().isEmpty()) {
158 SkMatrix xform = SkMatrix().setRSXform(
159 SkRSXform{pos.x(), pos.y(), scaleRotate.x(), scaleRotate.y()});
160 xform.preScale(strikeToSourceScale, strikeToSourceScale);
161 bounds.join(xform.mapRect(glyph->rect()));
162 }
163 }
164 return bounds;
165 }
166 }
167
168 // Use conservative bounds. All glyph have a box of fontBounds size.
169 if (scaledRotations.empty()) {
171 bounds.setBounds(positions.data(), SkCount(positions));
172 bounds.fLeft += fontBounds.left();
173 bounds.fTop += fontBounds.top();
174 bounds.fRight += fontBounds.right();
175 bounds.fBottom += fontBounds.bottom();
176 return bounds;
177 } else {
178 // RSXForm case glyphs can be any scale or rotation.
180 bounds.setEmpty();
181 for (auto [pos, scaleRotate] : SkMakeZip(positions, scaledRotations)) {
182 const SkRSXform xform{pos.x(), pos.y(), scaleRotate.x(), scaleRotate.y()};
183 bounds.join(SkMatrix().setRSXform(xform).mapRect(fontBounds));
184 }
185 return bounds;
186 }
187}
SkPoint pos
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr int SkCount(const Container &c)
Definition: SkTLogic.h:54
constexpr auto SkMakeZip(Ts &&... ts)
Definition: SkZip.h:212
bool empty() const
Definition: SkBitmap.h:210
static SkRect GetFontBounds(const SkFont &)
Definition: SkFont.cpp:354
SkMatrix & setRSXform(const SkRSXform &rsxForm)
Definition: SkMatrix.cpp:420
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:315
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
constexpr T * data() const
Definition: SkSpan_impl.h:94
constexpr bool empty() const
Definition: SkSpan_impl.h:96
static std::tuple< SkStrikeSpec, SkScalar > MakeCanonicalized(const SkFont &font, const SkPaint *paint=nullptr)
const Paint & paint
Definition: color_source.cc:38
SkBitmap source
Definition: examples.cpp:28
Optional< SkRect > bounds
Definition: SkRecords.h:189
const Scalar scale
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595
constexpr float left() const
Definition: SkRect.h:734
constexpr float top() const
Definition: SkRect.h:741
constexpr float right() const
Definition: SkRect.h:748
bool isEmpty() const
Definition: SkRect.h:693
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646
constexpr float bottom() const
Definition: SkRect.h:755