Skip to content

Commit

Permalink
Patch qt5base to allow configuration of screen rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
icedream committed Jun 11, 2022
1 parent 942722c commit 10b7bc8
Showing 1 changed file with 135 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
From f0e27ab344952596c11abf84e54e0925243039ad Mon Sep 17 00:00:00 2001
From: Carl Kittelberger <[email protected]>
Date: Sat, 11 Jun 2022 15:13:09 +0200
Subject: [PATCH] package/qt5/qt5base: Allow configuration of screen rotation
in linuxfb.

---
...ration-of-screen-rotation-in-linuxfb.patch | 115 ++++++++++++++++++
1 file changed, 115 insertions(+)
create mode 100644 package/qt5/qt5base/A000-Allow-configuration-of-screen-rotation-in-linuxfb.patch

diff --git a/package/qt5/qt5base/A000-Allow-configuration-of-screen-rotation-in-linuxfb.patch b/package/qt5/qt5base/A000-Allow-configuration-of-screen-rotation-in-linuxfb.patch
new file mode 100644
index 0000000000..058d0e45d3
--- /dev/null
+++ b/package/qt5/qt5base/A000-Allow-configuration-of-screen-rotation-in-linuxfb.patch
@@ -0,0 +1,115 @@
+From ca5418769e21e36a2ad5437f663f5de155eef033 Mon Sep 17 00:00:00 2001
+From: Carl Kittelberger <[email protected]>
+Date: Sat, 11 Jun 2022 15:09:19 +0200
+Subject: [PATCH] Allow configuration of screen rotation in linuxfb.
+
+---
+ .../platforms/linuxfb/qlinuxfbscreen.cpp | 37 +++++++++++++++++--
+ .../platforms/linuxfb/qlinuxfbscreen.h | 1 +
+ 2 files changed, 34 insertions(+), 4 deletions(-)
+
+diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+index cb8962d4b8..7f293d6b1c 100644
+--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
++++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+@@ -287,7 +287,7 @@ static void blankScreen(int fd, bool on)
+ }
+
+ QLinuxFbScreen::QLinuxFbScreen(const QStringList &args)
+- : mArgs(args), mFbFd(-1), mTtyFd(-1), mBlitter(0)
++ : mArgs(args), mFbFd(-1), mTtyFd(-1), mBlitter(0), mRotation(90)
+ {
+ mMmap.data = 0;
+ }
+@@ -313,6 +313,7 @@ bool QLinuxFbScreen::initialize()
+ QRegularExpression mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)"));
+ QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)"));
+ QRegularExpression offsetRx(QLatin1String("offset=(\\d+)x(\\d+)"));
++ QRegularExpression rotationRx(QLatin1String("rotation=(0|90|180|270)"));
+
+ QString fbDevice, ttyDevice;
+ QSize userMmSize;
+@@ -334,6 +335,8 @@ bool QLinuxFbScreen::initialize()
+ ttyDevice = match.captured(1);
+ else if (arg.contains(fbRx, &match))
+ fbDevice = match.captured(1);
++ else if (arg.contains(rotationRx, &match))
++ mRotation = match.captured(1).toInt();
+ }
+
+ if (fbDevice.isEmpty()) {
+@@ -372,9 +375,17 @@ bool QLinuxFbScreen::initialize()
+ mDepth = determineDepth(vinfo);
+ mBytesPerLine = finfo.line_length;
+ QRect geometry = determineGeometry(vinfo, userGeometry);
++ QRect originalGeometry = geometry;
++ if( mRotation == 90 || mRotation == 270 )
++ {
++ int tmp = geometry.width();
++ geometry.setWidth(geometry.height());
++ geometry.setHeight(tmp);
++ }
++
+ mGeometry = QRect(QPoint(0, 0), geometry.size());
+ mFormat = determineFormat(vinfo, mDepth);
+- mPhysicalSize = determinePhysicalSize(vinfo, userMmSize, geometry.size());
++ mPhysicalSize = determinePhysicalSize(vinfo, userMmSize, originalGeometry.size());
+
+ // mmap the framebuffer
+ mMmap.size = finfo.smem_len;
+@@ -384,11 +395,11 @@ bool QLinuxFbScreen::initialize()
+ return false;
+ }
+
+- mMmap.offset = geometry.y() * mBytesPerLine + geometry.x() * mDepth / 8;
++ mMmap.offset = originalGeometry.y() * mBytesPerLine + originalGeometry.x() * mDepth / 8;
+ mMmap.data = data + mMmap.offset;
+
+ QFbScreen::initializeCompositor();
+- mFbScreenImage = QImage(mMmap.data, geometry.width(), geometry.height(), mBytesPerLine, mFormat);
++ mFbScreenImage = QImage(mMmap.data, originalGeometry.width(), originalGeometry.height(), mBytesPerLine, mFormat);
+
+ mCursor = new QFbCursor(this);
+
+@@ -414,8 +425,26 @@ QRegion QLinuxFbScreen::doRedraw()
+
+ mBlitter->setCompositionMode(QPainter::CompositionMode_Source);
+ for (const QRect &rect : touched)
++ {
++ if (mRotation == 90 || mRotation == 270)
++ {
++ mBlitter->translate(mGeometry.height() / 2, mGeometry.width() / 2);
++ }
++ else if (mRotation == 180)
++ {
++ mBlitter->translate(mGeometry.width() / 2, mGeometry.height() / 2);
++ }
++ if (mRotation != 0)
++ {
++ mBlitter->rotate(mRotation);
++ mBlitter->translate(-mGeometry.width() / 2, -mGeometry.height() / 2);
++ }
++
+ mBlitter->drawImage(rect, mScreenImage, rect);
+
++ mBlitter->resetTransform();
++ }
++
+ return touched;
+ }
+
+diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
+index c7ce455e6a..385d29c365 100644
+--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
++++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
+@@ -64,6 +64,7 @@ private:
+ QStringList mArgs;
+ int mFbFd;
+ int mTtyFd;
++ int mRotation;
+
+ QImage mFbScreenImage;
+ int mBytesPerLine;
+--
+2.36.1
+
--
2.36.1

0 comments on commit 10b7bc8

Please sign in to comment.