TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::PrimitiveRenderer Class Reference

#include <gui_core/graphics/gui_primitive_renderer.h>

Inheritance diagram for tachyon::PrimitiveRenderer:

Public Member Functions

void Reset () override
void SetTransform (tachyon::float3x2 transform) override
void SetOpacity (float opacity) override
 How opaque what is drawn from now on is, 0 to 1 (1 until set).
void RenderBox (tachyon::IntRect rect, tachyon::IntRect clipRect, uint32_t fromStyleIndex, uint32_t toStyleIndex, float blendT, tachyon::VisualColorStyleIndex colorStyleIndex={}, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx={}) override
 Draws a styled box, blended from fromStyleIndex to toStyleIndex (flat GPU style indices) by blendT in [0, 1].
void RenderGlyph (tachyon::float2 pos, tachyon::float2 size, tachyon::float2 uvMin, tachyon::float2 uvMax, float scale, int bpp, int mode, tachyon::VisualColorStyleIndex textColorIndex, tachyon::IntRect clipRect, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, float shadowBlur=-1.0f) override
 A glyph from the text atlas.
void RenderLine (tachyon::int2 p0, tachyon::int2 p1, tachyon::int2 p2, tachyon::int2 p3, tachyon::IntRect clipRect, const tachyon::LineStyle &lineStyle) override
void RenderCircle (tachyon::float2 center, float radius, tachyon::IntRect clipRect, const tachyon::LineStyle &lineStyle) override
 A circle outline lineStyle.lineWidth wide, exactly round.
void RenderDot (tachyon::float2 pos, tachyon::IntRect clipRect, float size, tachyon::color4f color) override
void RenderTriangle (tachyon::float2 p0, tachyon::float2 p1, tachyon::float2 p2, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, TriangleEdges hardEdges=TriangleEdges::None) override
 A filled triangle.
void RenderQuad (tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius=0.0f, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid) override
 Draws a filled, optionally rounded and textured rect: a box without borders, style blending or element state.
void RenderShadow (tachyon::IntRect rect, tachyon::IntRect clipRect, tachyon::VisualColorStyleIndex colorStyleIndex, float cornerRadius, int blur) override
 A box shadow: rect is the shadow's shape, which fades out over blur pixels on either side of its edge (Gaussian, sigma = blur / 2, as CSS).
void RenderOccluder (tachyon::IntRect rect, tachyon::IntRect clipRect) override
 Draws nothing: marks rect as covered by opaque content drawn after this call, so what was drawn before it there is skipped on the GPU.
PrimitiveRenderTarget & GetTarget (tachyon::ID id)
void ReleaseTarget (tachyon::ID id)
 Drops the CPU-side target of window id, when the window is destroyed.
void ReleaseAllTargets ()
bool StartResizing (tachyon::ID id) override
void StopResizing () override
bool BeginWindow (tachyon::ID id) override
void EndWindow () override
void BeginScopeCapture (tachyon::ID scopeId) override
 Starts recording primitives under scopeId, replacing its previous capture.
void EndScopeCapture (tachyon::ID scopeId) override
 Ends the capture of scopeId and draws it into the current window.
bool ReplayScopeCapture (tachyon::ID scopeId, tachyon::int2 delta) override
 Draws the capture of scopeId again, moved by delta pixels; false if there is none.
bool HasScopeCapture (tachyon::ID scopeId) const override
 True when scopeId has a non-empty capture.
void InvalidateScopeCapture (tachyon::ID scopeId) override
 Drops the capture of scopeId.
void ClearScopeCaptures () override
 Drops every capture.
void Render (tachyon::ID id, RHI::RenderCommandList &cmdList, const PipelineSet &pipelines, GPUDrawPushConstants &push_constants)
size_t LastFrameUploadBytes () const
 Primitive bytes the last Render uploaded with the frame; cached scopes drawn from their GPU copy add nothing.
size_t ResidentScopeCount () const
 Captured scopes with a GPU copy (made or on its way).
Public Member Functions inherited from tachyon::GUIRenderer
virtual ~GUIRenderer ()
void RenderBox (tachyon::IntRect rect, tachyon::IntRect clipRect, VisualBoxStyleIndex boxStyleIndex, tachyon::ElementState state, tachyon::VisualColorStyleIndex colorStyleIndex={}, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx={})
void RenderBox (tachyon::IntRect rect, tachyon::IntRect clipRect, VisualBoxStyleIndex boxStyleIndex, tachyon::VisualColorStyleIndex colorStyleIndex={}, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid, tachyon::IntRect snappedPx={})
void RenderLine (tachyon::int2 p0, tachyon::int2 p1, tachyon::IntRect clipRect, const LineStyle &lineStyle)
void RenderFilledPolygon (std::span< const tachyon::float2 > points, tachyon::IntRect clipRect, VisualColorStyleIndex colorIndex, tachyon::ImageIndex textureIndex=tachyon::ImageIndex::Invalid)
 Convex polygon, fan-triangulated from points[0]; needs at least 3 points.
void RenderPolyline (std::span< const tachyon::int2 > points, bool closed, tachyon::IntRect clipRect, const LineStyle &style)
 Outlined polyline; closed adds a segment from the last point back to the first.

Public Attributes

std::unordered_map< tachyon::ID, PrimitiveRenderTarget > idTargets
PrimitiveRenderTarget * currentTarget { nullptr }
PrimitiveRenderTarget * resizingTarget { nullptr }

Static Public Attributes

static constexpr uint64_t kEvictAfterFrames = 240
 A capture neither recorded nor replayed for this many frames is dropped, its GPU copy freed (as UICacheManager drops its scopes).

Additional Inherited Members

Static Public Member Functions inherited from tachyon::GUIRenderer
static uint32_t StyleIndex (VisualBoxStyleIndex boxStyleIndex, tachyon::ElementState state)
 The flat GPU style index of boxStyleIndex in state, as RenderBox takes it.

Member Function Documentation

◆ Reset()

void tachyon::PrimitiveRenderer::Reset ( )
overridevirtual

Implements tachyon::GUIRenderer.

◆ SetTransform()

void tachyon::PrimitiveRenderer::SetTransform ( tachyon::float3x2 transform)
overridevirtual

Implements tachyon::GUIRenderer.

◆ SetOpacity()

void tachyon::PrimitiveRenderer::SetOpacity ( float opacity)
overridevirtual

How opaque what is drawn from now on is, 0 to 1 (1 until set).

Below 1, occluders are dropped: what is under the drawing shows through it.

Reimplemented from tachyon::GUIRenderer.

◆ RenderBox()

void tachyon::PrimitiveRenderer::RenderBox ( tachyon::IntRect rect,
tachyon::IntRect clipRect,
uint32_t fromStyleIndex,
uint32_t toStyleIndex,
float blendT,
tachyon::VisualColorStyleIndex colorStyleIndex = {},
tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid,
tachyon::IntRect snappedPx = {} )
overridevirtual

Draws a styled box, blended from fromStyleIndex to toStyleIndex (flat GPU style indices) by blendT in [0, 1].

colorStyleIndex overrides the background (Invalid: none). snappedPx is the box in window pixels snapped relative to its parent (SnapToParent); empty snaps the transformed rect to the pixel grid.

Implements tachyon::GUIRenderer.

◆ RenderGlyph()

void tachyon::PrimitiveRenderer::RenderGlyph ( tachyon::float2 pos,
tachyon::float2 size,
tachyon::float2 uvMin,
tachyon::float2 uvMax,
float scale,
int bpp,
int mode,
tachyon::VisualColorStyleIndex textColorIndex,
tachyon::IntRect clipRect,
tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid,
float shadowBlur = -1.0f )
overridevirtual

A glyph from the text atlas.

scale is atlas texels per pixel. With a shadowBlur of 0 or more it is a text shadow instead: the glyph's shape in textColorIndex alone (a color glyph's too), blurred by that many pixels (Gaussian, sigma = blur / 2, as CSS) as far as the atlas' distance field reaches.

Implements tachyon::GUIRenderer.

◆ RenderLine()

void tachyon::PrimitiveRenderer::RenderLine ( tachyon::int2 p0,
tachyon::int2 p1,
tachyon::int2 p2,
tachyon::int2 p3,
tachyon::IntRect clipRect,
const tachyon::LineStyle & lineStyle )
overridevirtual

Implements tachyon::GUIRenderer.

◆ RenderCircle()

void tachyon::PrimitiveRenderer::RenderCircle ( tachyon::float2 center,
float radius,
tachyon::IntRect clipRect,
const tachyon::LineStyle & lineStyle )
overridevirtual

A circle outline lineStyle.lineWidth wide, exactly round.

A gradient and dashes run clockwise from the right (+x towards +y); gradientOffset / gradientScale pick the part of the gradient that goes once around.

Implements tachyon::GUIRenderer.

◆ RenderDot()

void tachyon::PrimitiveRenderer::RenderDot ( tachyon::float2 pos,
tachyon::IntRect clipRect,
float size,
tachyon::color4f color )
overridevirtual

Implements tachyon::GUIRenderer.

◆ RenderTriangle()

void tachyon::PrimitiveRenderer::RenderTriangle ( tachyon::float2 p0,
tachyon::float2 p1,
tachyon::float2 p2,
tachyon::IntRect clipRect,
tachyon::VisualColorStyleIndex colorStyleIndex,
tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid,
TriangleEdges hardEdges = TriangleEdges::None )
overridevirtual

A filled triangle.

hardEdges end without a soft edge, for edges it shares with another triangle of the same shape.

Implements tachyon::GUIRenderer.

◆ RenderQuad()

void tachyon::PrimitiveRenderer::RenderQuad ( tachyon::IntRect rect,
tachyon::IntRect clipRect,
tachyon::VisualColorStyleIndex colorStyleIndex,
float cornerRadius = 0.0f,
tachyon::ImageIndex textureIndex = tachyon::ImageIndex::Invalid )
overridevirtual

Draws a filled, optionally rounded and textured rect: a box without borders, style blending or element state.

Implements tachyon::GUIRenderer.

◆ RenderShadow()

void tachyon::PrimitiveRenderer::RenderShadow ( tachyon::IntRect rect,
tachyon::IntRect clipRect,
tachyon::VisualColorStyleIndex colorStyleIndex,
float cornerRadius,
int blur )
overridevirtual

A box shadow: rect is the shadow's shape, which fades out over blur pixels on either side of its edge (Gaussian, sigma = blur / 2, as CSS).

Implements tachyon::GUIRenderer.

◆ RenderOccluder()

void tachyon::PrimitiveRenderer::RenderOccluder ( tachyon::IntRect rect,
tachyon::IntRect clipRect )
overridevirtual

Draws nothing: marks rect as covered by opaque content drawn after this call, so what was drawn before it there is skipped on the GPU.

Only for a rect the later content covers completely, with no anti-aliased edge.

Reimplemented from tachyon::GUIRenderer.

◆ GetTarget()

PrimitiveRenderTarget & tachyon::PrimitiveRenderer::GetTarget ( tachyon::ID id)
inline

◆ ReleaseTarget()

void tachyon::PrimitiveRenderer::ReleaseTarget ( tachyon::ID id)

Drops the CPU-side target of window id, when the window is destroyed.

Transient GPU storage belongs to the window's frame slots, not to this target.

◆ ReleaseAllTargets()

void tachyon::PrimitiveRenderer::ReleaseAllTargets ( )

◆ StartResizing()

bool tachyon::PrimitiveRenderer::StartResizing ( tachyon::ID id)
inlineoverridevirtual

Implements tachyon::GUIRenderer.

◆ StopResizing()

void tachyon::PrimitiveRenderer::StopResizing ( )
inlineoverridevirtual

Implements tachyon::GUIRenderer.

◆ BeginWindow()

bool tachyon::PrimitiveRenderer::BeginWindow ( tachyon::ID id)
overridevirtual

Implements tachyon::GUIRenderer.

◆ EndWindow()

void tachyon::PrimitiveRenderer::EndWindow ( )
overridevirtual

Implements tachyon::GUIRenderer.

◆ BeginScopeCapture()

void tachyon::PrimitiveRenderer::BeginScopeCapture ( tachyon::ID scopeId)
overridevirtual

Starts recording primitives under scopeId, replacing its previous capture.

Captures don't nest.

Reimplemented from tachyon::GUIRenderer.

◆ EndScopeCapture()

void tachyon::PrimitiveRenderer::EndScopeCapture ( tachyon::ID scopeId)
overridevirtual

Ends the capture of scopeId and draws it into the current window.

Reimplemented from tachyon::GUIRenderer.

◆ ReplayScopeCapture()

bool tachyon::PrimitiveRenderer::ReplayScopeCapture ( tachyon::ID scopeId,
tachyon::int2 delta )
overridevirtual

Draws the capture of scopeId again, moved by delta pixels; false if there is none.

Reimplemented from tachyon::GUIRenderer.

◆ HasScopeCapture()

bool tachyon::PrimitiveRenderer::HasScopeCapture ( tachyon::ID scopeId) const
overridevirtual

True when scopeId has a non-empty capture.

Reimplemented from tachyon::GUIRenderer.

◆ InvalidateScopeCapture()

void tachyon::PrimitiveRenderer::InvalidateScopeCapture ( tachyon::ID scopeId)
overridevirtual

Drops the capture of scopeId.

Reimplemented from tachyon::GUIRenderer.

◆ ClearScopeCaptures()

void tachyon::PrimitiveRenderer::ClearScopeCaptures ( )
overridevirtual

Drops every capture.

Reimplemented from tachyon::GUIRenderer.

◆ Render()

void tachyon::PrimitiveRenderer::Render ( tachyon::ID id,
RHI::RenderCommandList & cmdList,
const PipelineSet & pipelines,
GPUDrawPushConstants & push_constants )

◆ LastFrameUploadBytes()

size_t tachyon::PrimitiveRenderer::LastFrameUploadBytes ( ) const
inline

Primitive bytes the last Render uploaded with the frame; cached scopes drawn from their GPU copy add nothing.

◆ ResidentScopeCount()

size_t tachyon::PrimitiveRenderer::ResidentScopeCount ( ) const

Captured scopes with a GPU copy (made or on its way).

Member Data Documentation

◆ idTargets

std::unordered_map<tachyon::ID, PrimitiveRenderTarget> tachyon::PrimitiveRenderer::idTargets

◆ currentTarget

PrimitiveRenderTarget* tachyon::PrimitiveRenderer::currentTarget { nullptr }

◆ resizingTarget

PrimitiveRenderTarget* tachyon::PrimitiveRenderer::resizingTarget { nullptr }

◆ kEvictAfterFrames

uint64_t tachyon::PrimitiveRenderer::kEvictAfterFrames = 240
staticconstexpr

A capture neither recorded nor replayed for this many frames is dropped, its GPU copy freed (as UICacheManager drops its scopes).


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