diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-01-06 14:51:37 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-17 14:30:48 +0100 |
commit | 328f2f9c35f3cc5e7049a060a608c3f72876484a (patch) | |
tree | 984f0f52446b95da5d7240122dcfbec02b0933b5 /src/plugins/platforms/eglfs/qeglfsintegration.cpp | |
parent | 93154216ca7c7a46836716150fe70987d28d6f3c (diff) |
eglfs: Move reusable functionality to eglconvenience
The cursor implementation is generic GL(ES) code that should be shared
by all the present and future egl-based embedded platform
plugins. Follow the pattern of QEGLPlatformContext and move this class
into eglconvenience as QEGLPlatformCursor.
Similarly, the common bits from the context implementation context are
moved back to EGLPlatformContext.
eglconvenience has now base classes for integration, screen, window,
etc. too. By using these, eglfs becomes much smaller and cleaner. This
also paves the way for creating new, separate EGL-based platform
plugins for Android, embedded Linux, etc.
Also added some documentation to each of the base classes.
devicediscovery is now fixed to be usable on any platform. The
implementation in this case is naturally a dummy one. This finally
allows using it from anywhere without myriads of ugly ifdefs.
Change-Id: I02946e360c04e02de7fe234a23a08320eff4ccf5
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfsintegration.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfsintegration.cpp | 189 |
1 files changed, 15 insertions, 174 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index d6832493f1..dfe240a888 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -42,15 +42,10 @@ #include "qeglfsintegration.h" #include "qeglfswindow.h" -#include "qeglfsbackingstore.h" -#include "qeglfscompositor.h" #include "qeglfshooks.h" #include <QtGui/private/qguiapplication_p.h> -#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> -#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> -#include <QtPlatformSupport/private/qgenericunixservices_p.h> #include <QtPlatformSupport/private/qeglconvenience_p.h> #include <QtPlatformSupport/private/qeglplatformcontext_p.h> #include <QtPlatformSupport/private/qeglpbuffer_p.h> @@ -68,8 +63,6 @@ #include <QtGui/QOffscreenSurface> #include <qpa/qplatformcursor.h> -#include <qpa/qplatforminputcontextfactory_p.h> - #include "qeglfscontext.h" #include <EGL/egl.h> @@ -82,10 +75,6 @@ static void initResources() QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() - : mFontDb(new QGenericUnixFontDatabase) - , mServices(new QGenericUnixServices) - , mScreen(0) - , mInputContext(0) { mDisableInputHandlers = qgetenv("QT_QPA_EGLFS_DISABLE_INPUT").toInt(); @@ -94,9 +83,6 @@ QEglFSIntegration::QEglFSIntegration() QEglFSIntegration::~QEglFSIntegration() { - QEglFSCompositor::destroy(); - delete mScreen; - eglTerminate(mDisplay); QEglFSHooks::hooks()->platformDestroy(); } @@ -106,33 +92,12 @@ bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) cons if (QEglFSHooks::hooks() && QEglFSHooks::hooks()->hasCapability(cap)) return true; - switch (cap) { - case ThreadedPixmaps: return true; - case OpenGL: return true; - case ThreadedOpenGL: return true; - case WindowManagement: return false; - default: return QPlatformIntegration::hasCapability(cap); - } -} - -QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window) const -{ - QWindowSystemInterface::flushWindowSystemEvents(); - QEglFSWindow *w = new QEglFSWindow(window); - w->create(); - if (window->type() != Qt::ToolTip) - w->requestActivateWindow(); - return w; -} - -QPlatformBackingStore *QEglFSIntegration::createPlatformBackingStore(QWindow *window) const -{ - return new QEglFSBackingStore(window); + return QEGLPlatformIntegration::hasCapability(cap); } QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { - return new QEglFSContext(QEglFSHooks::hooks()->surfaceFormatFor(context->format()), context->shareHandle(), mDisplay); + return new QEglFSContext(QEglFSHooks::hooks()->surfaceFormatFor(context->format()), context->shareHandle(), display()); } QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const @@ -141,164 +106,40 @@ QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOf return new QEGLPbuffer(screen->display(), QEglFSHooks::hooks()->surfaceFormatFor(surface->requestedFormat()), surface); } -QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const -{ - return mFontDb.data(); -} - -QAbstractEventDispatcher *QEglFSIntegration::createEventDispatcher() const -{ - return createUnixEventDispatcher(); -} - void QEglFSIntegration::initialize() { QEglFSHooks::hooks()->platformInit(); - EGLint major, minor; - - if (!eglBindAPI(EGL_OPENGL_ES_API)) { - qWarning("Could not bind GL_ES API\n"); - qFatal("EGL error"); - } - - mDisplay = eglGetDisplay(QEglFSHooks::hooks() ? QEglFSHooks::hooks()->platformDisplay() : EGL_DEFAULT_DISPLAY); - if (mDisplay == EGL_NO_DISPLAY) { - qWarning("Could not open egl display\n"); - qFatal("EGL error"); - } - - if (!eglInitialize(mDisplay, &major, &minor)) { - qWarning("Could not initialize egl display\n"); - qFatal("EGL error"); - } - - mScreen = createScreen(); - screenAdded(mScreen); - - mInputContext = QPlatformInputContextFactory::create(); + QEGLPlatformIntegration::initialize(); if (!mDisableInputHandlers) createInputHandlers(); } -QEglFSScreen *QEglFSIntegration::createScreen() const +EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const { - return new QEglFSScreen(mDisplay); + return QEglFSHooks::hooks()->platformDisplay(); } -QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const +QEGLPlatformScreen *QEglFSIntegration::createScreen() const { - switch (hint) - { - case QPlatformIntegration::ShowIsFullScreen: - return mScreen->rootWindow() == 0; - default: - return QPlatformIntegration::styleHint(hint); - } -} - -QPlatformServices *QEglFSIntegration::services() const -{ - return mServices.data(); + return new QEglFSScreen(display()); } -QPlatformNativeInterface *QEglFSIntegration::nativeInterface() const +QEGLPlatformWindow *QEglFSIntegration::createWindow(QWindow *window) const { - return const_cast<QEglFSIntegration *>(this); + return new QEglFSWindow(window); } -enum ResourceType { - EglDisplay, - EglWindow, - EglContext -}; - -static int resourceType(const QByteArray &key) -{ - static const QByteArray names[] = { // match ResourceType - QByteArrayLiteral("egldisplay"), - QByteArrayLiteral("eglwindow"), - QByteArrayLiteral("eglcontext") - }; - const QByteArray *end = names + sizeof(names) / sizeof(names[0]); - const QByteArray *result = std::find(names, end, key); - if (result == end) - result = std::find(names, end, key.toLower()); - return int(result - names); -} - -void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource) -{ - void *result = 0; - - switch (resourceType(resource)) { - case EglDisplay: - result = mScreen->display(); - break; - default: - break; - } - - return result; -} - -void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) -{ - void *result = 0; - - switch (resourceType(resource)) { - case EglDisplay: - if (window && window->handle()) - result = static_cast<QEglFSScreen *>(window->handle()->screen())->display(); - else - result = mScreen->display(); - break; - case EglWindow: - if (window && window->handle()) - result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->eglWindow()); - break; - default: - break; - } - - return result; -} - -void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) +QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const { - void *result = 0; - - switch (resourceType(resource)) { - case EglContext: - if (context->handle()) - result = static_cast<QEGLPlatformContext *>(context->handle())->eglContext(); - break; + switch (hint) + { + case QPlatformIntegration::ShowIsFullScreen: + return screen()->compositingWindow() == 0; default: - break; + return QPlatformIntegration::styleHint(hint); } - - return result; -} - -static void *eglContextForContext(QOpenGLContext *context) -{ - Q_ASSERT(context); - - QEGLPlatformContext *handle = static_cast<QEGLPlatformContext *>(context->handle()); - if (!handle) - return 0; - - return handle->eglContext(); -} - -QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::nativeResourceFunctionForContext(const QByteArray &resource) -{ - QByteArray lowerCaseResource = resource.toLower(); - if (lowerCaseResource == "get_egl_context") - return NativeResourceForContextFunction(eglContextForContext); - - return 0; } EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format) |