|
KiCad PCB EDA Suite
|
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 |
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.
| 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().
| KIGFX::SWAPCHAIN_CONTROLLER::~SWAPCHAIN_CONTROLLER | ( | ) |
Definition at line 39 of file swapchain_controller.cpp.
References m_created, and OnCloseSync().
|
delete |
References SWAPCHAIN_CONTROLLER().
| bool KIGFX::SWAPCHAIN_CONTROLLER::OnClose | ( | ) |
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().
| 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.
Definition at line 165 of file swapchain_controller.cpp.
References m_renderThread, m_windowId, OnClose(), and traceRhi.
Referenced by ~SWAPCHAIN_CONTROLLER().
| bool KIGFX::SWAPCHAIN_CONTROLLER::OnPaint | ( | const RHI_NATIVE_WINDOW_HANDLE & | aHandle, |
| uint32_t | aWidth, | ||
| uint32_t | aHeight, | ||
| float | aDpiScale = 1.0f ) |
The first call creates the swapchain.
Every call requests a frame.
| aHandle | is only used by the first call. |
Definition at line 46 of file swapchain_controller.cpp.
References RHI_CMD_SWAPCHAIN_CREATE::dpiScale, KIGFX::EvaluateRenderThreadPhaseStall(), RHI_CMD_SWAPCHAIN_CREATE::frame2DMailbox, RHI_CMD_FRAME_REQUEST::generation, RHI_CMD_SWAPCHAIN_CREATE::height, m_created, m_dpiScale, m_frameMailbox, m_generation, m_height, m_lastLoggedGeneration, m_phaseStallTracker, m_refreshHz, m_renderThread, m_width, m_windowId, RHI_CMD_SWAPCHAIN_CREATE::nativeHandle, RHI_NATIVE_WINDOW_HANDLE::nativeHandle, RHI_CMD_FRAME_REQUEST::refreshHz, traceRhi, RHI_CMD_SWAPCHAIN_CREATE::width, RHI_CMD_FRAME_REQUEST::windowId, and RHI_CMD_SWAPCHAIN_CREATE::windowId.
| bool KIGFX::SWAPCHAIN_CONTROLLER::OnResize | ( | uint32_t | aWidth, |
| uint32_t | aHeight, | ||
| float | aDpiScale = 1.0f ) |
Definition at line 114 of file swapchain_controller.cpp.
References RHI_CMD_SWAPCHAIN_RESIZE::dpiScale, RHI_CMD_SWAPCHAIN_RESIZE::height, m_created, m_dpiScale, m_height, m_renderThread, m_width, m_windowId, traceRhi, RHI_CMD_SWAPCHAIN_RESIZE::width, and RHI_CMD_SWAPCHAIN_RESIZE::windowId.
|
delete |
References SWAPCHAIN_CONTROLLER().
|
inline |
Definition at line 145 of file swapchain_controller.h.
References m_frameMailbox.
|
inline |
Display refresh rate sent with each frame request, 0 when unknown.
Definition at line 148 of file swapchain_controller.h.
References m_refreshHz.
|
private |
Definition at line 153 of file swapchain_controller.h.
Referenced by OnClose(), OnPaint(), OnResize(), and ~SWAPCHAIN_CONTROLLER().
|
private |
Definition at line 157 of file swapchain_controller.h.
Referenced by OnPaint(), and OnResize().
|
private |
Definition at line 159 of file swapchain_controller.h.
Referenced by OnPaint(), and SetFrameMailbox().
|
private |
Definition at line 154 of file swapchain_controller.h.
Referenced by OnPaint().
|
private |
Definition at line 156 of file swapchain_controller.h.
Referenced by OnPaint(), and OnResize().
|
private |
Definition at line 160 of file swapchain_controller.h.
Referenced by OnPaint().
|
private |
Definition at line 161 of file swapchain_controller.h.
Referenced by OnPaint().
|
private |
Definition at line 158 of file swapchain_controller.h.
Referenced by OnPaint(), and SetRefreshRate().
|
private |
Definition at line 151 of file swapchain_controller.h.
Referenced by OnClose(), OnCloseSync(), OnPaint(), OnResize(), and SWAPCHAIN_CONTROLLER().
|
private |
Definition at line 155 of file swapchain_controller.h.
Referenced by OnPaint(), and OnResize().
|
private |
Definition at line 152 of file swapchain_controller.h.
Referenced by OnClose(), OnCloseSync(), OnPaint(), OnResize(), and SWAPCHAIN_CONTROLLER().