diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-03 06:46:44 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-03 10:00:12 (GMT) |
commit | c0eb289559705e15fe13013c72a218e647ad6d90 (patch) | |
tree | 1f734f40e39ebf0a40c8a44ee245fd5e306d2364 /src/plugins/platforms | |
parent | 6e0edcce4c215f01416a5ee8467b7abe4665e592 (diff) | |
download | Qt-c0eb289559705e15fe13013c72a218e647ad6d90.zip Qt-c0eb289559705e15fe13013c72a218e647ad6d90.tar.gz Qt-c0eb289559705e15fe13013c72a218e647ad6d90.tar.bz2 |
Make it possible to view what format a QPlatformGlContext has
QPlatformGlContext has now a pure virtual format getter.
The way its intended to work is that the tlw has a QPlatformWindowFormat
which is the requested format. Once you get the QPlatformGlContext of
the window, you can request the QPlatformWindowFormat of the context to
see what you really got.
Diffstat (limited to 'src/plugins/platforms')
6 files changed, 121 insertions, 5 deletions
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index c50101d..b3a4c53 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -1,5 +1,7 @@ #include "qeglconvenience.h" +QT_BEGIN_NAMESPACE + QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) { int redSize = format.redBufferSize(); @@ -228,3 +230,46 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW qWarning("Cant find EGLConfig, returning null config"); return 0; } + +QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config) +{ + QPlatformWindowFormat format; + EGLint redSize = 0; + EGLint greenSize = 0; + EGLint blueSize = 0; + EGLint alphaSize = 0; + EGLint depthSize = 0; + EGLint stencilSize = 0; + EGLint sampleCount = 0; + EGLint level = 0; + + eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); + eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); + eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); + eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); + eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); + eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); + eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); + eglGetConfigAttrib(display, config, EGL_LEVEL, &level); + + format.setRedBufferSize(redSize); + format.setGreenBufferSize(greenSize); + format.setBlueBufferSize(blueSize); + format.setAlphaBufferSize(alphaSize); + format.setDepthBufferSize(depthSize); + format.setStencilBufferSize(stencilSize); + format.setSamples(sampleCount); + format.setDirectRendering(true); // All EGL contexts are direct-rendered + format.setRgba(true); // EGL doesn't support colour index rendering + format.setStereo(false); // EGL doesn't support stereo buffers + format.setAccumBufferSize(0); // EGL doesn't support accululation buffers + + // Clear the EGL error state because some of the above may + // have errored out because the attribute is not applicable + // to the surface type. Such errors don't matter. + eglGetError(); + + return format; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index bd5a6d3..12731e1 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -46,9 +46,13 @@ #include <QtGui/QPlatformWindowFormat> #include <QtCore/QVector> +QT_BEGIN_NAMESPACE + QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes); EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format); +QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config); +QT_END_NAMESPACE #endif //QEGLCONVENIENCE_H diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index b3a5bba..87cd958 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -45,8 +45,11 @@ #include <QtGui/QPlatformWindow> +#include "qeglconvenience.h" + QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi) - : m_eglDisplay(display) + : QPlatformGLContext() + , m_eglDisplay(display) , m_eglSurface(surface) , m_eglApi(eglApi) { @@ -61,6 +64,8 @@ QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, E eglTerminate(m_eglDisplay); qFatal("EGL error"); } + + m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config); } QEGLPlatformContext::~QEGLPlatformContext() @@ -142,3 +147,8 @@ void QEGLPlatformContext::makeDefaultSaredContext() { setDefaultSharedContext(this); } + +QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const +{ + return m_windowFormat; +} diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index 2a49129..b0cbbe0 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -57,11 +57,15 @@ public: void* getProcAddress(const QString& procName); void makeDefaultSaredContext(); + + QPlatformWindowFormat platformWindowFormat() const; private: EGLContext m_eglContext; EGLDisplay m_eglDisplay; EGLSurface m_eglSurface; EGLenum m_eglApi; + + QPlatformWindowFormat m_windowFormat; }; #endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index e554e8d..57f9de4 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -125,6 +125,54 @@ GLXFBConfig QGLXGLContext::findConfig(const GLXFBConfig *configs, int configCoun return chosenConfig; } +QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config) +{ + QPlatformWindowFormat format; + int redSize = 0; + int greenSize = 0; + int blueSize = 0; + int alphaSize = 0; + int depthSize = 0; + int stencilSize = 0; + int sampleCount = 0; + int level = 0; + int rgba = 0; + int stereo = 0; + int accumSizeA = 0; + int accumSizeR = 0; + int accumSizeG = 0; + int accumSizeB = 0; + + glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); + glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); + glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); + glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); + glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); + glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); + glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleCount); + glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); + glXGetFBConfigAttrib(display, config, GLX_RGBA, &rgba); + glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB); + + format.setRedBufferSize(redSize); + format.setGreenBufferSize(greenSize); + format.setBlueBufferSize(blueSize); + format.setAlphaBufferSize(alphaSize); + format.setDepthBufferSize(depthSize); + format.setStencilBufferSize(stencilSize); + format.setSamples(sampleCount); + format.setDirectRendering(true); // We don't support anything else for now. + format.setRgba(rgba); + format.setStereo(stereo); + format.setAccumBufferSize(accumSizeA + accumSizeB + accumSizeG + accumSizeR); + + return format; +} + QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_xd(xd) @@ -159,6 +207,7 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow { GLXFBConfig config = findConfig(configs,confcount,format,xd); m_context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,shareGlxContext,TRUE); + m_windowFormat = QGLXGLContext::platformWindowFromGLXFBConfig(xd->display,config); XFree(configs); } else { qFatal("Warning no context created"); @@ -167,9 +216,6 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow #ifdef MYX11_DEBUG qDebug() << "QGLXGLContext::create context" << m_context; #endif - -// TODO: Populate the QGLFormat with the values of the GLXFBConfig - } QGLXGLContext::QGLXGLContext(MyDisplay *display, Drawable drawable, GLXContext context) @@ -266,4 +312,9 @@ void* QGLXGLContext::getProcAddress(const QString& procName) return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data())); } +QPlatformWindowFormat QGLXGLContext::platformWindowFormat() const +{ + return m_windowFormat; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index decbe36..5a98e25 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -68,14 +68,16 @@ public: GLXContext glxContext() {return m_context;} - + QPlatformWindowFormat platformWindowFormat() const; private: static QVector<int> buildSpec(const QPlatformWindowFormat &format); static GLXFBConfig findConfig(const GLXFBConfig *configs,int configCount, const QPlatformWindowFormat &format, const MyDisplay *xd); + static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config); MyDisplay *m_xd; Drawable m_drawable; GLXContext m_context; + QPlatformWindowFormat m_windowFormat; QGLXGLContext (MyDisplay *display, Drawable drawable, GLXContext context); static QMutex m_defaultSharedContextMutex; |