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 +- 4 files changed, 21 insertions(+), 43 deletions(-) (limited to 'src/plugins/platforms/eglconvenience') 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 -- cgit v1.2.3