|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
Owns the GL textures the advanced editor uses for overlay and composited presentation. More...
#include "donner/editor/GlTextureCache.h"
Classes | |
| struct | ThumbnailTextureView |
| Upload a Layers-panel preview thumbnail bitmap into a per-row GL/WGPU texture and return its ImGui texture handle. More... | |
| struct | TileView |
| One composite-tile entry as presentation sees it: the GL texture handle (resolved from the upload cache) plus its paint-order geometry. More... | |
Public Member Functions | |
| GlTextureCache (std::shared_ptr<::donner::geode::GeodeDevice > geodeDevice=nullptr) | |
| GlTextureCache (const GlTextureCache &)=delete | |
| GlTextureCache & | operator= (const GlTextureCache &)=delete |
| void | initialize () |
| void | uploadComposited (const RenderResult::CompositedPreview &preview, std::optional< EditorRasterViewport > rasterViewport=std::nullopt) |
| Upload the worker's tile snapshot into per-tile GL textures. Allocates/reuses one texture per tile id; bumps a per-tile upload-generation so identity uploads short-circuit; evicts textures whose tile is absent from the snapshot. | |
| void | uploadCompositedOverview (const RenderResult::CompositedPreview &preview, const EditorRasterViewport &rasterViewport) |
| Upload a full-document overview preview without replacing active viewport-bounded tiles. | |
| void | advancePresentationFrame () |
| Advance one presentation frame, retiring WGPU texture snapshots whose handles have aged past the backend's frames-in-flight window. | |
| void | resetComposited () |
| ThumbnailTextureView | uploadThumbnail (std::uint64_t key, const svg::RendererBitmap &bitmap) |
| ThumbnailTextureView | retainThumbnailTextureSnapshot (std::uint64_t key, std::shared_ptr< const svg::RendererTextureSnapshot > textureSnapshot) |
| void | setDocumentCompositeBytes (std::uint64_t bytes) |
| Report bytes retained by the non-WGPU explicit document compositor. | |
| void | retainThumbnailsOnly (const std::vector< std::uint64_t > &liveKeys) |
Evict every cached thumbnail texture whose key is not in liveKeys, freeing the backing GL/WGPU texture. Called after each Layers-panel render so thumbnails for removed rows do not leak across refreshes. | |
| std::size_t | thumbnailTextureCount () const |
| Number of thumbnail textures currently retained (testing/diagnostics). | |
| const std::vector< TileView > & | tiles () const |
| Paint-order tile view; metadata-only direct-surface entries have a zero texture handle. Empty when no composited preview has been uploaded yet (or the preview was cleared via resetComposited). | |
| const std::vector< TileView > & | overviewTiles () const |
| Last retained unbounded full-document tile set, drawn underneath viewport-bounded tiles as a coherent zoom-out fallback. | |
| bool | activeTilesViewportBounded () const |
| True when the active tile set was rendered from a viewport-bounded raster target. | |
| int | metadataOnlyMissCount () const |
| Number of metadata-only tiles skipped during the most recent composited upload because their cached texture identity was absent or stale. | |
| int | duplicateLiveTextureCount () const |
| Number of duplicate live texture handles found in the most recent composited upload across different tile ids. | |
| const FrameCostBreakdown::CompositedUpload & | lastCompositedUploadCost () const |
| Cost counters for the most recent composited upload. | |
| PresentationResourceStats | presentationResourceStats () const |
| Resource counters for the textures currently retained by this cache. | |
| PresentationCoverageDiagnostics | coverageDiagnostics () const |
| Coverage counters for active bounded tiles and retained overview infill. | |
Owns the GL textures the advanced editor uses for overlay and composited presentation.
The cache is intentionally dumb: callers decide when textures should update; this class only owns the texture names, uploads pixel buffers, and tracks the currently-valid dimensions.
Composited preview rendering is per-tile: instead of three named bg/promoted/fg textures, the cache owns one GL texture per CompositedTile (keyed on the tile id), allocated lazily on first upload and freed when the tile leaves the snapshot. The GL presentation compositor samples tiles() in paint order into one pane-sized texture. WebGPU builds retain the direct-framebuffer presentation path.
| struct donner::editor::GlTextureCache::ThumbnailTextureView |
Upload a Layers-panel preview thumbnail bitmap into a per-row GL/WGPU texture and return its ImGui texture handle.
Reuses the same Donner-bitmap -> texture path as the render pane (UploadBitmap / uploadBitmapToWgpu). One texture is owned per key (the Layers row stable id); it is reuploaded only when the bitmap's dimensions or a cheap content fingerprint change, so calling this every frame with an unchanged thumbnail does not re-upload. Donner renders the thumbnail pixels; this only blits them to a texture – see CLAUDE.md "No
Rendering Vector Graphics With ImGui".
| key | Stable id of the Layers row the thumbnail belongs to. |
| bitmap | Donner-rendered RGBA thumbnail bitmap. |
| Class Members | ||
|---|---|---|
| ImTextureID | texture = 0 | ImGui texture handle. |
| Vector2d | uvBottomRight = Vector2d(1.0, 1.0) | Bottom-right valid payload UV. |
| struct donner::editor::GlTextureCache::TileView |
One composite-tile entry as presentation sees it: the GL texture handle (resolved from the upload cache) plus its paint-order geometry.
| Class Members | ||
|---|---|---|
| Vector2d | bitmapDimsDoc = Vector2d::Zero() | |
| Vector2i | bitmapDimsPx = Vector2i::Zero() | |
| Vector2d | canvasOffsetDoc = Vector2d::Zero() | |
| Transform2d | documentFromCachedDocument = Transform2d() | |
| Vector2d | dragTranslationDoc = Vector2d::Zero() | |
| uint64_t | generation = 0 | |
| string | id | |
| bool | isDragTarget = false | |
| Kind | kind = RenderResult::CompositedTile::Kind::Segment | |
| Entity | layerEntity = entt::null | |
| bool | metadataOnly = false | |
| Vector2i | rasterCanvasSize = Vector2i::Zero() | |
| ImTextureID | texture = 0 | |
| shared_ptr< const RendererTextureSnapshot > | textureSnapshot | |
| Vector2d | uvBottomRight = Vector2d(1.0, 1.0) | |
| void donner::editor::GlTextureCache::retainThumbnailsOnly | ( | const std::vector< std::uint64_t > & | liveKeys | ) |
Evict every cached thumbnail texture whose key is not in liveKeys, freeing the backing GL/WGPU texture. Called after each Layers-panel render so thumbnails for removed rows do not leak across refreshes.
| liveKeys | Stable ids of the rows currently shown by the panel. |