Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
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
 Owns the GL textures the advanced editor uses for overlay and composited presentation. More...
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. More...
struct  donner::editor::GlTextureCache::TileView
 One composite-tile entry as the presenter sees it: the GL texture handle (resolved from the upload cache) plus the geometry fields the presenter needs to blit in paint order. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

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

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".

Parameters
keyStable id of the Layers row the thumbnail belongs to.
bitmapDonner-rendered RGBA thumbnail bitmap.
Returns
ImGui texture handle plus the UV range that contains the valid payload, or an empty view if the texture could not be created.
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 composite-tile entry as the presenter sees it: the GL texture handle (resolved from the upload cache) plus the geometry fields the presenter needs to blit in paint order.

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)

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.