[fix] eliminate Slint UI frame rate cap on macOS and Linux

This commit is contained in:
dijunkun
2026-08-24 16:35:09 +08:00
parent 05885ecd48
commit 3f93dc05aa
5 changed files with 12 additions and 11 deletions
+2 -1
View File
@@ -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 会自动下载并使用
+2 -1
View File
@@ -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
+1 -1
View File
@@ -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
+6 -8
View File
@@ -36,9 +36,15 @@
#include "platform/tray/win_tray.h"
#elif defined(__APPLE__)
#ifndef GL_SILENCE_DEPRECATION
#define GL_SILENCE_DEPRECATION
#endif
#include <OpenGL/gl.h>
#include "platform/tray/mac_tray.h"
#include "platform/window_drag.h"
#elif defined(__linux__)
#include <GL/gl.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <unistd.h>
@@ -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<slint::VectorModel<slint::SharedString>>();
std::unordered_map<std::string, uint64_t> displayed_frame_sequence;
std::vector<uint8_t> scaled_video_frame;
#if _WIN32
std::mutex video_gl_mutex;
std::vector<uint8_t> video_gl_conversion_frame;
std::vector<uint8_t> 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<std::string> tab_order;
std::vector<std::string> 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<slint::Rgb8Pixel> 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() {
+1
View File
@@ -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