Make the GL extension list a QList<QByteArray>

It doesn't make sense to convert the extension names to QStrings.

This also replaces the QString parameter in hasGLExtension() with
a QByteArray and adjusts all callers.
This commit is contained in:
Fredrik Höglund 2014-02-11 19:35:54 +01:00
parent 3b8b1455a6
commit d9c4b77f0f
9 changed files with 54 additions and 50 deletions

View file

@ -134,7 +134,7 @@ void EglWaylandBackend::init()
setSupportsBufferAge(false);
if (hasGLExtension("EGL_EXT_buffer_age")) {
if (hasGLExtension(QByteArrayLiteral("EGL_EXT_buffer_age"))) {
const QByteArray useBufferAge = qgetenv("KWIN_USE_BUFFER_AGE");
if (useBufferAge != "0")

View file

@ -74,9 +74,9 @@ void EglOnXBackend::init()
}
initEGL();
if (!hasGLExtension(QStringLiteral("EGL_KHR_image")) &&
(!hasGLExtension(QStringLiteral("EGL_KHR_image_base")) ||
!hasGLExtension(QStringLiteral("EGL_KHR_image_pixmap")))) {
if (!hasGLExtension(QByteArrayLiteral("EGL_KHR_image")) &&
(!hasGLExtension(QByteArrayLiteral("EGL_KHR_image_base")) ||
!hasGLExtension(QByteArrayLiteral("EGL_KHR_image_pixmap")))) {
setFailed(QStringLiteral("Required support for binding pixmaps to EGLImages not found, disabling compositing"));
return;
}
@ -89,13 +89,13 @@ void EglOnXBackend::init()
options->setGlPreferBufferSwap('e'); // for unknown drivers - should not happen
glPlatform->printResults();
initGL(EglPlatformInterface);
if (!hasGLExtension(QStringLiteral("GL_OES_EGL_image"))) {
if (!hasGLExtension(QByteArrayLiteral("GL_OES_EGL_image"))) {
setFailed(QStringLiteral("Required extension GL_OES_EGL_image not found, disabling compositing"));
return;
}
// check for EGL_NV_post_sub_buffer and whether it can be used on the surface
if (hasGLExtension(QStringLiteral("EGL_NV_post_sub_buffer"))) {
if (hasGLExtension(QByteArrayLiteral("EGL_NV_post_sub_buffer"))) {
if (eglQuerySurface(dpy, surface, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceHasSubPost) == EGL_FALSE) {
EGLint error = eglGetError();
if (error != EGL_SUCCESS && error != EGL_BAD_ATTRIBUTE) {
@ -109,7 +109,7 @@ void EglOnXBackend::init()
setSupportsBufferAge(false);
if (hasGLExtension("EGL_EXT_buffer_age")) {
if (hasGLExtension(QByteArrayLiteral("EGL_EXT_buffer_age"))) {
const QByteArray useBufferAge = qgetenv("KWIN_USE_BUFFER_AGE");
if (useBufferAge != "0")

View file

@ -112,16 +112,16 @@ void GlxBackend::init()
initGL(GlxPlatformInterface);
// Check whether certain features are supported
m_haveMESACopySubBuffer = hasGLExtension(QStringLiteral("GLX_MESA_copy_sub_buffer"));
m_haveMESASwapControl = hasGLExtension(QStringLiteral("GLX_MESA_swap_control"));
m_haveEXTSwapControl = hasGLExtension(QStringLiteral("GLX_EXT_swap_control"));
m_haveSGISwapControl = hasGLExtension(QStringLiteral("GLX_SGI_swap_control"));
m_haveMESACopySubBuffer = hasGLExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer"));
m_haveMESASwapControl = hasGLExtension(QByteArrayLiteral("GLX_MESA_swap_control"));
m_haveEXTSwapControl = hasGLExtension(QByteArrayLiteral("GLX_EXT_swap_control"));
m_haveSGISwapControl = hasGLExtension(QByteArrayLiteral("GLX_SGI_swap_control"));
haveSwapInterval = m_haveMESASwapControl || m_haveEXTSwapControl || m_haveSGISwapControl;
setSupportsBufferAge(false);
if (hasGLExtension("GLX_EXT_buffer_age")) {
if (hasGLExtension(QByteArrayLiteral("GLX_EXT_buffer_age"))) {
const QByteArray useBufferAge = qgetenv("KWIN_USE_BUFFER_AGE");
if (useBufferAge != "0")
@ -144,7 +144,7 @@ void GlxBackend::init()
gs_tripleBufferUndetected = false;
}
gs_tripleBufferNeedsDetection = gs_tripleBufferUndetected;
} else if (hasGLExtension(QStringLiteral("GLX_SGI_video_sync"))) {
} else if (hasGLExtension(QByteArrayLiteral("GLX_SGI_video_sync"))) {
unsigned int sync;
if (glXGetVideoSyncSGI(&sync) == 0 && glXWaitVideoSyncSGI(1, 0, &sync) == 0) {
setSyncsToVBlank(true);
@ -175,7 +175,7 @@ bool GlxBackend::initRenderingContext()
const bool direct = true;
// Use glXCreateContextAttribsARB() when it's available
if (hasGLExtension(QStringLiteral("GLX_ARB_create_context"))) {
if (hasGLExtension(QByteArrayLiteral("GLX_ARB_create_context"))) {
const int attribs_31_core_robustness[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
@ -202,7 +202,7 @@ bool GlxBackend::initRenderingContext()
0
};
const bool have_robustness = hasGLExtension(QStringLiteral("GLX_ARB_create_context_robustness"));
const bool have_robustness = hasGLExtension(QByteArrayLiteral("GLX_ARB_create_context_robustness"));
// Try to create a 3.1 context first
if (options->glCoreProfile()) {

View file

@ -261,7 +261,7 @@ ColorCorrectionPrivate::ColorCorrectionPrivate(ColorCorrection *parent)
connect(m_csi, SIGNAL(updateFailed()), this, SLOT(colorServerUpdateFailedSlot()));
#ifdef KWIN_HAVE_OPENGLES
m_haveTexture3D = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_OES_texture_3D"));
m_haveTexture3D = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_OES_texture_3D"));
#endif
}

View file

@ -161,15 +161,15 @@ void GLTexturePrivate::initStatic()
sNPOTTextureSupported = true;
sFramebufferObjectSupported = true;
sSaturationSupported = true;
if (hasGLExtension(QStringLiteral("GL_EXT_texture_format_BGRA8888")))
if (hasGLExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888")))
sTextureFormat = GL_BGRA_EXT;
else
sTextureFormat = GL_RGBA;
#else
sNPOTTextureSupported = hasGLExtension(QStringLiteral("GL_ARB_texture_non_power_of_two"));
sFramebufferObjectSupported = hasGLExtension(QStringLiteral("GL_EXT_framebuffer_object"));
sSaturationSupported = ((hasGLExtension(QStringLiteral("GL_ARB_texture_env_crossbar"))
&& hasGLExtension(QStringLiteral("GL_ARB_texture_env_dot3"))) || hasGLVersion(1, 4))
sNPOTTextureSupported = hasGLExtension(QByteArrayLiteral("GL_ARB_texture_non_power_of_two"));
sFramebufferObjectSupported = hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object"));
sSaturationSupported = ((hasGLExtension(QByteArrayLiteral("GL_ARB_texture_env_crossbar"))
&& hasGLExtension(QByteArrayLiteral("GL_ARB_texture_env_dot3"))) || hasGLVersion(1, 4))
&& (glTextureUnitsCount >= 4) && glActiveTexture != nullptr;
sTextureFormat = GL_BGRA;
#endif
@ -254,7 +254,7 @@ void GLTexture::update(const QImage &image, const QPoint &offset, const QRect &s
Q_D(GLTexture);
#ifdef KWIN_HAVE_OPENGLES
static bool s_supportsUnpack = hasGLExtension(QStringLiteral("GL_EXT_unpack_subimage"));
static bool s_supportsUnpack = hasGLExtension(QByteArrayLiteral("GL_EXT_unpack_subimage"));
#else
static bool s_supportsUnpack = true;
#endif

View file

@ -56,9 +56,9 @@ static int glXVersion;
// EGL version, use MAKE_GL_VERSION() macro for comparing with a specific version
static int eglVersion;
// List of all supported GL, EGL and GLX extensions
static QStringList glExtensions;
static QStringList glxExtensions;
static QStringList eglExtension;
static QList<QByteArray> glExtensions;
static QList<QByteArray> glxExtensions;
static QList<QByteArray> eglExtensions;
int glTextureUnitsCount;
@ -72,9 +72,8 @@ void initGLX()
glXQueryVersion(display(), &major, &minor);
glXVersion = MAKE_GL_VERSION(major, minor, 0);
// Get list of supported GLX extensions
glxExtensions = QString::fromUtf8(glXQueryExtensionsString(
display(), QX11Info::appScreen())).split(QStringLiteral(" "));
const QByteArray string = (const char *) glXQueryExtensionsString(display(), QX11Info::appScreen());
glxExtensions = string.split(' ');
glxResolveFunctions();
#endif
}
@ -86,8 +85,8 @@ void initEGL()
int major, minor;
eglInitialize(dpy, &major, &minor);
eglVersion = MAKE_GL_VERSION(major, minor, 0);
eglExtension = QString::fromUtf8(eglQueryString(dpy, EGL_EXTENSIONS)).split(QStringLiteral(" "));
const QByteArray string = eglQueryString(dpy, EGL_EXTENSIONS);
eglExtensions = string.split(' ');
eglResolveFunctions();
#endif
}
@ -109,12 +108,12 @@ void initGL(OpenGLPlatformInterface platformInterface)
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
for (int i = 0; i < count; i++) {
const char *name = (const char *) glGetStringi(GL_EXTENSIONS, i);
glExtensions << QString::fromUtf8(name);
const QByteArray name = (const char *) glGetStringi(GL_EXTENSIONS, i);
glExtensions << name;
}
} else
#endif
glExtensions = QString::fromUtf8((const char*)glGetString(GL_EXTENSIONS)).split(QStringLiteral(" "));
glExtensions = QByteArray((const char*)glGetString(GL_EXTENSIONS)).split(' ');
// handle OpenGL extensions functions
glResolveFunctions(platformInterface);
@ -134,7 +133,7 @@ void cleanupGL()
glExtensions.clear();
glxExtensions.clear();
eglExtension.clear();
eglExtensions.clear();
glVersion = 0;
glXVersion = 0;
@ -157,9 +156,9 @@ bool hasEGLVersion(int major, int minor, int release)
return eglVersion >= MAKE_GL_VERSION(major, minor, release);
}
bool hasGLExtension(const QString& extension)
bool hasGLExtension(const QByteArray &extension)
{
return glExtensions.contains(extension) || glxExtensions.contains(extension) || eglExtension.contains(extension);
return glExtensions.contains(extension) || glxExtensions.contains(extension) || eglExtensions.contains(extension);
}
static QString formatGLError(GLenum err)
@ -386,7 +385,7 @@ void GLShader::bindAttributeLocation(const char *name, int index)
void GLShader::bindFragDataLocation(const char *name, int index)
{
#ifndef KWIN_HAVE_OPENGLES
if (hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_EXT_gpu_shader4")))
if (hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_EXT_gpu_shader4")))
glBindFragDataLocation(mProgram, index, name);
#else
Q_UNUSED(name)
@ -921,8 +920,13 @@ void GLRenderTarget::initStatic()
sSupported = true;
s_blitSupported = false;
#else
sSupported = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_framebuffer_object")) || hasGLExtension(QStringLiteral("GL_EXT_framebuffer_object"));
s_blitSupported = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_framebuffer_object")) || hasGLExtension(QStringLiteral("GL_EXT_framebuffer_blit"));
sSupported = hasGLVersion(3, 0) ||
hasGLExtension(QByteArrayLiteral("GL_ARB_framebuffer_object")) ||
hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object"));
s_blitSupported = hasGLVersion(3, 0) ||
hasGLExtension(QByteArrayLiteral("GL_ARB_framebuffer_object")) ||
hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_blit"));
#endif
}
@ -1866,12 +1870,12 @@ void GLVertexBuffer::reset()
void GLVertexBuffer::initStatic()
{
#ifdef KWIN_HAVE_OPENGLES
GLVertexBufferPrivate::hasMapBufferRange = hasGLExtension(QStringLiteral("GL_EXT_map_buffer_range"));
GLVertexBufferPrivate::hasMapBufferRange = hasGLExtension(QByteArrayLiteral("GL_EXT_map_buffer_range"));
GLVertexBufferPrivate::supportsIndexedQuads = false;
#else
bool haveBaseVertex = hasGLVersion(3, 2) || hasGLExtension(QStringLiteral("GL_ARB_draw_elements_base_vertex"));
bool haveCopyBuffer = hasGLVersion(3, 1) || hasGLExtension(QStringLiteral("GL_ARB_copy_buffer"));
bool haveMapBufferRange = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_map_buffer_range"));
bool haveBaseVertex = hasGLVersion(3, 2) || hasGLExtension(QByteArrayLiteral("GL_ARB_draw_elements_base_vertex"));
bool haveCopyBuffer = hasGLVersion(3, 1) || hasGLExtension(QByteArrayLiteral("GL_ARB_copy_buffer"));
bool haveMapBufferRange = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_ARB_map_buffer_range"));
GLVertexBufferPrivate::hasMapBufferRange = haveMapBufferRange;
GLVertexBufferPrivate::supportsIndexedQuads = haveBaseVertex && haveCopyBuffer && haveMapBufferRange;

View file

@ -68,7 +68,7 @@ bool KWINGLUTILS_EXPORT hasGLVersion(int major, int minor, int release = 0);
bool KWINGLUTILS_EXPORT hasGLXVersion(int major, int minor, int release = 0);
bool KWINGLUTILS_EXPORT hasEGLVersion(int major, int minor, int release = 0);
// use for both OpenGL and GLX extensions
bool KWINGLUTILS_EXPORT hasGLExtension(const QString& extension);
bool KWINGLUTILS_EXPORT hasGLExtension(const QByteArray &extension);
// detect OpenGL error (add to various places in code to pinpoint the place)
bool KWINGLUTILS_EXPORT checkGLError(const char* txt);

View file

@ -75,7 +75,7 @@ static glXFuncPtr getProcAddress(const char* name)
void glxResolveFunctions()
{
if (hasGLExtension(QStringLiteral("GLX_MESA_swap_control")))
if (hasGLExtension(QByteArrayLiteral("GLX_MESA_swap_control")))
glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA");
else
glXSwapIntervalMESA = nullptr;
@ -91,7 +91,7 @@ void eglResolveFunctions()
void glResolveFunctions(OpenGLPlatformInterface platformInterface)
{
#ifndef KWIN_HAVE_OPENGLES
if (hasGLExtension(QStringLiteral("GL_ARB_robustness"))) {
if (hasGLExtension(QByteArrayLiteral("GL_ARB_robustness"))) {
// See http://www.opengl.org/registry/specs/ARB/robustness.txt
GL_RESOLVE_WITH_EXT(glGetGraphicsResetStatus, glGetGraphicsResetStatusARB);
GL_RESOLVE_WITH_EXT(glReadnPixels, glReadnPixelsARB);
@ -102,7 +102,7 @@ void glResolveFunctions(OpenGLPlatformInterface platformInterface)
glGetnUniformfv = KWin::GetnUniformfv;
}
#else
if (hasGLExtension(QStringLiteral("GL_EXT_robustness"))) {
if (hasGLExtension(QByteArrayLiteral("GL_EXT_robustness"))) {
// See http://www.khronos.org/registry/gles/extensions/EXT/EXT_robustness.txt
glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func) eglGetProcAddress("glGetGraphicsResetStatusEXT");
glReadnPixels = (glReadnPixels_func) eglGetProcAddress("glReadnPixelsEXT");

View file

@ -157,8 +157,8 @@ SceneOpenGL::SceneOpenGL(Workspace* ws, OpenGLBackend *backend)
// perform Scene specific checks
GLPlatform *glPlatform = GLPlatform::instance();
#ifndef KWIN_HAVE_OPENGLES
if (!hasGLExtension(QStringLiteral("GL_ARB_texture_non_power_of_two"))
&& !hasGLExtension(QStringLiteral("GL_ARB_texture_rectangle"))) {
if (!hasGLExtension(QByteArrayLiteral("GL_ARB_texture_non_power_of_two"))
&& !hasGLExtension(QByteArrayLiteral("GL_ARB_texture_rectangle"))) {
qCritical() << "GL_ARB_texture_non_power_of_two and GL_ARB_texture_rectangle missing";
init_ok = false;
return; // error
@ -627,7 +627,7 @@ SceneOpenGL2::SceneOpenGL2(OpenGLBackend *backend)
#ifndef KWIN_HAVE_OPENGLES
// It is not legal to not have a vertex array object bound in a core context
if (hasGLExtension(QStringLiteral("GL_ARB_vertex_array_object"))) {
if (hasGLExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) {
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
}