Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
GeodeTextureEncoder.h File Reference

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

#include <cstdint>
#include <optional>
#include <webgpu/webgpu.hpp>
#include "donner/base/Box.h"
Include dependency graph for GeodeTextureEncoder.h:

Classes

class  donner::geode::GeodeTextureEncoder
 Reusable helpers for uploading pixel data to a wgpu::Texture and drawing it as a textured quad through GeodeImagePipeline. More...
struct  donner::geode::GeodeTextureEncoder::QuadParams
 Parameters for a single textured-quad draw call. 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::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.

Collaboration diagram for donner::geode::GeodeTextureEncoder::QuadParams:
[legend]
Class Members
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 Phase 3d 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.
TextureView clipMaskView Phase 3b 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.
Box2d destRect Destination rectangle (in target-pixel space after applying targetFromLocal).
Texture dstSnapshotTexture 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.
Filter filter = Filter::Linear Sampling filter mode.
Box2d maskBounds Mask bounds in target-pixel space. Ignored unless applyMaskBounds is true.
Texture maskTexture Phase 3c <mask> luminance compositing. When non-null, this texture is sampled alongside the source and its BT.709 luminance (multiplied by alpha, to match tiny-skia's Mask::fromPixmap(Luminance)) is used as a coverage multiplier on the output. Ignored unless RendererGeode::popMask sets it.
double opacity = 1.0 Overall opacity multiplier in [0, 1]. Combined with the sampled alpha inside the fragment shader.
bool sourceIsPremultiplied = false Set when the source texture already stores premultiplied-alpha pixels. drawImage uses straight-alpha textures uploaded from ImageResource (default = false). Offscreen render targets that Geode blits back during popIsolatedLayer / pattern compositing are premultiplied and must set this flag to avoid a double premultiplication that darkens the RGB channel.
Box2d srcRect = Box2d({0.0, 0.0}, {1.0, 1.0}) Source UV rectangle in [0,1] × [0,1]. Default = entire texture.