diff options
author | vaxerski <[email protected]> | 2023-02-16 22:51:34 +0000 |
---|---|---|
committer | vaxerski <[email protected]> | 2023-02-16 22:51:38 +0000 |
commit | dbfa6eea7bf7a6f153cadf970719081e4ef729ee (patch) | |
tree | f9eb49cc47b79f91c5aa2d3fee91eaa288d95ad4 | |
parent | f3d1ab55a2a804968b92641452875ba1f0b9dd71 (diff) | |
download | Hyprland-dbfa6eea7bf7a6f153cadf970719081e4ef729ee.tar.gz Hyprland-dbfa6eea7bf7a6f153cadf970719081e4ef729ee.zip |
fixup stutter in rendering with toplevel_export
-rw-r--r-- | src/events/Monitors.cpp | 4 | ||||
-rw-r--r-- | src/protocols/ToplevelExport.cpp | 17 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 11a83073..bbc86bee 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -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); diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index 98afb154..4d7f881a 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -74,8 +74,8 @@ static const struct hyprland_toplevel_export_manager_v1_interface toplevelExport static const struct hyprland_toplevel_export_frame_v1_interface toplevelFrameImpl = {.copy = handleCopyFrame, .destroy = handleDestroyFrame}; SToplevelClient* clientFromResource(wl_resource* resource) { - ASSERT(wl_resource_instance_of(resource, &hyprland_toplevel_export_manager_v1_interface, &toplevelExportManagerImpl)); - return (SToplevelClient*)wl_resource_get_user_data(resource); + ASSERT(wl_resource_instance_of(resource, &hyprland_toplevel_export_manager_v1_interface, &toplevelExportManagerImpl)); + return (SToplevelClient*)wl_resource_get_user_data(resource); } SToplevelFrame* frameFromResource(wl_resource* resource) { @@ -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); @@ -391,4 +400,4 @@ void CToplevelExportProtocolManager::onWindowUnmap(CWindow* pWindow) { if (f.pWindow == pWindow) f.pWindow = nullptr; } -}
\ No newline at end of file +} |