diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2013-10-08 14:55:28 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-09 13:52:58 +0200 |
commit | 80cd06fd9d26aa7df02f71e001b449d65bb5b7a3 (patch) | |
tree | 240ef609bab7f481e7b86cd6ad625b457de38c28 /src/plugins/platforms/eglfs/qeglfswindow.cpp | |
parent | 8d2c6206fdf564aa75680f4fea58e31d26a3d6dd (diff) |
eglfs: Separate compositor and improve raster window support
Separating the compositor into a separate source file improves the
chances of possible future reuse and paves the way to supporting
multiple GL windows. Tooltips are now working too. Implemented a few
window functions like raise() and lower(). Fixed the qFatal for
multiple GL windows to be raised in non-SDK based Android builds too.
Change-Id: Id94d2fb2a4382766f3d130eebe1e6f397a535852
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfswindow.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfswindow.cpp | 87 |
1 files changed, 61 insertions, 26 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 17ab68f747..70f0e437b2 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -42,9 +42,11 @@ #include "qeglfswindow.h" #include "qeglfshooks.h" #include "qeglfscursor.h" +#include "qeglfsbackingstore.h" #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformintegration.h> #include <private/qguiapplication_p.h> +#include <QtGui/QOpenGLContext> #include <QtPlatformSupport/private/qeglconvenience_p.h> @@ -99,18 +101,21 @@ void QEglFSWindow::create() if (window()->surfaceType() == QSurface::RasterSurface) m_flags |= IsRaster; - // Stop if there is already a raster root window backed by a native window and - // surface. Other raster windows will not have their own native window, surface and - // context. Instead, they will be composited onto the root window's surface. - if (screen()->primarySurface() != EGL_NO_SURFACE) { - if (m_flags.testFlag(IsRaster) && screen()->rootWindow()->m_flags.testFlag(IsRaster)) + // Stop if there is already a window backed by a native window and surface. Additional + // raster windows will not have their own native window, surface and context. Instead, + // they will be composited onto the root window's surface. + QEglFSScreen *screen = this->screen(); + if (screen->primarySurface() != EGL_NO_SURFACE) { + if (m_flags.testFlag(IsRaster) && screen->rootWindow()->m_flags.testFlag(IsRaster)) return; -#ifndef Q_OS_ANDROID +#if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK) // We can have either a single OpenGL window or multiple raster windows. // Other combinations cannot work. qFatal("EGLFS: OpenGL windows cannot be mixed with others."); #endif + + return; } window()->setSurfaceType(QSurface::OpenGLSurface); @@ -118,31 +123,40 @@ void QEglFSWindow::create() setGeometry(QRect()); // will become fullscreen QWindowSystemInterface::handleExposeEvent(window(), geometry()); - EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display(); + EGLDisplay display = static_cast<QEglFSScreen *>(screen)->display(); QSurfaceFormat platformFormat = QEglFSHooks::hooks()->surfaceFormatFor(window()->requestedFormat()); m_config = QEglFSIntegration::chooseConfig(display, platformFormat); m_format = q_glFormatFromConfig(display, m_config); resetSurface(); - if (screen()->primarySurface() == EGL_NO_SURFACE) { - screen()->setPrimarySurface(m_surface); - m_flags |= IsRasterRoot; + screen->setPrimarySurface(m_surface); + + if (m_flags.testFlag(IsRaster)) { + QOpenGLContext *context = new QOpenGLContext(QGuiApplication::instance()); + context->setFormat(window()->requestedFormat()); + context->setScreen(window()->screen()); + context->create(); + screen->setRootContext(context); } } void QEglFSWindow::destroy() { + QEglFSScreen *screen = this->screen(); if (m_flags.testFlag(HasNativeWindow)) { - QEglFSCursor *cursor = static_cast<QEglFSCursor *>(screen()->cursor()); + QEglFSCursor *cursor = static_cast<QEglFSCursor *>(screen->cursor()); if (cursor) cursor->resetResources(); - if (screen()->primarySurface() == m_surface) - screen()->setPrimarySurface(EGL_NO_SURFACE); + + if (screen->primarySurface() == m_surface) + screen->setPrimarySurface(EGL_NO_SURFACE); + invalidateSurface(); } + m_flags = 0; - screen()->removeWindow(this); + screen->removeWindow(this); } // The virtual functions resetSurface and invalidateSurface may get overridden @@ -182,20 +196,15 @@ void QEglFSWindow::setVisible(bool visible) } else { screen()->removeWindow(this); windows = screen()->windows(); - // try activating the window below if (windows.size()) windows.last()->requestActivateWindow(); } } - // trigger an update - QEglFSWindow *rootWin = screen()->rootWindow(); - if (rootWin) { - QWindowSystemInterface::handleExposeEvent(rootWin->window(), rootWin->window()->geometry()); - QWindowSystemInterface::flushWindowSystemEvents(); - } + QWindowSystemInterface::handleExposeEvent(window(), window()->geometry()); - QPlatformWindow::setVisible(visible); + if (visible) + QWindowSystemInterface::flushWindowSystemEvents(); } void QEglFSWindow::setGeometry(const QRect &r) @@ -230,13 +239,31 @@ WId QEglFSWindow::winId() const void QEglFSWindow::requestActivateWindow() { + if (window()->type() != Qt::Desktop) + screen()->moveToTop(this); + + QWindowSystemInterface::handleWindowActivated(window()); + QWindowSystemInterface::handleExposeEvent(window(), window()->geometry()); +} + +void QEglFSWindow::raise() +{ if (window()->type() != Qt::Desktop) { - // move to the end of the list, to be on top - screen()->removeWindow(this); - screen()->addWindow(this); + screen()->moveToTop(this); + QWindowSystemInterface::handleExposeEvent(window(), window()->geometry()); } +} - QWindowSystemInterface::handleWindowActivated(window()); +void QEglFSWindow::lower() +{ + QList<QEglFSWindow *> windows = screen()->windows(); + if (window()->type() != Qt::Desktop && windows.count() > 1) { + int idx = windows.indexOf(this); + if (idx > 0) { + screen()->changeWindowIndex(this, idx - 1); + QWindowSystemInterface::handleExposeEvent(windows.last()->window(), windows.last()->geometry()); + } + } } EGLSurface QEglFSWindow::surface() const @@ -259,4 +286,12 @@ QEglFSScreen *QEglFSWindow::screen() const return static_cast<QEglFSScreen *>(QPlatformWindow::screen()); } +uint QEglFSWindow::texture() const +{ + if (m_backingStore) + return m_backingStore->texture(); + + return 0; +} + QT_END_NAMESPACE |