Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::compositor::CompositorLayer Class Reference

Represents a single compositor layer with its cached bitmap and dirty state. More...

#include "donner/svg/compositor/CompositorLayer.h"

Public Member Functions

 CompositorLayer (uint32_t id, Entity entity, Entity firstEntity, Entity lastEntity)
 Construct a layer for the given entity.
Accessors
uint32_t id () const
 Returns the unique layer identifier.
Entity entity () const
 Returns the root entity of this layer.
Entity firstEntity () const
 Returns the first entity in the layer's render range.
Entity lastEntity () const
 Returns the last entity in the layer's render range.
const RendererBitmapbitmap () const
 Returns the cached bitmap for this layer. Empty if not yet rasterized.
const Transform2dcanvasFromBitmap () const
 Returns the canvasFromBitmap transform applied during blitting. Maps bitmap-local pixel coordinates (origin at the bitmap's top left, i.e. the rasterize-time coordinate frame) into canvas pixels. Identity when the DOM entity has not moved since rasterization; a pure translation during the bitmap-reuse fast path; other transforms force re-rasterization before compose.
const std::optional< Transform2d > & bitmapEntityFromWorldTransform () const
 Returns the entity's absolute transform at the moment the cached bitmap was rasterized, if any. The compositor uses this to decide whether a subsequent DOM transform mutation can reuse the bitmap by updating canvasFromBitmap_ (pure-translation delta) vs forcing re-rasterization (any other delta).
bool isDirty () const
 Returns true if the layer needs re-rasterization.
bool hasValidBitmap () const
 Returns true if the layer has a valid cached bitmap.
FallbackReason fallbackReasons () const
 Returns the fallback reasons for this layer, or FallbackReason::None.
bool requiresConservativeFallback () const
 Returns true if this layer requires conservative fallback (re-rasterize every frame).
Mutators
void markDirty ()
 Mark the layer as needing re-rasterization.
void clearDirty ()
 Clear the dirty flag after re-rasterization.
void setBitmap (RendererBitmap bitmap, const Transform2d &worldFromEntityTransform)
 Set the cached bitmap for this layer, along with the entity's absolute transform at the moment of rasterization. Stored so a subsequent fast-path DOM translation mutation can detect that the bitmap's pixel content is still valid (only its world-space position drifted) and reuse it via a compose-offset delta.
uint64_t generation () const
 Monotonic version counter — bumped on every setBitmap. The editor uses it to decide whether to re-upload this layer's bitmap to its cached GL texture.
void setCanvasFromBitmap (const Transform2d &transform)
 Set the canvasFromBitmap transform used during blitting.
void setFallbackReasons (FallbackReason reasons)
 Set the fallback reasons for this layer.
void setEntityRange (Entity firstEntity, Entity lastEntity)
 Update the entity range rendered into this layer.
void remapEntities (Entity newEntity, Entity newFirstEntity, Entity newLastEntity)
 Remap the layer's entity ids (entity_, firstEntity_, lastEntity_) from old to new — used by CompositorController::remapAfterStructural Replace when a structurally-identical document swap gives every element a new entity id but leaves the rasterized pixels valid. The cached bitmap_, canvasFromBitmap_, bitmapEntityFromWorld Transform_, and fallbackReasons_ survive unchanged — they're keyed on position-in-paint-order, not entity id.
void setLayerId (uint32_t id)
 Reassign the layer's numeric id. Used by CompositorController::reconcileLayers() when the resolver reassigns an id for a still-promoted entity (e.g. after a higher-weight neighbor demotes and this entity shifts up). The cached bitmap, dirty flag, and composition transform are preserved across an id change.

Detailed Description

Represents a single compositor layer with its cached bitmap and dirty state.

Each layer corresponds to a promoted entity subtree. The layer caches its rasterized output and tracks whether re-rasterization is needed (dirty) or only the composition transform has changed.

Constructor & Destructor Documentation

◆ CompositorLayer()

donner::svg::compositor::CompositorLayer::CompositorLayer ( uint32_t id,
Entity entity,
Entity firstEntity,
Entity lastEntity )

Construct a layer for the given entity.

Parameters
idUnique layer identifier.
entityThe root entity of this layer.
firstEntityFirst entity in the layer's render range (inclusive).
lastEntityLast entity in the layer's render range (inclusive).

Member Function Documentation

◆ setBitmap()

void donner::svg::compositor::CompositorLayer::setBitmap ( RendererBitmap bitmap,
const Transform2d & worldFromEntityTransform )
inline

Set the cached bitmap for this layer, along with the entity's absolute transform at the moment of rasterization. Stored so a subsequent fast-path DOM translation mutation can detect that the bitmap's pixel content is still valid (only its world-space position drifted) and reuse it via a compose-offset delta.

Bumps generation_ so the editor can tell a fresh rasterization from a preserved-across-remap cache via CompositorTile:: generation and skip redundant GL texture uploads.


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