diff options
author | Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com> | 2012-04-10 22:06:48 -0700 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-11 09:24:58 +0200 |
commit | e60ca0de6015a8ee16c7be54d0d430252ef525c1 (patch) | |
tree | 0ec0d9f8b5160806ccfda4255105d8f29e2d008f /mkspecs/devices/linux-rasp-pi-g++ | |
parent | 42f3bf772bab75d639b9211d66a0e085538526e2 (diff) |
eglfs: rework hooks design
There are two problems with the current design:
1. if (hooks) hooks->foo() doesn't work in debug mode when no platform hook
is defined. The problem doesn't arise in release mode because the compiler
optimizes away the if (hooks) into a no-op since hooks is NULL when no
platform hook is defined.
2. Adding a new hook requires changing every platform's hook implementation.
New approach:
1. Define QEglFSHooks as a class with virtual functions. A stub file provides
the default implementation.
2. Platform hooks derive from above class and reimplement whatever is needed.
The filenames and variables have been changed to be more in line with the
Qt style.
Change-Id: I2eaaa5ad7c8b48a06361c4747d4f210c428c983f
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'mkspecs/devices/linux-rasp-pi-g++')
-rw-r--r-- | mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp (renamed from mkspecs/devices/linux-rasp-pi-g++/qeglfs_hooks.cpp) | 31 | ||||
-rw-r--r-- | mkspecs/devices/linux-rasp-pi-g++/qmake.conf | 2 |
2 files changed, 23 insertions, 10 deletions
diff --git a/mkspecs/devices/linux-rasp-pi-g++/qeglfs_hooks.cpp b/mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp index f17af55947..21052a5b63 100644 --- a/mkspecs/devices/linux-rasp-pi-g++/qeglfs_hooks.cpp +++ b/mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qeglfs_hooks.h" +#include "qeglfshooks.h" #include <bcm_host.h> @@ -55,23 +55,35 @@ static DISPMANX_DISPLAY_HANDLE_T dispman_display = 0; static DISPMANX_UPDATE_HANDLE_T dispman_update = 0; -void QEglFSHooks::platformInit() +class QEglFSPiHooks : public QEglFSHooks +{ +public: + virtual void platformInit(); + virtual void platformDestroy(); + virtual EGLNativeDisplayType platformDisplay() const; + virtual QSize screenSize() const; + virtual EGLNativeWindowType createNativeWindow(const QSize &size); + virtual void destroyNativeWindow(EGLNativeWindowType window); + virtual bool hasCapability(QPlatformIntegration::Capability cap) const; +}; + +void QEglFSPiHooks::platformInit() { bcm_host_init(); } -EGLNativeDisplayType QEglFSHooks::platformDisplay() const +EGLNativeDisplayType QEglFSPiHooks::platformDisplay() const { dispman_display = vc_dispmanx_display_open(0/* LCD */); return EGL_DEFAULT_DISPLAY; } -void QEglFSHooks::platformDestroy() +void QEglFSPiHooks::platformDestroy() { vc_dispmanx_display_close(dispman_display); } -QSize QEglFSHooks::screenSize() const +QSize QEglFSPiHooks::screenSize() const { //both mechanisms work #if 1 @@ -98,7 +110,7 @@ QSize QEglFSHooks::screenSize() const #endif } -EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size) +EGLNativeWindowType QEglFSPiHooks::createNativeWindow(const QSize &size) { VC_RECT_T dst_rect; dst_rect.x = 0; @@ -133,14 +145,14 @@ EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size) return eglWindow; } -void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window) +void QEglFSPiHooks::destroyNativeWindow(EGLNativeWindowType window) { EGL_DISPMANX_WINDOW_T *eglWindow = static_cast<EGL_DISPMANX_WINDOW_T *>(window); vc_dispmanx_element_remove(dispman_update, eglWindow->element); delete eglWindow; } -bool QEglFSHooks::hasCapability(QPlatformIntegration::Capability cap) const +bool QEglFSPiHooks::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { case QPlatformIntegration::ThreadedPixmaps: @@ -153,4 +165,5 @@ bool QEglFSHooks::hasCapability(QPlatformIntegration::Capability cap) const } } -QEglFSHooks platform_hooks; +QEglFSPiHooks eglFSPiHooks; +QEglFSHooks *platformHooks = &eglFSPiHooks; diff --git a/mkspecs/devices/linux-rasp-pi-g++/qmake.conf b/mkspecs/devices/linux-rasp-pi-g++/qmake.conf index 326d6b3b61..4c75e0b0b2 100644 --- a/mkspecs/devices/linux-rasp-pi-g++/qmake.conf +++ b/mkspecs/devices/linux-rasp-pi-g++/qmake.conf @@ -48,7 +48,7 @@ QMAKE_CFLAGS_RELEASE += \ QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfs_hooks.cpp +EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_pi.cpp # Sanity check deviceSanityCheckCompiler() |