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/qeglfsscreen.cpp | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/eglfs/qeglfsscreen.cpp') 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); -- cgit v1.2.3