FreeRDP
Loading...
Searching...
No Matches
SdlOverlay Class Reference

#include <sdl_overlay.hpp>

Public Member Functions

 SdlOverlay (SdlContext *sdl)
 SdlOverlay (const SdlOverlay &other)=delete
 SdlOverlay (SdlOverlay &&other)=delete
SdlOverlay & operator= (const SdlOverlay &other)=delete
SdlOverlay & operator= (SdlOverlay &&other)=delete
bool visible () const
bool show (bool on)
bool connected ()
bool update (int windowWidth, int windowHeight, const char *rendererName)
const std::vector< sdl::overlay::Row > & left () const
const std::vector< sdl::overlay::Row > & right () const
uint64_t generation () const

Detailed Description

The stats and info overlay: off by default, a hotkey shows and hides it.

The client's runtime statistics are read once a second on the session thread, by a FreeRDP timer that runs only while the overlay shows, and drawn on SDL's thread over the picture, never into it: the session's size and picture do not change. Off, nothing runs.

Definition at line 45 of file sdl_overlay.hpp.

Constructor & Destructor Documentation

◆ SdlOverlay()

SdlOverlay::SdlOverlay ( SdlContext * sdl)
explicit

Definition at line 109 of file sdl_overlay.cpp.

109 : _sdl(sdl)
110{
111 WINPR_ASSERT(_sdl);
112}

Member Function Documentation

◆ connected()

bool SdlOverlay::connected ( )
nodiscard

The session thread, when a connection (or a reconnect) is up: rows start again.

Definition at line 127 of file sdl_overlay.cpp.

128{
129 {
130 std::scoped_lock lock(_mutex);
131 _since = std::chrono::steady_clock::now();
132 _pending.reset();
133 _restart = true;
134 }
135 if (!_visible)
136 return true;
137 return arm();
138}

◆ generation()

uint64_t SdlOverlay::generation ( ) const
nodiscard

Definition at line 257 of file sdl_overlay.cpp.

258{
259 return _generation;
260}

◆ left()

const std::vector< sdl::overlay::Row > & SdlOverlay::left ( ) const
nodiscard

The rows to draw: client info on the left, the real-time part on the right. A new generation means the rows changed.

Definition at line 247 of file sdl_overlay.cpp.

248{
249 return _left;
250}

◆ right()

const std::vector< sdl::overlay::Row > & SdlOverlay::right ( ) const
nodiscard

Definition at line 252 of file sdl_overlay.cpp.

253{
254 return _right;
255}

◆ show()

bool SdlOverlay::show ( bool on)
nodiscard

SDL's thread: show or hide. Shown before the session connects, it starts with it.

Definition at line 119 of file sdl_overlay.cpp.

120{
121 _visible = on;
122 if (!on || !_sdl->isConnected())
123 return true;
124 return arm();
125}

◆ update()

bool SdlOverlay::update ( int windowWidth,
int windowHeight,
const char * rendererName )
nodiscard

SDL's thread, on SDL_EVENT_USER_OVERLAY: take the newest reading, build the rows.

Returns
true when there is something new to draw

Definition at line 212 of file sdl_overlay.cpp.

213{
214 std::optional<sdl::overlay::Reading> reading;
215 std::chrono::steady_clock::time_point since;
216 bool restart = false;
217 {
218 std::scoped_lock lock(_mutex);
219 reading.swap(_pending);
220 since = _since;
221 restart = _restart;
222 _restart = false;
223 }
224 if (restart)
225 _prev.reset();
226 if (!reading || !_visible)
227 return false;
228
229 const auto& names = _names ? *_names : _names.emplace(statsNames());
230 if (_client.empty())
231 clientRows(rendererName);
232
233 sdl::overlay::View view;
234 view.windowWidth = windowWidth;
235 view.windowHeight = windowHeight;
236 view.sessionSeconds = static_cast<uint64_t>(
237 std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - since)
238 .count());
239
240 _left = _client;
241 _right = sdl::overlay::realtimeRows(names, *reading, _prev ? &*_prev : nullptr, view);
242 _prev = std::move(reading);
243 _generation++;
244 return true;
245}
std::vector< Row > realtimeRows(const Names &names, const Reading &now, const Reading *prev, const View &view)

References sdl::overlay::realtimeRows().

Here is the call graph for this function:

◆ visible()

bool SdlOverlay::visible ( ) const
nodiscard

Definition at line 114 of file sdl_overlay.cpp.

115{
116 return _visible;
117}

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