[vlc-commits] [Git][videolan/vlc][master] qt: fix video scaling with mutter wayland
Thomas Guillem (@tguillem)
gitlab at videolan.org
Fri Jan 19 13:46:00 UTC 2024
Thomas Guillem pushed to branch master at VideoLAN / VLC
Commits:
c08d8d3f by Pierre Lamot at 2024-01-19T13:25:40+00:00
qt: fix video scaling with mutter wayland
partially reverts 32836475cbe594eb55d26ee38c5db220246c010f
- - - - -
4 changed files:
- modules/gui/qt/maininterface/compositor_wayland.cpp
- modules/gui/qt/maininterface/compositor_wayland_module.c
- modules/gui/qt/maininterface/compositor_wayland_module.h
- modules/gui/qt/maininterface/videosurface.cpp
Changes:
=====================================
modules/gui/qt/maininterface/compositor_wayland.cpp
=====================================
@@ -34,6 +34,15 @@
namespace vlc {
+static qreal dprForWindow(QQuickWindow* window)
+{
+ QPlatformWindow* nativeWindow = window->handle();
+ if (!nativeWindow)
+ return 1.0;
+
+ return nativeWindow->devicePixelRatio();
+}
+
CompositorWayland::CompositorWayland(qt_intf_t *p_intf, QObject* parent)
: CompositorVideo(p_intf, parent)
{
@@ -108,7 +117,7 @@ bool CompositorWayland::makeMainInterface(MainCtx* mainCtx)
if (!interfaceSurface)
return false;
- m_waylandImpl->setupInterface(m_waylandImpl, interfaceSurface);
+ m_waylandImpl->setupInterface(m_waylandImpl, interfaceSurface, dprForWindow(m_qmlView.get()));
return commonGUICreate(m_qmlView.get(), m_qmlView.get(),
CompositorVideo::CAN_SHOW_PIP);
@@ -175,33 +184,27 @@ void CompositorWayland::windowDisable()
commonWindowDisable();
}
-static qreal dprForWindow(QQuickWindow* window)
-{
- qreal dpr = window->devicePixelRatio();
-
- QPlatformWindow* nativeWindow = window->handle();
- if (nativeWindow)
- dpr /= nativeWindow->devicePixelRatio();
-
- return dpr;
-}
-
void CompositorWayland::onSurfacePositionChanged(const QPointF& position)
{
QMargins margins = m_qmlView->frameMargins();
- qreal dpr = dprForWindow(m_qmlView.get());
+ qreal qtDpr = m_qmlView.get()->effectiveDevicePixelRatio();
+ qreal nativeDpr = dprForWindow(m_qmlView.get());
- m_waylandImpl->move(m_waylandImpl,
- margins.left() * dpr + position.x(),
- margins.top() * dpr + position.y());
+ m_waylandImpl->move(
+ m_waylandImpl,
+ (margins.left() * qtDpr + position.x() ) / nativeDpr,
+ (margins.top() * qtDpr + position.y() ) / nativeDpr
+ );
}
void CompositorWayland::onSurfaceSizeChanged(const QSizeF& size)
{
+ qreal nativeDpr = dprForWindow(m_qmlView.get());
+
m_waylandImpl->resize(m_waylandImpl,
- size.width(),
- size.height());
+ size.width() / nativeDpr,
+ size.height() / nativeDpr);
}
}
=====================================
modules/gui/qt/maininterface/compositor_wayland_module.c
=====================================
@@ -38,6 +38,8 @@ typedef struct
struct wl_surface* video_surface;
struct wl_subsurface* video_subsurface;
+
+ int buffer_scale;
} qtwayland_priv_t;
static void registry_global_cb(void* data, struct wl_registry* registry,
@@ -66,7 +68,7 @@ static const struct wl_registry_listener registry_cbs = {
registry_global_remove_cb,
};
-static int SetupInterface(qtwayland_t* obj, void* qpni_interface_surface)
+static int SetupInterface(qtwayland_t* obj, void* qpni_interface_surface, int scale)
{
qtwayland_priv_t* sys = (qtwayland_priv_t*)obj->p_sys;
@@ -74,6 +76,7 @@ static int SetupInterface(qtwayland_t* obj, void* qpni_interface_surface)
return VLC_EGENERIC;
sys->interface_surface = (struct wl_surface*)qpni_interface_surface;
+ sys->buffer_scale = scale;
return VLC_SUCCESS;
}
@@ -87,6 +90,8 @@ static int SetupVoutWindow(qtwayland_t* obj, vlc_window_t* wnd)
if (!sys->video_surface)
return VLC_EGENERIC;
+ wl_surface_set_buffer_scale(sys->video_surface, sys->buffer_scale);
+
struct wl_region* region = wl_compositor_create_region(sys->compositor);
if (!region)
{
=====================================
modules/gui/qt/maininterface/compositor_wayland_module.h
=====================================
@@ -30,7 +30,7 @@ typedef struct qtwayland_t
bool (*init)(struct qtwayland_t*, void* display);
- int (*setupInterface)(struct qtwayland_t*, void* video_surface );
+ int (*setupInterface)(struct qtwayland_t*, void* video_surface, int scale);
int (*setupVoutWindow)(struct qtwayland_t*, vlc_window_t* p_wnd);
void (*teardownVoutWindow)(struct qtwayland_t*);
=====================================
modules/gui/qt/maininterface/videosurface.cpp
=====================================
@@ -381,15 +381,7 @@ static qreal dprForWindow(QQuickWindow* quickWindow)
if (!window)
window = quickWindow;
- qreal dpr = window->devicePixelRatio();
-
-#ifdef QT5_DECLARATIVE_PRIVATE
- QPlatformWindow* nativeWindow = window->handle();
- if (nativeWindow)
- dpr /= nativeWindow->devicePixelRatio();
-#endif
-
- return dpr;
+ return window->devicePixelRatio();
}
void VideoSurface::onSurfaceSizeChanged()
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c08d8d3f830bb8aa65b83792429705478e7a17d9
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c08d8d3f830bb8aa65b83792429705478e7a17d9
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list