MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
AtlasImage.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "GlyphAtlas.hpp"
4
5namespace MayaFlux::Core {
6class VKImage;
7}
8
10
11/**
12 * @class AtlasImage
13 * @brief The GPU image of a GlyphAtlas, for anything that samples glyph coverage.
14 *
15 * Holds an R8 image of the atlas and keeps it current: sync() uploads the
16 * atlas when glyphs were rasterized since the last call, and recreates the
17 * image when the atlas was replaced or grew. Growth rewrites every glyph's
18 * UVs, so generation() increments whenever the image object changes; vertices
19 * built against an earlier generation are stale and must be re-emitted, and
20 * the image must be bound again where it was bound.
21 *
22 * The atlas dirty flag is consumed here: one AtlasImage per atlas.
23 */
24class MAYAFLUX_API AtlasImage {
25public:
26 /**
27 * @brief Bring the image up to date with @p atlas.
28 *
29 * Creates the image on first use and again when @p atlas is a different
30 * atlas, has a different size from the one last synced, or the image was
31 * released by the texture manager shutting down. Otherwise
32 * uploads the atlas pixels only when it is dirty.
33 *
34 * @param atlas Atlas to mirror.
35 * @return The current image, or null if the texture manager is not
36 * initialized or the image could not be created.
37 */
38 [[nodiscard]] std::shared_ptr<Core::VKImage> sync(GlyphAtlas& atlas);
39
40 /// @brief Increments every time sync() replaces the image object.
41 [[nodiscard]] uint64_t generation() const noexcept { return m_generation; }
42
43 /// @brief The image from the last sync(), null before the first.
44 [[nodiscard]] const std::shared_ptr<Core::VKImage>& image() const noexcept { return m_image; }
45
46private:
47 std::shared_ptr<Core::VKImage> m_image;
48 const GlyphAtlas* m_atlas { nullptr };
49 uint32_t m_size { 0 };
50 uint64_t m_generation { 0 };
51};
52
53} // namespace MayaFlux::Portal::Text
uint64_t generation() const noexcept
Increments every time sync() replaces the image object.
std::shared_ptr< Core::VKImage > m_image
const std::shared_ptr< Core::VKImage > & image() const noexcept
The image from the last sync(), null before the first.
The GPU image of a GlyphAtlas, for anything that samples glyph coverage.
Rasterizes and packs glyphs from a FontFace into a TextureContainer.