Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
SkGlyph Class Reference

#include <SkGlyph.h>

Public Member Functions

constexpr SkGlyph ()
 
 SkGlyph (const SkGlyph &)
 
SkGlyphoperator= (const SkGlyph &)
 
 SkGlyph (SkGlyph &&)
 
SkGlyphoperator= (SkGlyph &&)
 
 ~SkGlyph ()
 
constexpr SkGlyph (SkPackedGlyphID id)
 
SkVector advanceVector () const
 
SkScalar advanceX () const
 
SkScalar advanceY () const
 
SkGlyphID getGlyphID () const
 
SkPackedGlyphID getPackedID () const
 
SkFixed getSubXFixed () const
 
SkFixed getSubYFixed () const
 
size_t rowBytes () const
 
size_t rowBytesUsingFormat (SkMask::Format format) const
 
void zeroMetrics ()
 
SkMask mask () const
 
SkMask mask (SkPoint position) const
 
bool setImage (SkArenaAlloc *alloc, SkScalerContext *scalerContext)
 
bool setImage (SkArenaAlloc *alloc, const void *image)
 
size_t setMetricsAndImage (SkArenaAlloc *alloc, const SkGlyph &from)
 
bool setImageHasBeenCalled () const
 
const void * image () const
 
size_t imageSize () const
 
bool setPath (SkArenaAlloc *alloc, SkScalerContext *scalerContext)
 
bool setPath (SkArenaAlloc *alloc, const SkPath *path, bool hairline)
 
bool setPathHasBeenCalled () const
 
const SkPathpath () const
 
bool pathIsHairline () const
 
bool setDrawable (SkArenaAlloc *alloc, SkScalerContext *scalerContext)
 
bool setDrawable (SkArenaAlloc *alloc, sk_sp< SkDrawable > drawable)
 
bool setDrawableHasBeenCalled () const
 
SkDrawabledrawable () const
 
bool isColor () const
 
SkMask::Format maskFormat () const
 
size_t formatAlignment () const
 
int maxDimension () const
 
SkIRect iRect () const
 
SkRect rect () const
 
SkGlyphRect glyphRect () const
 
int left () const
 
int top () const
 
int width () const
 
int height () const
 
bool isEmpty () const
 
bool imageTooLarge () const
 
uint16_t extraBits () const
 
void ensureIntercepts (const SkScalar bounds[2], SkScalar scale, SkScalar xPos, SkScalar *array, int *count, SkArenaAlloc *alloc)
 
void setImage (void *image)
 
void flattenMetrics (SkWriteBuffer &) const
 
void flattenImage (SkWriteBuffer &) const
 
size_t addImageFromBuffer (SkReadBuffer &, SkArenaAlloc *)
 
void flattenPath (SkWriteBuffer &) const
 
size_t addPathFromBuffer (SkReadBuffer &, SkArenaAlloc *)
 
void flattenDrawable (SkWriteBuffer &) const
 
size_t addDrawableFromBuffer (SkReadBuffer &, SkArenaAlloc *)
 

Static Public Member Functions

static std::optional< SkGlyphMakeFromBuffer (SkReadBuffer &)
 

Friends

class SkScalerContext
 
class SkGlyphTestPeer
 

Detailed Description

Definition at line 413 of file SkGlyph.h.

Constructor & Destructor Documentation

◆ SkGlyph() [1/4]

constexpr SkGlyph::SkGlyph ( )
inlineconstexpr

Definition at line 417 of file SkGlyph.h.

◆ SkGlyph() [2/4]

SkGlyph::SkGlyph ( const SkGlyph )
default

◆ SkGlyph() [3/4]

SkGlyph::SkGlyph ( SkGlyph &&  )
default

◆ ~SkGlyph()

SkGlyph::~SkGlyph ( )
default

◆ SkGlyph() [4/4]

constexpr SkGlyph::SkGlyph ( SkPackedGlyphID  id)
inlineexplicitconstexpr

Definition at line 423 of file SkGlyph.h.

423: fID{id} { }

Member Function Documentation

◆ addDrawableFromBuffer()

size_t SkGlyph::addDrawableFromBuffer ( SkReadBuffer buffer,
SkArenaAlloc alloc 
)

Definition at line 425 of file SkGlyph.cpp.

425 {
426 SkASSERT(buffer.isValid());
427
429 if (!buffer.isValid()) {
430 return 0;
431 }
432
433 if (this->setDrawable(alloc, std::move(drawable))) {
434 return this->drawable()->approximateBytesUsed();
435 }
436
437 return 0;
438}
#define SkASSERT(cond)
Definition SkAssert.h:116
size_t approximateBytesUsed()
bool setDrawable(SkArenaAlloc *alloc, SkScalerContext *scalerContext)
Definition SkGlyph.cpp:310
SkDrawable * drawable() const
Definition SkGlyph.cpp:327
static sk_sp< SkPictureBackedGlyphDrawable > MakeFromBuffer(SkReadBuffer &buffer)
Definition SkGlyph.cpp:37
static const uint8_t buffer[]

◆ addImageFromBuffer()

size_t SkGlyph::addImageFromBuffer ( SkReadBuffer buffer,
SkArenaAlloc alloc 
)

Definition at line 358 of file SkGlyph.cpp.

358 {
359 SkASSERT(buffer.isValid());
360
361 // If the glyph is empty or too big, then no image data is received.
362 if (this->isEmpty() || !SkGlyphDigest::FitsInAtlas(*this)) {
363 return 0;
364 }
365
366 size_t memoryIncrease = 0;
367
368 void* imageData = alloc->makeBytesAlignedTo(this->imageSize(), this->formatAlignment());
369 buffer.readByteArray(imageData, this->imageSize());
370 if (buffer.isValid()) {
371 this->installImage(imageData);
372 memoryIncrease += this->imageSize();
373 }
374
375 return memoryIncrease;
376}
void * makeBytesAlignedTo(size_t size, size_t align)
static bool FitsInAtlas(const SkGlyph &glyph)
Definition SkGlyph.cpp:684
bool isEmpty() const
Definition SkGlyph.h:514
size_t formatAlignment() const
Definition SkGlyph.cpp:173
size_t imageSize() const
Definition SkGlyph.cpp:241
bool readByteArray(void *value, size_t size)
bool isValid() const

◆ addPathFromBuffer()

size_t SkGlyph::addPathFromBuffer ( SkReadBuffer buffer,
SkArenaAlloc alloc 
)

Definition at line 389 of file SkGlyph.cpp.

389 {
390 SkASSERT(buffer.isValid());
391
392 size_t memoryIncrease = 0;
393 const bool hasPath = buffer.readBool();
394 // Check if the buffer is invalid, so as to not make a logical decision on invalid data.
395 if (!buffer.isValid()) {
396 return 0;
397 }
398 if (hasPath) {
399 const bool pathIsHairline = buffer.readBool();
400 SkPath path;
401 buffer.readPath(&path);
402 if (buffer.isValid()) {
403 if (this->setPath(alloc, &path, pathIsHairline)) {
404 memoryIncrease += path.approximateBytesUsed();
405 }
406 }
407 } else {
408 this->setPath(alloc, nullptr, false);
409 }
410
411 return memoryIncrease;
412}
const SkPath * path() const
Definition SkGlyph.cpp:284
bool setPath(SkArenaAlloc *alloc, SkScalerContext *scalerContext)
Definition SkGlyph.cpp:266
bool pathIsHairline() const
Definition SkGlyph.cpp:293
size_t approximateBytesUsed() const
Definition SkPath.cpp:562

◆ advanceVector()

SkVector SkGlyph::advanceVector ( ) const
inline

Definition at line 425 of file SkGlyph.h.

425{ return SkVector{fAdvanceX, fAdvanceY}; }

◆ advanceX()

SkScalar SkGlyph::advanceX ( ) const
inline

Definition at line 426 of file SkGlyph.h.

426{ return fAdvanceX; }

◆ advanceY()

SkScalar SkGlyph::advanceY ( ) const
inline

Definition at line 427 of file SkGlyph.h.

427{ return fAdvanceY; }

◆ drawable()

SkDrawable * SkGlyph::drawable ( ) const

Definition at line 327 of file SkGlyph.cpp.

327 {
328 // setDrawable must have been called previously.
330 if (fDrawableData->fHasDrawable) {
331 return fDrawableData->fDrawable.get();
332 }
333 return nullptr;
334}
bool setDrawableHasBeenCalled() const
Definition SkGlyph.h:495

◆ ensureIntercepts()

void SkGlyph::ensureIntercepts ( const SkScalar  bounds[2],
SkScalar  scale,
SkScalar  xPos,
SkScalar array,
int count,
SkArenaAlloc alloc 
)

Definition at line 547 of file SkGlyph.cpp.

548 {
549
550 auto offsetResults = [scale, xPos](
551 const SkGlyph::Intercept* intercept,SkScalar* array, int* count) {
552 if (array) {
553 array += *count;
554 for (int index = 0; index < 2; index++) {
555 *array++ = intercept->fInterval[index] * scale + xPos;
556 }
557 }
558 *count += 2;
559 };
560
561 const SkGlyph::Intercept* match =
562 [this](const SkScalar bounds[2]) -> const SkGlyph::Intercept* {
563 if (fPathData == nullptr) {
564 return nullptr;
565 }
566 const SkGlyph::Intercept* intercept = fPathData->fIntercept;
567 while (intercept != nullptr) {
568 if (bounds[0] == intercept->fBounds[0] && bounds[1] == intercept->fBounds[1]) {
569 return intercept;
570 }
571 intercept = intercept->fNext;
572 }
573 return nullptr;
574 }(bounds);
575
576 if (match != nullptr) {
577 if (match->fInterval[0] < match->fInterval[1]) {
578 offsetResults(match, array, count);
579 }
580 return;
581 }
582
583 SkGlyph::Intercept* intercept = alloc->make<SkGlyph::Intercept>();
584 intercept->fNext = fPathData->fIntercept;
585 intercept->fBounds[0] = bounds[0];
586 intercept->fBounds[1] = bounds[1];
587 intercept->fInterval[0] = SK_ScalarMax;
588 intercept->fInterval[1] = SK_ScalarMin;
589 fPathData->fIntercept = intercept;
590 const SkPath* path = &(fPathData->fPath);
591 const SkRect& pathBounds = path->getBounds();
592 if (pathBounds.fBottom < bounds[0] || bounds[1] < pathBounds.fTop) {
593 return;
594 }
595
596 std::tie(intercept->fInterval[0], intercept->fInterval[1])
597 = calculate_path_gap(bounds[0], bounds[1], *path);
598
599 if (intercept->fInterval[0] >= intercept->fInterval[1]) {
600 intercept->fInterval[0] = SK_ScalarMax;
601 intercept->fInterval[1] = SK_ScalarMin;
602 return;
603 }
604 offsetResults(intercept, array, count);
605}
static bool match(const char *needle, const char *haystack)
Definition DM.cpp:1132
int count
static std::tuple< SkScalar, SkScalar > calculate_path_gap(SkScalar topOffset, SkScalar bottomOffset, const SkPath &path)
Definition SkGlyph.cpp:440
#define SK_ScalarMin
Definition SkScalar.h:25
#define SK_ScalarMax
Definition SkScalar.h:24
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
const SkRect & getBounds() const
Definition SkPath.cpp:420
float SkScalar
Definition extension.cpp:12
Optional< SkRect > bounds
Definition SkRecords.h:189
const Scalar scale
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ extraBits()

uint16_t SkGlyph::extraBits ( ) const
inline

Definition at line 519 of file SkGlyph.h.

519{ return fScalerContextBits; }

◆ flattenDrawable()

void SkGlyph::flattenDrawable ( SkWriteBuffer buffer) const

Definition at line 414 of file SkGlyph.cpp.

414 {
416
417 if (this->isEmpty() || this->drawable() == nullptr) {
419 return;
420 }
421
423}
static void FlattenDrawable(SkWriteBuffer &buffer, SkDrawable *drawable)
Definition SkGlyph.cpp:59

◆ flattenImage()

void SkGlyph::flattenImage ( SkWriteBuffer buffer) const

Definition at line 349 of file SkGlyph.cpp.

349 {
351
352 // If the glyph is empty or too big, then no image data is sent.
353 if (!this->isEmpty() && SkGlyphDigest::FitsInAtlas(*this)) {
354 buffer.writeByteArray(this->image(), this->imageSize());
355 }
356}
bool setImageHasBeenCalled() const
Definition SkGlyph.h:459
const void * image() const
Definition SkGlyph.h:465
virtual void writeByteArray(const void *data, size_t size)=0

◆ flattenMetrics()

void SkGlyph::flattenMetrics ( SkWriteBuffer buffer) const

Definition at line 336 of file SkGlyph.cpp.

336 {
337 buffer.writeUInt(fID.value());
338 buffer.writePoint({fAdvanceX, fAdvanceY});
339 buffer.writeUInt(fWidth << 16 | fHeight);
340 // Note: << has undefined behavior for negative values, so convert everything to the bit
341 // values of uint16_t. Using the cast keeps the signed values fLeft and fTop from sign
342 // extending.
343 const uint32_t left = static_cast<uint16_t>(fLeft);
344 const uint32_t top = static_cast<uint16_t>(fTop);
345 buffer.writeUInt(left << 16 | top);
346 buffer.writeUInt(SkTo<uint32_t>(fMaskFormat));
347}
int top() const
Definition SkGlyph.h:511
int left() const
Definition SkGlyph.h:510

◆ flattenPath()

void SkGlyph::flattenPath ( SkWriteBuffer buffer) const

Definition at line 378 of file SkGlyph.cpp.

378 {
380
381 const bool hasPath = this->path() != nullptr;
382 buffer.writeBool(hasPath);
383 if (hasPath) {
384 buffer.writeBool(this->pathIsHairline());
385 buffer.writePath(*this->path());
386 }
387}
bool setPathHasBeenCalled() const
Definition SkGlyph.h:486
virtual void writeBool(bool value)=0
virtual void writePath(const SkPath &path)=0

◆ formatAlignment()

size_t SkGlyph::formatAlignment ( ) const

Definition at line 173 of file SkGlyph.cpp.

173 {
174 return format_alignment(this->maskFormat());
175}
static size_t format_alignment(SkMask::Format format)
Definition SkGlyph.cpp:150
SkMask::Format maskFormat() const
Definition SkGlyph.h:500

◆ getGlyphID()

SkGlyphID SkGlyph::getGlyphID ( ) const
inline

Definition at line 429 of file SkGlyph.h.

429{ return fID.glyphID(); }

◆ getPackedID()

SkPackedGlyphID SkGlyph::getPackedID ( ) const
inline

Definition at line 430 of file SkGlyph.h.

430{ return fID; }

◆ getSubXFixed()

SkFixed SkGlyph::getSubXFixed ( ) const
inline

Definition at line 431 of file SkGlyph.h.

431{ return fID.getSubXFixed(); }

◆ getSubYFixed()

SkFixed SkGlyph::getSubYFixed ( ) const
inline

Definition at line 432 of file SkGlyph.h.

432{ return fID.getSubYFixed(); }

◆ glyphRect()

SkGlyphRect SkGlyph::glyphRect ( ) const
inline

Definition at line 507 of file SkGlyph.h.

507 {
508 return SkGlyphRect(fLeft, fTop, fLeft + fWidth, fTop + fHeight);
509 }

◆ height()

int SkGlyph::height ( ) const
inline

Definition at line 513 of file SkGlyph.h.

513{ return fHeight; }

◆ image()

const void * SkGlyph::image ( ) const
inline

Definition at line 465 of file SkGlyph.h.

465{ SkASSERT(this->setImageHasBeenCalled()); return fImage; }

◆ imageSize()

size_t SkGlyph::imageSize ( ) const

Definition at line 241 of file SkGlyph.cpp.

241 {
242 if (this->isEmpty() || this->imageTooLarge()) { return 0; }
243
244 size_t size = this->rowBytes() * fHeight;
245
246 if (fMaskFormat == SkMask::k3D_Format) {
247 size *= 3;
248 }
249
250 return size;
251}
size_t rowBytes() const
Definition SkGlyph.cpp:233
bool imageTooLarge() const
Definition SkGlyph.h:517
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 Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
@ k3D_Format
3 8bit per pixl planes: alpha, mul, add
Definition SkMask.h:29

◆ imageTooLarge()

bool SkGlyph::imageTooLarge ( ) const
inline

Definition at line 517 of file SkGlyph.h.

517{ return fWidth >= kMaxGlyphWidth; }

◆ iRect()

SkIRect SkGlyph::iRect ( ) const
inline

Definition at line 505 of file SkGlyph.h.

505{ return SkIRect::MakeXYWH(fLeft, fTop, fWidth, fHeight); }
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104

◆ isColor()

bool SkGlyph::isColor ( ) const
inline

Definition at line 499 of file SkGlyph.h.

499{ return fMaskFormat == SkMask::kARGB32_Format; }
@ kARGB32_Format
SkPMColor.
Definition SkMask.h:30

◆ isEmpty()

bool SkGlyph::isEmpty ( ) const
inline

Definition at line 514 of file SkGlyph.h.

514 {
515 return fWidth == 0 || fHeight == 0;
516 }

◆ left()

int SkGlyph::left ( ) const
inline

Definition at line 510 of file SkGlyph.h.

510{ return fLeft; }

◆ MakeFromBuffer()

std::optional< SkGlyph > SkGlyph::MakeFromBuffer ( SkReadBuffer buffer)
static

Definition at line 95 of file SkGlyph.cpp.

95 {
96 SkASSERT(buffer.isValid());
97 const SkPackedGlyphID packedID{buffer.readUInt()};
98 const SkVector advance = buffer.readPoint();
99 const uint32_t dimensions = buffer.readUInt();
100 const uint32_t leftTop = buffer.readUInt();
101 const SkMask::Format format = SkTo<SkMask::Format>(buffer.readUInt());
102
103 if (!buffer.validate(SkMask::IsValidFormat(format))) {
104 return std::nullopt;
105 }
106
107 SkGlyph glyph{packedID};
108 glyph.fAdvanceX = advance.x();
109 glyph.fAdvanceY = advance.y();
110 glyph.fWidth = dimensions >> 16;
111 glyph.fHeight = dimensions & 0xffffu;
112 glyph.fLeft = leftTop >> 16;
113 glyph.fTop = leftTop & 0xffffu;
114 glyph.fMaskFormat = format;
115 SkDEBUGCODE(glyph.fAdvancesBoundsFormatAndInitialPathDone = true;)
116 return glyph;
117}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
uint32_t uint32_t * format
Format
Definition SkMask.h:26
static bool IsValidFormat(uint8_t format)
Definition SkMask.h:46
constexpr float y() const
constexpr float x() const

◆ mask() [1/2]

SkMask SkGlyph::mask ( ) const

Definition at line 125 of file SkGlyph.cpp.

125 {
126 SkIRect bounds = SkIRect::MakeXYWH(fLeft, fTop, fWidth, fHeight);
127 return SkMask(static_cast<const uint8_t*>(fImage), bounds, this->rowBytes(), fMaskFormat);
128}

◆ mask() [2/2]

SkMask SkGlyph::mask ( SkPoint  position) const

Definition at line 130 of file SkGlyph.cpp.

130 {
131 SkASSERT(SkScalarIsInt(position.x()) && SkScalarIsInt(position.y()));
132 SkIRect bounds = SkIRect::MakeXYWH(fLeft, fTop, fWidth, fHeight);
133 bounds.offset(SkScalarFloorToInt(position.x()), SkScalarFloorToInt(position.y()));
134 return SkMask(static_cast<const uint8_t*>(fImage), bounds, this->rowBytes(), fMaskFormat);
135}
static bool SkScalarIsInt(SkScalar x)
Definition SkScalar.h:80
#define SkScalarFloorToInt(x)
Definition SkScalar.h:35

◆ maskFormat()

SkMask::Format SkGlyph::maskFormat ( ) const
inline

Definition at line 500 of file SkGlyph.h.

500{ return fMaskFormat; }

◆ maxDimension()

int SkGlyph::maxDimension ( ) const
inline

Definition at line 504 of file SkGlyph.h.

504{ return std::max(fWidth, fHeight); }

◆ operator=() [1/2]

SkGlyph & SkGlyph::operator= ( const SkGlyph )
default

◆ operator=() [2/2]

SkGlyph & SkGlyph::operator= ( SkGlyph &&  )
default

◆ path()

const SkPath * SkGlyph::path ( ) const

Definition at line 284 of file SkGlyph.cpp.

284 {
285 // setPath must have been called previously.
287 if (fPathData->fHasPath) {
288 return &fPathData->fPath;
289 }
290 return nullptr;
291}

◆ pathIsHairline()

bool SkGlyph::pathIsHairline ( ) const

Definition at line 293 of file SkGlyph.cpp.

293 {
294 // setPath must have been called previously.
296 return fPathData->fHairline;
297}

◆ rect()

SkRect SkGlyph::rect ( ) const
inline

Definition at line 506 of file SkGlyph.h.

506{ return SkRect::MakeXYWH(fLeft, fTop, fWidth, fHeight); }
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

◆ rowBytes()

size_t SkGlyph::rowBytes ( ) const

Definition at line 233 of file SkGlyph.cpp.

233 {
234 return format_rowbytes(fWidth, fMaskFormat);
235}
static size_t format_rowbytes(int width, SkMask::Format format)
Definition SkGlyph.cpp:168

◆ rowBytesUsingFormat()

size_t SkGlyph::rowBytesUsingFormat ( SkMask::Format  format) const

Definition at line 237 of file SkGlyph.cpp.

237 {
238 return format_rowbytes(fWidth, format);
239}

◆ setDrawable() [1/2]

bool SkGlyph::setDrawable ( SkArenaAlloc alloc,
sk_sp< SkDrawable drawable 
)

Definition at line 319 of file SkGlyph.cpp.

319 {
320 if (!this->setDrawableHasBeenCalled()) {
321 this->installDrawable(alloc, std::move(drawable));
322 return this->drawable() != nullptr;
323 }
324 return false;
325}

◆ setDrawable() [2/2]

bool SkGlyph::setDrawable ( SkArenaAlloc alloc,
SkScalerContext scalerContext 
)

Definition at line 310 of file SkGlyph.cpp.

310 {
311 if (!this->setDrawableHasBeenCalled()) {
312 sk_sp<SkDrawable> drawable = scalerContext->getDrawable(*this);
313 this->installDrawable(alloc, std::move(drawable));
314 return this->drawable() != nullptr;
315 }
316 return false;
317}
sk_sp< SkDrawable > getDrawable(SkGlyph &)

◆ setDrawableHasBeenCalled()

bool SkGlyph::setDrawableHasBeenCalled ( ) const
inline

Definition at line 495 of file SkGlyph.h.

495{ return fDrawableData != nullptr; }

◆ setImage() [1/3]

bool SkGlyph::setImage ( SkArenaAlloc alloc,
const void *  image 
)

Definition at line 198 of file SkGlyph.cpp.

198 {
199 if (!this->setImageHasBeenCalled()) {
200 this->allocImage(alloc);
201 memcpy(fImage, image, this->imageSize());
202 return true;
203 }
204 return false;
205}

◆ setImage() [2/3]

bool SkGlyph::setImage ( SkArenaAlloc alloc,
SkScalerContext scalerContext 
)

Definition at line 185 of file SkGlyph.cpp.

185 {
186 if (!this->setImageHasBeenCalled()) {
187 // It used to be that getImage() could change the fMaskFormat. Extra checking to make
188 // sure there are no regressions.
189 SkDEBUGCODE(SkMask::Format oldFormat = this->maskFormat());
190 this->allocImage(alloc);
191 scalerContext->getImage(*this);
192 SkASSERT(oldFormat == this->maskFormat());
193 return true;
194 }
195 return false;
196}
void getImage(const SkGlyph &)

◆ setImage() [3/3]

void SkGlyph::setImage ( void *  image)
inline

Definition at line 531 of file SkGlyph.h.

531{ fImage = image; }

◆ setImageHasBeenCalled()

bool SkGlyph::setImageHasBeenCalled ( ) const
inline

Definition at line 459 of file SkGlyph.h.

459 {
460 // Check for empty bounds first to guard against fImage somehow being set.
461 return this->isEmpty() || fImage != nullptr || this->imageTooLarge();
462 }

◆ setMetricsAndImage()

size_t SkGlyph::setMetricsAndImage ( SkArenaAlloc alloc,
const SkGlyph from 
)

Definition at line 207 of file SkGlyph.cpp.

207 {
208 // Since the code no longer tries to find replacement glyphs, the image should always be
209 // nullptr.
210 SkASSERT(fImage == nullptr || from.fImage == nullptr);
211
212 // TODO(herb): remove "if" when we are sure there are no colliding glyphs.
213 if (fImage == nullptr) {
214 fAdvanceX = from.fAdvanceX;
215 fAdvanceY = from.fAdvanceY;
216 fWidth = from.fWidth;
217 fHeight = from.fHeight;
218 fTop = from.fTop;
219 fLeft = from.fLeft;
220 fScalerContextBits = from.fScalerContextBits;
221 fMaskFormat = from.fMaskFormat;
222
223 // From glyph may not have an image because the glyph is too large.
224 if (from.fImage != nullptr && this->setImage(alloc, from.image())) {
225 return this->imageSize();
226 }
227
228 SkDEBUGCODE(fAdvancesBoundsFormatAndInitialPathDone = from.fAdvancesBoundsFormatAndInitialPathDone;)
229 }
230 return 0;
231}

◆ setPath() [1/2]

bool SkGlyph::setPath ( SkArenaAlloc alloc,
const SkPath path,
bool  hairline 
)

Definition at line 276 of file SkGlyph.cpp.

276 {
277 if (!this->setPathHasBeenCalled()) {
278 this->installPath(alloc, path, hairline);
279 return this->path() != nullptr;
280 }
281 return false;
282}

◆ setPath() [2/2]

bool SkGlyph::setPath ( SkArenaAlloc alloc,
SkScalerContext scalerContext 
)

Definition at line 266 of file SkGlyph.cpp.

266 {
267 if (!this->setPathHasBeenCalled()) {
268 scalerContext->getPath(*this, alloc);
270 return this->path() != nullptr;
271 }
272
273 return false;
274}
void getPath(SkGlyph &, SkArenaAlloc *)

◆ setPathHasBeenCalled()

bool SkGlyph::setPathHasBeenCalled ( ) const
inline

Definition at line 486 of file SkGlyph.h.

486{ return fPathData != nullptr; }

◆ top()

int SkGlyph::top ( ) const
inline

Definition at line 511 of file SkGlyph.h.

511{ return fTop; }

◆ width()

int SkGlyph::width ( ) const
inline

Definition at line 512 of file SkGlyph.h.

512{ return fWidth; }

◆ zeroMetrics()

void SkGlyph::zeroMetrics ( )

Definition at line 137 of file SkGlyph.cpp.

137 {
138 fAdvanceX = 0;
139 fAdvanceY = 0;
140 fWidth = 0;
141 fHeight = 0;
142 fTop = 0;
143 fLeft = 0;
144}

Friends And Related Symbol Documentation

◆ SkGlyphTestPeer

friend class SkGlyphTestPeer
friend

Definition at line 561 of file SkGlyph.h.

◆ SkScalerContext

friend class SkScalerContext
friend

Definition at line 560 of file SkGlyph.h.


The documentation for this class was generated from the following files: