mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 22:31:46 +00:00
[client] ds: change signalNextFrame to waitFrame
This commit is contained in:
parent
37196f1f0e
commit
77b3d45e0e
5 changed files with 24 additions and 19 deletions
|
@ -172,7 +172,7 @@ struct LG_DisplayServerOps LGDS_Wayland =
|
||||||
.glSetSwapInterval = waylandGLSetSwapInterval,
|
.glSetSwapInterval = waylandGLSetSwapInterval,
|
||||||
.glSwapBuffers = waylandGLSwapBuffers,
|
.glSwapBuffers = waylandGLSwapBuffers,
|
||||||
#endif
|
#endif
|
||||||
.signalNextFrame = waylandSignalNextFrame,
|
.waitFrame = waylandWaitFrame,
|
||||||
.guestPointerUpdated = waylandGuestPointerUpdated,
|
.guestPointerUpdated = waylandGuestPointerUpdated,
|
||||||
.setPointer = waylandSetPointer,
|
.setPointer = waylandSetPointer,
|
||||||
.grabPointer = waylandGrabPointer,
|
.grabPointer = waylandGrabPointer,
|
||||||
|
|
|
@ -176,6 +176,8 @@ struct WaylandDSState
|
||||||
struct wl_list surfaceOutputs; // SurfaceOutput::link
|
struct wl_list surfaceOutputs; // SurfaceOutput::link
|
||||||
bool useFractionalScale;
|
bool useFractionalScale;
|
||||||
|
|
||||||
|
LGEvent * frameEvent;
|
||||||
|
|
||||||
struct wl_list poll; // WaylandPoll::link
|
struct wl_list poll; // WaylandPoll::link
|
||||||
struct wl_list pollFree; // WaylandPoll::link
|
struct wl_list pollFree; // WaylandPoll::link
|
||||||
LG_Lock pollLock;
|
LG_Lock pollLock;
|
||||||
|
@ -304,4 +306,4 @@ void waylandWindowFree(void);
|
||||||
void waylandWindowUpdateScale(void);
|
void waylandWindowUpdateScale(void);
|
||||||
void waylandSetWindowSize(int x, int y);
|
void waylandSetWindowSize(int x, int y);
|
||||||
bool waylandIsValidPointerPos(int x, int y);
|
bool waylandIsValidPointerPos(int x, int y);
|
||||||
void waylandSignalNextFrame(LGEvent * event);
|
void waylandWaitFrame(void);
|
||||||
|
|
|
@ -80,6 +80,14 @@ bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool
|
||||||
{
|
{
|
||||||
wlWm.scale = wl_fixed_from_int(1);
|
wlWm.scale = wl_fixed_from_int(1);
|
||||||
|
|
||||||
|
wlWm.frameEvent = lgCreateEvent(true, 0);
|
||||||
|
if (!wlWm.frameEvent)
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("Failed to initialize event for waitFrame");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
lgSignalEvent(wlWm.frameEvent);
|
||||||
|
|
||||||
if (!wlWm.compositor)
|
if (!wlWm.compositor)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Compositor missing wl_compositor (version 3+), will not proceed");
|
DEBUG_ERROR("Compositor missing wl_compositor (version 3+), will not proceed");
|
||||||
|
@ -105,6 +113,7 @@ bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool
|
||||||
void waylandWindowFree(void)
|
void waylandWindowFree(void)
|
||||||
{
|
{
|
||||||
wl_surface_destroy(wlWm.surface);
|
wl_surface_destroy(wlWm.surface);
|
||||||
|
lgFreeEvent(wlWm.frameEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void waylandSetWindowSize(int x, int y)
|
void waylandSetWindowSize(int x, int y)
|
||||||
|
@ -119,8 +128,7 @@ bool waylandIsValidPointerPos(int x, int y)
|
||||||
|
|
||||||
static void frameHandler(void * opaque, struct wl_callback * callback, unsigned int data)
|
static void frameHandler(void * opaque, struct wl_callback * callback, unsigned int data)
|
||||||
{
|
{
|
||||||
LGEvent * event = opaque;
|
lgSignalEvent(wlWm.frameEvent);
|
||||||
lgSignalEvent(event);
|
|
||||||
wl_callback_destroy(callback);
|
wl_callback_destroy(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,9 +136,11 @@ static const struct wl_callback_listener frame_listener = {
|
||||||
.done = frameHandler,
|
.done = frameHandler,
|
||||||
};
|
};
|
||||||
|
|
||||||
void waylandSignalNextFrame(LGEvent * event)
|
void waylandWaitFrame(void)
|
||||||
{
|
{
|
||||||
|
lgWaitEvent(wlWm.frameEvent, TIMEOUT_INFINITE);
|
||||||
|
|
||||||
struct wl_callback * callback = wl_surface_frame(wlWm.surface);
|
struct wl_callback * callback = wl_surface_frame(wlWm.surface);
|
||||||
if (callback)
|
if (callback)
|
||||||
wl_callback_add_listener(callback, &frame_listener, event);
|
wl_callback_add_listener(callback, &frame_listener, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,11 +149,10 @@ struct LG_DisplayServerOps
|
||||||
void (*glSwapBuffers)(void);
|
void (*glSwapBuffers)(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Signals event when the next frame should be rendered in time for the next vblank.
|
/* Waits for a good time to render the next frame in time for the next vblank.
|
||||||
* This must be invoked on the render thread before swapping buffers.
|
* Once this returns, a frame must be rendered.
|
||||||
* If used, the render thread MUST wait for event before rendering the next frame.
|
|
||||||
* This is optional and a display server may choose to not implement it. */
|
* This is optional and a display server may choose to not implement it. */
|
||||||
void (*signalNextFrame)(LGEvent * event);
|
void (*waitFrame)(void);
|
||||||
|
|
||||||
/* dm specific cursor implementations */
|
/* dm specific cursor implementations */
|
||||||
void (*guestPointerUpdated)(double x, double y, double localX, double localY);
|
void (*guestPointerUpdated)(double x, double y, double localX, double localY);
|
||||||
|
|
|
@ -167,8 +167,8 @@ static int renderThread(void * unused)
|
||||||
|
|
||||||
while(g_state.state != APP_STATE_SHUTDOWN)
|
while(g_state.state != APP_STATE_SHUTDOWN)
|
||||||
{
|
{
|
||||||
if (g_state.jitRender)
|
if (g_state.jitRender || (g_state.ds->waitFrame && g_state.overlayInput))
|
||||||
lgWaitEvent(g_state.jitEvent, TIMEOUT_INFINITE);
|
g_state.ds->waitFrame();
|
||||||
else if (g_params.fpsMin != 0)
|
else if (g_params.fpsMin != 0)
|
||||||
{
|
{
|
||||||
float ups = atomic_load_explicit(&g_state.ups, memory_order_relaxed);
|
float ups = atomic_load_explicit(&g_state.ups, memory_order_relaxed);
|
||||||
|
@ -182,12 +182,6 @@ static int renderThread(void * unused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_params.jitRender && g_state.ds->signalNextFrame)
|
|
||||||
g_state.jitRender = g_state.overlayInput;
|
|
||||||
|
|
||||||
if (g_state.jitRender)
|
|
||||||
g_state.ds->signalNextFrame(g_state.jitEvent);
|
|
||||||
|
|
||||||
int resize = atomic_load(&g_state.lgrResize);
|
int resize = atomic_load(&g_state.lgrResize);
|
||||||
if (resize)
|
if (resize)
|
||||||
{
|
{
|
||||||
|
@ -828,7 +822,7 @@ static int lg_run(void)
|
||||||
|
|
||||||
if (g_params.jitRender)
|
if (g_params.jitRender)
|
||||||
{
|
{
|
||||||
if (g_state.ds->signalNextFrame)
|
if (g_state.ds->waitFrame)
|
||||||
g_state.jitRender = true;
|
g_state.jitRender = true;
|
||||||
else
|
else
|
||||||
DEBUG_WARN("JIT render not supported on display server backend, disabled");
|
DEBUG_WARN("JIT render not supported on display server backend, disabled");
|
||||||
|
|
Loading…
Reference in a new issue