MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ ink_quads()

MAYAFLUX_API void MayaFlux::Portal::Text::ink_quads ( const std::shared_ptr< Buffers::TextBuffer > &  target,
std::span< const GlyphQuad quads,
glm::vec4  color 
)

Rasterize a mutated quad span into an existing TextBuffer.

Clears the buffer's pixel region, rasterizes quads via rasterize_quads(), and marks the buffer dirty for GPU upload. The scratch pixel buffer is thread-local and reused across calls, so no heap allocation occurs after the first call at a given buffer size.

Typical usage:

auto layout = Portal::Text::create_layout(text, 0.F, 0.F, wrap_w);
// ... per-quad mutation ...
Portal::Text::ink_quads(text_buf, layout->quads, color);
std::optional< glm::vec3 > color
void ink_quads(const std::shared_ptr< Buffers::TextBuffer > &target, std::span< const GlyphQuad > quads, glm::vec4 color)
Rasterize a mutated quad span into an existing TextBuffer.
Definition InkPress.cpp:203
std::shared_ptr< LayoutResult > create_layout(std::string_view text, float pen_x, float pen_y, uint32_t wrap_w)
Lay out a UTF-8 string into screen-space glyph quads using the default atlas.
Definition Text.cpp:52
Parameters
targetTextBuffer to write into. Dimensions are read from the buffer.
quadsQuads produced by create_layout(), optionally mutated by the caller.
colorRGBA glyph color in [0, 1].

Definition at line 203 of file InkPress.cpp.

207{
208 if (!target) {
209 MF_ERROR(Journal::Component::Portal, Journal::Context::API,
210 "ink_quads: target buffer is null");
211 return;
212 }
213
214 GlyphAtlas* atlas = resolve_atlas(nullptr);
215 if (!atlas) {
216 return;
217 }
218
219 const uint32_t buf_w = target->get_budget_width();
220 const uint32_t buf_h = target->get_budget_height();
221 const size_t buf_bytes = static_cast<size_t>(buf_w) * buf_h * 4;
222
223 thread_local std::vector<uint8_t> pixels;
224 pixels.assign(buf_bytes, 0);
225
226 rasterize_quads(quads, *atlas, color, pixels.data(), buf_w, buf_h);
227 target->set_pixel_data(pixels.data(), buf_bytes);
228}
#define MF_ERROR(comp, ctx,...)
std::vector< uint8_t > pixels
Definition InkPress.cpp:28

References MayaFlux::Journal::API, color, MF_ERROR, pixels, MayaFlux::Journal::Portal, and rasterize_quads().

+ Here is the call graph for this function: