Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::GlTextureCache Class Reference

Owns the GL textures the advanced editor uses for overlay and composited presentation. More...

#include "donner/editor/GlTextureCache.h"

Classes

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

Public Member Functions

 GlTextureCache (std::shared_ptr<::donner::geode::GeodeDevice > geodeDevice=nullptr)
 GlTextureCache (const GlTextureCache &)=delete
GlTextureCache & operator= (const GlTextureCache &)=delete
void initialize ()
void uploadOverlay (const svg::RendererBitmap &bitmap)
void uploadOverlayTexture (std::shared_ptr< const svg::RendererTextureSnapshot > textureSnapshot)
 Register an overlay texture snapshot without CPU readback/upload.
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 clearOverlay ()
void resetComposited ()
ImTextureID overlayTexture () const
int overlayWidth () const
int overlayHeight () const
const Vector2doverlayUvBottomRight () const
 Bottom-right UV for sampling the valid overlay payload from its backing texture.
const std::optional< Box2d > & overlayScreenRect () const
 Screen rect for viewport-space overlay textures.
void setOverlayScreenRect (std::optional< Box2d > screenRect)
 Record the screen-space placement for the currently uploaded overlay.
const std::vector< TileView > & tiles () const
 Paint-order tile view; 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::CompositedUploadlastCompositedUploadCost () const
 Cost counters for the most recent composited upload.
const FrameCostBreakdown::OverlaylastOverlayUploadCost () const
 Cost counters for the most recent overlay upload or clear.
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.

Detailed Description

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 follows design doc 0033 §M2C: 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 editor's RenderPanePresenter iterates tiles() in paint order and blits each tile at its (canvasOffsetDoc + dragTranslationDoc) * pixelsPerDocUnit origin.


Class Documentation

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

Collaboration diagram for donner::editor::GlTextureCache::TileView:
[legend]
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
Vector2d uvBottomRight = Vector2d(1.0, 1.0)

Member Function Documentation

◆ overlayScreenRect()

const std::optional< Box2d > & donner::editor::GlTextureCache::overlayScreenRect ( ) const
inlinenodiscard

Screen rect for viewport-space overlay textures.

Nullopt means the overlay texture uses the legacy document-viewBox placement path.

◆ setOverlayScreenRect()

void donner::editor::GlTextureCache::setOverlayScreenRect ( std::optional< Box2d > screenRect)

Record the screen-space placement for the currently uploaded overlay.

Parameters
screenRectImGui screen rect covered by the overlay texture, or nullopt to use the legacy document-viewBox placement path.

The documentation for this class was generated from the following file: