From d1af0a90e6663d49c3e78ac674b0a1ae040c2085 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 17 Jun 2014 14:23:15 +0200 Subject: Use qNextPowerOfTwo instead of reimplementing it This patch uses the new shared qNextPowerOfTwo implementation introduced in qtbase. Change-Id: I831d056f584897a99df2ceb8c1d840764464e344 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/util/qsgatlastexture.cpp | 17 +++-------------- src/quick/scenegraph/util/qsgpainternode.cpp | 18 +++--------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index f7cf97954a..ceeaa977d7 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -67,18 +68,6 @@ static QElapsedTimer qsg_renderer_timer; namespace QSGAtlasTexture { -static inline int qsg_powerOfTwo(int v) -{ - v--; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - ++v; - return v; -} - static int qsg_envInt(const char *name, int defaultValue) { QByteArray content = qgetenv(name); @@ -98,8 +87,8 @@ Manager::Manager() int max; gl->functions()->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max); - int w = qMin(max, qsg_envInt("QSG_ATLAS_WIDTH", qMax(512, qsg_powerOfTwo(surfaceSize.width())))); - int h = qMin(max, qsg_envInt("QSG_ATLAS_HEIGHT", qMax(512, qsg_powerOfTwo(surfaceSize.height())))); + int w = qMin(max, qsg_envInt("QSG_ATLAS_WIDTH", qMax(512U, qNextPowerOfTwo(surfaceSize.width() - 1)))); + int h = qMin(max, qsg_envInt("QSG_ATLAS_HEIGHT", qMax(512U, qNextPowerOfTwo(surfaceSize.height() - 1)))); if (surface->surfaceClass() == QSurface::Window) { QWindow *window = static_cast(surface); diff --git a/src/quick/scenegraph/util/qsgpainternode.cpp b/src/quick/scenegraph/util/qsgpainternode.cpp index 8ccb9d2ffb..c9bb5daed1 100644 --- a/src/quick/scenegraph/util/qsgpainternode.cpp +++ b/src/quick/scenegraph/util/qsgpainternode.cpp @@ -53,19 +53,7 @@ QT_BEGIN_NAMESPACE -#define QT_MINIMUM_DYNAMIC_FBO_SIZE 64 - -static inline int qt_next_power_of_two(int v) -{ - v--; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - ++v; - return v; -} +#define QT_MINIMUM_DYNAMIC_FBO_SIZE 64U QSGPainterTexture::QSGPainterTexture() : QSGPlainTexture() @@ -322,8 +310,8 @@ void QSGPainterNode::updateFBOSize() int fboWidth; int fboHeight; if (m_fastFBOResizing) { - fboWidth = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qt_next_power_of_two(m_size.width())); - fboHeight = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qt_next_power_of_two(m_size.height())); + fboWidth = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qNextPowerOfTwo(m_size.width() - 1)); + fboHeight = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qNextPowerOfTwo(m_size.height() - 1)); } else { QSize minimumFBOSize = m_context->sceneGraphContext()->minimumFBOSize(); fboWidth = qMax(minimumFBOSize.width(), m_size.width()); -- cgit v1.2.3