diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-09-03 10:53:14 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-09-03 10:56:00 (GMT) |
commit | 136c32ddb97a12eefcbbfebf63075237c07d4cd4 (patch) | |
tree | 825f3d4d5fcaaf867b37dc0581171dc2568fc4a1 /src/plugins/platforms/directfb | |
parent | 975490d721ca98251aefa7e7f50e6e54e63b79c1 (diff) | |
download | Qt-136c32ddb97a12eefcbbfebf63075237c07d4cd4.zip Qt-136c32ddb97a12eefcbbfebf63075237c07d4cd4.tar.gz Qt-136c32ddb97a12eefcbbfebf63075237c07d4cd4.tar.bz2 |
Lighthouse: Added QDirectFbGlContext
This is untested since I have no HW to test on, but its in the public
api, so that we have something to build on.
Diffstat (limited to 'src/plugins/platforms/directfb')
-rw-r--r-- | src/plugins/platforms/directfb/directfb.pro | 6 | ||||
-rw-r--r-- | src/plugins/platforms/directfb/qdirectfbglcontext.cpp | 58 | ||||
-rw-r--r-- | src/plugins/platforms/directfb/qdirectfbglcontext.h | 28 | ||||
-rw-r--r-- | src/plugins/platforms/directfb/qdirectfbwindow.cpp | 23 | ||||
-rw-r--r-- | src/plugins/platforms/directfb/qdirectfbwindow.h | 3 |
5 files changed, 115 insertions, 3 deletions
diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index 48128fb..65c49e3 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -19,14 +19,16 @@ SOURCES = main.cpp \ qdirectfbconvenience.cpp \ qdirectfbinput.cpp \ qdirectfbcursor.cpp \ - qdirectfbwindow.cpp + qdirectfbwindow.cpp \ + qdirectfbglcontext.cpp HEADERS = qdirectfbintegration.h \ qdirectfbwindowsurface.h \ qdirectfbblitter.h \ qdirectfbconvenience.h \ qdirectfbinput.h \ qdirectfbcursor.h \ - qdirectfbwindow.h + qdirectfbwindow.h \ + qdirectfbglcontext.h include(../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.cpp b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp new file mode 100644 index 0000000..fe96efe --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp @@ -0,0 +1,58 @@ +#include "qdirectfbglcontext.h" + +#include <directfb/directfbgl.h> + +#include <QDebug> + +QDirectFbGLContext::QDirectFbGLContext(IDirectFBGL *glContext) + : m_dfbGlContext(glContext) +{ + DFBResult result; + DFBGLAttributes glAttribs; + result = m_dfbGlContext->GetAttributes(glContext, &glAttribs); + if (result == DFB_OK) { + m_windowFormat.setDepthBufferSize(glAttribs.depth_size); + m_windowFormat.setStencilBufferSize(glAttribs.stencil_size); + + m_windowFormat.setRedBufferSize(glAttribs.red_size); + m_windowFormat.setGreenBufferSize(glAttribs.green_size); + m_windowFormat.setBlueBufferSize(glAttribs.blue_size); + m_windowFormat.setAlphaBufferSize(glAttribs.alpha_size); + + m_windowFormat.setAccumBufferSize(glAttribs.accum_red_size); + m_windowFormat.setAlpha(glAttribs.accum_alpha_size); + + m_windowFormat.setDoubleBuffer(glAttribs.double_buffer); + m_windowFormat.setStereo(glAttribs.stereo); + } +} + +void QDirectFbGLContext::makeCurrent() +{ + m_dfbGlContext->Lock(m_dfbGlContext); +} + +void QDirectFbGLContext::doneCurrent() +{ + m_dfbGlContext->Unlock(m_dfbGlContext); +} + +void *QDirectFbGLContext::getProcAddress(const QString &procName) +{ + void *proc; + DFBResult result = m_dfbGlContext->GetProcAddress(m_dfbGlContext,qPrintable(procName),&proc); + if (result == DFB_OK) + return proc; + return 0; +} + +void QDirectFbGLContext::swapBuffers() +{ +// m_dfbGlContext->Unlock(m_dfbGlContext); //maybe not in doneCurrent() + qDebug() << "Swap buffers"; +} + +QPlatformWindowFormat QDirectFbGLContext::platformWindowFormat() const +{ + return m_windowFormat; +} diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.h b/src/plugins/platforms/directfb/qdirectfbglcontext.h new file mode 100644 index 0000000..037587e --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbglcontext.h @@ -0,0 +1,28 @@ +#ifndef QDIRECTFBGLCONTEXT_H +#define QDIRECTFBGLCONTEXT_H + +#include <QPlatformGLContext> + +#include "qdirectfbconvenience.h" + +class QDirectFbGLContext : public QPlatformGLContext +{ +public: + explicit QDirectFbGLContext(IDirectFBGL *glContext); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void *getProcAddress(const QString &procName); + + QPlatformWindowFormat platformWindowFormat() const; + + +private: + IDirectFBGL *m_dfbGlContext; + + QPlatformWindowFormat m_windowFormat; + +}; + +#endif // QDIRECTFBGLCONTEXT_H diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp index 30e6f5a..f82fbd6 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp @@ -40,13 +40,14 @@ ****************************************************************************/ #include "qdirectfbwindow.h" #include "qdirectfbinput.h" +#include "qdirectfbglcontext.h" #include <QWidget> #include <directfb.h> QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler) - : QPlatformWindow(tlw), m_inputHandler(inputhandler) + : QPlatformWindow(tlw), m_inputHandler(inputhandler), m_context(0) { IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); DFBDisplayLayerConfig layerConfig; @@ -155,3 +156,23 @@ WId QDirectFbWindow::winId() const m_dfbWindow->GetID(m_dfbWindow, &id); return WId(id); } + +QPlatformGLContext *QDirectFbWindow::glContext() const +{ + if (!m_context) { + IDirectFBSurface *surface; + DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&surface); + if (result != DFB_OK) { + qWarning("could not retrieve surface in QDirectFbWindow::glContext()"); + return 0; + } + IDirectFBGL *gl; + result = surface->GetGL(surface,&gl); + if (result != DFB_OK) { + qWarning("could not retrieve IDirectFBGL in QDirectFbWindow::glContext()"); + return 0; + } + const_cast<QDirectFbWindow *>(this)->m_context = new QDirectFbGLContext(gl); + } + return m_context; +} diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h index b512afd..eaf5173 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.h +++ b/src/plugins/platforms/directfb/qdirectfbwindow.h @@ -65,10 +65,13 @@ public: void lower(); WId winId() const; + QPlatformGLContext *glContext() const; + private: IDirectFBWindow *m_dfbWindow; QDirectFbInput *m_inputHandler; + QPlatformGLContext *m_context; }; QT_END_NAMESPACE |