diff options
Diffstat (limited to 'src/platformsupport')
6 files changed, 42 insertions, 54 deletions
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index a9973b642a..63f564c2d5 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE -QVector<EGLint> q_createConfigAttributesFromFormat(const QGuiGLFormat &format) +QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format) { int redSize = format.redBufferSize(); int greenSize = format.greenBufferSize(); @@ -70,7 +70,7 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QGuiGLFormat &format) // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that - // if the application sets the red/green/blue size to 5/6/5 on the QGuiGLFormat, + // if the application sets the red/green/blue size to 5/6/5 on the QSurfaceFormat, // they will probably get a 32-bit config, even when there's an RGB565 config available. // // Now normalize the values so -1 becomes 0 @@ -197,7 +197,7 @@ bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes) return false; } -EGLConfig q_configFromGLFormat(EGLDisplay display, const QGuiGLFormat &format, bool highestPixelFormat, int surfaceType) +EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType) { EGLConfig cfg = 0; QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format); @@ -259,9 +259,9 @@ EGLConfig q_configFromGLFormat(EGLDisplay display, const QGuiGLFormat &format, b return 0; } -QGuiGLFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config) +QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config) { - QGuiGLFormat format; + QSurfaceFormat format; EGLint redSize = 0; EGLint greenSize = 0; EGLint blueSize = 0; diff --git a/src/platformsupport/eglconvenience/qeglconvenience_p.h b/src/platformsupport/eglconvenience/qeglconvenience_p.h index 302aba318f..7b5b970415 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience_p.h +++ b/src/platformsupport/eglconvenience/qeglconvenience_p.h @@ -43,16 +43,16 @@ #define QEGLCONVENIENCE_H -#include <QtGui/QGuiGLFormat> +#include <QtGui/QSurfaceFormat> #include <QtCore/QVector> #include <EGL/egl.h> QT_BEGIN_NAMESPACE -QVector<EGLint> q_createConfigAttributesFromFormat(const QGuiGLFormat &format); +QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format); bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes); -EGLConfig q_configFromGLFormat(EGLDisplay display, const QGuiGLFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); -QGuiGLFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config); +EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); +QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config); bool q_hasEglExtension(EGLDisplay display,const char* extensionName); QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index bb2d167c81..0e61dd3486 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -47,13 +47,7 @@ #include <EGL/egl.h> -QEGLSurface::QEGLSurface(EGLSurface surface, const QGuiGLFormat &format) - : QPlatformGLSurface(format) - , m_eglSurface(surface) -{ -} - -QEGLPlatformContext::QEGLPlatformContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display, +QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display, EGLint eglClientVersion, EGLenum eglApi) : m_eglDisplay(display) , m_eglApi(eglApi) @@ -78,18 +72,18 @@ QEGLPlatformContext::QEGLPlatformContext(const QGuiGLFormat &format, QPlatformGL } } -bool QEGLPlatformContext::makeCurrent(const QPlatformGLSurface &surface) +bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface) { #ifdef QEGL_EXTRA_DEBUG qWarning("QEglContext::makeCurrent: %p\n",this); #endif eglBindAPI(m_eglApi); - EGLSurface eglSurface = static_cast<const QEGLSurface &>(surface).eglSurface(); + EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface); bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext); if (!ok) - qWarning("QEGLPlatformContext::makeCurrent: eglError: %d, this: %p \n", eglGetError(), this); + qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this); #ifdef QEGL_EXTRA_DEBUG static bool showDebug = true; if (showDebug) { @@ -134,13 +128,14 @@ void QEGLPlatformContext::doneCurrent() qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this); } -void QEGLPlatformContext::swapBuffers(const QPlatformGLSurface &surface) +void QEGLPlatformContext::swapBuffers(QPlatformSurface *surface) { #ifdef QEGL_EXTRA_DEBUG qWarning("QEglContext::swapBuffers:%p\n",this); #endif eglBindAPI(m_eglApi); - bool ok = eglSwapBuffers(m_eglDisplay, static_cast<const QEGLSurface &>(surface).eglSurface()); + EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface); + bool ok = eglSwapBuffers(m_eglDisplay, eglSurface); if (!ok) qWarning("QEGLPlatformContext::swapBuffers(): eglError: %d, this: %p \n", eglGetError(), this); } @@ -154,7 +149,7 @@ void (*QEGLPlatformContext::getProcAddress(const QByteArray &procName)) () return eglGetProcAddress(procName.constData()); } -QGuiGLFormat QEGLPlatformContext::format() const +QSurfaceFormat QEGLPlatformContext::format() const { return m_format; } diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index 9877b77e4e..56a873afcb 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -42,42 +42,35 @@ #ifndef QEGLPLATFORMCONTEXT_H #define QEGLPLATFORMCONTEXT_H +#include <QtGui/QPlatformWindow> #include <QtGui/QPlatformGLContext> #include <EGL/egl.h> -class QEGLSurface : public QPlatformGLSurface -{ -public: - QEGLSurface(EGLSurface surface, const QGuiGLFormat &format); - - virtual EGLSurface eglSurface() const { return m_eglSurface; } - -private: - EGLSurface m_eglSurface; -}; - class QEGLPlatformContext : public QPlatformGLContext { public: - QEGLPlatformContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display, + QEGLPlatformContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display, EGLint eglClientVersion = 2, EGLenum eglApi = EGL_OPENGL_ES_API); ~QEGLPlatformContext(); - bool makeCurrent(const QPlatformGLSurface &surface); + bool makeCurrent(QPlatformSurface *surface); void doneCurrent(); - void swapBuffers(const QPlatformGLSurface &surface); + void swapBuffers(QPlatformSurface *surface); void (*getProcAddress(const QByteArray &procName)) (); - QGuiGLFormat format() const; + QSurfaceFormat format() const; EGLContext eglContext() const; +protected: + virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0; + private: EGLContext m_eglContext; EGLDisplay m_eglDisplay; EGLenum m_eglApi; - QGuiGLFormat m_format; + QSurfaceFormat m_format; }; #endif //QEGLPLATFORMCONTEXT_H diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index fc506df3bd..ce0c49d93f 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -70,7 +70,7 @@ enum { #undef FontChange #endif -QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit) +QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit) { QVector<int> spec(48); int i = 0; @@ -88,7 +88,7 @@ QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit) spec[i++] = GLX_ALPHA_SIZE; spec[i++] = format.alphaBufferSize(); } - spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QGuiGLFormat::SingleBuffer ? True : False; + spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QSurfaceFormat::SingleBuffer ? True : False; spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; @@ -111,11 +111,11 @@ QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit) return spec; } -GLXFBConfig qglx_findConfig(Display *display, int screen , const QGuiGLFormat &format, int drawableBit) +GLXFBConfig qglx_findConfig(Display *display, int screen , const QSurfaceFormat &format, int drawableBit) { bool reduced = true; GLXFBConfig chosenConfig = 0; - QGuiGLFormat reducedFormat = format; + QSurfaceFormat reducedFormat = format; while (!chosenConfig && reduced) { QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; @@ -147,7 +147,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QGuiGLFormat &f XFree(configs); } - reducedFormat = qglx_reduceGuiGLFormat(reducedFormat,&reduced); + reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced); } if (!chosenConfig) @@ -156,16 +156,16 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QGuiGLFormat &f return chosenConfig; } -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QGuiGLFormat &format) +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QSurfaceFormat &format) { GLXFBConfig config = qglx_findConfig(display,screen,format); XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config); return visualInfo; } -QGuiGLFormat qglx_guiGLFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) +QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) { - QGuiGLFormat format; + QSurfaceFormat format; int redSize = 0; int greenSize = 0; int blueSize = 0; @@ -203,9 +203,9 @@ QGuiGLFormat qglx_guiGLFormatFromGLXFBConfig(Display *display, GLXFBConfig confi return format; } -QGuiGLFormat qglx_reduceGuiGLFormat(const QGuiGLFormat &format, bool *reduced) +QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced) { - QGuiGLFormat retFormat = format; + QSurfaceFormat retFormat = format; *reduced = true; if (retFormat.samples() > 1) { diff --git a/src/platformsupport/glxconvenience/qglxconvenience_p.h b/src/platformsupport/glxconvenience/qglxconvenience_p.h index 1a0510067b..4892b07729 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience_p.h +++ b/src/platformsupport/glxconvenience/qglxconvenience_p.h @@ -42,16 +42,16 @@ #ifndef QGLXCONVENIENCE_H #define QGLXCONVENIENCE_H -#include <QGuiGLFormat> +#include <QSurfaceFormat> #include <QVector> #include <X11/Xlib.h> #include <GL/glx.h> -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QGuiGLFormat &format); -GLXFBConfig qglx_findConfig(Display *display, int screen, const QGuiGLFormat &format, int drawableBit = GLX_WINDOW_BIT); -QGuiGLFormat qglx_guiGLFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); -QVector<int> qglx_buildSpec(const QGuiGLFormat &format, int drawableBit = GLX_WINDOW_BIT); -QGuiGLFormat qglx_reduceGuiGLFormat(const QGuiGLFormat &format, bool *reduced); +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QSurfaceFormat &format); +GLXFBConfig qglx_findConfig(Display *display, int screen, const QSurfaceFormat &format, int drawableBit = GLX_WINDOW_BIT); +QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); +QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit = GLX_WINDOW_BIT); +QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced); #endif // QGLXCONVENIENCE_H |