Skip to content

Commit

Permalink
runtime: refactor text.buildRenderStyles
Browse files Browse the repository at this point in the history
This PR does sth similar to https://github.com/rive-app/rive/pull/8988. This PR is written in preparation for text follow path, whose runtime version will be very similar to https://github.com/rive-app/rive/pull/8961/files.

There are golden tests covering text rendering in 8988.

Diffs=
63c22338aa runtime: refactor text.buildRenderStyles (#9009)

Co-authored-by: Susan Wang <[email protected]>
  • Loading branch information
susan101566 and susan101566 committed Feb 19, 2025
1 parent 4a63768 commit 061ba6b
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8f9da9d694556c39397c96dbd24dde118220f0ed
63c22338aa4ae1ff4dd872ed7ed9ee096baf6b48
24 changes: 24 additions & 0 deletions include/rive/text/text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#define _RIVE_TEXT_CORE_HPP_
#include "rive/generated/text/text_base.hpp"
#include "rive/math/aabb.hpp"
#include "rive/math/rect.hpp"
#include "rive/text/text_value_run.hpp"
#include "rive/text_engine.hpp"
#include "rive/shapes/shape_paint_path.hpp"
#include "rive/simple_array.hpp"
#include <unordered_map>
#include <vector>
#include "rive/text/glyph_lookup.hpp"
namespace rive
Expand Down Expand Up @@ -178,6 +180,22 @@ class OrderedLine
}
};

struct TextBoundsInfo
{
float minY;
float maxWidth;
float totalHeight;
int ellipsisLine;
bool isEllipsisLineLast;
};

enum class LineIter : uint8_t
{
drawLine,
skipThisLine,
yOutOfBounds
};

class TextStyle;
class Text : public TextBase
{
Expand Down Expand Up @@ -294,6 +312,12 @@ class Text : public TextBase
StyledText m_modifierStyledText;

GlyphLookup m_glyphLookup;

std::unordered_map<uint16_t, std::vector<Rect>> m_textValueRunToRects;
void clearRenderStyles();
TextBoundsInfo computeBoundsInfo();
LineIter shouldDrawLine(float y, float totalHeight, const GlyphLine& line);

#endif
float m_layoutWidth = NAN;
float m_layoutHeight = NAN;
Expand Down
Loading

0 comments on commit 061ba6b

Please sign in to comment.