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

◆ sync()

std::shared_ptr< Core::VKImage > MayaFlux::Portal::Text::AtlasImage::sync ( GlyphAtlas &  atlas)

Bring the image up to date with atlas.

Creates the image on first use and again when atlas is a different atlas, has a different size from the one last synced, or the image was released by the texture manager shutting down. Otherwise uploads the atlas pixels only when it is dirty.

Parameters
atlasAtlas to mirror.
Returns
The current image, or null if the texture manager is not initialized or the image could not be created.

Definition at line 9 of file AtlasImage.cpp.

10{
12 if (!loom.is_initialized()) {
13 return nullptr;
14 }
15
16 const std::span<const uint8_t> pixels = atlas.texture().pixel_bytes(0);
17 const uint32_t size = atlas.atlas_size();
18
19 if (!m_image || !m_image->is_initialized() || m_atlas != &atlas || m_size != size) {
20 m_image = loom.create_2d(size, size, Portal::Graphics::ImageFormat::R8, pixels.data(), 1);
21 if (!m_image) {
23 "AtlasImage: could not create a {}x{} atlas image", size, size);
24 m_atlas = nullptr;
25 m_size = 0;
26 return nullptr;
27 }
28 m_atlas = &atlas;
29 m_size = size;
31 atlas.clear_dirty();
32 return m_image;
33 }
34
35 if (atlas.is_dirty()) {
36 loom.upload_data(m_image, pixels.data(), pixels.size());
37 atlas.clear_dirty();
38 }
39
40 return m_image;
41}
#define MF_ERROR(comp, ctx,...)
const std::vector< float > * pixels
Definition Decoder.cpp:48
bool size
std::shared_ptr< Core::VKImage > m_image
void clear_dirty()
Clear the dirty flag after re-uploading the atlas to GPU.
@ API
API calls from external code.
@ Portal
High-level user-facing API layer.
MAYAFLUX_API TextureLoom & get_texture_manager()
Get the global texture manager instance.

References MayaFlux::Journal::API, MayaFlux::Portal::Text::GlyphAtlas::atlas_size(), MayaFlux::Portal::Text::GlyphAtlas::clear_dirty(), MayaFlux::Portal::Graphics::get_texture_manager(), MayaFlux::Portal::Text::GlyphAtlas::is_dirty(), m_atlas, m_generation, m_image, m_size, MF_ERROR, MayaFlux::Kakshya::TextureContainer::pixel_bytes(), pixels, MayaFlux::Journal::Portal, size, and MayaFlux::Portal::Text::GlyphAtlas::texture().

Referenced by MayaFlux::Portal::Forma::internal::TextSlice::refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: