summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-07-28 11:59:06 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-08-01 15:29:38 +0000
commitc4b4eba188d2fc0273aaa38533e19dcbd4cfc7be (patch)
treebe5d7b72874a17bded380b8da9535de01be2edc4 /src/plugins/platforms/eglfs
parent97c00e66c8ce3fff0f3bb748d3f3c290b30dd296 (diff)
eglfs: Add support for raster content rotation
Running QWidget or other raster window-based apps with QT_QPA_EGLFS_ROTATION=180 will now flip the screen as expected. In addition, 90 and -90 are supported too. These will affect the reported screen geometry as well. The OpenGL mouse cursor is repositioned and rotated accordingly. For true OpenGL content the rotation is ignored. Hardware mouse cursors (DRM) ignore it as well for the time being. [ChangeLog][Platform Specific Changes] QWidget-based applications running on the eglfs platform plugin can now request 180 or 90 degrees rotated output by setting the QT_QPA_EGLFS_ROTATION environment variable. Task-number: QTBUG-39959 Change-Id: I3570b515d0233c6c6a0e813899b935ee222eab62 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins/platforms/eglfs')
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscursor.cpp9
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscursor_p.h3
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen.cpp25
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen_p.h1
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow.cpp6
5 files changed, 41 insertions, 3 deletions
diff --git a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
index ffee21a9b0..7c1f11372a 100644
--- a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
@@ -72,6 +72,10 @@ QEglFSCursor::QEglFSCursor(QPlatformScreen *screen)
if (!m_visible)
return;
+ int rotation = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION");
+ if (rotation)
+ m_rotationMatrix.rotate(rotation, 0, 0, 1);
+
// Try to load the cursor atlas. If this fails, m_visible is set to false and
// paintOnScreen() and setCurrentCursor() become no-ops.
initCursorAtlas();
@@ -129,9 +133,10 @@ void QEglFSCursor::createShaderPrograms()
"attribute highp vec2 vertexCoordEntry;\n"
"attribute highp vec2 textureCoordEntry;\n"
"varying highp vec2 textureCoord;\n"
+ "uniform highp mat4 mat;\n"
"void main() {\n"
" textureCoord = textureCoordEntry;\n"
- " gl_Position = vec4(vertexCoordEntry, 1.0, 1.0);\n"
+ " gl_Position = mat * vec4(vertexCoordEntry, 1.0, 1.0);\n"
"}\n";
static const char *textureFragmentProgram =
@@ -149,6 +154,7 @@ void QEglFSCursor::createShaderPrograms()
m_program->link();
m_textureEntry = m_program->uniformLocation("texture");
+ m_matEntry = m_program->uniformLocation("mat");
}
void QEglFSCursor::createCursorTexture(uint *texture, const QImage &image)
@@ -492,6 +498,7 @@ void QEglFSCursor::draw(const QRectF &r)
m_program->setAttributeArray(1, textureCoordinates, 2);
m_program->setUniformValue(m_textureEntry, 0);
+ m_program->setUniformValue(m_matEntry, m_rotationMatrix);
glDisable(GL_CULL_FACE);
glFrontFace(GL_CCW);
diff --git a/src/plugins/platforms/eglfs/api/qeglfscursor_p.h b/src/plugins/platforms/eglfs/api/qeglfscursor_p.h
index bb30d53d6c..f72e4c0374 100644
--- a/src/plugins/platforms/eglfs/api/qeglfscursor_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfscursor_p.h
@@ -54,6 +54,7 @@
#include "qeglfsglobal.h"
#include <qpa/qplatformcursor.h>
#include <qpa/qplatformscreen.h>
+#include <QtGui/QMatrix4x4>
#include <QtGui/QOpenGLFunctions>
#include <QtGui/private/qinputdevicemanager_p.h>
@@ -138,8 +139,10 @@ private:
QEglFSScreen *m_screen;
QOpenGLShaderProgram *m_program;
int m_textureEntry;
+ int m_matEntry;
QEglFSCursorDeviceListener *m_deviceListener;
bool m_updateRequested;
+ QMatrix4x4 m_rotationMatrix;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
index d636a783ec..47ef2f64e7 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
@@ -65,6 +65,31 @@ QEglFSScreen::~QEglFSScreen()
QRect QEglFSScreen::geometry() const
{
+ QRect r = geometryForSurface();
+
+ static int rotation = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION");
+ switch (rotation) {
+ case 0:
+ case 180:
+ case -180:
+ break;
+ case 90:
+ case -90: {
+ int h = r.height();
+ r.setHeight(r.width());
+ r.setWidth(h);
+ break;
+ }
+ default:
+ qWarning("Invalid rotation %d specified in QT_QPA_EGLFS_ROTATION", rotation);
+ break;
+ }
+
+ return r;
+}
+
+QRect QEglFSScreen::geometryForSurface() const
+{
return QRect(QPoint(0, 0), qt_egl_device_integration()->screenSize());
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
index 092d853ffd..232525fae3 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
@@ -68,6 +68,7 @@ public:
~QEglFSScreen();
QRect geometry() const Q_DECL_OVERRIDE;
+ QRect geometryForSurface() const;
int depth() const Q_DECL_OVERRIDE;
QImage::Format format() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
index f602c1b976..74723955c6 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
@@ -142,7 +142,8 @@ void QEglFSWindow::create()
context->setScreen(window()->screen());
if (Q_UNLIKELY(!context->create()))
qFatal("EGLFS: Failed to create compositing context");
- compositor->setTarget(context, window());
+ compositor->setTarget(context, window(), screen->geometryForSurface());
+ compositor->setRotation(qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION"));
// If there is a "root" window into which raster and QOpenGLWidget content is
// composited, all other contexts must share with its context.
if (!qt_gl_global_share_context()) {
@@ -189,7 +190,8 @@ void QEglFSWindow::resetSurface()
m_config = QEglFSDeviceIntegration::chooseConfig(display, platformFormat);
m_format = q_glFormatFromConfig(display, m_config, platformFormat);
- m_window = qt_egl_device_integration()->createNativeWindow(this, screen()->geometry().size(), m_format);
+ const QSize surfaceSize = screen()->geometryForSurface().size();
+ m_window = qt_egl_device_integration()->createNativeWindow(this, surfaceSize, m_format);
m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL);
}