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 259 of file sdl_overlay.cpp.

260{
261 return _generation;
262}

◆ 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 249 of file sdl_overlay.cpp.

250{
251 return _left;
252}

◆ right()

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

Definition at line 254 of file sdl_overlay.cpp.

255{
256 return _right;
257}

◆ 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 214 of file sdl_overlay.cpp.

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