fixup stutter in rendering with toplevel_export

This commit is contained in:
vaxerski 2023-02-16 22:51:34 +00:00
parent f3d1ab55a2
commit dbfa6eea7b
2 changed files with 15 additions and 6 deletions

View file

@ -177,6 +177,8 @@ void Events::listener_monitorFrame(void* owner, void* data) {
}
}
g_pProtocolManager->m_pToplevelExportProtocolManager->onMonitorRender(PMONITOR); // dispatch any toplevel sharing
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
@ -285,8 +287,6 @@ void Events::listener_monitorFrame(void* owner, void* data) {
g_pHyprOpenGL->end();
g_pProtocolManager->m_pToplevelExportProtocolManager->onMonitorRender(PMONITOR); // dispatch any toplevel sharing
// calc frame damage
pixman_region32_t frameDamage;
pixman_region32_init(&frameDamage);

View file

@ -347,6 +347,13 @@ bool CToplevelExportProtocolManager::copyFrameShm(SToplevelFrame* frame, timespe
pixman_region32_t fakeDamage;
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10);
if (!wlr_output_attach_render(PMONITOR->output, nullptr)) {
Debug::log(ERR, "[toplevel_export] Couldn't attach render");
pixman_region32_fini(&fakeDamage);
wlr_buffer_end_data_ptr_access(frame->buffer);
return false;
}
g_pHyprOpenGL->begin(PMONITOR, &fakeDamage, true);
g_pHyprOpenGL->clear(CColor(0, 0, 0, 1.0));
@ -358,7 +365,7 @@ bool CToplevelExportProtocolManager::copyFrameShm(SToplevelFrame* frame, timespe
// copy pixels
const auto PFORMAT = get_gles2_format_from_drm(format);
if (!PFORMAT) {
Debug::log(ERR, "Cannot read pixels, unsupported format %x", PFORMAT);
Debug::log(ERR, "[toplevel_export] Cannot read pixels, unsupported format %x", PFORMAT);
g_pHyprOpenGL->end();
pixman_region32_fini(&fakeDamage);
wlr_buffer_end_data_ptr_access(frame->buffer);
@ -373,6 +380,8 @@ bool CToplevelExportProtocolManager::copyFrameShm(SToplevelFrame* frame, timespe
g_pHyprOpenGL->end();
wlr_output_rollback(PMONITOR->output);
pixman_region32_fini(&fakeDamage);
wlr_buffer_end_data_ptr_access(frame->buffer);