KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::SWAPCHAIN_CONTROLLER Class Reference

Turns one window's paint, resize and close events into render thread control commands. More...

#include <swapchain_controller.h>

Public Member Functions

 SWAPCHAIN_CONTROLLER (RENDER_THREAD &aRenderThread, RHI_WINDOW_ID aWindowId)
 
 ~SWAPCHAIN_CONTROLLER ()
 
 SWAPCHAIN_CONTROLLER (const SWAPCHAIN_CONTROLLER &)=delete
 
SWAPCHAIN_CONTROLLER & operator= (const SWAPCHAIN_CONTROLLER &)=delete
 
bool OnPaint (const RHI_NATIVE_WINDOW_HANDLE &aHandle, uint32_t aWidth, uint32_t aHeight, float aDpiScale=1.0f)
 The first call creates the swapchain.
 
bool OnResize (uint32_t aWidth, uint32_t aHeight, float aDpiScale=1.0f)
 
bool OnClose ()
 
bool OnCloseSync (std::chrono::milliseconds aTimeout=std::chrono::milliseconds(2000))
 Close and wait for the render thread to release the window's GPU resources, so the native window can be destroyed right after.
 
void SetFrameMailbox (FRAME_MAILBOX *aMailbox)
 
void SetRefreshRate (float aHz)
 Display refresh rate sent with each frame request, 0 when unknown.
 

Private Attributes

RENDER_THREAD & m_renderThread
 
RHI_WINDOW_ID m_windowId
 
bool m_created = false
 
uint64_t m_generation = 0
 
uint32_t m_width = 0
 
uint32_t m_height = 0
 
float m_dpiScale = 1.0f
 
float m_refreshHz = 0.0f
 
FRAME_MAILBOX * m_frameMailbox = nullptr
 
uint64_t m_lastLoggedGeneration = 0
 
RHI_PHASE_STALL_TRACKER m_phaseStallTracker
 

Detailed Description

Turns one window's paint, resize and close events into render thread control commands.

Not thread-safe. Call only from the UI thread.

Definition at line 108 of file swapchain_controller.h.

Constructor & Destructor Documentation

◆ SWAPCHAIN_CONTROLLER() [1/2]

KIGFX::SWAPCHAIN_CONTROLLER::SWAPCHAIN_CONTROLLER ( RENDER_THREAD & aRenderThread,
RHI_WINDOW_ID aWindowId )

Definition at line 31 of file swapchain_controller.cpp.

References m_renderThread, and m_windowId.

Referenced by operator=(), and SWAPCHAIN_CONTROLLER().

◆ ~SWAPCHAIN_CONTROLLER()

KIGFX::SWAPCHAIN_CONTROLLER::~SWAPCHAIN_CONTROLLER ( )

Definition at line 39 of file swapchain_controller.cpp.

References m_created, and OnCloseSync().

◆ SWAPCHAIN_CONTROLLER() [2/2]

KIGFX::SWAPCHAIN_CONTROLLER::SWAPCHAIN_CONTROLLER ( const SWAPCHAIN_CONTROLLER & )
delete

Member Function Documentation

◆ OnClose()

bool KIGFX::SWAPCHAIN_CONTROLLER::OnClose ( )
Returns
true if a swapchain existed and its destroy was submitted.

Definition at line 145 of file swapchain_controller.cpp.

References m_created, m_renderThread, m_windowId, traceRhi, and RHI_CMD_SWAPCHAIN_DESTROY::windowId.

Referenced by OnCloseSync().

◆ OnCloseSync()

bool KIGFX::SWAPCHAIN_CONTROLLER::OnCloseSync ( std::chrono::milliseconds aTimeout = std::chrono::milliseconds( 2000 ))

Close and wait for the render thread to release the window's GPU resources, so the native window can be destroyed right after.

Returns
true if the destroy was processed within the timeout.

Definition at line 165 of file swapchain_controller.cpp.

References m_renderThread, m_windowId, OnClose(), and traceRhi.

Referenced by ~SWAPCHAIN_CONTROLLER().

◆ OnPaint()

◆ OnResize()

bool KIGFX::SWAPCHAIN_CONTROLLER::OnResize ( uint32_t aWidth,
uint32_t aHeight,
float aDpiScale = 1.0f )

◆ operator=()

SWAPCHAIN_CONTROLLER & KIGFX::SWAPCHAIN_CONTROLLER::operator= ( const SWAPCHAIN_CONTROLLER & )
delete

◆ SetFrameMailbox()

void KIGFX::SWAPCHAIN_CONTROLLER::SetFrameMailbox ( FRAME_MAILBOX * aMailbox)
inline

Definition at line 145 of file swapchain_controller.h.

References m_frameMailbox.

◆ SetRefreshRate()

void KIGFX::SWAPCHAIN_CONTROLLER::SetRefreshRate ( float aHz)
inline

Display refresh rate sent with each frame request, 0 when unknown.

Definition at line 148 of file swapchain_controller.h.

References m_refreshHz.

Member Data Documentation

◆ m_created

bool KIGFX::SWAPCHAIN_CONTROLLER::m_created = false
private

Definition at line 153 of file swapchain_controller.h.

Referenced by OnClose(), OnPaint(), OnResize(), and ~SWAPCHAIN_CONTROLLER().

◆ m_dpiScale

float KIGFX::SWAPCHAIN_CONTROLLER::m_dpiScale = 1.0f
private

Definition at line 157 of file swapchain_controller.h.

Referenced by OnPaint(), and OnResize().

◆ m_frameMailbox

FRAME_MAILBOX* KIGFX::SWAPCHAIN_CONTROLLER::m_frameMailbox = nullptr
private

Definition at line 159 of file swapchain_controller.h.

Referenced by OnPaint(), and SetFrameMailbox().

◆ m_generation

uint64_t KIGFX::SWAPCHAIN_CONTROLLER::m_generation = 0
private

Definition at line 154 of file swapchain_controller.h.

Referenced by OnPaint().

◆ m_height

uint32_t KIGFX::SWAPCHAIN_CONTROLLER::m_height = 0
private

Definition at line 156 of file swapchain_controller.h.

Referenced by OnPaint(), and OnResize().

◆ m_lastLoggedGeneration

uint64_t KIGFX::SWAPCHAIN_CONTROLLER::m_lastLoggedGeneration = 0
private

Definition at line 160 of file swapchain_controller.h.

Referenced by OnPaint().

◆ m_phaseStallTracker

RHI_PHASE_STALL_TRACKER KIGFX::SWAPCHAIN_CONTROLLER::m_phaseStallTracker
private

Definition at line 161 of file swapchain_controller.h.

Referenced by OnPaint().

◆ m_refreshHz

float KIGFX::SWAPCHAIN_CONTROLLER::m_refreshHz = 0.0f
private

Definition at line 158 of file swapchain_controller.h.

Referenced by OnPaint(), and SetRefreshRate().

◆ m_renderThread

RENDER_THREAD& KIGFX::SWAPCHAIN_CONTROLLER::m_renderThread
private

Definition at line 151 of file swapchain_controller.h.

Referenced by OnClose(), OnCloseSync(), OnPaint(), OnResize(), and SWAPCHAIN_CONTROLLER().

◆ m_width

uint32_t KIGFX::SWAPCHAIN_CONTROLLER::m_width = 0
private

Definition at line 155 of file swapchain_controller.h.

Referenced by OnPaint(), and OnResize().

◆ m_windowId

RHI_WINDOW_ID KIGFX::SWAPCHAIN_CONTROLLER::m_windowId
private

Definition at line 152 of file swapchain_controller.h.

Referenced by OnClose(), OnCloseSync(), OnPaint(), OnResize(), and SWAPCHAIN_CONTROLLER().


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