Flutter Impeller
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)
 
void ResetTextFrames ()
 
std::shared_ptr< GlyphAtlasCreateOrGetGlyphAtlas (Context &context, GlyphAtlas::Type type) const
 

Detailed Description

Definition at line 17 of file lazy_glyph_atlas.h.

Constructor & Destructor Documentation

◆ LazyGlyphAtlas()

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

Definition at line 14 of file lazy_glyph_atlas.cc.

16  : typographer_context_(std::move(typographer_context)),
17  alpha_context_(typographer_context_
18  ? typographer_context_->CreateGlyphAtlasContext()
19  : nullptr),
20  color_context_(typographer_context_
21  ? typographer_context_->CreateGlyphAtlasContext()
22  : nullptr) {}

◆ ~LazyGlyphAtlas()

impeller::LazyGlyphAtlas::~LazyGlyphAtlas ( )
default

Member Function Documentation

◆ AddTextFrame()

void impeller::LazyGlyphAtlas::AddTextFrame ( const TextFrame frame,
Scalar  scale 
)

Definition at line 26 of file lazy_glyph_atlas.cc.

26  {
27  FML_DCHECK(atlas_map_.empty());
28  if (frame.GetAtlasType() == GlyphAtlas::Type::kAlphaBitmap) {
29  frame.CollectUniqueFontGlyphPairs(alpha_glyph_map_, scale);
30  } else {
31  frame.CollectUniqueFontGlyphPairs(color_glyph_map_, scale);
32  }
33 }

References impeller::TextFrame::CollectUniqueFontGlyphPairs(), impeller::TextFrame::GetAtlasType(), and impeller::GlyphAtlas::kAlphaBitmap.

Referenced by impeller::testing::TEST_P().

◆ CreateOrGetGlyphAtlas()

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

Definition at line 41 of file lazy_glyph_atlas.cc.

43  {
44  {
45  auto atlas_it = atlas_map_.find(type);
46  if (atlas_it != atlas_map_.end()) {
47  return atlas_it->second;
48  }
49  }
50 
51  if (!typographer_context_) {
52  VALIDATION_LOG << "Unable to render text because a TypographerContext has "
53  "not been set.";
54  return nullptr;
55  }
56  if (!typographer_context_->IsValid()) {
58  << "Unable to render text because the TypographerContext is invalid.";
59  return nullptr;
60  }
61 
62  auto& glyph_map = type == GlyphAtlas::Type::kAlphaBitmap ? alpha_glyph_map_
63  : color_glyph_map_;
64  auto atlas_context =
65  type == GlyphAtlas::Type::kAlphaBitmap ? alpha_context_ : color_context_;
66  auto atlas = typographer_context_->CreateGlyphAtlas(context, type,
67  atlas_context, glyph_map);
68  if (!atlas || !atlas->IsValid()) {
69  VALIDATION_LOG << "Could not create valid atlas.";
70  return nullptr;
71  }
72  atlas_map_[type] = atlas;
73  return atlas;
74 }

References impeller::GlyphAtlas::kAlphaBitmap, and VALIDATION_LOG.

Referenced by impeller::testing::TEST_P().

◆ ResetTextFrames()

void impeller::LazyGlyphAtlas::ResetTextFrames ( )

Definition at line 35 of file lazy_glyph_atlas.cc.

35  {
36  alpha_glyph_map_.clear();
37  color_glyph_map_.clear();
38  atlas_map_.clear();
39 }

The documentation for this class was generated from the following files:
impeller::GlyphAtlas::Type::kAlphaBitmap
@ kAlphaBitmap
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60