| 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 std::shared_ptr< TextFrame > &frame, Rational scale, Point offset, const Matrix &transform, std::optional< GlyphProperties > properties)
void | ResetTextFrames ()
const std::shared_ptr< GlyphAtlas > & | CreateOrGetGlyphAtlas (Context &context, HostBuffer &host_buffer, GlyphAtlas::Type type) const

## Detailed Description

Definition at line 16 of file lazy_glyph_atlas.h.

## Constructor & Destructor Documentation

## ◆ LazyGlyphAtlas()

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

Definition at line 20 of file lazy_glyph_atlas.cc.

22 : typographer_context_(std::move(typographer_context)),
23 alpha_context_(typographer_context_
24 ? typographer_context_->CreateGlyphAtlasContext(
25 GlyphAtlas::Type::kAlphaBitmap)
26 : nullptr),
27 color_context_(typographer_context_
28 ? typographer_context_->CreateGlyphAtlasContext(
29 GlyphAtlas::Type::kColorBitmap)
30 : nullptr) {}
impeller::GlyphAtlas::Type::kAlphaBitmap
@ kAlphaBitmap
impeller::GlyphAtlas::Type::kColorBitmap
@ kColorBitmap

## ◆ ~LazyGlyphAtlas()

impeller::LazyGlyphAtlas::~LazyGlyphAtlas | ( |  | ) |
| default

## Member Function Documentation

## ◆ AddTextFrame()

void impeller::LazyGlyphAtlas::AddTextFrame | ( | const std::shared_ptr< TextFrame > & | frame,
|  | Rational | scale,
|  | Point | offset,
|  | const Matrix & | transform,
|  | std::optional< GlyphProperties > | properties
| ) |  |

Definition at line 34 of file lazy_glyph_atlas.cc.

38 {
39 frame->SetPerFrameData(scale, offset, transform, properties);
40 FML_DCHECK(alpha_atlas_ == nullptr && color_atlas_ == nullptr);
41 if (frame->GetAtlasType() == GlyphAtlas::Type::kAlphaBitmap) {
42 alpha_text_frames_.push_back(frame);
43 } else {
44 color_text_frames_.push_back(frame);
45 }
46 }
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:214
scale
const Scalar scale
Definition: stroke_path_geometry.cc:319
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:322

References impeller::GlyphAtlas::kAlphaBitmap, offset, scale, and transform.

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 55 of file lazy_glyph_atlas.cc.

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

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 48 of file lazy_glyph_atlas.cc.

48 {
49 alpha_text_frames_.clear();
50 color_text_frames_.clear();
51 alpha_atlas_.reset();
52 color_atlas_.reset();
53 }

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

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