mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 05:12:25 +08:00
Wayland: Moved frame-time checking to CWaylandOpenGLDriver instead of viewports
Wayland doesn't require specifics timings, each frame drawn re-queues a new frame so treating it as "render the screens" seems to be a safe bet for now As indicated in the TODOs once actual work is being done in the event loop it should be replaced by a non-blocking option in case no surface is being rendered Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
dad98d93bd
commit
723fca552c
@ -235,6 +235,7 @@ CWaylandOpenGLDriver::CWaylandOpenGLDriver(CApplicationContext& context, CWallpa
|
||||
m_fullscreenDetector (context, *this),
|
||||
m_output (context, *this),
|
||||
m_requestedExit (false),
|
||||
m_context (context),
|
||||
CVideoDriver (app)
|
||||
{
|
||||
m_waylandContext.display = wl_display_connect (nullptr);
|
||||
@ -304,11 +305,26 @@ void CWaylandOpenGLDriver::dispatchEventQueue()
|
||||
for (const auto& viewport : this->getOutput ().getViewports ())
|
||||
this->getApp ().update (viewport.second);
|
||||
}
|
||||
|
||||
|
||||
// TODO: FRAMETIME CONTROL SHOULD GO BACK TO THE CWALLPAPAERAPPLICATION ONCE ACTUAL PARTICLES ARE IMPLEMENTED
|
||||
// TODO: AS THOSE, MORE THAN LIKELY, WILL REQUIRE OF A DIFFERENT PROCESSING RATE
|
||||
|
||||
// TODO: WRITE A NON-BLOCKING VERSION OF THIS ONCE PARTICLE SIMULATION STARTS WORKING
|
||||
// TODO: OTHERWISE wl_display_dispatch WILL BLOCK IF NO SURFACES ARE BEING DRAWN
|
||||
static float startTime, endTime, minimumTime = 1.0f / this->m_context.settings.render.maximumFPS;
|
||||
// get the start time of the frame
|
||||
startTime = this->getRenderTime ();
|
||||
|
||||
if (wl_display_dispatch(m_waylandContext.display) == -1)
|
||||
m_requestedExit = true;
|
||||
|
||||
m_frameCounter ++;
|
||||
|
||||
endTime = this->getRenderTime ();
|
||||
|
||||
// ensure the frame time is correct to not overrun FPS
|
||||
if ((endTime - startTime) < minimumTime)
|
||||
usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
Detectors::CFullScreenDetector& CWaylandOpenGLDriver::getFullscreenDetector ()
|
||||
|
@ -106,6 +106,7 @@ namespace WallpaperEngine::Render::Drivers
|
||||
void finishEGL();
|
||||
|
||||
uint32_t m_frameCounter;
|
||||
CApplicationContext& m_context;
|
||||
|
||||
std::chrono::high_resolution_clock::time_point renderStart = std::chrono::high_resolution_clock::now();
|
||||
};
|
||||
|
@ -158,6 +158,8 @@ void CX11OpenGLDriver::dispatchEventQueue()
|
||||
this->m_output->getImageBuffer ()
|
||||
);
|
||||
|
||||
// TODO: FRAMETIME CONTROL SHOULD GO BACK TO THE CWALLPAPAERAPPLICATION ONCE ACTUAL PARTICLES ARE IMPLEMENTED
|
||||
// TODO: AS THOSE, MORE THAN LIKELY, WILL REQUIRE OF A DIFFERENT PROCESSING RATE
|
||||
// update the output with the given image
|
||||
this->m_output->updateRender ();
|
||||
// do buffer swapping first
|
||||
|
@ -104,11 +104,6 @@ static void surfaceFrameCallback(void *data, struct wl_callback *cb, uint32_t ti
|
||||
viewport->rendering = false;
|
||||
|
||||
float renderTime = viewport->getDriver ()->getRenderTime();
|
||||
|
||||
if ((renderTime - viewport->lastTime) < viewport->minimumTime)
|
||||
usleep ((viewport->minimumTime - (renderTime - viewport->lastTime)) * CLOCKS_PER_SEC);
|
||||
|
||||
viewport->lastTime = renderTime;
|
||||
}
|
||||
|
||||
const struct wl_callback_listener frameListener =
|
||||
@ -184,8 +179,6 @@ void CWaylandOutputViewport::setupLS ()
|
||||
if (eglMakeCurrent(m_driver->getEGLContext ()->display, eglSurface, eglSurface, m_driver->getEGLContext ()->context) == EGL_FALSE)
|
||||
sLog.exception("Failed to make egl current");
|
||||
|
||||
minimumTime = 1.0f / m_driver->getApp ().getContext().settings.render.maximumFPS;
|
||||
|
||||
this->m_driver->getOutput ().reset ();
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,6 @@ namespace WallpaperEngine::Render::Drivers
|
||||
wl_cursor* pointer = nullptr;
|
||||
wl_surface* cursorSurface = nullptr;
|
||||
bool callbackInitialized = false;
|
||||
float lastTime, minimumTime;
|
||||
|
||||
void setupLS ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user