diff -ru qt-everywhere-opensource-src-5.9.1/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp qt-everywhere-opensource-src-5.9.1-patched/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp --- qt-everywhere-opensource-src-5.9.1/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp 2017-06-22 07:46:59.000000000 -0400 +++ qt-everywhere-opensource-src-5.9.1-patched/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp 2017-08-10 18:58:06.000000000 -0400 @@ -67,7 +67,6 @@ , m_blitProgram(0) , m_blitBuffer(QOpenGLBuffer::VertexBuffer) , m_fboGuard(0) - , m_funcs(c->functions()) #if !defined(QT_OPENGL_ES_2) , m_coreFuncs(0) #endif @@ -85,7 +84,7 @@ QSGDefaultDistanceFieldGlyphCache::~QSGDefaultDistanceFieldGlyphCache() { for (int i = 0; i < m_textures.count(); ++i) - m_funcs->glDeleteTextures(1, &m_textures[i].texture); + QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_textures[i].texture); if (m_fboGuard != 0) m_fboGuard->free(); @@ -163,10 +162,10 @@ GlyphTextureHash glyphTextures; GLint alignment = 4; // default value - m_funcs->glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); // Distance field data is always tightly packed - m_funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + QOpenGLContext::currentContext()->functions()->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); for (int i = 0; i < glyphs.size(); ++i) { QDistanceField glyph = glyphs.at(i); @@ -175,7 +174,7 @@ TextureInfo *texInfo = m_glyphsTexture.value(glyphIndex); resizeTexture(texInfo, texInfo->allocatedArea.width(), texInfo->allocatedArea.height()); - m_funcs->glBindTexture(GL_TEXTURE_2D, texInfo->texture); + QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, texInfo->texture); glyphTextures[texInfo].append(glyphIndex); @@ -201,13 +200,13 @@ #endif if (useTextureUploadWorkaround()) { for (int i = 0; i < glyph.height(); ++i) { - m_funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, + QOpenGLContext::currentContext()->functions()->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x - padding, c.y + i - padding, glyph.width(),1, format, GL_UNSIGNED_BYTE, glyph.scanLine(i)); } } else { - m_funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, + QOpenGLContext::currentContext()->functions()->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x - padding, c.y - padding, glyph.width(), glyph.height(), format, GL_UNSIGNED_BYTE, glyph.constBits()); @@ -215,7 +214,7 @@ } // restore to previous alignment - m_funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); + QOpenGLContext::currentContext()->functions()->glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); for (GlyphTextureHashConstIt i = glyphTextures.constBegin(), cend = glyphTextures.constEnd(); i != cend; ++i) { Texture t; @@ -240,18 +239,18 @@ if (useTextureResizeWorkaround() && texInfo->image.isNull()) texInfo->image = QDistanceField(width, height); - while (m_funcs->glGetError() != GL_NO_ERROR) { } + while (QOpenGLContext::currentContext()->functions()->glGetError() != GL_NO_ERROR) { } - m_funcs->glGenTextures(1, &texInfo->texture); - m_funcs->glBindTexture(GL_TEXTURE_2D, texInfo->texture); + QOpenGLContext::currentContext()->functions()->glGenTextures(1, &texInfo->texture); + QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, texInfo->texture); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #if !defined(QT_OPENGL_ES_2) if (!QOpenGLContext::currentContext()->isOpenGLES()) - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); const GLint internalFormat = isCoreProfile() ? GL_R8 : GL_ALPHA; const GLenum format = isCoreProfile() ? GL_RED : GL_ALPHA; #else @@ -260,14 +259,14 @@ #endif QByteArray zeroBuf(width * height, 0); - m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, zeroBuf.constData()); + QOpenGLContext::currentContext()->functions()->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, zeroBuf.constData()); texInfo->size = QSize(width, height); - GLuint error = m_funcs->glGetError(); + GLuint error = QOpenGLContext::currentContext()->functions()->glGetError(); if (error != GL_NO_ERROR) { - m_funcs->glBindTexture(GL_TEXTURE_2D, 0); - m_funcs->glDeleteTextures(1, &texInfo->texture); + QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, 0); + QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &texInfo->texture); texInfo->texture = 0; } @@ -344,8 +343,8 @@ if (useTextureResizeWorkaround()) { #endif GLint alignment = 4; // default value - m_funcs->glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); - m_funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); + QOpenGLContext::currentContext()->functions()->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); #if !defined(QT_OPENGL_ES_2) const GLenum format = isCoreProfile() ? GL_RED : GL_ALPHA; @@ -355,22 +354,22 @@ if (useTextureUploadWorkaround()) { for (int i = 0; i < texInfo->image.height(); ++i) { - m_funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, + QOpenGLContext::currentContext()->functions()->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, oldWidth, 1, format, GL_UNSIGNED_BYTE, texInfo->image.scanLine(i)); } } else { - m_funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, + QOpenGLContext::currentContext()->functions()->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, format, GL_UNSIGNED_BYTE, texInfo->image.constBits()); } - m_funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); // restore to previous value + QOpenGLContext::currentContext()->functions()->glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); // restore to previous value texInfo->image = texInfo->image.copy(0, 0, width, height); - m_funcs->glDeleteTextures(1, &oldTexture); + QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &oldTexture); return; } @@ -381,30 +380,30 @@ if (!m_fboGuard) { GLuint fbo; - m_funcs->glGenFramebuffers(1, &fbo); + QOpenGLContext::currentContext()->functions()->glGenFramebuffers(1, &fbo); m_fboGuard = new QOpenGLSharedResourceGuard(ctx, fbo, freeFramebufferFunc); } - m_funcs->glBindFramebuffer(GL_FRAMEBUFFER, m_fboGuard->id()); + QOpenGLContext::currentContext()->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_fboGuard->id()); GLuint tmp_texture; - m_funcs->glGenTextures(1, &tmp_texture); - m_funcs->glBindTexture(GL_TEXTURE_2D, tmp_texture); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + QOpenGLContext::currentContext()->functions()->glGenTextures(1, &tmp_texture); + QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, tmp_texture); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #if !defined(QT_OPENGL_ES_2) if (!ctx->isOpenGLES()) - m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + QOpenGLContext::currentContext()->functions()->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); #endif - m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, + QOpenGLContext::currentContext()->functions()->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - m_funcs->glBindTexture(GL_TEXTURE_2D, 0); - m_funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, 0); + QOpenGLContext::currentContext()->functions()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmp_texture, 0); - m_funcs->glActiveTexture(GL_TEXTURE0); - m_funcs->glBindTexture(GL_TEXTURE_2D, oldTexture); + QOpenGLContext::currentContext()->functions()->glActiveTexture(GL_TEXTURE0); + QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, oldTexture); // save current render states GLboolean stencilTestEnabled; @@ -413,19 +412,19 @@ GLboolean blendEnabled; GLint viewport[4]; GLint oldProgram; - m_funcs->glGetBooleanv(GL_STENCIL_TEST, &stencilTestEnabled); - m_funcs->glGetBooleanv(GL_DEPTH_TEST, &depthTestEnabled); - m_funcs->glGetBooleanv(GL_SCISSOR_TEST, &scissorTestEnabled); - m_funcs->glGetBooleanv(GL_BLEND, &blendEnabled); - m_funcs->glGetIntegerv(GL_VIEWPORT, &viewport[0]); - m_funcs->glGetIntegerv(GL_CURRENT_PROGRAM, &oldProgram); - - m_funcs->glDisable(GL_STENCIL_TEST); - m_funcs->glDisable(GL_DEPTH_TEST); - m_funcs->glDisable(GL_SCISSOR_TEST); - m_funcs->glDisable(GL_BLEND); + QOpenGLContext::currentContext()->functions()->glGetBooleanv(GL_STENCIL_TEST, &stencilTestEnabled); + QOpenGLContext::currentContext()->functions()->glGetBooleanv(GL_DEPTH_TEST, &depthTestEnabled); + QOpenGLContext::currentContext()->functions()->glGetBooleanv(GL_SCISSOR_TEST, &scissorTestEnabled); + QOpenGLContext::currentContext()->functions()->glGetBooleanv(GL_BLEND, &blendEnabled); + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_VIEWPORT, &viewport[0]); + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_CURRENT_PROGRAM, &oldProgram); + + QOpenGLContext::currentContext()->functions()->glDisable(GL_STENCIL_TEST); + QOpenGLContext::currentContext()->functions()->glDisable(GL_DEPTH_TEST); + QOpenGLContext::currentContext()->functions()->glDisable(GL_SCISSOR_TEST); + QOpenGLContext::currentContext()->functions()->glDisable(GL_BLEND); - m_funcs->glViewport(0, 0, oldWidth, oldHeight); + QOpenGLContext::currentContext()->functions()->glViewport(0, 0, oldWidth, oldHeight); const bool vaoInit = m_vao.isCreated(); if (isCoreProfile()) { @@ -445,35 +444,35 @@ m_blitProgram->disableAttributeArray(int(QT_OPACITY_ATTR)); m_blitProgram->setUniformValue("imageTexture", GLuint(0)); - m_funcs->glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + QOpenGLContext::currentContext()->functions()->glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - m_funcs->glBindTexture(GL_TEXTURE_2D, texInfo->texture); + QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, texInfo->texture); if (useTextureUploadWorkaround()) { for (int i = 0; i < oldHeight; ++i) - m_funcs->glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, 0, i, oldWidth, 1); + QOpenGLContext::currentContext()->functions()->glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, 0, i, oldWidth, 1); } else { - m_funcs->glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight); + QOpenGLContext::currentContext()->functions()->glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight); } - m_funcs->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + QOpenGLContext::currentContext()->functions()->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0); - m_funcs->glDeleteTextures(1, &tmp_texture); - m_funcs->glDeleteTextures(1, &oldTexture); + QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &tmp_texture); + QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &oldTexture); QOpenGLFramebufferObject::bindDefault(); // restore render states if (stencilTestEnabled) - m_funcs->glEnable(GL_STENCIL_TEST); + QOpenGLContext::currentContext()->functions()->glEnable(GL_STENCIL_TEST); if (depthTestEnabled) - m_funcs->glEnable(GL_DEPTH_TEST); + QOpenGLContext::currentContext()->functions()->glEnable(GL_DEPTH_TEST); if (scissorTestEnabled) - m_funcs->glEnable(GL_SCISSOR_TEST); + QOpenGLContext::currentContext()->functions()->glEnable(GL_SCISSOR_TEST); if (blendEnabled) - m_funcs->glEnable(GL_BLEND); - m_funcs->glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); - m_funcs->glUseProgram(oldProgram); + QOpenGLContext::currentContext()->functions()->glEnable(GL_BLEND); + QOpenGLContext::currentContext()->functions()->glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + QOpenGLContext::currentContext()->functions()->glUseProgram(oldProgram); m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR)); m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR)); @@ -499,7 +498,7 @@ static bool set = false; static bool useWorkaround = false; if (!set) { - useWorkaround = qstrcmp(reinterpret_cast(m_funcs->glGetString(GL_RENDERER)), + useWorkaround = qstrcmp(reinterpret_cast(QOpenGLContext::currentContext()->functions()->glGetString(GL_RENDERER)), "Mali-400 MP") == 0; set = true; } @@ -514,7 +513,7 @@ int QSGDefaultDistanceFieldGlyphCache::maxTextureSize() const { if (!m_maxTextureSize) - m_funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); return m_maxTextureSize; } diff -ru qt-everywhere-opensource-src-5.9.1/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h qt-everywhere-opensource-src-5.9.1-patched/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h --- qt-everywhere-opensource-src-5.9.1/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h 2017-06-22 07:46:59.000000000 -0400 +++ qt-everywhere-opensource-src-5.9.1-patched/qtdeclarative/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h 2017-08-10 18:59:07.000000000 -0400 @@ -146,7 +146,6 @@ QOpenGLVertexArrayObject m_vao; QOpenGLSharedResourceGuard *m_fboGuard; - QOpenGLFunctions *m_funcs; #if !defined(QT_OPENGL_ES_2) QOpenGLFunctions_3_2_Core *m_coreFuncs; #endif