From 3f93dc05aa0b39afdd1ebc20e2e2b05976db75f8 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Mon, 24 Aug 2026 16:35:09 +0800 Subject: [PATCH] [fix] eliminate Slint UI frame rate cap on macOS and Linux --- README.md | 3 ++- README_EN.md | 3 ++- scripts/linux/package_deb.sh | 2 +- src/gui/application/gui_application.cpp | 14 ++++++-------- xmake/targets.lua | 1 + 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2596618..b23e3a0 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,8 @@ sudo apt-get install -y \ libxinerama-dev libxcursor-dev libxi-dev libxfixes-dev libxv-dev \ libxtst-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev \ libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxcb-shm0-dev \ - libasound2-dev libsndio-dev libpulse-dev + libasound2-dev libsndio-dev libpulse-dev \ + libgl1-mesa-dev ``` Ubuntu 20.04 自带的 CMake 3.16 不满足要求时,xmake 会自动下载并使用 diff --git a/README_EN.md b/README_EN.md index e496ca1..a3ce71f 100644 --- a/README_EN.md +++ b/README_EN.md @@ -120,7 +120,8 @@ sudo apt-get install -y \ libxinerama-dev libxcursor-dev libxi-dev libxfixes-dev libxv-dev \ libxtst-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev \ libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxcb-shm0-dev \ - libasound2-dev libsndio-dev libpulse-dev + libasound2-dev libsndio-dev libpulse-dev \ + libgl1-mesa-dev ``` When Ubuntu 20.04's bundled CMake 3.16 is too old, xmake automatically diff --git a/scripts/linux/package_deb.sh b/scripts/linux/package_deb.sh index 775dfb3..a30c43e 100755 --- a/scripts/linux/package_deb.sh +++ b/scripts/linux/package_deb.sh @@ -160,7 +160,7 @@ Depends: libc6 (>= 2.31), libstdc++6 (>= 10), libx11-6, libxext6, libxrender1, libxft2, libxrandr2, libxfixes3, libxcb1, libxcb-randr0, libxcb-xtest0, libxcb-xinerama0, libxcb-shape0, libxcb-xkb1, libxcb-xfixes0, libxv1, libxtst6, $ALSA_RUNTIME_DEP, libsndio7.0, - libxcb-shm0, libpulse0, libdrm2, libdbus-1-3 + libxcb-shm0, libpulse0, libdrm2, libdbus-1-3, libgl1 Recommends: $RECOMMENDS Priority: optional Section: utils diff --git a/src/gui/application/gui_application.cpp b/src/gui/application/gui_application.cpp index 6aa2cde..7f9a615 100644 --- a/src/gui/application/gui_application.cpp +++ b/src/gui/application/gui_application.cpp @@ -36,9 +36,15 @@ #include "platform/tray/win_tray.h" #elif defined(__APPLE__) +#ifndef GL_SILENCE_DEPRECATION +#define GL_SILENCE_DEPRECATION +#endif +#include + #include "platform/tray/mac_tray.h" #include "platform/window_drag.h" #elif defined(__linux__) +#include #include #include #include @@ -53,9 +59,7 @@ namespace { using namespace std::chrono_literals; -#if _WIN32 constexpr GLint kGlClampToEdge = 0x812F; -#endif struct VideoRenderSize { int width = 0; @@ -860,7 +864,6 @@ struct GuiApplication::SlintUi { std::make_shared>(); std::unordered_map displayed_frame_sequence; std::vector scaled_video_frame; -#if _WIN32 std::mutex video_gl_mutex; std::vector video_gl_conversion_frame; std::vector video_gl_pending_frame; @@ -869,7 +872,6 @@ struct GuiApplication::SlintUi { VideoRenderSize video_gl_image_size; VideoRenderSize video_gl_pending_size; bool video_gl_pending_dirty = false; -#endif std::vector tab_order; std::vector tab_ids; std::string tab_model_signature; @@ -2837,7 +2839,6 @@ void GuiApplication::SyncStreamVideoFrame() { } } -#if _WIN32 uint32_t texture_id = 0; { std::lock_guard lock(ui_->video_gl_mutex); @@ -2878,7 +2879,6 @@ void GuiApplication::SyncStreamVideoFrame() { ++props->frame_count_; return; } -#endif slint::SharedPixelBuffer pixels(output_width, output_height); @@ -2897,7 +2897,6 @@ void GuiApplication::SyncStreamVideoFrame() { } void GuiApplication::ConfigureStreamVideoRenderer() { -#if _WIN32 if (!ui_ || !ui_->stream) { return; } @@ -2972,7 +2971,6 @@ void GuiApplication::ConfigureStreamVideoRenderer() { if (error.has_value()) { LOG_WARN("Slint OpenGL video renderer unavailable, using pixel buffers"); } -#endif } void GuiApplication::ScheduleNextVideoFrame() { diff --git a/xmake/targets.lua b/xmake/targets.lua index 7b89d33..2eb3cec 100644 --- a/xmake/targets.lua +++ b/xmake/targets.lua @@ -282,6 +282,7 @@ function setup_targets() add_files("src/gui/runtime/*.mm", "src/gui/platform/tray/*.mm", "src/gui/platform/window_drag_mac.mm") elseif is_os("linux") then + add_links("GL") add_files("src/gui/platform/tray/linux_tray.cpp") end