Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Public Attributes | List of all members
skottie::Shaper::ShapedGlyphs Struct Reference

#include <TextShaper.h>

Public Types

enum class  BoundsType { kConservative , kTight }
 

Public Member Functions

SkRect computeBounds (BoundsType) const
 
void draw (SkCanvas *, const SkPoint &origin, const SkPaint &) const
 

Public Attributes

std::vector< RunRecfRuns
 
std::vector< SkGlyphIDfGlyphIDs
 
std::vector< SkPointfGlyphPos
 
std::vector< size_t > fClusters
 

Detailed Description

Definition at line 48 of file TextShaper.h.

Member Enumeration Documentation

◆ BoundsType

Enumerator
kConservative 
kTight 

Definition at line 60 of file TextShaper.h.

60{ kConservative, kTight };

Member Function Documentation

◆ computeBounds()

SkRect skottie::Shaper::ShapedGlyphs::computeBounds ( BoundsType  btype) const

Definition at line 676 of file TextShaper.cpp.

676 {
677 auto bounds = SkRect::MakeEmpty();
678
679 AutoSTArray<16, SkRect> glyphBounds;
680
681 size_t offset = 0;
682 for (const auto& run : fRuns) {
683 SkRect font_bounds;
684 if (btype == BoundsType::kConservative) {
685 font_bounds = SkFontPriv::GetFontBounds(run.fFont);
686
687 // Empty font bounds is likely a font bug -- fall back to tight bounds.
688 if (font_bounds.isEmpty()) {
689 btype = BoundsType::kTight;
690 }
691 }
692
693 switch (btype) {
695 SkRect run_bounds;
696 run_bounds.setBounds(fGlyphPos.data() + offset, SkToInt(run.fSize));
697 run_bounds.fLeft += font_bounds.left();
698 run_bounds.fTop += font_bounds.top();
699 run_bounds.fRight += font_bounds.right();
700 run_bounds.fBottom += font_bounds.bottom();
701
702 bounds.join(run_bounds);
703 } break;
704 case BoundsType::kTight: {
705 glyphBounds.reset(SkToInt(run.fSize));
706 run.fFont.getBounds(fGlyphIDs.data() + offset,
707 SkToInt(run.fSize), glyphBounds.data(), nullptr);
708
709 for (size_t i = 0; i < run.fSize; ++i) {
710 bounds.join(glyphBounds[SkToInt(i)].makeOffset(fGlyphPos[offset + i]));
711 }
712 } break;
713 }
714
715 offset += run.fSize;
716 }
717
718 return bounds;
719}
constexpr int SkToInt(S x)
Definition: SkTo.h:29
static SkRect GetFontBounds(const SkFont &)
Definition: SkFont.cpp:354
void reset(int count)
Definition: SkTemplates.h:195
const T * data() const
Definition: SkTemplates.h:251
Optional< SkRect > bounds
Definition: SkRecords.h:189
Definition: run.py:1
SeparatedVector2 offset
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
constexpr float left() const
Definition: SkRect.h:734
constexpr float top() const
Definition: SkRect.h:741
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
constexpr float right() const
Definition: SkRect.h:748
void setBounds(const SkPoint pts[], int count)
Definition: SkRect.h:881
bool isEmpty() const
Definition: SkRect.h:693
constexpr float bottom() const
Definition: SkRect.h:755
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15
std::vector< SkGlyphID > fGlyphIDs
Definition: TextShaper.h:52
std::vector< SkPoint > fGlyphPos
Definition: TextShaper.h:53
std::vector< RunRec > fRuns
Definition: TextShaper.h:49

◆ draw()

void skottie::Shaper::ShapedGlyphs::draw ( SkCanvas canvas,
const SkPoint origin,
const SkPaint paint 
) const

Definition at line 721 of file TextShaper.cpp.

723 {
724 size_t offset = 0;
725 for (const auto& run : fRuns) {
726 canvas->drawGlyphs(SkToInt(run.fSize),
727 fGlyphIDs.data() + offset,
728 fGlyphPos.data() + offset,
729 origin,
730 run.fFont,
731 paint);
732 offset += run.fSize;
733 }
734}
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[], const uint32_t clusters[], int textByteCount, const char utf8text[], SkPoint origin, const SkFont &font, const SkPaint &paint)
const Paint & paint
Definition: color_source.cc:38

Member Data Documentation

◆ fClusters

std::vector<size_t> skottie::Shaper::ShapedGlyphs::fClusters

Definition at line 58 of file TextShaper.h.

◆ fGlyphIDs

std::vector<SkGlyphID> skottie::Shaper::ShapedGlyphs::fGlyphIDs

Definition at line 52 of file TextShaper.h.

◆ fGlyphPos

std::vector<SkPoint> skottie::Shaper::ShapedGlyphs::fGlyphPos

Definition at line 53 of file TextShaper.h.

◆ fRuns

std::vector<RunRec> skottie::Shaper::ShapedGlyphs::fRuns

Definition at line 49 of file TextShaper.h.


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