| Flutter Impeller |

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(
24 GlyphAtlas::Type::kAlphaBitmap)
25 : nullptr),
26 color_context_(typographer_context_
27 ? typographer_context_->CreateGlyphAtlasContext(
28 GlyphAtlas::Type::kColorBitmap)
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 }

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

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

## ◆ 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()) {
73 VALIDATION_LOG
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 }
88 if (type == GlyphAtlas::Type::kAlphaBitmap) {
89 alpha_atlas_ = std::move(atlas);
90 return alpha_atlas_;
91 }
92 if (type == GlyphAtlas::Type::kColorBitmap) {
93 color_atlas_ = std::move(atlas);
94 return color_atlas_;
95 }
96 FML_UNREACHABLE();
97 }

References impeller::GlyphAtlas::kAlphaBitmap, impeller::GlyphAtlas::kColorBitmap, impeller::kNullGlyphAtlas, type, and VALIDATION_LOG.

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

## ◆ 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:

- impeller/typographer/lazy_glyph_atlas.h
- impeller/typographer/lazy_glyph_atlas.cc

impeller::GlyphAtlas::Type::kColorBitmap
@ kColorBitmap
impeller::GlyphAtlas::Type::kAlphaBitmap
@ kAlphaBitmap
impeller::kNullGlyphAtlas
static const std::shared_ptr< GlyphAtlas > kNullGlyphAtlas
Definition: lazy_glyph_atlas.cc:17
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:304
type
GLenum type
Definition: blit_command_gles.cc:127
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
scale
const Scalar scale
Definition: stroke_path_geometry.cc:301