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

A rendered image that lives either in a backend GPU texture or in CPU pixels. More...

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

Public Member Functions

 RendererImage ()=default
 Constructs an empty image.
 RendererImage (RendererBitmap bitmap)
 Constructs a CPU-resident image.
 RendererImage (std::shared_ptr< const RendererTextureSnapshot > texture)
 Constructs a GPU-resident image.
bool empty () const
 Returns true when this image has no content.
Vector2i dimensions () const
 Pixel dimensions in device pixels, or zero when empty.
const std::shared_ptr< const RendererTextureSnapshot > & textureSnapshot () const
 The backend texture when this image is GPU-resident, or null when it is CPU pixels.
const RendererBitmapbitmap () const
 CPU pixels for this image.

Detailed Description

A rendered image that lives either in a backend GPU texture or in CPU pixels.

Renderers return whichever form the active backend produces natively - a GPU backend hands back a sampleable texture, a software backend hands back pixels - so callers do not have to pick a rendering entry point per backend. A consumer that can sample a texture takes textureSnapshot and uses bitmap only when it is null; a consumer that needs CPU pixels calls bitmap and pays a readback only when the image is GPU-resident.

Constructor & Destructor Documentation

◆ RendererImage() [1/2]

donner::svg::RendererImage::RendererImage ( RendererBitmap bitmap)
inlineexplicit

Constructs a CPU-resident image.

Parameters
bitmapRendered pixels. An empty bitmap yields an empty image.

◆ RendererImage() [2/2]

donner::svg::RendererImage::RendererImage ( std::shared_ptr< const RendererTextureSnapshot > texture)
inlineexplicit

Constructs a GPU-resident image.

Parameters
textureBackend texture holding the rendered pixels. A null texture yields an empty image.

Member Function Documentation

◆ bitmap()

const RendererBitmap & donner::svg::RendererImage::bitmap ( ) const
inlinenodiscard

CPU pixels for this image.

A GPU-resident image is read back on the first call and the result cached, so a consumer that only ever samples the texture never pays for a readback. The readback may submit GPU work and block for completion.

Returns
Rendered pixels, or an empty bitmap when the image is empty or readback is unsupported.

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