Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
impeller::LazyGlyphAtlas Class Reference

#include <lazy_glyph_atlas.h>

Public Member Functions

 LazyGlyphAtlas (std::shared_ptr< TypographerContext > typographer_context)
 
 ~LazyGlyphAtlas ()
 
void AddTextFrame (const TextFrame &frame, Scalar scale, Point offset, const GlyphProperties &properties)
 
void ResetTextFrames ()
 
const std::shared_ptr< GlyphAtlas > & CreateOrGetGlyphAtlas (Context &context, HostBuffer &host_buffer, GlyphAtlas::Type type) const
 

Detailed Description

Definition at line 15 of file lazy_glyph_atlas.h.

Constructor & Destructor Documentation

◆ LazyGlyphAtlas()

impeller::LazyGlyphAtlas::LazyGlyphAtlas ( std::shared_ptr< TypographerContext typographer_context)
explicit

Definition at line 19 of file lazy_glyph_atlas.cc.

21 : typographer_context_(std::move(typographer_context)),
22 alpha_context_(typographer_context_
23 ? typographer_context_->CreateGlyphAtlasContext(
25 : nullptr),
26 color_context_(typographer_context_
27 ? typographer_context_->CreateGlyphAtlasContext(
29 : nullptr) {}

◆ ~LazyGlyphAtlas()

impeller::LazyGlyphAtlas::~LazyGlyphAtlas ( )
default

Member Function Documentation

◆ AddTextFrame()

void impeller::LazyGlyphAtlas::AddTextFrame ( const TextFrame frame,
Scalar  scale,
Point  offset,
const GlyphProperties properties 
)

Definition at line 33 of file lazy_glyph_atlas.cc.

36 {
37 FML_DCHECK(alpha_atlas_ == nullptr && color_atlas_ == nullptr);
38 if (frame.GetAtlasType() == GlyphAtlas::Type::kAlphaBitmap) {
39 frame.CollectUniqueFontGlyphPairs(alpha_glyph_map_, scale, offset,
40 properties);
41 } else {
42 frame.CollectUniqueFontGlyphPairs(color_glyph_map_, scale, offset,
43 properties);
44 }
45}
double frame
Definition: examples.cpp:31
#define FML_DCHECK(condition)
Definition: logging.h:103
const Scalar scale
SeparatedVector2 offset

◆ CreateOrGetGlyphAtlas()

const std::shared_ptr< GlyphAtlas > & impeller::LazyGlyphAtlas::CreateOrGetGlyphAtlas ( Context context,
HostBuffer host_buffer,
GlyphAtlas::Type  type 
) const

Definition at line 54 of file lazy_glyph_atlas.cc.

57 {
58 {
59 if (type == GlyphAtlas::Type::kAlphaBitmap && alpha_atlas_) {
60 return alpha_atlas_;
61 }
62 if (type == GlyphAtlas::Type::kColorBitmap && color_atlas_) {
63 return color_atlas_;
64 }
65 }
66
67 if (!typographer_context_) {
68 VALIDATION_LOG << "Unable to render text because a TypographerContext has "
69 "not been set.";
70 return kNullGlyphAtlas;
71 }
72 if (!typographer_context_->IsValid()) {
74 << "Unable to render text because the TypographerContext is invalid.";
75 return kNullGlyphAtlas;
76 }
77
78 auto& glyph_map = type == GlyphAtlas::Type::kAlphaBitmap ? alpha_glyph_map_
79 : color_glyph_map_;
80 const std::shared_ptr<GlyphAtlasContext>& atlas_context =
81 type == GlyphAtlas::Type::kAlphaBitmap ? alpha_context_ : color_context_;
82 std::shared_ptr<GlyphAtlas> atlas = typographer_context_->CreateGlyphAtlas(
83 context, type, host_buffer, atlas_context, glyph_map);
84 if (!atlas || !atlas->IsValid()) {
85 VALIDATION_LOG << "Could not create valid atlas.";
86 return kNullGlyphAtlas;
87 }
89 alpha_atlas_ = std::move(atlas);
90 return alpha_atlas_;
91 }
93 color_atlas_ = std::move(atlas);
94 return color_atlas_;
95 }
97}
GLenum type
#define FML_UNREACHABLE()
Definition: logging.h:109
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
static const std::shared_ptr< GlyphAtlas > kNullGlyphAtlas
#define VALIDATION_LOG
Definition: validation.h:73

◆ ResetTextFrames()

void impeller::LazyGlyphAtlas::ResetTextFrames ( )

Definition at line 47 of file lazy_glyph_atlas.cc.

47 {
48 alpha_glyph_map_.clear();
49 color_glyph_map_.clear();
50 alpha_atlas_.reset();
51 color_atlas_.reset();
52}

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