Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
GlTextureCache.h File Reference
#include <cstdint>
#include <deque>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "glad/glad.h"
#include "donner/base/Box.h"
#include "donner/base/Transform.h"
#include "donner/base/Vector2.h"
#include "donner/editor/AsyncRenderer.h"
#include "donner/editor/FrameCostBreakdown.h"
#include "donner/editor/ImGuiIncludes.h"
Include dependency graph for GlTextureCache.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::CompositedTileTextureIdentity
 Stable identity for deciding whether a metadata-only composited tile can reuse an existing presentation texture. More...
struct  donner::editor::PresentationResourceStats
 Approximate resource footprint retained by the editor presentation texture cache. More...
struct  donner::editor::PresentationCoverageDiagnostics
 Presentation coverage state for composited tile fallback diagnostics. More...
class  donner::editor::GlTextureCache
 Retains editor presentation textures for composited tiles and Layers thumbnails. More...
struct  donner::editor::GlTextureCache::ThumbnailTextureView
 ImGui texture handle and UV range for valid thumbnail content. More...
struct  donner::editor::GlTextureCache::TileView
 One cached tile's ImGui texture handle and paint-order geometry. More...
struct  donner::editor::GlTextureCache::RasterCoverageGroup
 Owner-indexed coverage and paint bounds in one immutable raster coordinate system. More...
class  donner::editor::GlTextureCache::PresentationResources
 Immutable resource manifest published only after complete preparation succeeds. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.
namespace  donner::svg
 Donner SVG library, which can load, manipulate and render SVG files.

Functions

CompositedTileTextureIdentity donner::editor::TextureIdentityForCompositedTile (const RenderResult::CompositedTile &tile)
 Return the presentation texture identity carried by tile.
bool donner::editor::TextureIdentityMatchesCompositedTile (const CompositedTileTextureIdentity &cachedIdentity, const RenderResult::CompositedTile &tile)
 Return true when a metadata-only tile can reuse cachedIdentity.
Vector2i donner::editor::PowerOfTwoTextureDimensionsForPayload (const Vector2i &payloadDimensions)
 Return the power-of-two backing texture dimensions for a payload.
Vector2d donner::editor::TextureUvBottomRightForPayload (const Vector2i &payloadDimensions, const Vector2i &allocationDimensions)
 Return the max UV that samples only the payload inside a backing texture.
std::uint64_t donner::editor::BitmapPayloadBytes (const svg::RendererBitmap &bitmap)
 Return the byte size of a CPU bitmap payload as submitted to the presentation cache.
std::uint64_t donner::editor::TexturePayloadBytes (const Vector2i &dimensions)
 Return the approximate byte size of a backend texture payload, assuming RGBA8 storage.
FrameCostBreakdown::CompositedUpload donner::editor::CostForCompositedPreviewUpload (const RenderResult::CompositedPreview &preview)
 Compute upload-cost counters for a composited preview without touching GL/WGPU state.

Class Documentation

◆ donner::editor::GlTextureCache::ThumbnailTextureView

struct donner::editor::GlTextureCache::ThumbnailTextureView

ImGui texture handle and UV range for valid thumbnail content.

Class Members
ImTextureID texture = 0 ImGui texture handle.
Vector2d uvBottomRight = Vector2d(1.0, 1.0) Bottom-right valid payload UV.

◆ donner::editor::GlTextureCache::TileView

struct donner::editor::GlTextureCache::TileView

One cached tile's ImGui texture handle and paint-order geometry.

Class Members
Vector2d bitmapDimsDoc = Vector2d::Zero() Document-space tile dimensions.
Vector2i bitmapDimsPx = Vector2i::Zero() Valid texture payload dimensions in pixels.
Vector2d canvasOffsetDoc = Vector2d::Zero() Document-space tile origin.
Transform2d documentFromCachedDocument Transform from cached-document to current-document space.
Vector2d dragTranslationDoc Document-space drag offset for presentation.
uint64_t generation = 0 Generation of the tile payload.
shared_ptr< const GLuint > glTextureLifetime Shared GL allocation retained by every frame referencing this tile.
string id Stable composited tile identifier.
bool isDragTarget = false Whether this tile is the active drag target.
Kind kind Composited tile category.
Entity layerEntity = entt::null Layer entity when this is a promoted layer.
bool metadataOnly = false True when the tile carries no new texture payload.
Vector2i rasterCanvasSize = Vector2i::Zero() Raster canvas size that produced this tile.
ImTextureID texture ImGui handle for this tile, or zero when no cached payload can be reused.
shared_ptr< const RendererTextureSnapshot > textureSnapshot Retained GPU snapshot backing a Geode tile.
shared_ptr< const void > uiTextureLifetime Registration owned by all published users.
Vector2d uvBottomRight = Vector2d(1.0, 1.0) Bottom-right UV of valid texture content.

◆ donner::editor::GlTextureCache::RasterCoverageGroup

struct donner::editor::GlTextureCache::RasterCoverageGroup

Owner-indexed coverage and paint bounds in one immutable raster coordinate system.

Class Members
Transform2d documentFromRaster
vector< Box2d > paintBounds
vector< Box2d > tileBounds

Function Documentation

◆ BitmapPayloadBytes()

std::uint64_t donner::editor::BitmapPayloadBytes ( const svg::RendererBitmap & bitmap)
nodiscard

Return the byte size of a CPU bitmap payload as submitted to the presentation cache.

Parameters
bitmapCPU renderer bitmap.

◆ CostForCompositedPreviewUpload()

FrameCostBreakdown::CompositedUpload donner::editor::CostForCompositedPreviewUpload ( const RenderResult::CompositedPreview & preview)
nodiscard

Compute upload-cost counters for a composited preview without touching GL/WGPU state.

Parameters
previewComposited preview to inspect.

◆ PowerOfTwoTextureDimensionsForPayload()

Vector2i donner::editor::PowerOfTwoTextureDimensionsForPayload ( const Vector2i & payloadDimensions)
nodiscard

Return the power-of-two backing texture dimensions for a payload.

Parameters
payloadDimensionsValid content dimensions in pixels.

◆ TextureIdentityForCompositedTile()

CompositedTileTextureIdentity donner::editor::TextureIdentityForCompositedTile ( const RenderResult::CompositedTile & tile)
nodiscard

Return the presentation texture identity carried by tile.

Parameters
tileComposited tile whose payload or metadata should be identified.

◆ TextureIdentityMatchesCompositedTile()

bool donner::editor::TextureIdentityMatchesCompositedTile ( const CompositedTileTextureIdentity & cachedIdentity,
const RenderResult::CompositedTile & tile )
nodiscard

Return true when a metadata-only tile can reuse cachedIdentity.

Parameters
cachedIdentityIdentity recorded for the currently cached texture.
tileIncoming composited tile metadata.

◆ TexturePayloadBytes()

std::uint64_t donner::editor::TexturePayloadBytes ( const Vector2i & dimensions)
nodiscard

Return the approximate byte size of a backend texture payload, assuming RGBA8 storage.

Parameters
dimensionsTexture dimensions in pixels.

◆ TextureUvBottomRightForPayload()

Vector2d donner::editor::TextureUvBottomRightForPayload ( const Vector2i & payloadDimensions,
const Vector2i & allocationDimensions )
nodiscard

Return the max UV that samples only the payload inside a backing texture.

Parameters
payloadDimensionsValid content dimensions in pixels.
allocationDimensionsBacking texture allocation dimensions in pixels.