6 #include "flutter/display_list/geometry/dl_path.h"
7 #include "fml/status.h"
20 : runs_(
std::move(runs)),
22 has_color_(has_color),
23 path_creator_(path_creator) {}
49 constexpr uint32_t kDenominator = 200;
50 constexpr int32_t kMaximumTextScale = 48;
56 if (scale > kMaximumTextScale) {
57 return Rational(kMaximumTextScale * kDenominator, kDenominator);
71 return std::clamp(result,
Rational(0, kDenominator),
72 Rational(kMaximumTextScale * kDenominator, kDenominator));
121 std::optional<GlyphProperties> properties) {
122 bound_values_.clear();
125 properties_ = properties;
137 std::optional<GlyphProperties> TextFrame::GetProperties()
const {
141 void TextFrame::AppendFrameBounds(
const FrameBounds& frame_bounds) {
142 bound_values_.push_back(frame_bounds);
145 void TextFrame::ClearFrameBounds() {
146 bound_values_.clear();
151 return path_creator_();
153 return fml::Status(fml::StatusCode::kCancelled,
"no path creator specified.");
158 for (
const auto&
x : runs_) {
159 run_size +=
x.GetGlyphCount();
161 return bound_values_.size() == run_size;
165 return runs_[0].GetFont();
169 if (runs_.size() == 1 && runs_[0].GetGlyphCount() == 1) {
170 return runs_[0].GetGlyphPositions()[0].glyph;
176 FML_DCHECK(index < bound_values_.size());
177 return bound_values_[index];
181 return std::make_pair(generation_, atlas_id_);
184 void TextFrame::SetAtlasGeneration(
size_t value, intptr_t atlas_id) {
186 atlas_id_ = atlas_id;
Describes a typeface along with any modifications to its intrinsic properties.
Type
Describes how the glyphs are represented in the texture.
int32_t GetNumerator() const
uint32_t GetDenominator() const
static Rational RoundScaledFontSize(Scalar scale)
Rect GetBounds() const
The conservative bounding box for this text frame.
bool IsFrameComplete() const
Verifies that all glyphs in this text frame have computed bounds information.
GlyphAtlas::Type GetAtlasType() const
The type of atlas this run should be place in.
std::optional< Glyph > AsSingleGlyph() const
If this text frame contains a single glyph (such as for an Icon), then return it, otherwise std::null...
bool HasColor() const
Returns the paint color this text frame was recorded with.
Rational GetScale() const
const FrameBounds & GetFrameBounds(size_t index) const
Retrieve the frame bounds for the glyph at [index].
const Font & GetFont() const
Return the font of the first glyph run.
std::pair< size_t, intptr_t > GetAtlasGenerationAndID() const
size_t GetRunCount() const
The number of runs in this text frame.
void SetPerFrameData(Rational scale, Point offset, const Matrix &transform, std::optional< GlyphProperties > properties)
Store text frame scale, offset, and properties for hashing in th glyph atlas.
Matrix GetOffsetTransform() const
fml::StatusOr< flutter::DlPath > GetPath() const
static SubpixelPosition ComputeSubpixelPosition(const TextRun::GlyphPosition &glyph_position, AxisAlignment alignment, const Matrix &transform)
const std::vector< TextRun > & GetRuns() const
Returns a reference to all the text runs in this frame.
AxisAlignment
Determines the axis along which there is subpixel positioning.
std::function< fml::StatusOr< flutter::DlPath >()> PathCreator
static constexpr SubpixelPosition ComputeFractionalPosition(Scalar value)
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)