Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkGlyphDigest Class Reference

#include <SkGlyph.h>

Public Member Functions

 SkGlyphDigest ()=default
 
 SkGlyphDigest (size_t index, const SkGlyph &glyph)
 
int index () const
 
bool isEmpty () const
 
bool isColor () const
 
SkMask::Format maskFormat () const
 
skglyph::GlyphAction actionFor (skglyph::ActionType actionType) const
 
void setActionFor (skglyph::ActionType, SkGlyph *, sktext::StrikeForGPU *)
 
uint16_t maxDimension () const
 
bool fitsInAtlasDirect () const
 
bool fitsInAtlasInterpolated () const
 
SkGlyphRect bounds () const
 

Static Public Member Functions

static bool FitsInAtlas (const SkGlyph &glyph)
 
static SkPackedGlyphID GetKey (SkGlyphDigest digest)
 
static uint32_t Hash (SkPackedGlyphID packedID)
 

Static Public Attributes

static constexpr uint16_t kSkSideTooBigForAtlas = 256
 

Detailed Description

Definition at line 329 of file SkGlyph.h.

Constructor & Destructor Documentation

◆ SkGlyphDigest() [1/2]

SkGlyphDigest::SkGlyphDigest ( )
default

◆ SkGlyphDigest() [2/2]

SkGlyphDigest::SkGlyphDigest ( size_t  index,
const SkGlyph glyph 
)

Definition at line 623 of file SkGlyph.cpp.

624 : fPackedID{SkTo<uint64_t>(glyph.getPackedID().value())}
625 , fIndex{SkTo<uint64_t>(index)}
626 , fIsEmpty(glyph.isEmpty())
627 , fFormat(glyph.maskFormat())
628 , fActions{init_actions(glyph)}
629 , fLeft{SkTo<int16_t>(glyph.left())}
630 , fTop{SkTo<int16_t>(glyph.top())}
631 , fWidth{SkTo<uint16_t>(glyph.width())}
632 , fHeight{SkTo<uint16_t>(glyph.height())} {}
uint64_t fIndex
Definition: SkGlyph.h:391
uint64_t fIsEmpty
Definition: SkGlyph.h:392
uint64_t fFormat
Definition: SkGlyph.h:393
uint64_t fActions
Definition: SkGlyph.h:394
uint64_t fPackedID
Definition: SkGlyph.h:390
int index() const
Definition: SkGlyph.h:338
int top() const
Definition: SkGlyph.h:511
bool isEmpty() const
Definition: SkGlyph.h:514
SkMask::Format maskFormat() const
Definition: SkGlyph.h:500
int height() const
Definition: SkGlyph.h:513
int width() const
Definition: SkGlyph.h:512
int left() const
Definition: SkGlyph.h:510
SkPackedGlyphID getPackedID() const
Definition: SkGlyph.h:430
uint32_t value() const
Definition: SkGlyph.h:110

Member Function Documentation

◆ actionFor()

skglyph::GlyphAction SkGlyphDigest::actionFor ( skglyph::ActionType  actionType) const
inline

Definition at line 343 of file SkGlyph.h.

343 {
344 return static_cast<skglyph::GlyphAction>((fActions >> actionType) & 0b11);
345 }
GlyphAction
Definition: SkGlyph.h:304

◆ bounds()

SkGlyphRect SkGlyphDigest::bounds ( ) const
inline

Definition at line 362 of file SkGlyph.h.

362 {
363 return SkGlyphRect(fLeft, fTop, (SkScalar)fLeft + fWidth, (SkScalar)fTop + fHeight);
364 }
float SkScalar
Definition: extension.cpp:12

◆ FitsInAtlas()

bool SkGlyphDigest::FitsInAtlas ( const SkGlyph glyph)
static

Definition at line 684 of file SkGlyph.cpp.

684 {
685 return glyph.maxDimension() <= kSkSideTooBigForAtlas;
686}
static constexpr uint16_t kSkSideTooBigForAtlas
Definition: SkGlyph.h:333
int maxDimension() const
Definition: SkGlyph.h:504

◆ fitsInAtlasDirect()

bool SkGlyphDigest::fitsInAtlasDirect ( ) const
inline

Definition at line 353 of file SkGlyph.h.

353 {
354 return this->maxDimension() <= kSkSideTooBigForAtlas;
355 }
uint16_t maxDimension() const
Definition: SkGlyph.h:349

◆ fitsInAtlasInterpolated()

bool SkGlyphDigest::fitsInAtlasInterpolated ( ) const
inline

Definition at line 357 of file SkGlyph.h.

357 {
358 // Include the padding needed for interpolating the glyph when drawing.
359 return this->maxDimension() <= kSkSideTooBigForAtlas - 2;
360 }

◆ GetKey()

static SkPackedGlyphID SkGlyphDigest::GetKey ( SkGlyphDigest  digest)
inlinestatic

Definition at line 369 of file SkGlyph.h.

369 {
370 return SkPackedGlyphID{SkTo<uint32_t>(digest.fPackedID)};
371 }

◆ Hash()

static uint32_t SkGlyphDigest::Hash ( SkPackedGlyphID  packedID)
inlinestatic

Definition at line 372 of file SkGlyph.h.

372 {
373 return packedID.hash();
374 }
uint32_t hash() const
Definition: SkGlyph.h:122

◆ index()

int SkGlyphDigest::index ( ) const
inline

Definition at line 338 of file SkGlyph.h.

338{ return fIndex; }

◆ isColor()

bool SkGlyphDigest::isColor ( ) const
inline

Definition at line 340 of file SkGlyph.h.

340{ return fFormat == SkMask::kARGB32_Format; }
@ kARGB32_Format
SkPMColor.
Definition: SkMask.h:30

◆ isEmpty()

bool SkGlyphDigest::isEmpty ( ) const
inline

Definition at line 339 of file SkGlyph.h.

339{ return fIsEmpty; }

◆ maskFormat()

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

Definition at line 341 of file SkGlyph.h.

341{ return static_cast<SkMask::Format>(fFormat); }
Format
Definition: SkMask.h:26

◆ maxDimension()

uint16_t SkGlyphDigest::maxDimension ( ) const
inline

Definition at line 349 of file SkGlyph.h.

349 {
350 return std::max(fWidth, fHeight);
351 }
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ setActionFor()

void SkGlyphDigest::setActionFor ( skglyph::ActionType  actionType,
SkGlyph glyph,
sktext::StrikeForGPU strike 
)

Definition at line 634 of file SkGlyph.cpp.

636 {
637 // We don't have to do any more if the glyph is marked as kDrop because it was isEmpty().
638 if (this->actionFor(actionType) == GlyphAction::kUnset) {
639 GlyphAction action = GlyphAction::kReject;
640 switch (actionType) {
641 case kDirectMask: {
642 if (this->fitsInAtlasDirect()) {
643 action = GlyphAction::kAccept;
644 }
645 break;
646 }
647 case kDirectMaskCPU: {
648 if (strike->prepareForImage(glyph)) {
649 SkASSERT(!glyph->isEmpty());
650 action = GlyphAction::kAccept;
651 }
652 break;
653 }
654 case kMask: {
655 if (this->fitsInAtlasInterpolated()) {
656 action = GlyphAction::kAccept;
657 }
658 break;
659 }
660 case kSDFT: {
661 if (this->fitsInAtlasDirect() &&
662 this->maskFormat() == SkMask::Format::kSDF_Format) {
663 action = GlyphAction::kAccept;
664 }
665 break;
666 }
667 case kPath: {
668 if (strike->prepareForPath(glyph)) {
669 action = GlyphAction::kAccept;
670 }
671 break;
672 }
673 case kDrawable: {
674 if (strike->prepareForDrawable(glyph)) {
675 action = GlyphAction::kAccept;
676 }
677 break;
678 }
679 }
680 this->setAction(actionType, action);
681 }
682}
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kDrawable
SkMask::Format maskFormat() const
Definition: SkGlyph.h:341
bool fitsInAtlasInterpolated() const
Definition: SkGlyph.h:357
bool fitsInAtlasDirect() const
Definition: SkGlyph.h:353
skglyph::GlyphAction actionFor(skglyph::ActionType actionType) const
Definition: SkGlyph.h:343
virtual bool prepareForPath(SkGlyph *)=0
virtual bool prepareForDrawable(SkGlyph *)=0
virtual bool prepareForImage(SkGlyph *)=0
@ kSDFT
Definition: SkGlyph.h:316
@ kDirectMask
Definition: SkGlyph.h:313
@ kDirectMaskCPU
Definition: SkGlyph.h:314

Member Data Documentation

◆ fActions

uint64_t SkGlyphDigest::fActions

Definition at line 394 of file SkGlyph.h.

◆ fFormat

uint64_t SkGlyphDigest::fFormat

Definition at line 393 of file SkGlyph.h.

◆ fIndex

uint64_t SkGlyphDigest::fIndex

Definition at line 391 of file SkGlyph.h.

◆ fIsEmpty

uint64_t SkGlyphDigest::fIsEmpty

Definition at line 392 of file SkGlyph.h.

◆ fPackedID

uint64_t SkGlyphDigest::fPackedID

Definition at line 390 of file SkGlyph.h.

◆ kSkSideTooBigForAtlas

constexpr uint16_t SkGlyphDigest::kSkSideTooBigForAtlas = 256
staticconstexpr

Definition at line 333 of file SkGlyph.h.


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