summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton <anton@picapica.im>2026-11-27 04:36:15 +0400
committerAnton <anton@picapica.im>2026-11-27 04:36:15 +0400
commitcf57b9c33311a646611599f9f9dca1f4523451be (patch)
treeab79665ce6ef294f14ff0da961c7f7f374ac3201
parenta43b9038f90d17ec522242bcbed21f0a3af464a2 (diff)
downloadpica-pica-cf57b9c33311a646611599f9f9dca1f4523451be.tar.gz
pica-pica-cf57b9c33311a646611599f9f9dca1f4523451be.zip
pica-client: fix VAAPI video rendering on highdpi setups with scaling
-rw-r--r--pica-client/vaapivideowidget.cpp12
-rw-r--r--pica-client/vaapivideowidget.h1
-rw-r--r--pica-client/vaapix11widget.cpp9
3 files changed, 14 insertions, 8 deletions
diff --git a/pica-client/vaapivideowidget.cpp b/pica-client/vaapivideowidget.cpp
index 1f3f3a6..a685ecd 100644
--- a/pica-client/vaapivideowidget.cpp
+++ b/pica-client/vaapivideowidget.cpp
@@ -334,6 +334,13 @@ bool VaapiVideoWidget::importFrame()
void VaapiVideoWidget::paintGL()
{
+ // The framebuffer is in real pixels, width() and height() are in Qt's
+ // device-independent ones - the two differ by the display scale factor,
+ // which Qt 6 always applies. Set here rather than in resizeGL() so that
+ // it follows the widget to a screen with a different scale as well.
+ const qreal dpr = devicePixelRatioF();
+ glViewport(0, 0, qRound(width() * dpr), qRound(height() * dpr));
+
glClear(GL_COLOR_BUFFER_BIT);
if (!m_working || !m_program || !m_frame)
@@ -404,9 +411,4 @@ void VaapiVideoWidget::paintGL()
releaseImports();
}
-void VaapiVideoWidget::resizeGL(int w, int h)
-{
- glViewport(0, 0, w, h);
-}
-
#endif // HAVE_VAAPI
diff --git a/pica-client/vaapivideowidget.h b/pica-client/vaapivideowidget.h
index 9ea7a50..cfeca3e 100644
--- a/pica-client/vaapivideowidget.h
+++ b/pica-client/vaapivideowidget.h
@@ -62,7 +62,6 @@ signals:
protected:
void initializeGL() override;
void paintGL() override;
- void resizeGL(int w, int h) override;
private:
// Builds the two textures for the current frame out of the surface's
diff --git a/pica-client/vaapix11widget.cpp b/pica-client/vaapix11widget.cpp
index 0788577..8d026e3 100644
--- a/pica-client/vaapix11widget.cpp
+++ b/pica-client/vaapix11widget.cpp
@@ -178,8 +178,13 @@ bool VaapiX11Widget::putFrame()
// Letterbox rather than stretch, matching what the software path does with
// Qt::KeepAspectRatio. Everything the picture does not cover keeps the
// window's black background.
- int windowWidth = width();
- int windowHeight = height();
+ //
+ // vaPutSurface() works in the X window's real pixels, while width() and
+ // height() are in Qt's device-independent ones - the two differ by the
+ // display scale factor, which Qt 6 always applies.
+ const qreal dpr = devicePixelRatioF();
+ int windowWidth = qRound(width() * dpr);
+ int windowHeight = qRound(height() * dpr);
int destWidth = windowWidth;
int destHeight = (int)((qint64)windowWidth * frameHeight / frameWidth);