Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::RendererGeodeTextureSnapshot Class Referencefinal

WebGPU texture snapshot exported by RendererGeode. More...

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

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

Public Member Functions

 RendererGeodeTextureSnapshot (std::shared_ptr< geode::GeodeDevice > device, wgpu::Texture texture, Vector2i dimensions, wgpu::TextureFormat format, AlphaType alphaType=AlphaType::Premultiplied)
 Construct a Geode texture snapshot.
 RendererGeodeTextureSnapshot (const RendererGeodeTextureSnapshot &)=delete
RendererGeodeTextureSnapshotoperator= (const RendererGeodeTextureSnapshot &)=delete
 RendererGeodeTextureSnapshot (RendererGeodeTextureSnapshot &&) noexcept=default
RendererGeodeTextureSnapshotoperator= (RendererGeodeTextureSnapshot &&other) noexcept
RendererTextureSnapshotBackend backend () const override
 Renderer backend that produced this texture.
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.
void setDimensions (Vector2i dimensions)
 Re-point the snapshot at a different content extent inside the same backing texture.
const wgpu::Texture & texture () const
 Resolved single-sample WebGPU texture.
const wgpu::TextureView & textureView () const
 Lazily-created texture view suitable for ImGui_ImplWGPU's ImTextureID.
wgpu::TextureFormat format () const
 WebGPU texture format.

Static Public Member Functions

static RendererGeodeTextureSnapshot AdoptRuntimeTexture (std::shared_ptr< geode::GeodeDevice > device, gpu::Texture texture, Vector2i dimensions, wgpu::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

WebGPU 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 ( std::shared_ptr< geode::GeodeDevice > device,
wgpu::Texture texture,
Vector2i dimensions,
wgpu::TextureFormat format,
AlphaType alphaType = AlphaType::Premultiplied )

Construct a Geode texture snapshot.

Parameters
deviceShared Geode device that owns the WebGPU handle lifetime.
textureResolved single-sample texture containing the rendered frame.
dimensionsValid content dimensions in device pixels, anchored at the texture origin. May be smaller than the texture when the producer keeps an oversized allocation.
formatTexture format.
alphaTypeAlpha interpretation of the stored texels. Geode render targets are premultiplied; host-uploaded CPU bitmaps generally are not.

Member Function Documentation

◆ AdoptRuntimeTexture()

RendererGeodeTextureSnapshot donner::svg::RendererGeodeTextureSnapshot::AdoptRuntimeTexture ( std::shared_ptr< geode::GeodeDevice > device,
gpu::Texture texture,
Vector2i dimensions,
wgpu::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.

Parameters
deviceDevice the texture belongs to.
textureRuntime texture handle to take ownership of.
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.

◆ setDimensions()

void donner::svg::RendererGeodeTextureSnapshot::setDimensions ( Vector2i dimensions)
inline

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.

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


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