From 61c6f64872a363cbde209e6f9a7cd05e79713c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 26 Apr 2011 17:32:02 +0200 Subject: Dont call QPlatformGLContext::makeCurrent from subclass (cherry picked from commit fc0a6ab220ab97b8f6acf90bf04b46de513a4d96) --- .../platforms/eglconvenience/qeglconvenience.cpp | 46 ++++++---------------- .../platforms/eglconvenience/qeglconvenience.h | 8 ++-- .../eglconvenience/qeglplatformcontext.cpp | 6 +-- .../platforms/eglconvenience/qeglplatformcontext.h | 4 +- .../readback_egl/qwaylandreadbackeglcontext.cpp | 2 +- .../wayland_egl/qwaylandglcontext.cpp | 2 +- .../qwaylandxcompositeeglcontext.cpp | 2 +- src/plugins/platforms/xcb/qdri2context.cpp | 2 - src/plugins/platforms/xcb/qglxintegration.cpp | 2 - 9 files changed, 24 insertions(+), 50 deletions(-) diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index df7abc1401..f3ce0fa809 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE -QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) +QVector q_createConfigAttributesFromFormat(const QWindowFormat &format) { int redSize = format.redBufferSize(); int greenSize = format.greenBufferSize(); @@ -53,17 +53,6 @@ QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat & int stencilSize = format.stencilBufferSize(); int sampleCount = format.samples(); - // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that - // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1: - if (format.alpha() && alphaSize <= 0) - alphaSize = 1; - if (format.depth() && depthSize <= 0) - depthSize = 1; - if (format.stencil() && stencilSize <= 0) - stencilSize = 1; - if (format.sampleBuffers() && sampleCount <= 0) - sampleCount = 1; - // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide // the best performance. The EGL config selection algorithm is a bit stange in this regard: // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard @@ -82,14 +71,14 @@ QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat & // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat, // they will probably get a 32-bit config, even when there's an RGB565 config available. - // Now normalize the values so -1 becomes 0 - redSize = redSize > 0 ? redSize : 0; - greenSize = greenSize > 0 ? greenSize : 0; - blueSize = blueSize > 0 ? blueSize : 0; - alphaSize = alphaSize > 0 ? alphaSize : 0; - depthSize = depthSize > 0 ? depthSize : 0; - stencilSize = stencilSize > 0 ? stencilSize : 0; - sampleCount = sampleCount > 0 ? sampleCount : 0; +// // Now normalize the values so -1 becomes 0 +// redSize = redSize > 0 ? redSize : 0; +// greenSize = greenSize > 0 ? greenSize : 0; +// blueSize = blueSize > 0 ? blueSize : 0; +// alphaSize = alphaSize > 0 ? alphaSize : 0; +// depthSize = depthSize > 0 ? depthSize : 0; +// stencilSize = stencilSize > 0 ? stencilSize : 0; +// sampleCount = sampleCount > 0 ? sampleCount : 0; QVector configAttributes; @@ -206,7 +195,7 @@ bool q_reduceConfigAttributes(QVector *configAttributes) return false; } -EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType) +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QWindowFormat &format, bool highestPixelFormat, int surfaceType) { EGLConfig cfg = 0; QVector configureAttributes = q_createConfigAttributesFromFormat(format); @@ -214,11 +203,7 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW configureAttributes.append(surfaceType); configureAttributes.append(EGL_RENDERABLE_TYPE); - if (format.windowApi() == QPlatformWindowFormat::OpenVG) { - configureAttributes.append(EGL_OPENVG_BIT); - } else { - configureAttributes.append(EGL_OPENGL_ES2_BIT); - } + configureAttributes.append(EGL_OPENGL_ES2_BIT); configureAttributes.append(EGL_NONE); do { @@ -272,9 +257,9 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW return 0; } -QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config) +QWindowFormat q_windowFormatFromConfig(EGLDisplay display, const EGLConfig config) { - QPlatformWindowFormat format; + QWindowFormat format; EGLint redSize = 0; EGLint greenSize = 0; EGLint blueSize = 0; @@ -282,7 +267,6 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con 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); @@ -291,7 +275,6 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con 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); @@ -300,10 +283,7 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con 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 diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index c7d3d61ae5..d0863219ab 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -43,16 +43,16 @@ #define QEGLCONVENIENCE_H -#include +#include #include #include QT_BEGIN_NAMESPACE -QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); +QVector q_createConfigAttributesFromFormat(const QWindowFormat &format); bool q_reduceConfigAttributes(QVector *configAttributes); -EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); -QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config); +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); +QWindowFormat q_windowFormatFromConfig(EGLDisplay display, const EGLConfig config); bool q_hasEglExtension(EGLDisplay display,const char* extensionName); QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index ae5215f320..30dd86215d 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -66,7 +66,7 @@ QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, E qFatal("EGL error"); } - m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config); + m_windowFormat = q_windowFormatFromConfig(display,config); } QEGLPlatformContext::~QEGLPlatformContext() @@ -88,7 +88,6 @@ QEGLPlatformContext::~QEGLPlatformContext() void QEGLPlatformContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); #ifdef QEGL_EXTRA_DEBUG qWarning("QEglContext::makeCurrent: %p\n",this); #endif @@ -118,7 +117,6 @@ void QEGLPlatformContext::makeCurrent() } void QEGLPlatformContext::doneCurrent() { - QPlatformGLContext::doneCurrent(); #ifdef QEGL_EXTRA_DEBUG qWarning("QEglContext::doneCurrent:%p\n",this); #endif @@ -146,7 +144,7 @@ void* QEGLPlatformContext::getProcAddress(const QString& procName) return (void *)eglGetProcAddress(qPrintable(procName)); } -QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const +QWindowFormat QEGLPlatformContext::windowFormat() const { return m_windowFormat; } diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index 69835d7eb4..048fd72215 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -56,7 +56,7 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - QPlatformWindowFormat platformWindowFormat() const; + QWindowFormat windowFormat() const; EGLContext eglContext() const; private: @@ -65,7 +65,7 @@ private: EGLSurface m_eglSurface; EGLenum m_eglApi; - QPlatformWindowFormat m_windowFormat; + QWindowFormat m_windowFormat; }; #endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp index d63087d934..7e84b5d3ab 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -145,7 +145,7 @@ void * QWaylandReadbackEglContext::getProcAddress(const QString &procName) QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const { - return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); + return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } void QWaylandReadbackEglContext::geometryChanged() diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index d293019909..5c5e88afb1 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -55,7 +55,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo , mEglDisplay(eglDisplay) , mSurface(EGL_NO_SURFACE) , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true)) - , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig)) + , mFormat(q_windowFormatFromConfig(mEglDisplay,mConfig)) { QPlatformGLContext *sharePlatformContext = 0; sharePlatformContext = format.sharedGLContext(); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index 92acf752e4..1536b2e5ca 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -102,7 +102,7 @@ void * QWaylandXCompositeEGLContext::getProcAddress(const QString &procName) QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const { - return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); + return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } void QWaylandXCompositeEGLContext::sync_function(void *data) diff --git a/src/plugins/platforms/xcb/qdri2context.cpp b/src/plugins/platforms/xcb/qdri2context.cpp index dbbfa67d8f..e208769336 100644 --- a/src/plugins/platforms/xcb/qdri2context.cpp +++ b/src/plugins/platforms/xcb/qdri2context.cpp @@ -146,7 +146,6 @@ QDri2Context::~QDri2Context() void QDri2Context::makeCurrent() { - QPlatformGLContext::makeCurrent(); Q_D(QDri2Context); eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext); @@ -156,7 +155,6 @@ void QDri2Context::makeCurrent() void QDri2Context::doneCurrent() { - QPlatformGLContext::doneCurrent(); Q_D(QDri2Context); eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); } diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 3af627c324..5640944ac3 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -94,7 +94,6 @@ QGLXContext::~QGLXContext() void QGLXContext::makeCurrent() { Q_XCB_NOOP(m_screen->connection()); - QPlatformGLContext::makeCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context); Q_XCB_NOOP(m_screen->connection()); } @@ -102,7 +101,6 @@ void QGLXContext::makeCurrent() void QGLXContext::doneCurrent() { Q_XCB_NOOP(m_screen->connection()); - QPlatformGLContext::doneCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0); Q_XCB_NOOP(m_screen->connection()); } -- cgit v1.2.3