|
TachyonUI 0.1.0
High-performance UI for building tools.
|
The atlas that the colors of color styles are baked into: pages of 2D textures, one row per gradient, with solid and 2..4-color blocks packed into shared rows. More...
#include <gui_core/style/gui_gradient_manager.h>
Public Member Functions | |
| GradientManager (size_t width=256) | |
| An empty atlas whose pages are width texels wide. | |
| void | ReleaseAll (GraphicsContext *graphicsContext) |
| Destroys every GPU image of the atlas (deferred through graphicsContext). | |
| void | AddRef (GradientHandle handle) |
| Raises the refcount of a live handle; pair with one Release. | |
| bool | Release (GradientHandle handle) |
| Lowers the refcount; true when it reached zero and the slot was reclaimed. | |
| AtlasLocation | GetLocation (GradientHandle handle) const |
| The atlas position of a handle; all zero for an invalid or stale handle. | |
| bool | IsValid (GradientHandle handle) const |
| True if the handle is live (slot occupied and generation matches). | |
| uint16_t | GetRefcount (GradientHandle handle) const |
| Refcount of a live handle; 0 for an invalid or stale handle. | |
| size_t | Width () const noexcept |
| Page width in texels, the same for every page. | |
| uint32_t | PageCount () const noexcept |
| Number of pages allocated. | |
| size_t | PageHeight (uint32_t pageIndex) const noexcept |
| Allocated height of a page in rows; the rows in use are at most this. | |
| std::span< const color4b > | PageTextureData (uint32_t pageIndex) const noexcept |
| CPU texels of a page, PageHeight x Width. | |
| std::span< color4b > | PageTextureData (uint32_t pageIndex) noexcept |
| Writable CPU texels of a page; call MarkPageModified after writing. | |
| void | MarkPageModified (uint32_t pageIndex) noexcept |
| Makes the next GetGradientImage re-upload the page. | |
| void | ClearAll () noexcept |
| Releases every slot; every outstanding GradientHandle becomes stale, so holders (StyleManager, the text system's caret) re-register. | |
| tachyon::Image * | GetGradientImage (GraphicsContext *graphicsContext, uint32_t pageIndex=0) |
| The GPU image of a page, created or re-uploaded as needed; nullptr when pageIndex is out of range. | |
Static Public Attributes | |
| static constexpr uint32_t | kMaxPageHeight = 8192 |
| Page height cap; a full page gets a new page instead of growing. | |
| static constexpr int32_t | kUnregisteredPage = -1 |
| GetPagePhysicalImageIndex of a page the renderer hasn't registered. | |
Acquire | |
A slot holding the colors (solid, 2..4-color block or full gradient row). Identical content returns the same handle with its refcount raised; each call pairs with one Release. | |
| GradientHandle | AcquireSolidColor (const color4b &color) |
| GradientHandle | AcquireSolidColor (const color4f &color) |
| GradientHandle | AcquireColors (const color4b &c0, const color4b &c1) |
| GradientHandle | AcquireColors (const color4f &c0, const color4f &c1) |
| GradientHandle | AcquireColors (const color4b &c0, const color4b &c1, const color4b &c2) |
| GradientHandle | AcquireColors (const color4f &c0, const color4f &c1, const color4f &c2) |
| GradientHandle | AcquireColors (const color4b &c0, const color4b &c1, const color4b &c2, const color4b &c3) |
| GradientHandle | AcquireColors (const color4f &c0, const color4f &c1, const color4f &c2, const color4f &c3) |
| GradientHandle | AcquireGradient (const Gradient &g) |
Renderer page table | |
The renderer registers each page in its bindless image set and records the 0-based shader slot here; color style uploads map logical pages through it. HasPageTableChanged is set when the mapping changes, so the color styles must be re-uploaded. | |
| int32_t | GetPagePhysicalImageIndex (uint32_t pageIndex) const noexcept |
| void | SetPagePhysicalImageIndex (uint32_t pageIndex, int32_t shaderSlotZeroBased) noexcept |
| bool | HasPageTableChanged () const noexcept |
| void | ClearPageTableChanged () noexcept |
The atlas that the colors of color styles are baked into: pages of 2D textures, one row per gradient, with solid and 2..4-color blocks packed into shared rows.
Slots are reference counted and deduplicated by content; a slot is reclaimed at refcount 0 and may be reused by a later Acquire.
A page doubles its height up to kMaxPageHeight; then a new page is added. A grown page's old GPU image is destroyed at the end of the frame.
| tachyon::GradientManager::GradientManager | ( | size_t | width = 256 | ) |
An empty atlas whose pages are width texels wide.
| void tachyon::GradientManager::ReleaseAll | ( | GraphicsContext * | graphicsContext | ) |
Destroys every GPU image of the atlas (deferred through graphicsContext).
Safe to call more than once.
| GradientHandle tachyon::GradientManager::AcquireSolidColor | ( | const color4b & | color | ) |
| GradientHandle tachyon::GradientManager::AcquireSolidColor | ( | const color4f & | color | ) |
| GradientHandle tachyon::GradientManager::AcquireColors | ( | const color4b & | c0, |
| const color4b & | c1 ) |
| GradientHandle tachyon::GradientManager::AcquireColors | ( | const color4f & | c0, |
| const color4f & | c1 ) |
| GradientHandle tachyon::GradientManager::AcquireColors | ( | const color4b & | c0, |
| const color4b & | c1, | ||
| const color4b & | c2 ) |
| GradientHandle tachyon::GradientManager::AcquireColors | ( | const color4f & | c0, |
| const color4f & | c1, | ||
| const color4f & | c2 ) |
| GradientHandle tachyon::GradientManager::AcquireColors | ( | const color4b & | c0, |
| const color4b & | c1, | ||
| const color4b & | c2, | ||
| const color4b & | c3 ) |
| GradientHandle tachyon::GradientManager::AcquireColors | ( | const color4f & | c0, |
| const color4f & | c1, | ||
| const color4f & | c2, | ||
| const color4f & | c3 ) |
| GradientHandle tachyon::GradientManager::AcquireGradient | ( | const Gradient & | g | ) |
| void tachyon::GradientManager::AddRef | ( | GradientHandle | handle | ) |
Raises the refcount of a live handle; pair with one Release.
| bool tachyon::GradientManager::Release | ( | GradientHandle | handle | ) |
Lowers the refcount; true when it reached zero and the slot was reclaimed.
| AtlasLocation tachyon::GradientManager::GetLocation | ( | GradientHandle | handle | ) | const |
The atlas position of a handle; all zero for an invalid or stale handle.
| bool tachyon::GradientManager::IsValid | ( | GradientHandle | handle | ) | const |
True if the handle is live (slot occupied and generation matches).
| uint16_t tachyon::GradientManager::GetRefcount | ( | GradientHandle | handle | ) | const |
Refcount of a live handle; 0 for an invalid or stale handle.
|
inlinenoexcept |
Page width in texels, the same for every page.
|
inlinenoexcept |
Number of pages allocated.
|
noexcept |
Allocated height of a page in rows; the rows in use are at most this.
|
noexcept |
CPU texels of a page, PageHeight x Width.
|
noexcept |
Writable CPU texels of a page; call MarkPageModified after writing.
|
noexcept |
Makes the next GetGradientImage re-upload the page.
|
noexcept |
|
noexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Releases every slot; every outstanding GradientHandle becomes stale, so holders (StyleManager, the text system's caret) re-register.
For a theme reload.
| tachyon::Image * tachyon::GradientManager::GetGradientImage | ( | GraphicsContext * | graphicsContext, |
| uint32_t | pageIndex = 0 ) |
The GPU image of a page, created or re-uploaded as needed; nullptr when pageIndex is out of range.
|
staticconstexpr |
Page height cap; a full page gets a new page instead of growing.
Stays well under the usual maxImageDimension2D (16384 on desktop GPUs).
|
staticconstexpr |
GetPagePhysicalImageIndex of a page the renderer hasn't registered.