From 24afb1097d6257063786a9e36b92e85adfa8ed74 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 16 Mar 2012 16:52:39 -0700 Subject: eglfs: Introduce hooks for the eglfs plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EGL provides an api to create a rendering context for khronos APIs on native surfaces. The board initialization and window creation is platform specific. This commit adds platform hooks/extensions to the EGLFS plugin and implements them for the Amlogic 8726M. The hook interface is internal and there are no ABI/API guarantees. EGLFS is now linked with -Wl,-no-undefined to make sure that a hook does not add unresolvable symbols. Change-Id: I7f4fcdb422aacbf00de468f4d8e85ae5368bfacf Reviewed-by: Girish Ramakrishnan Reviewed-by: Samuel Rødal --- src/plugins/platforms/eglfs/eglfs.pro | 11 +++- src/plugins/platforms/eglfs/qeglfs_hooks.h | 61 +++++++++++++++++++++++ src/plugins/platforms/eglfs/qeglfsintegration.cpp | 3 +- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 30 +++++++++-- src/plugins/platforms/eglfs/qeglfsscreen.h | 3 +- 5 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 src/plugins/platforms/eglfs/qeglfs_hooks.h (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index c12d612c98..89d56efc82 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -21,7 +21,16 @@ SOURCES = main.cpp \ HEADERS = qeglfsintegration.h \ qeglfswindow.h \ qeglfsbackingstore.h \ - qeglfsscreen.h + qeglfsscreen.h \ + qeglfs_hooks.h + +QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF + +!isEmpty(EGLFS_PLATFORM_HOOKS_SOURCES) { + HEADERS += $$EGLFS_PLATFORM_HOOKS_HEADERS + SOURCES += $$EGLFS_PLATFORM_HOOKS_SOURCES + DEFINES += EGLFS_PLATFORM_HOOKS +} CONFIG += egl qpa/genericunixfontdatabase diff --git a/src/plugins/platforms/eglfs/qeglfs_hooks.h b/src/plugins/platforms/eglfs/qeglfs_hooks.h new file mode 100644 index 0000000000..a30af9409f --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfs_hooks.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLFS_HOOKS_H +#define QEGLFS_HOOKS_H + +#include "qplatformintegration_qpa.h" +#include + +QT_BEGIN_NAMESPACE + +struct QEglFSHooks { + void platformInit(); + void platformDestroy(); + EGLNativeDisplayType platformDisplay() const; + QSize screenSize() const; + EGLNativeWindowType createNativeWindow(const QSize &size); + void destroyNativeWindow(EGLNativeWindowType window); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index ef889cd70d..d9214f87fe 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -43,6 +43,7 @@ #include "qeglfswindow.h" #include "qeglfsbackingstore.h" +#include "qeglfs_hooks.h" #include #include @@ -57,7 +58,7 @@ QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() - : mFontDb(new QGenericUnixFontDatabase()), mScreen(new QEglFSScreen(EGL_DEFAULT_DISPLAY)) + : mFontDb(new QGenericUnixFontDatabase()), mScreen(new QEglFSScreen) { screenAdded(mScreen); diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index fdffd96d6e..c7e983b0fb 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -41,6 +41,7 @@ #include "qeglfsscreen.h" #include "qeglfswindow.h" +#include "qeglfs_hooks.h" #include #include @@ -52,6 +53,13 @@ QT_BEGIN_NAMESPACE +#ifdef EGLFS_PLATFORM_HOOKS +extern QEglFSHooks platform_hooks; +static QEglFSHooks *hooks = &platform_hooks; +#else +static QEglFSHooks *hooks = 0; +#endif + // #define QEGL_EXTRA_DEBUG #ifdef QEGL_EXTRA_DEBUG @@ -104,16 +112,20 @@ public: } }; -QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) +QEglFSScreen::QEglFSScreen() : m_depth(32) , m_format(QImage::Format_Invalid) , m_platformContext(0) , m_surface(0) + , m_window(0) { #ifdef QEGL_EXTRA_DEBUG qWarning("QEglScreen %p\n", this); #endif + if (hooks) + hooks->platformInit(); + EGLint major, minor; if (!eglBindAPI(EGL_OPENGL_ES_API)) { @@ -121,7 +133,7 @@ QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) qFatal("EGL error"); } - m_dpy = eglGetDisplay(display); + m_dpy = eglGetDisplay(hooks ? hooks->platformDisplay() : EGL_DEFAULT_DISPLAY); if (m_dpy == EGL_NO_DISPLAY) { qWarning("Could not open egl display\n"); qFatal("EGL error"); @@ -151,7 +163,13 @@ QEglFSScreen::~QEglFSScreen() if (m_surface) eglDestroySurface(m_dpy, m_surface); + if (hooks) + hooks->destroyNativeWindow(m_window); + eglTerminate(m_dpy); + + if (hooks) + hooks->platformDestroy(); } void QEglFSScreen::createAndSetPlatformContext() const { @@ -185,14 +203,16 @@ void QEglFSScreen::createAndSetPlatformContext() EGLConfig config = q_configFromGLFormat(m_dpy, platformFormat); - EGLNativeWindowType eglWindow = 0; #ifdef Q_OPENKODE if (kdInitializeNV() == KD_ENOTINITIALIZED) { qFatal("Did not manage to initialize openkode"); } KDWindow *window = kdCreateWindow(m_dpy,config,0); - kdRealizeWindow(window,&eglWindow); + kdRealizeWindow(window, &m_window); +#else + if (hooks) + m_window = hooks->createNativeWindow(hooks->screenSize()); #endif #ifdef QEGL_EXTRA_DEBUG @@ -209,7 +229,7 @@ void QEglFSScreen::createAndSetPlatformContext() qWarning("\n"); #endif - m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL); + m_surface = eglCreateWindowSurface(m_dpy, config, m_window, NULL); if (m_surface == EGL_NO_SURFACE) { qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError()); eglTerminate(m_dpy); diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h index 30ef55f13f..66e600d7c2 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.h +++ b/src/plugins/platforms/eglfs/qeglfsscreen.h @@ -55,7 +55,7 @@ class QPlatformOpenGLContext; class QEglFSScreen : public QPlatformScreen //huh: FullScreenScreen ;) just to follow namespace { public: - QEglFSScreen(EGLNativeDisplayType display); + QEglFSScreen(); ~QEglFSScreen(); QRect geometry() const; @@ -76,6 +76,7 @@ private: QPlatformOpenGLContext *m_platformContext; EGLDisplay m_dpy; EGLSurface m_surface; + EGLNativeWindowType m_window; }; QT_END_NAMESPACE -- cgit v1.2.3