http://stevegigijoe.blogspot.tw/2015/03/qt5-eglfs-rotate-screen.html
今年升級到QT5.5發覺EGLFS相關的程式碼有些許更動,screen旋轉90度必須重寫.
網路上有大陸的網友已經完成這個功能,省了我不少時間.
http://blog.csdn.net/neyes/article/details/48517119
不過跟著實際修改後還是有點問題,因此我再多做了一些修改.
**************************************************
+++ ../buildroot/output/build/qt5base-5.5.0/src/platformsupport/platformcompositor/qopenglcompositor.cpp 2016-06-04 19:41:01.716707272 +0800
@@ -123,7 +123,12 @@
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
const QRect targetWindowRect(QPoint(0, 0), m_targetWindow->geometry().size());
+#if 0
glViewport(0, 0, targetWindowRect.width(), targetWindowRect.height());
+#else
+ // rotate 90
+ glViewport(0, 0, targetWindowRect.height(), targetWindowRect.width()); //swap width / height
+#endif
if (!m_blitter.isCreated())
m_blitter.create();
@@ -185,9 +190,14 @@
const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
+#if 0
const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
+#else
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
+ target.rotate(90, 0, 0, 1);
+#endif
const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect, rectInWindow.size(),
- QOpenGLTextureBlitter::OriginBottomLeft);
+ QOpenGLTextureBlitter::OriginBottomLeft);
blitter->blit(textures->textureId(idx), target, source);
}
@@ -213,13 +223,23 @@
if (textures->count() > 1 && i == textures->count() - 1) {
// Backingstore for a widget with QOpenGLWidget subwidgets
blend.set(true);
+#if 0
const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+#else
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ target.rotate(90, 0, 0, 1);
+#endif
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (textures->count() == 1) {
// A regular QWidget window
const bool translucent = window->sourceWindow()->requestedFormat().alphaBufferSize() > 0;
blend.set(translucent);
+#if 0
const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+#else
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ target.rotate(90, 0, 0, 1);
+#endif
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
// Texture from an FBO belonging to a QOpenGLWidget
**************************************************
--- output/build/qt5base-5.5.0/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp 2015-06-30 04:04:43.000000000 +0800
+++ ../buildroot/output/build/qt5base-5.5.0/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp 2016-05-30 14:43:28.698792014 +0800
@@ -53,8 +53,14 @@
mNativeDisplay = fbGetDisplayByIndex(framebufferIndex());
fbGetDisplayGeometry(mNativeDisplay, &width, &height);
+#if 0
mScreenSize.setHeight(height);
mScreenSize.setWidth(width);
+#else
+ // rotate 90
+ mScreenSize.setHeight(width);
+ mScreenSize.setWidth(height);
+#endif
}
QSize QEglFSVivIntegration::screenSize() const
@@ -71,8 +77,12 @@
{
Q_UNUSED(window)
Q_UNUSED(format)
-
+#if 0
EGLNativeWindowType eglWindow = fbCreateWindow(mNativeDisplay, 0, 0, size.width(), size.height());
+#else
+ // rotate 90
+ EGLNativeWindowType eglWindow = fbCreateWindow(mNativeDisplay, 0, 0, size.height(), size.width());
+#endif
return eglWindow;
}