Dont call QPlatformGLContext::makeCurrent from subclass
(cherry picked from commit fc0a6ab220ab97b8f6acf90bf04b46de513a4d96)bb10
parent
ef77e8b651
commit
61c6f64872
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format)
|
||||
QVector<EGLint> q_createConfigAttributesFromFormat(const QWindowFormat &format)
|
||||
{
|
||||
int redSize = format.redBufferSize();
|
||||
int greenSize = format.greenBufferSize();
|
||||
|
|
@ -53,17 +53,6 @@ QVector<EGLint> 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<EGLint> 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<EGLint> configAttributes;
|
||||
|
||||
|
|
@ -206,7 +195,7 @@ bool q_reduceConfigAttributes(QVector<EGLint> *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<EGLint> 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
|
||||
|
|
|
|||
|
|
@ -43,16 +43,16 @@
|
|||
#define QEGLCONVENIENCE_H
|
||||
|
||||
|
||||
#include <QtGui/QPlatformWindowFormat>
|
||||
#include <QtGui/QWindowFormat>
|
||||
#include <QtCore/QVector>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format);
|
||||
QVector<EGLint> q_createConfigAttributesFromFormat(const QWindowFormat &format);
|
||||
bool q_reduceConfigAttributes(QVector<EGLint> *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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue