Loading...
Searching...
No Matches
Gfx::RhiPreviewWidget Class Reference

A QWidget that paints a score::gfx render-graph output without using QWidget::createWindowContainer (broken on macOS) or QRhiWidget (forces the toplevel to switch to RHI compositing — flash + perf impact). More...

Inheritance diagram for Gfx::RhiPreviewWidget:

Detailed Description

A QWidget that paints a score::gfx render-graph output without using QWidget::createWindowContainer (broken on macOS) or QRhiWidget (forces the toplevel to switch to RHI compositing — flash + perf impact).

The graph renders into an offscreen QRhi texture owned by a score::gfx::BackgroundNode; each frame is read back into a QImage-shaped QByteArray and drawn in paintEvent. CPU readback is cheap at preview resolutions and avoids touching Qt's compositor RHI entirely.

Two backends:

Public Member Functions

 RhiPreviewWidget (QWidget *parent=nullptr)
 
void useGraph (score::gfx::Graph *graph, std::function< void(score::gfx::BackgroundNode &)> onAttached, std::function< void(score::gfx::BackgroundNode &)> onAboutToDetach)
 
void useContext (GfxContext *ctx, port_index producer)
 
void setProducer (port_index producer)
 

Protected Member Functions

void paintEvent (QPaintEvent *ev) override
 
void resizeEvent (QResizeEvent *ev) override
 
void timerEvent (QTimerEvent *ev) override
 

Member Function Documentation

◆ useContext()

void Gfx::RhiPreviewWidget::useContext ( GfxContext ctx,
port_index  producer 
)

Context backend. The producer endpoint can be updated at any time; the widget rewires the preview edge accordingly. It is a (node, port) pair, not just a node: a process whose texture outlet is not its first outlet registers under that outlet's own index.

◆ useGraph()

void Gfx::RhiPreviewWidget::useGraph ( score::gfx::Graph graph,
std::function< void(score::gfx::BackgroundNode &)>  onAttached,
std::function< void(score::gfx::BackgroundNode &)>  onAboutToDetach 
)

Graph backend. onAttached fires once the BackgroundNode has been registered with the graph (its render list is built). The caller wires producer→preview edges in there. onAboutToDetach fires before the BackgroundNode is removed; the caller must remove any edges it added.


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