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

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_data_(typographer_context_
24  ? typographer_context_->CreateGlyphAtlasContext(
26  : nullptr),
27  color_data_(typographer_context_
28  ? typographer_context_->CreateGlyphAtlasContext(
30  : nullptr) {}

◆ ~LazyGlyphAtlas()

impeller::LazyGlyphAtlas::~LazyGlyphAtlas ( )
default

Member Function Documentation

◆ AddTextFrame()

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

Definition at line 34 of file lazy_glyph_atlas.cc.

38  {
39  FML_DCHECK(alpha_data_.atlas == nullptr && color_data_.atlas == nullptr);
40  AtlasData& data = GetData(frame->GetAtlasType());
41  data.renderable_frames.emplace_back(
42  frame, transform * Matrix::MakeTranslation(position), properties);
43 }
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95

References impeller::Matrix::MakeTranslation(), 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 
)

Definition at line 50 of file lazy_glyph_atlas.cc.

53  {
54  AtlasData& data = GetData(type);
55  if (data.atlas) {
56  return data.atlas;
57  }
58 
59  if (!typographer_context_) {
60  VALIDATION_LOG << "Unable to render text because a TypographerContext has "
61  "not been set.";
62  return kNullGlyphAtlas;
63  }
64  if (!typographer_context_->IsValid()) {
66  << "Unable to render text because the TypographerContext is invalid.";
67  return kNullGlyphAtlas;
68  }
69 
70  data.atlas = typographer_context_->CreateGlyphAtlas(
71  context, type, data_host_buffer, data.context, data.renderable_frames);
72  if (!data.atlas || !data.atlas->IsValid()) {
73  VALIDATION_LOG << "Could not create valid atlas.";
74  return kNullGlyphAtlas;
75  }
76  return data.atlas;
77 }
static const std::shared_ptr< GlyphAtlas > kNullGlyphAtlas
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::kNullGlyphAtlas, and VALIDATION_LOG.

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

◆ ResetTextFrames()

void impeller::LazyGlyphAtlas::ResetTextFrames ( )

Definition at line 45 of file lazy_glyph_atlas.cc.

45  {
46  alpha_data_.reset();
47  color_data_.reset();
48 }

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