From: Laszlo Agocs Date: Fri, 16 Jan 2015 10:01:58 +0000 (+0100) Subject: Scale mipmapped npot images when not supported X-Git-Tag: v5.5.90+alpha1~3^2~242^2~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a6323c2de23bd7a23e44ff3a534b06f7be994c6;p=platform%2Fupstream%2Fqtdeclarative.git Scale mipmapped npot images when not supported Task-number: QTBUG-43847 Task-number: QTBUG-40789 Change-Id: Iceacaa49bafffb31752a9fb26c896df570153fec Reviewed-by: Gunnar Sletta --- diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index fc50500..bfc9212 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();