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 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 GlyphProperties &  properties 
)

Definition at line 34 of file lazy_glyph_atlas.cc.

37  {
38  FML_DCHECK(alpha_data_.atlas == nullptr && color_data_.atlas == nullptr);
39  AtlasData& data = GetData(frame->GetAtlasType());
40  data.renderable_frames.emplace_back(
41  frame, transform * Matrix::MakeTranslation(position), properties);
42 }
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 49 of file lazy_glyph_atlas.cc.

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

References context, impeller::kNullGlyphAtlas, and VALIDATION_LOG.

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

◆ ResetTextFrames()

void impeller::LazyGlyphAtlas::ResetTextFrames ( )

Definition at line 44 of file lazy_glyph_atlas.cc.

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

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