Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkGlyph.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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 SkGlyph_DEFINED
9#define SkGlyph_DEFINED
10
12#include "include/core/SkPath.h"
15#include "include/core/SkRect.h"
23#include "src/base/SkVx.h"
24#include "src/core/SkChecksum.h"
25#include "src/core/SkMask.h"
26
27#include <algorithm>
28#include <cmath>
29#include <cstddef>
30#include <cstdint>
31#include <limits>
32#include <optional>
33
34class SkArenaAlloc;
35class SkCanvas;
36class SkGlyph;
37class SkReadBuffer;
38class SkScalerContext;
39class SkWriteBuffer;
40namespace sktext {
41class StrikeForGPU;
42} // namespace sktext
43
44// -- SkPackedGlyphID ------------------------------------------------------------------------------
45// A combination of SkGlyphID and sub-pixel position information.
47 inline static constexpr uint32_t kImpossibleID = ~0u;
48 enum {
49 // Lengths
52
53 // Bit positions
58
59 // Masks
62 kMaskAll = (1u << kEndData) - 1,
63
64 // Location of sub pixel info in a fixed pointer number.
67 };
68
69 inline static const constexpr SkScalar kSubpixelRound =
70 1.f / (1u << (SkPackedGlyphID::kSubPixelPosLen + 1));
71
74
75 struct Hash {
76 uint32_t operator() (SkPackedGlyphID packedID) const {
77 return packedID.hash();
78 }
79 };
80
81 constexpr explicit SkPackedGlyphID(SkGlyphID glyphID)
82 : fID{(uint32_t)glyphID << kGlyphID} { }
83
85 : fID {PackIDXY(glyphID, x, y)} { }
86
87 constexpr SkPackedGlyphID(SkGlyphID glyphID, uint32_t x, uint32_t y)
88 : fID {PackIDSubXSubY(glyphID, x, y)} { }
89
91 : fID{PackIDSkPoint(glyphID, pt, mask)} { }
92
93 constexpr explicit SkPackedGlyphID(uint32_t v) : fID{v & kMaskAll} { }
94 constexpr SkPackedGlyphID() : fID{kImpossibleID} {}
95
96 bool operator==(const SkPackedGlyphID& that) const {
97 return fID == that.fID;
98 }
99 bool operator!=(const SkPackedGlyphID& that) const {
100 return !(*this == that);
101 }
102 bool operator<(SkPackedGlyphID that) const {
103 return this->fID < that.fID;
104 }
105
107 return (fID >> kGlyphID) & kGlyphIDMask;
108 }
109
110 uint32_t value() const {
111 return fID;
112 }
113
115 return this->subToFixed(kSubPixelX);
116 }
117
119 return this->subToFixed(kSubPixelY);
120 }
121
122 uint32_t hash() const {
123 return SkChecksum::CheapMix(fID);
124 }
125
126 SkString dump() const {
127 SkString str;
128 str.appendf("glyphID: %d, x: %d, y:%d", glyphID(), getSubXFixed(), getSubYFixed());
129 return str;
130 }
131
133 SkString str;
134 str.appendf("0x%x|%1u|%1u", this->glyphID(),
135 this->subPixelField(kSubPixelX),
136 this->subPixelField(kSubPixelY));
137 return str;
138 }
139
140private:
141 static constexpr uint32_t PackIDSubXSubY(SkGlyphID glyphID, uint32_t x, uint32_t y) {
142 SkASSERT(x < (1u << kSubPixelPosLen));
143 SkASSERT(y < (1u << kSubPixelPosLen));
144
145 return (x << kSubPixelX) | (y << kSubPixelY) | (glyphID << kGlyphID);
146 }
147
148 // Assumptions: pt is properly rounded. mask is set for the x or y fields.
149 //
150 // A sub-pixel field is a number on the interval [2^kSubPixel, 2^(kSubPixel + kSubPixelPosLen)).
151 // Where kSubPixel is either kSubPixelX or kSubPixelY. Given a number x on [0, 1) we can
152 // generate a sub-pixel field using:
153 // sub-pixel-field = x * 2^(kSubPixel + kSubPixelPosLen)
154 //
155 // We can generate the integer sub-pixel field by &-ing the integer part of sub-filed with the
156 // sub-pixel field mask.
157 // int-sub-pixel-field = int(sub-pixel-field) & (kSubPixelPosMask << kSubPixel)
158 //
159 // The last trick is to extend the range from [0, 1) to [0, 2). The extend range is
160 // necessary because the modulo 1 calculation (pt - floor(pt)) generates numbers on [-1, 1).
161 // This does not round (floor) properly when converting to integer. Adding one to the range
162 // causes truncation and floor to be the same. Coincidentally, masking to produce the field also
163 // removes the +1.
164 static uint32_t PackIDSkPoint(SkGlyphID glyphID, SkPoint pt, SkIPoint mask) {
165 #if 0
166 // TODO: why does this code not work on GCC 8.3 x86 Debug builds?
167 using namespace skvx;
168 using XY = Vec<2, float>;
169 using SubXY = Vec<2, int>;
170
171 const XY magic = {1.f * (1u << (kSubPixelPosLen + kSubPixelX)),
172 1.f * (1u << (kSubPixelPosLen + kSubPixelY))};
173 XY pos{pt.x(), pt.y()};
174 XY subPos = (pos - floor(pos)) + 1.0f;
175 SubXY sub = cast<int>(subPos * magic) & SubXY{mask.x(), mask.y()};
176 #else
177 const float magicX = 1.f * (1u << (kSubPixelPosLen + kSubPixelX)),
178 magicY = 1.f * (1u << (kSubPixelPosLen + kSubPixelY));
179
180 float x = pt.x(),
181 y = pt.y();
182 x = (x - floorf(x)) + 1.0f;
183 y = (y - floorf(y)) + 1.0f;
184 int sub[] = {
185 (int)(x * magicX) & mask.x(),
186 (int)(y * magicY) & mask.y(),
187 };
188 #endif
189
190 SkASSERT(sub[0] / (1u << kSubPixelX) < (1u << kSubPixelPosLen));
191 SkASSERT(sub[1] / (1u << kSubPixelY) < (1u << kSubPixelPosLen));
192 return (glyphID << kGlyphID) | sub[0] | sub[1];
193 }
194
195 static constexpr uint32_t PackIDXY(SkGlyphID glyphID, SkFixed x, SkFixed y) {
196 return PackIDSubXSubY(glyphID, FixedToSub(x), FixedToSub(y));
197 }
198
199 static constexpr uint32_t FixedToSub(SkFixed n) {
200 return ((uint32_t)n >> kFixedPointSubPixelPosBits) & kSubPixelPosMask;
201 }
202
203 constexpr uint32_t subPixelField(uint32_t subPixelPosBit) const {
204 return (fID >> subPixelPosBit) & kSubPixelPosMask;
205 }
206
207 constexpr SkFixed subToFixed(uint32_t subPixelPosBit) const {
208 uint32_t subPixelPosition = this->subPixelField(subPixelPosBit);
209 return subPixelPosition << kFixedPointSubPixelPosBits;
210 }
211
212 uint32_t fID;
213};
214
215// -- SkAxisAlignment ------------------------------------------------------------------------------
216// SkAxisAlignment specifies the x component of a glyph's position is rounded when kX, and the y
217// component is rounded when kY. If kNone then neither are rounded.
218enum class SkAxisAlignment : uint32_t {
219 kNone,
220 kX,
221 kY,
222};
223
224// round and ignorePositionMask are used to calculate the subpixel position of a glyph.
225// The per component (x or y) calculation is:
226//
227// subpixelOffset = (floor((viewportPosition + rounding) & mask) >> 14) & 3
228//
229// where mask is either 0 or ~0, and rounding is either
230// 1/2 for non-subpixel or 1/8 for subpixel.
232 SkGlyphPositionRoundingSpec(bool isSubpixel, SkAxisAlignment axisAlignment);
236
237private:
238 static SkVector HalfAxisSampleFreq(bool isSubpixel, SkAxisAlignment axisAlignment);
239 static SkIPoint IgnorePositionMask(bool isSubpixel, SkAxisAlignment axisAlignment);
240 static SkIPoint IgnorePositionFieldMask(bool isSubpixel, SkAxisAlignment axisAlignment);
241};
242
243class SkGlyphRect;
244namespace skglyph {
246SkGlyphRect rect_intersection(SkGlyphRect, SkGlyphRect);
247} // namespace skglyph
248
249// SkGlyphRect encodes rectangles with coordinates using SkScalar. It is specialized for
250// rectangle union and intersection operations.
252public:
253 SkGlyphRect() = default;
255 : fRect{-left, -top, right, bottom} { }
256 bool empty() const {
257 return -fRect[0] >= fRect[2] || -fRect[1] >= fRect[3];
258 }
259 SkRect rect() const {
260 return SkRect::MakeLTRB(-fRect[0], -fRect[1], fRect[2], fRect[3]);
261 }
263 return SkGlyphRect{fRect + Storage{-x, -y, x, y}};
264 }
266 return this->offset(pt.x(), pt.y());
267 }
269 auto [x, y] = offset;
270 return fRect * scale + Storage{-x, -y, x, y};
271 }
273 return fRect - Storage{dx, dy, dx, dy};
274 }
275 SkPoint leftTop() const { return -this->negLeftTop(); }
276 SkPoint rightBottom() const { return {fRect[2], fRect[3]}; }
277 SkPoint widthHeight() const { return this->rightBottom() + negLeftTop(); }
278 friend SkGlyphRect skglyph::rect_union(SkGlyphRect, SkGlyphRect);
279 friend SkGlyphRect skglyph::rect_intersection(SkGlyphRect, SkGlyphRect);
280
281private:
282 SkPoint negLeftTop() const { return {fRect[0], fRect[1]}; }
283 using Storage = skvx::Vec<4, SkScalar>;
284 SkGlyphRect(Storage rect) : fRect{rect} { }
285 Storage fRect;
286};
287
288namespace skglyph {
289inline SkGlyphRect empty_rect() {
290 constexpr SkScalar max = std::numeric_limits<SkScalar>::max();
291 return {max, max, -max, -max};
292}
293inline SkGlyphRect full_rect() {
294 constexpr SkScalar max = std::numeric_limits<SkScalar>::max();
295 return {-max, -max, max, max};
296}
297inline SkGlyphRect rect_union(SkGlyphRect a, SkGlyphRect b) {
298 return skvx::max(a.fRect, b.fRect);
299}
300inline SkGlyphRect rect_intersection(SkGlyphRect a, SkGlyphRect b) {
301 return skvx::min(a.fRect, b.fRect);
302}
303
304enum class GlyphAction {
305 kUnset,
306 kAccept,
307 kReject,
308 kDrop,
309 kSize,
310};
311
312enum ActionType {
313 kDirectMask = 0,
314 kDirectMaskCPU = 2,
315 kMask = 4,
316 kSDFT = 6,
317 kPath = 8,
318 kDrawable = 10,
319};
320
321enum ActionTypeSize {
322 kTotalBits = 12
323};
324} // namespace skglyph
325
326// SkGlyphDigest contains a digest of information for making GPU drawing decisions. It can be
327// referenced instead of the glyph itself in many situations. In the remote glyphs cache the
328// SkGlyphDigest is the only information that needs to be stored in the cache.
330public:
331 // An atlas consists of plots, and plots hold glyphs. The minimum a plot can be is 256x256.
332 // This means that the maximum size a glyph can be is 256x256.
333 static constexpr uint16_t kSkSideTooBigForAtlas = 256;
334
335 // Default ctor is only needed for the hash table.
336 SkGlyphDigest() = default;
337 SkGlyphDigest(size_t index, const SkGlyph& glyph);
338 int index() const { return fIndex; }
339 bool isEmpty() const { return fIsEmpty; }
340 bool isColor() const { return fFormat == SkMask::kARGB32_Format; }
341 SkMask::Format maskFormat() const { return static_cast<SkMask::Format>(fFormat); }
342
343 skglyph::GlyphAction actionFor(skglyph::ActionType actionType) const {
344 return static_cast<skglyph::GlyphAction>((fActions >> actionType) & 0b11);
345 }
346
347 void setActionFor(skglyph::ActionType, SkGlyph*, sktext::StrikeForGPU*);
348
349 uint16_t maxDimension() const {
350 return std::max(fWidth, fHeight);
351 }
352
353 bool fitsInAtlasDirect() const {
354 return this->maxDimension() <= kSkSideTooBigForAtlas;
355 }
356
358 // Include the padding needed for interpolating the glyph when drawing.
359 return this->maxDimension() <= kSkSideTooBigForAtlas - 2;
360 }
361
363 return SkGlyphRect(fLeft, fTop, (SkScalar)fLeft + fWidth, (SkScalar)fTop + fHeight);
364 }
365
366 static bool FitsInAtlas(const SkGlyph& glyph);
367
368 // GetKey and Hash implement the required methods for THashTable.
370 return SkPackedGlyphID{SkTo<uint32_t>(digest.fPackedID)};
371 }
372 static uint32_t Hash(SkPackedGlyphID packedID) {
373 return packedID.hash();
374 }
375
376private:
377 void setAction(skglyph::ActionType actionType, skglyph::GlyphAction action) {
378 using namespace skglyph;
379 SkASSERT(action != GlyphAction::kUnset);
380 SkASSERT(this->actionFor(actionType) == GlyphAction::kUnset);
381 const uint64_t mask = 0b11 << actionType;
382 fActions &= ~mask;
383 fActions |= SkTo<uint64_t>(action) << actionType;
384 }
385
386 static_assert(SkPackedGlyphID::kEndData == 20);
387 static_assert(SkMask::kCountMaskFormats <= 8);
388 static_assert(SkTo<int>(skglyph::GlyphAction::kSize) <= 4);
389 struct {
392 uint64_t fIsEmpty : 1;
393 uint64_t fFormat : 3;
394 uint64_t fActions : skglyph::ActionTypeSize::kTotalBits;
395 };
396 int16_t fLeft, fTop;
397 uint16_t fWidth, fHeight;
398};
399
401public:
403 static void FlattenDrawable(SkWriteBuffer& buffer, SkDrawable* drawable);
405
406private:
407 sk_sp<SkPicture> fPicture;
408 SkRect onGetBounds() override;
409 size_t onApproximateBytesUsed() override;
410 void onDraw(SkCanvas* canvas) override;
411};
412
413class SkGlyph {
414public:
415 static std::optional<SkGlyph> MakeFromBuffer(SkReadBuffer&);
416 // SkGlyph() is used for testing.
417 constexpr SkGlyph() : SkGlyph{SkPackedGlyphID()} { }
423 constexpr explicit SkGlyph(SkPackedGlyphID id) : fID{id} { }
424
425 SkVector advanceVector() const { return SkVector{fAdvanceX, fAdvanceY}; }
426 SkScalar advanceX() const { return fAdvanceX; }
427 SkScalar advanceY() const { return fAdvanceY; }
428
429 SkGlyphID getGlyphID() const { return fID.glyphID(); }
430 SkPackedGlyphID getPackedID() const { return fID; }
431 SkFixed getSubXFixed() const { return fID.getSubXFixed(); }
432 SkFixed getSubYFixed() const { return fID.getSubYFixed(); }
433
434 size_t rowBytes() const;
436
437 // Call this to set all the metrics fields to 0 (e.g. if the scaler
438 // encounters an error measuring a glyph). Note: this does not alter the
439 // fImage, fPath, fID, fMaskFormat fields.
440 void zeroMetrics();
441
442 SkMask mask() const;
443
444 SkMask mask(SkPoint position) const;
445
446 // Image
447 // If we haven't already tried to associate an image with this glyph
448 // (i.e. setImageHasBeenCalled() returns false), then use the
449 // SkScalerContext or const void* argument to set the image.
450 bool setImage(SkArenaAlloc* alloc, SkScalerContext* scalerContext);
451 bool setImage(SkArenaAlloc* alloc, const void* image);
452
453 // Merge the 'from' glyph into this glyph using alloc to allocate image data. Return the number
454 // of bytes allocated. Copy the width, height, top, left, format, and image into this glyph
455 // making a copy of the image using the alloc.
456 size_t setMetricsAndImage(SkArenaAlloc* alloc, const SkGlyph& from);
457
458 // Returns true if the image has been set.
460 // Check for empty bounds first to guard against fImage somehow being set.
461 return this->isEmpty() || fImage != nullptr || this->imageTooLarge();
462 }
463
464 // Return a pointer to the path if the image exists, otherwise return nullptr.
465 const void* image() const { SkASSERT(this->setImageHasBeenCalled()); return fImage; }
466
467 // Return the size of the image.
468 size_t imageSize() const;
469
470 // Path
471 // If we haven't already tried to associate a path to this glyph
472 // (i.e. setPathHasBeenCalled() returns false), then use the
473 // SkScalerContext or SkPath argument to try to do so. N.B. this
474 // may still result in no path being associated with this glyph,
475 // e.g. if you pass a null SkPath or the typeface is bitmap-only.
476 //
477 // This setPath() call is sticky... once you call it, the glyph
478 // stays in its state permanently, ignoring any future calls.
479 //
480 // Returns true if this is the first time you called setPath()
481 // and there actually is a path; call path() to get it.
482 bool setPath(SkArenaAlloc* alloc, SkScalerContext* scalerContext);
483 bool setPath(SkArenaAlloc* alloc, const SkPath* path, bool hairline);
484
485 // Returns true if that path has been set.
486 bool setPathHasBeenCalled() const { return fPathData != nullptr; }
487
488 // Return a pointer to the path if it exists, otherwise return nullptr. Only works if the
489 // path was previously set.
490 const SkPath* path() const;
491 bool pathIsHairline() const;
492
493 bool setDrawable(SkArenaAlloc* alloc, SkScalerContext* scalerContext);
495 bool setDrawableHasBeenCalled() const { return fDrawableData != nullptr; }
496 SkDrawable* drawable() const;
497
498 // Format
499 bool isColor() const { return fMaskFormat == SkMask::kARGB32_Format; }
500 SkMask::Format maskFormat() const { return fMaskFormat; }
501 size_t formatAlignment() const;
502
503 // Bounds
504 int maxDimension() const { return std::max(fWidth, fHeight); }
505 SkIRect iRect() const { return SkIRect::MakeXYWH(fLeft, fTop, fWidth, fHeight); }
506 SkRect rect() const { return SkRect::MakeXYWH(fLeft, fTop, fWidth, fHeight); }
508 return SkGlyphRect(fLeft, fTop, fLeft + fWidth, fTop + fHeight);
509 }
510 int left() const { return fLeft; }
511 int top() const { return fTop; }
512 int width() const { return fWidth; }
513 int height() const { return fHeight; }
514 bool isEmpty() const {
515 return fWidth == 0 || fHeight == 0;
516 }
517 bool imageTooLarge() const { return fWidth >= kMaxGlyphWidth; }
518
519 uint16_t extraBits() const { return fScalerContextBits; }
520
521 // Make sure that the intercept information is on the glyph and return it, or return it if it
522 // already exists.
523 // * bounds - [0] - top of underline; [1] - bottom of underline.
524 // * scale, xPos - information about how wide the gap is.
525 // * array - accumulated gaps for many characters if not null.
526 // * count - the number of gaps.
527 void ensureIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos,
528 SkScalar* array, int* count, SkArenaAlloc* alloc);
529
530 // Deprecated. Do not use. The last use is in SkChromeRemoteCache, and will be deleted soon.
531 void setImage(void* image) { fImage = image; }
532
533 // Serialize/deserialize functions.
534 // Flatten the metrics portions, but no drawing data.
535 void flattenMetrics(SkWriteBuffer&) const;
536
537 // Flatten just the the mask data.
538 void flattenImage(SkWriteBuffer&) const;
539
540 // Read the image data, store it in the alloc, and add it to the glyph.
542
543 // Flatten just the path data.
544 void flattenPath(SkWriteBuffer&) const;
545
546 // Read the path data, create the glyph's path data in the alloc, and add it to the glyph.
548
549 // Flatten just the drawable data.
550 void flattenDrawable(SkWriteBuffer&) const;
551
552 // Read the drawable data, create the glyph's drawable data in the alloc, and add it to the
553 // glyph.
555
556private:
557 // There are two sides to an SkGlyph, the scaler side (things that create glyph data) have
558 // access to all the fields. Scalers are assumed to maintain all the SkGlyph invariants. The
559 // consumer side has a tighter interface.
560 friend class SkScalerContext;
561 friend class SkGlyphTestPeer;
562
563 inline static constexpr uint16_t kMaxGlyphWidth = 1u << 13u;
564
565 // Support horizontal and vertical skipping strike-through / underlines.
566 // The caller walks the linked list looking for a match. For a horizontal underline,
567 // the fBounds contains the top and bottom of the underline. The fInterval pair contains the
568 // beginning and end of the intersection of the bounds and the glyph's path.
569 // If interval[0] >= interval[1], no intersection was found.
570 struct Intercept {
571 Intercept* fNext;
572 SkScalar fBounds[2]; // for horz underlines, the boundaries in Y
573 SkScalar fInterval[2]; // the outside intersections of the axis and the glyph
574 };
575
576 struct PathData {
577 Intercept* fIntercept{nullptr};
579 bool fHasPath{false};
580 // A normal user-path will have patheffects applied to it and eventually become a dev-path.
581 // A dev-path is always a fill-path, except when it is hairline.
582 // The fPath is a dev-path, so sidecar the paths hairline status.
583 // This allows the user to avoid filling paths which should not be filled.
584 bool fHairline{false};
585 };
586
587 struct DrawableData {
588 Intercept* fIntercept{nullptr};
589 sk_sp<SkDrawable> fDrawable;
590 bool fHasDrawable{false};
591 };
592
593 size_t allocImage(SkArenaAlloc* alloc);
594
595 void installImage(void* imageData) {
597 fImage = imageData;
598 }
599
600 // path == nullptr indicates that there is no path.
601 void installPath(SkArenaAlloc* alloc, const SkPath* path, bool hairline);
602
603 // drawable == nullptr indicates that there is no path.
604 void installDrawable(SkArenaAlloc* alloc, sk_sp<SkDrawable> drawable);
605
606 // The width and height of the glyph mask.
607 uint16_t fWidth = 0,
608 fHeight = 0;
609
610 // The offset from the glyphs origin on the baseline to the top left of the glyph mask.
611 int16_t fTop = 0,
612 fLeft = 0;
613
614 // fImage must remain null if the glyph is empty or if width > kMaxGlyphWidth.
615 void* fImage = nullptr;
616
617 // Path data has tricky state. If the glyph isEmpty, then fPathData should always be nullptr,
618 // else if fPathData is not null, then a path has been requested. The fPath field of fPathData
619 // may still be null after the request meaning that there is no path for this glyph.
620 PathData* fPathData = nullptr;
621 DrawableData* fDrawableData = nullptr;
622
623 // The advance for this glyph.
624 float fAdvanceX = 0,
625 fAdvanceY = 0;
626
628
629 // Used by the SkScalerContext to pass state from generateMetrics to generateImage.
630 // Usually specifies which glyph representation was used to generate the metrics.
631 uint16_t fScalerContextBits = 0;
632
633 // An SkGlyph can be created with just a packedID, but generally speaking some glyph factory
634 // needs to actually fill out the glyph before it can be used as part of that system.
635 SkDEBUGCODE(bool fAdvancesBoundsFormatAndInitialPathDone{false};)
636
637 SkPackedGlyphID fID;
638};
639
640#endif
SkPath fPath
Instance * fNext
int count
SkPoint pos
const SkRect fBounds
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
int32_t SkFixed
Definition SkFixed.h:25
SkAxisAlignment
Definition SkGlyph.h:218
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
uint16_t SkGlyphID
Definition SkTypes.h:179
Type::kYUV Type::kRGBA() int(0.7 *637)
uint64_t fIndex
Definition SkGlyph.h:391
SkGlyphRect bounds() const
Definition SkGlyph.h:362
bool isColor() const
Definition SkGlyph.h:340
uint64_t fIsEmpty
Definition SkGlyph.h:392
uint64_t fFormat
Definition SkGlyph.h:393
uint64_t fActions
Definition SkGlyph.h:394
SkMask::Format maskFormat() const
Definition SkGlyph.h:341
static uint32_t Hash(SkPackedGlyphID packedID)
Definition SkGlyph.h:372
SkGlyphDigest()=default
static bool FitsInAtlas(const SkGlyph &glyph)
Definition SkGlyph.cpp:684
uint16_t maxDimension() const
Definition SkGlyph.h:349
static constexpr uint16_t kSkSideTooBigForAtlas
Definition SkGlyph.h:333
uint64_t fPackedID
Definition SkGlyph.h:390
bool fitsInAtlasInterpolated() const
Definition SkGlyph.h:357
void setActionFor(skglyph::ActionType, SkGlyph *, sktext::StrikeForGPU *)
Definition SkGlyph.cpp:634
static SkPackedGlyphID GetKey(SkGlyphDigest digest)
Definition SkGlyph.h:369
int index() const
Definition SkGlyph.h:338
bool fitsInAtlasDirect() const
Definition SkGlyph.h:353
bool isEmpty() const
Definition SkGlyph.h:339
skglyph::GlyphAction actionFor(skglyph::ActionType actionType) const
Definition SkGlyph.h:343
bool empty() const
Definition SkGlyph.h:256
SkPoint rightBottom() const
Definition SkGlyph.h:276
SkPoint widthHeight() const
Definition SkGlyph.h:277
SkPoint leftTop() const
Definition SkGlyph.h:275
SkRect rect() const
Definition SkGlyph.h:259
SkGlyphRect scaleAndOffset(SkScalar scale, SkPoint offset) const
Definition SkGlyph.h:268
SkGlyphRect offset(SkPoint pt) const
Definition SkGlyph.h:265
SkGlyphRect offset(SkScalar x, SkScalar y) const
Definition SkGlyph.h:262
SkGlyphRect()=default
SkGlyphRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
Definition SkGlyph.h:254
SkGlyphRect inset(SkScalar dx, SkScalar dy) const
Definition SkGlyph.h:272
int top() const
Definition SkGlyph.h:511
bool setPathHasBeenCalled() const
Definition SkGlyph.h:486
void zeroMetrics()
Definition SkGlyph.cpp:137
size_t rowBytes() const
Definition SkGlyph.cpp:233
uint16_t extraBits() const
Definition SkGlyph.h:519
bool isEmpty() const
Definition SkGlyph.h:514
size_t addPathFromBuffer(SkReadBuffer &, SkArenaAlloc *)
Definition SkGlyph.cpp:389
bool imageTooLarge() const
Definition SkGlyph.h:517
SkGlyphID getGlyphID() const
Definition SkGlyph.h:429
size_t formatAlignment() const
Definition SkGlyph.cpp:173
void ensureIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos, SkScalar *array, int *count, SkArenaAlloc *alloc)
Definition SkGlyph.cpp:547
void flattenMetrics(SkWriteBuffer &) const
Definition SkGlyph.cpp:336
bool setDrawableHasBeenCalled() const
Definition SkGlyph.h:495
size_t imageSize() const
Definition SkGlyph.cpp:241
SkMask mask() const
Definition SkGlyph.cpp:125
bool setImageHasBeenCalled() const
Definition SkGlyph.h:459
size_t setMetricsAndImage(SkArenaAlloc *alloc, const SkGlyph &from)
Definition SkGlyph.cpp:207
const SkPath * path() const
Definition SkGlyph.cpp:284
SkMask::Format maskFormat() const
Definition SkGlyph.h:500
SkGlyph & operator=(const SkGlyph &)
bool setDrawable(SkArenaAlloc *alloc, SkScalerContext *scalerContext)
Definition SkGlyph.cpp:310
bool setPath(SkArenaAlloc *alloc, SkScalerContext *scalerContext)
Definition SkGlyph.cpp:266
SkRect rect() const
Definition SkGlyph.h:506
constexpr SkGlyph(SkPackedGlyphID id)
Definition SkGlyph.h:423
bool pathIsHairline() const
Definition SkGlyph.cpp:293
void flattenPath(SkWriteBuffer &) const
Definition SkGlyph.cpp:378
size_t rowBytesUsingFormat(SkMask::Format format) const
Definition SkGlyph.cpp:237
bool setImage(SkArenaAlloc *alloc, SkScalerContext *scalerContext)
Definition SkGlyph.cpp:185
SkGlyph & operator=(SkGlyph &&)
void flattenDrawable(SkWriteBuffer &) const
Definition SkGlyph.cpp:414
SkScalar advanceX() const
Definition SkGlyph.h:426
void setImage(void *image)
Definition SkGlyph.h:531
constexpr SkGlyph()
Definition SkGlyph.h:417
SkScalar advanceY() const
Definition SkGlyph.h:427
int height() const
Definition SkGlyph.h:513
size_t addImageFromBuffer(SkReadBuffer &, SkArenaAlloc *)
Definition SkGlyph.cpp:358
SkGlyph(const SkGlyph &)
SkFixed getSubYFixed() const
Definition SkGlyph.h:432
size_t addDrawableFromBuffer(SkReadBuffer &, SkArenaAlloc *)
Definition SkGlyph.cpp:425
SkFixed getSubXFixed() const
Definition SkGlyph.h:431
SkIRect iRect() const
Definition SkGlyph.h:505
SkGlyphRect glyphRect() const
Definition SkGlyph.h:507
SkGlyph(SkGlyph &&)
void flattenImage(SkWriteBuffer &) const
Definition SkGlyph.cpp:349
int width() const
Definition SkGlyph.h:512
SkDrawable * drawable() const
Definition SkGlyph.cpp:327
int left() const
Definition SkGlyph.h:510
SkPackedGlyphID getPackedID() const
Definition SkGlyph.h:430
bool isColor() const
Definition SkGlyph.h:499
SkVector advanceVector() const
Definition SkGlyph.h:425
int maxDimension() const
Definition SkGlyph.h:504
const void * image() const
Definition SkGlyph.h:465
static std::optional< SkGlyph > MakeFromBuffer(SkReadBuffer &)
Definition SkGlyph.cpp:95
SkRect onGetBounds() override
Definition SkGlyph.cpp:82
void onDraw(SkCanvas *canvas) override
Definition SkGlyph.cpp:90
size_t onApproximateBytesUsed() override
Definition SkGlyph.cpp:86
static sk_sp< SkPictureBackedGlyphDrawable > MakeFromBuffer(SkReadBuffer &buffer)
Definition SkGlyph.cpp:37
static void FlattenDrawable(SkWriteBuffer &buffer, SkDrawable *drawable)
Definition SkGlyph.cpp:59
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550
float SkScalar
Definition extension.cpp:12
static bool b
struct MyStruct a[10]
static const uint8_t buffer[]
uint32_t uint32_t * format
static float max(float r, float g, float b)
Definition hsl.cpp:49
double y
double x
static uint32_t CheapMix(uint32_t hash)
Definition SkChecksum.h:45
constexpr SkISize kSize
Definition SkVx.h:73
SIT T max(const Vec< 1, T > &x)
Definition SkVx.h:641
SIT T min(const Vec< 1, T > &x)
Definition SkVx.h:640
SIN Vec< N, float > floor(const Vec< N, float > &x)
Definition SkVx.h:703
const Scalar scale
Point offset
const SkVector halfAxisSampleFreq
Definition SkGlyph.h:233
const SkIPoint ignorePositionFieldMask
Definition SkGlyph.h:235
const SkIPoint ignorePositionMask
Definition SkGlyph.h:234
constexpr int32_t y() const
constexpr int32_t x() const
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
Format
Definition SkMask.h:26
@ kARGB32_Format
SkPMColor.
Definition SkMask.h:30
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition SkMask.h:27
@ kCountMaskFormats
Definition SkMask.h:36
uint32_t operator()(SkPackedGlyphID packedID) const
Definition SkGlyph.h:76
SkString shortDump() const
Definition SkGlyph.h:132
constexpr SkPackedGlyphID(uint32_t v)
Definition SkGlyph.h:93
SkFixed getSubXFixed() const
Definition SkGlyph.h:114
constexpr SkPackedGlyphID(SkGlyphID glyphID, SkFixed x, SkFixed y)
Definition SkGlyph.h:84
bool operator<(SkPackedGlyphID that) const
Definition SkGlyph.h:102
bool operator!=(const SkPackedGlyphID &that) const
Definition SkGlyph.h:99
constexpr SkPackedGlyphID(SkGlyphID glyphID, uint32_t x, uint32_t y)
Definition SkGlyph.h:87
constexpr SkPackedGlyphID(SkGlyphID glyphID)
Definition SkGlyph.h:81
bool operator==(const SkPackedGlyphID &that) const
Definition SkGlyph.h:96
SkPackedGlyphID(SkGlyphID glyphID, SkPoint pt, SkIPoint mask)
Definition SkGlyph.h:90
SkString dump() const
Definition SkGlyph.h:126
static const constexpr SkScalar kSubpixelRound
Definition SkGlyph.h:69
uint32_t value() const
Definition SkGlyph.h:110
static const constexpr SkIPoint kXYFieldMask
Definition SkGlyph.h:72
uint32_t hash() const
Definition SkGlyph.h:122
@ kFixedPointBinaryPointPos
Definition SkGlyph.h:65
@ kFixedPointSubPixelPosBits
Definition SkGlyph.h:66
static constexpr uint32_t kImpossibleID
Definition SkGlyph.h:47
constexpr SkPackedGlyphID()
Definition SkGlyph.h:94
SkFixed getSubYFixed() const
Definition SkGlyph.h:118
SkGlyphID glyphID() const
Definition SkGlyph.h:106
constexpr float y() const
constexpr float x() const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646
const uintptr_t id