diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-03-05 16:29:53 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-03-05 16:31:28 (GMT) |
commit | 7d587efef35b3adbb3433a4baec1c5ee7105cf0b (patch) | |
tree | 9a91ea4dd498684fb5236512f427d2dc2ea03b47 /src/opengl/qgl_x11egl.cpp | |
parent | ee07fff45d49e69d9a4f4474861a219af8d557f2 (diff) | |
download | Qt-7d587efef35b3adbb3433a4baec1c5ee7105cf0b.zip Qt-7d587efef35b3adbb3433a4baec1c5ee7105cf0b.tar.gz Qt-7d587efef35b3adbb3433a4baec1c5ee7105cf0b.tar.bz2 |
Port QX11GLPixmapData & QX11GLWindowSurface to new QEgl API
It's still just as buggy, but at least it allows us to remove a lot
of crud from qgl_x11egl.cpp.
Reviewed-By: TrustMe
Diffstat (limited to 'src/opengl/qgl_x11egl.cpp')
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 123bbdd..5ffecc5 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -358,113 +358,6 @@ void QGLWidgetPrivate::recreateEglSurface(bool force) } } -// Selects which configs should be used -EGLConfig Q_OPENGL_EXPORT qt_chooseEGLConfigForPixmap(bool hasAlpha, bool readOnly) -{ - // Cache the configs we select as they wont change: - static EGLConfig roPixmapRGBConfig = 0; - static EGLConfig roPixmapRGBAConfig = 0; - static EGLConfig rwPixmapRGBConfig = 0; - static EGLConfig rwPixmapRGBAConfig = 0; - - EGLConfig* targetConfig; - - if (hasAlpha) { - if (readOnly) - targetConfig = &roPixmapRGBAConfig; - else - targetConfig = &rwPixmapRGBAConfig; - } - else { - if (readOnly) - targetConfig = &roPixmapRGBConfig; - else - targetConfig = &rwPixmapRGBConfig; - } - - if (*targetConfig == 0) { - QEglProperties configAttribs; - configAttribs.setValue(EGL_SURFACE_TYPE, EGL_PIXMAP_BIT); - configAttribs.setRenderableType(QEgl::OpenGL); - if (hasAlpha) - configAttribs.setValue(EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); - else - configAttribs.setValue(EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); - - // If this is going to be a render target, it needs to have a depth, stencil & sample buffer - if (!readOnly) { - configAttribs.setValue(EGL_DEPTH_SIZE, 1); - configAttribs.setValue(EGL_STENCIL_SIZE, 1); - configAttribs.setValue(EGL_SAMPLE_BUFFERS, 1); - } - - EGLint configCount = 0; - do { - eglChooseConfig(QEgl::display(), configAttribs.properties(), targetConfig, 1, &configCount); - if (configCount > 0) { - // Got one - qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB") << (readOnly ? "readonly" : "target" ) - << "config to create a pixmap surface:"; - -// QEglProperties configProps(*targetConfig); -// qDebug() << configProps.toString(); - break; - } - qWarning("choosePixmapConfig() - No suitible config found, reducing requirements"); - } while (configAttribs.reduceConfiguration()); - } - - if (*targetConfig == 0) - qWarning("choosePixmapConfig() - Couldn't find a suitable config"); - - return *targetConfig; -} - -bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnly) -{ - Q_ASSERT(pmd->classId() == QPixmapData::X11Class); - QX11PixmapData* pixmapData = static_cast<QX11PixmapData*>(pmd); - - bool hasAlpha = pixmapData->hasAlphaChannel(); - - EGLConfig pixmapConfig = qt_chooseEGLConfigForPixmap(hasAlpha, readOnly); - - QEglProperties pixmapAttribs; - - // If the pixmap can't be bound to a texture, it's pretty useless - pixmapAttribs.setValue(EGL_TEXTURE_TARGET, EGL_TEXTURE_2D); - if (hasAlpha) - pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA); - else - pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB); - - EGLSurface pixmapSurface; - pixmapSurface = eglCreatePixmapSurface(QEgl::display(), - pixmapConfig, - (EGLNativePixmapType) pixmapData->handle(), - pixmapAttribs.properties()); -// qDebug("qt_createEGLSurfaceForPixmap() created surface 0x%x for pixmap 0x%x", -// pixmapSurface, pixmapData->handle()); - if (pixmapSurface == EGL_NO_SURFACE) { - qWarning() << "Failed to create a pixmap surface:" << QEgl::errorString(); - return false; - } - - static bool doneOnce = false; - if (!doneOnce) { - // Make sure QGLTextureCache is instanciated so it can install cleanup hooks - // which cleanup the EGL surface. - QGLTextureCache::instance(); - doneOnce = true; - } - - Q_ASSERT(sizeof(Qt::HANDLE) >= sizeof(EGLSurface)); // Just to make totally sure! - pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface; - QImagePixmapCleanupHooks::enableCleanupHooks(pixmapData); // Make sure the cleanup hook gets called - - return true; -} - QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, const qint64 key, QGLContext::BindOptions options) |