mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-21 23:08:08 +00:00
[client] overlay: add 25Hz tick
function
This allows an overlay to manage itself for timed events like alerts/messages, etc.
This commit is contained in:
@@ -139,6 +139,26 @@ static bool fpsTimerFn(void * unused)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool tickTimerFn(void * unused)
|
||||
{
|
||||
static unsigned long long tickCount = 0;
|
||||
|
||||
bool needsRender = false;
|
||||
struct Overlay * overlay;
|
||||
for (ll_reset(g_state.overlays);
|
||||
ll_walk(g_state.overlays, (void **)&overlay); )
|
||||
{
|
||||
if (overlay->ops->tick && overlay->ops->tick(overlay->udata, tickCount))
|
||||
needsRender = true;
|
||||
}
|
||||
|
||||
if (needsRender)
|
||||
app_invalidateWindow(false);
|
||||
|
||||
++tickCount;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void preSwapCallback(void * udata)
|
||||
{
|
||||
const uint64_t * renderStart = (const uint64_t *)udata;
|
||||
@@ -169,6 +189,14 @@ static int renderThread(void * unused)
|
||||
return 1;
|
||||
}
|
||||
|
||||
LGTimer * tickTimer;
|
||||
if (!lgCreateTimer(40, tickTimerFn, NULL, &tickTimer))
|
||||
{
|
||||
lgTimerDestroy(fpsTimer);
|
||||
DEBUG_ERROR("Failed to create the tick timer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
LG_LOCK_INIT(g_state.lgrLock);
|
||||
|
||||
/* signal to other threads that the renderer is ready */
|
||||
@@ -289,6 +317,7 @@ static int renderThread(void * unused)
|
||||
|
||||
g_state.state = APP_STATE_SHUTDOWN;
|
||||
|
||||
lgTimerDestroy(tickTimer);
|
||||
lgTimerDestroy(fpsTimer);
|
||||
|
||||
core_stopCursorThread();
|
||||
|
Reference in New Issue
Block a user