Donner SVG main
0.8.0 · 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
GeodeTextureEncoder.h File Reference

Reusable GPU texture upload + textured-quad draw helpers for Geode. More...

#include <array>
#include <cstdint>
#include <optional>
#include <span>
#include <type_traits>
#include "donner/base/Box.h"
#include "donner/base/Transform.h"
#include "donner/gpu/CommandEncoder.h"
#include "donner/gpu/Handles.h"
#include "donner/gpu/shader/programs/ImageBlit.h"
#include "donner/svg/renderer/geode/GeodeGpuContext.h"
Include dependency graph for GeodeTextureEncoder.h:
This graph shows which files directly or indirectly include this file:

Classes

class  donner::geode::GeodeTextureEncoder
 Reusable helpers for uploading pixel data to a GPU texture and drawing it as a textured quad through GeodeImagePipeline. More...
struct  donner::geode::GeodeTextureEncoder::UniformAllocation
 Borrowed uniform-buffer range for one blit uniform upload. The buffer field is a raw non-owning handle: the provider keeps it alive (see UniformScratch's contract below); holders must not retain the allocation beyond the current frame. More...
class  donner::geode::GeodeTextureEncoder::UniformScratch
 Interface for callers that pool blit uniform uploads into a per-frame scratch arena instead of creating one uniform buffer per blit. More...
struct  donner::geode::GeodeTextureEncoder::QuadParams
 Parameters for a single textured-quad draw call. More...
class  donner::geode::GeodeTextureEncoder::RetainedQuadBinding
 Uniform buffer and bind group that one textured quad keeps across frames, so drawing it again with unchanged inputs writes no buffer and creates no bind group. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Detailed Description

Reusable GPU texture upload + textured-quad draw helpers for Geode.


Class Documentation

◆ donner::geode::GeodeTextureEncoder::UniformAllocation

struct donner::geode::GeodeTextureEncoder::UniformAllocation

Borrowed uniform-buffer range for one blit uniform upload. The buffer field is a raw non-owning handle: the provider keeps it alive (see UniformScratch's contract below); holders must not retain the allocation beyond the current frame.

Class Members
BufferRef buffer
uint64_t offset = 0
uint64_t size = 0

◆ donner::geode::GeodeTextureEncoder::QuadParams

struct donner::geode::GeodeTextureEncoder::QuadParams

Parameters for a single textured-quad draw call.

destRect is in target-pixel space; the caller must bake the current model-view transform into targetFromLocal if the rect is authored in a different coordinate system. This keeps drawTexturedQuad agnostic about where the MVP lives in the larger renderer's state stack.

Class Members
Vector2i anchor = Vector2i::Zero() Target pixel that the content stays aligned to for Filter::Anchored: two draws whose source and target differ by whole pixels, with the anchor at the same target pixel, sample corresponding pixels with the same bilinear weights.
bool applyMaskBounds = false When true, output pixels outside maskBounds are discarded. Used to honour the <mask> element's x/y/width/height.
uint32_t blendMode = 0 SVG mix-blend-mode selector. 0 = plain source-over; 1..=16 map to the enumeration in donner::svg::MixBlendMode (Normal..Luminosity). When non-zero, dstSnapshotTexture must hold the parent render target's frozen content for the fragment shader to read as the backdrop.
const TextureView * clipMaskView = nullptr Path-clip mask view. When set, the image shader samples it in target-pixel space and gates the source content before any blend/mask compositing. Borrowed.
Box2d destRect Destination rectangle (in target-pixel space after applying targetFromLocal).
const Texture * dstSnapshotTexture = nullptr Frozen snapshot of the parent render target - see RendererGeode::popIsolatedLayer which copies the prior parent content into a separate texture before opening the blend blit pass. Ignored unless blendMode != 0. Borrowed.
Filter filter = Filter::Linear Sampling filter mode.
Box2d maskBounds Mask bounds in target-pixel space. Ignored unless applyMaskBounds is true.
uint32_t maskMode = 0 Mask coverage selector: 0 disables masks, 1 uses sRGB luminance, 2 alpha, 3 linear luminance.
const Texture * maskTexture = nullptr <mask> compositing input. Ignored unless maskMode is nonzero. Borrowed.
double opacity = 1.0 Overall opacity multiplier in [0, 1]. Combined with the sampled alpha inside the fragment shader.
double pixelatedScaleX = 1.0 Device-pixel scale per source texel for CSS pixelated sampling.
double pixelatedScaleY = 1.0
See also
pixelatedScaleX
bool sourceIsPremultiplied = false Set when the source texture already stores premultiplied-alpha pixels. drawImage premultiplies ImageResource pixels before upload, and offscreen render targets blitted during popIsolatedLayer / pattern compositing are already premultiplied. Both paths set this flag to avoid a second premultiplication that darkens the RGB channel. Straight-alpha callers leave the default false so the shader premultiplies on output.
Box2d srcRect = Box2d({0.0, 0.0}, {1.0, 1.0}) Source UV rectangle in [0,1] × [0,1]. Default = entire texture.
Transform2d targetFromLocal Maps destRect's space to target pixels; the MVP must apply the same mapping. Nearest sampling inverts it to find the source texel under each pixel center.