Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::RendererGeodeTextureSnapshot Class Referencefinal

GPU runtime texture snapshot exported by RendererGeode. More...

#include "donner/svg/renderer/RendererGeode.h"

Inheritance diagram for donner::svg::RendererGeodeTextureSnapshot:
[legend]

Public Member Functions

 RendererGeodeTextureSnapshot ()=default
 Constructs an empty snapshot, naming nothing.
 RendererGeodeTextureSnapshot (const RendererGeodeTextureSnapshot &)=delete
RendererGeodeTextureSnapshot & operator= (const RendererGeodeTextureSnapshot &)=delete
 RendererGeodeTextureSnapshot (RendererGeodeTextureSnapshot &&other) noexcept
 Construct by moving another instance's state.
RendererGeodeTextureSnapshot & operator= (RendererGeodeTextureSnapshot &&other) noexcept
 Replace this object's state by moving another instance.
RendererTextureSnapshotBackend backend () const override
 Renderer backend that produced this texture.
bool isValid () const
 Whether the snapshot names valid content in a backing allocation.
const gpu::Texture * runtimeTexture () const
 Runtime identity of the texture this snapshot names, or null when it names nothing. The returned handle borrows this snapshot's lifetime and must never be consumed.
const gpu::TextureExport * textureExport () const
 The export another context registers this snapshot's texture through, taken on the producer's thread when the snapshot was adopted, or null when the snapshot only borrows a producer's frame target or its backend cannot share textures. Registering it never touches the producing device, so a consumer on any thread may use it.
uint64_t deviceId () const
 Identity of the runtime device the named texture belongs to, or zero when this snapshot names nothing.
Vector2i allocationDimensions () const
 Actual allocation extent; content may use a smaller prefix.
std::optional< gpu::TextureFormat > runtimeFormat () const
 Runtime format, if the backend format has a supported runtime representation.
gpu::Texture takeRuntimeRegistrationForTesting ()
 Takes the owning device's name for this snapshot's texture out of the snapshot, so a test can present a snapshot that no longer names what its backend handles point at. The caller becomes the owner of the returned handle and keeps the texture alive.
Vector2i dimensions () const override
 Valid content extent in device pixels, anchored at the texture origin. Sampling and readback are confined to this region even when the backing texture is larger.
AlphaType alphaType () const override
 Alpha interpretation of the texture contents.
RendererBitmap takeSnapshot () const override
 Capture a CPU-readable copy of this texture.
RendererBitmap takeSnapshotInterruptibly (const std::function< bool()> &shouldCancel) const override
 Captures a CPU-readable copy of this texture, as takeSnapshot does, but gives up when shouldCancel returns true.
bool setDimensions (Vector2i dimensions)
 Re-point the snapshot at a different content extent inside the same backing texture.

Static Public Member Functions

static RendererGeodeTextureSnapshot AdoptRuntimeTexture (std::shared_ptr< geode::GeodeDevice > device, gpu::Texture &&texture, Vector2i dimensions, gpu::TextureFormat format, AlphaType alphaType)
 Takes over a target the runtime allocated, so the snapshot keeps it alive after the renderer has let go of it.

Friends

class RendererGeode

Detailed Description

GPU runtime texture snapshot exported by RendererGeode.

The snapshot keeps the backing geode::GeodeDevice and texture alive so editor presentation code can sample the texture after the renderer has moved on to a later frame.

The snapshot is also the single owner for host-uploaded CPU bitmaps that presentation code wants to draw through Geode. Those uploads keep an oversized backing allocation so a resized payload can reuse the texture, so dimensions() reports the valid content extent rather than the allocation, and alphaType() reports the uploaded pixel format.

Constructor & Destructor Documentation

◆ RendererGeodeTextureSnapshot()

donner::svg::RendererGeodeTextureSnapshot::RendererGeodeTextureSnapshot ( RendererGeodeTextureSnapshot && other)
noexcept

Construct by moving another instance's state.

Parameters
otherSource object.

Member Function Documentation

◆ AdoptRuntimeTexture()

RendererGeodeTextureSnapshot donner::svg::RendererGeodeTextureSnapshot::AdoptRuntimeTexture ( std::shared_ptr< geode::GeodeDevice > device,
gpu::Texture && texture,
Vector2i dimensions,
gpu::TextureFormat format,
AlphaType alphaType )
static

Takes over a target the runtime allocated, so the snapshot keeps it alive after the renderer has let go of it.

Failure returns an empty snapshot (isValid() == false) and leaves the caller's handle unchanged. Validation uses the owning device and the texture's actual backing descriptor. External registrations are rejected because they do not own their backing allocation.

Parameters
deviceDevice the texture belongs to.
textureRuntime texture handle, consumed only after validation succeeds.
dimensionsTexture dimensions in pixels.
formatTexel format.
alphaTypeAlpha interpretation of the stored pixels.

◆ alphaType()

AlphaType donner::svg::RendererGeodeTextureSnapshot::alphaType ( ) const
inlinenodiscardoverridevirtual

Alpha interpretation of the texture contents.

Implements donner::svg::RendererTextureSnapshot.

◆ backend()

RendererTextureSnapshotBackend donner::svg::RendererGeodeTextureSnapshot::backend ( ) const
inlinenodiscardoverridevirtual

Renderer backend that produced this texture.

Reimplemented from donner::svg::RendererTextureSnapshot.

◆ dimensions()

Vector2i donner::svg::RendererGeodeTextureSnapshot::dimensions ( ) const
inlinenodiscardoverridevirtual

Valid content extent in device pixels, anchored at the texture origin. Sampling and readback are confined to this region even when the backing texture is larger.

Implements donner::svg::RendererTextureSnapshot.

◆ operator=()

RendererGeodeTextureSnapshot & donner::svg::RendererGeodeTextureSnapshot::operator= ( RendererGeodeTextureSnapshot && other)
noexcept

Replace this object's state by moving another instance.

Parameters
otherSource object.
Returns
This object after the move.

◆ setDimensions()

bool donner::svg::RendererGeodeTextureSnapshot::setDimensions ( Vector2i dimensions)

Re-point the snapshot at a different content extent inside the same backing texture.

Uploaders that keep an oversized allocation alive across re-uploads call this after writing a payload whose dimensions changed. The new extent must fit within the backing texture.

Parameters
dimensionsValid content dimensions in device pixels.
Returns
True if accepted; an invalid extent leaves the previous content unchanged.

◆ takeSnapshot()

RendererBitmap donner::svg::RendererGeodeTextureSnapshot::takeSnapshot ( ) const
nodiscardoverridevirtual

Capture a CPU-readable copy of this texture.

Backends that cannot read texture snapshots return an empty bitmap. The operation may submit GPU work and block for completion, so presentation code should keep using the texture directly and reserve readback for explicit capture, diagnostics, and tests.

Returns
CPU-readable bitmap, or an empty bitmap when readback is unsupported.

Reimplemented from donner::svg::RendererTextureSnapshot.

◆ takeSnapshotInterruptibly()

RendererBitmap donner::svg::RendererGeodeTextureSnapshot::takeSnapshotInterruptibly ( const std::function< bool()> & shouldCancel) const
nodiscardoverridevirtual

Captures a CPU-readable copy of this texture, as takeSnapshot does, but gives up when shouldCancel returns true.

It is polled while the capture waits for the device's readback context and while that context waits for the copy and its mapping, as RendererGeode::takeSnapshotInterruptibly polls it. Creating the readback context, the first time a device captures, is not interrupted.

Parameters
shouldCancelPolled on the capturing thread; empty never cancels.
Returns
CPU-readable bitmap, or an empty bitmap when the capture failed or was cancelled.

Reimplemented from donner::svg::RendererTextureSnapshot.


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