From 0a6323c2de23bd7a23e44ff3a534b06f7be994c6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 16 Jan 2015 11:01:58 +0100 Subject: Scale mipmapped npot images when not supported Task-number: QTBUG-43847 Task-number: QTBUG-40789 Change-Id: Iceacaa49bafffb31752a9fb26c896df570153fec Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/util/qsgtexture.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index fc5050014e..bfc9212138 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -75,13 +76,11 @@ static bool qsg_leak_check = !qgetenv("QML_LEAK_CHECK").isEmpty(); QT_BEGIN_NAMESPACE -#ifndef QT_NO_DEBUG inline static bool isPowerOfTwo(int x) { // Assumption: x >= 1 return x == (x & -x); } -#endif QSGTexturePrivate::QSGTexturePrivate() : wrapChanged(false) @@ -686,6 +685,16 @@ void QSGPlainTexture::bind() m_texture_size = tmp.size(); } + // Scale to a power of two size if mipmapping is requested and the + // texture is npot and npot textures are not properly supported. + if (mipmapFiltering() != QSGTexture::None + && (!isPowerOfTwo(m_texture_size.width()) || !isPowerOfTwo(m_texture_size.height())) + && !funcs->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures)) { + tmp = tmp.scaled(qNextPowerOfTwo(m_texture_size.width()), qNextPowerOfTwo(m_texture_size.height()), + Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + m_texture_size = tmp.size(); + } + if (tmp.width() * 4 != tmp.bytesPerLine()) tmp = tmp.copy(); -- cgit v1.2.3 From 15ffff51b5cc92eb875785bbd16b6385638fe5dd Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 19 Jan 2015 18:06:07 +0100 Subject: Avoid sRGB usage when targeting an incapable FBO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Native text rendering results in very different output on OS X with QQuickWidget/QOpenGLWidget. When targeting an FBO, enabling sRGB is futile if the FBO was not created with the correct format. In this case we need to disable the usage of sRGB. Task-number: QTBUG-42861 Change-Id: I887482e70be2cbfba40d6758546128d03b36def1 Reviewed-by: Eike Ziller Reviewed-by: Morten Johan Sørvig Reviewed-by: Jørgen Lind --- src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 5cca474ea1..9263d5676f 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -53,6 +53,10 @@ QT_BEGIN_NAMESPACE #define GL_FRAMEBUFFER_SRGB 0x8DB9 #endif +#ifndef GL_FRAMEBUFFER_SRGB_CAPABLE +#define GL_FRAMEBUFFER_SRGB_CAPABLE 0x8DBA +#endif + static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity) { float o = c.w() * globalOpacity; @@ -199,7 +203,11 @@ void QSG24BitTextMaskShader::initialize() if (QOpenGLContext::currentContext()->hasExtension(QByteArrayLiteral("GL_ARB_framebuffer_sRGB")) && m_glyphFormat == QFontEngine::Format_A32 && qAbs(fontSmoothingGamma() - 2.2) < 0.25) { - m_useSRGB = true; + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + GLint srgbCapable = 0; + funcs->glGetIntegerv(GL_FRAMEBUFFER_SRGB_CAPABLE, &srgbCapable); + if (srgbCapable) + m_useSRGB = true; } } -- cgit v1.2.3