diff options
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/util/qsgimagenode.h | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgninepatchnode.h | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgrectanglenode.h | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexture.cpp | 79 |
4 files changed, 12 insertions, 73 deletions
diff --git a/src/quick/scenegraph/util/qsgimagenode.h b/src/quick/scenegraph/util/qsgimagenode.h index 526f52b7e5..3b78f78a0e 100644 --- a/src/quick/scenegraph/util/qsgimagenode.h +++ b/src/quick/scenegraph/util/qsgimagenode.h @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE class Q_QUICK_EXPORT QSGImageNode : public QSGGeometryNode { public: - ~QSGImageNode() override { } + ~QSGImageNode() override = default; virtual void setRect(const QRectF &rect) = 0; inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); } diff --git a/src/quick/scenegraph/util/qsgninepatchnode.h b/src/quick/scenegraph/util/qsgninepatchnode.h index e76afd3c4a..b690a50e9d 100644 --- a/src/quick/scenegraph/util/qsgninepatchnode.h +++ b/src/quick/scenegraph/util/qsgninepatchnode.h @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE class Q_QUICK_EXPORT QSGNinePatchNode : public QSGGeometryNode { public: - ~QSGNinePatchNode() override { } + ~QSGNinePatchNode() override = default; virtual void setTexture(QSGTexture *texture) = 0; virtual void setBounds(const QRectF &bounds) = 0; diff --git a/src/quick/scenegraph/util/qsgrectanglenode.h b/src/quick/scenegraph/util/qsgrectanglenode.h index ba52b65b07..c435dc790f 100644 --- a/src/quick/scenegraph/util/qsgrectanglenode.h +++ b/src/quick/scenegraph/util/qsgrectanglenode.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class Q_QUICK_EXPORT QSGRectangleNode : public QSGGeometryNode { public: - ~QSGRectangleNode() override { } + ~QSGRectangleNode() override = default; virtual void setRect(const QRectF &rect) = 0; inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); } diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index 982d05691d..720f08f69b 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -49,6 +49,7 @@ # include <qopenglfunctions.h> # include <QtGui/qopenglcontext.h> # include <QtGui/qopenglfunctions.h> +# include <QtGui/private/qopengltextureuploader_p.h> # include <private/qsgdefaultrendercontext_p.h> #endif #include <private/qsgmaterialshader_p.h> @@ -89,7 +90,7 @@ static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK" QT_BEGIN_NAMESPACE -#if QT_CONFIG(opengl) +#if QT_CONFIG(opengl) && !defined(QT_NO_DEBUG) inline static bool isPowerOfTwo(int x) { // Assumption: x >= 1 @@ -755,9 +756,7 @@ void QSGPlainTexture::bind() // ### TODO: check for out-of-memory situations... - QImage tmp = (m_image.format() == QImage::Format_RGB32 || m_image.format() == QImage::Format_ARGB32_Premultiplied) - ? m_image - : m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption; // Downscale the texture to fit inside the max texture limit if it is too big. // It would be better if the image was already downscaled to the right size, @@ -771,75 +770,19 @@ void QSGPlainTexture::bind() max = rc->maxTextureSize(); else funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max); - if (tmp.width() > max || tmp.height() > max) { - tmp = tmp.scaled(qMin(max, tmp.width()), qMin(max, tmp.height()), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - m_texture_size = tmp.size(); - } + + m_texture_size = m_texture_size.boundedTo(QSize(max, max)); // 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(); + options |= QOpenGLTextureUploader::PowerOfTwoBindOption; } - if (tmp.width() * 4 != tmp.bytesPerLine()) - tmp = tmp.copy(); - - qint64 convertTime = 0; - if (profileFrames) - convertTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, - QQuickProfiler::SceneGraphTexturePrepareConvert); - updateBindOptions(m_dirty_bind_options); - GLenum externalFormat = GL_RGBA; - GLenum internalFormat = GL_RGBA; - -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) - QString *deviceName = - static_cast<QString *>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName")); - static bool wrongfullyReportsBgra8888Support = deviceName != 0 - && (deviceName->compare(QLatin1String("samsung SM-T211"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QLatin1String("samsung SM-T210"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QLatin1String("samsung SM-T215"), Qt::CaseInsensitive) == 0); -#else - static bool wrongfullyReportsBgra8888Support = false; -#endif - - if (context->hasExtension(QByteArrayLiteral("GL_EXT_bgra"))) { - externalFormat = GL_BGRA; -#ifdef QT_OPENGL_ES - internalFormat = GL_BGRA; -#else - if (context->isOpenGLES()) - internalFormat = GL_BGRA; -#endif // QT_OPENGL_ES - } else if (!wrongfullyReportsBgra8888Support - && (context->hasExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888")) - || context->hasExtension(QByteArrayLiteral("GL_IMG_texture_format_BGRA8888")))) { - externalFormat = GL_BGRA; - internalFormat = GL_BGRA; -#if defined(Q_OS_DARWIN) && !defined(Q_OS_OSX) - } else if (context->hasExtension(QByteArrayLiteral("GL_APPLE_texture_format_BGRA8888"))) { - externalFormat = GL_BGRA; - internalFormat = GL_RGBA; -#endif - } else { - tmp = std::move(tmp).convertToFormat(QImage::Format_RGBA8888_Premultiplied); - } - - qint64 swizzleTime = 0; - if (profileFrames) - swizzleTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, - QQuickProfiler::SceneGraphTexturePrepareSwizzle); - - funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, m_texture_size.width(), m_texture_size.height(), 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits()); + QOpenGLTextureUploader::textureImage(GL_TEXTURE_2D, m_image, options, QSize(max, max)); qint64 uploadTime = 0; if (profileFrames) @@ -856,15 +799,11 @@ void QSGPlainTexture::bind() if (profileFrames) { mipmapTime = qsg_renderer_timer.nsecsElapsed(); qCDebug(QSG_LOG_TIME_TEXTURE, - "plain texture uploaded in: %dms (%dx%d), bind=%d, convert=%d, swizzle=%d (%s->%s), upload=%d, mipmap=%d%s", + "plain texture uploaded in: %dms (%dx%d), bind=%d, upload=%d, mipmap=%d%s", int(mipmapTime / 1000000), m_texture_size.width(), m_texture_size.height(), int(bindTime / 1000000), - int((convertTime - bindTime)/1000000), - int((swizzleTime - convertTime)/1000000), - (externalFormat == GL_BGRA ? "BGRA" : "RGBA"), - (internalFormat == GL_BGRA ? "BGRA" : "RGBA"), - int((uploadTime - swizzleTime)/1000000), + int((uploadTime - bindTime)/1000000), int((mipmapTime - uploadTime)/1000000), m_texture_size != m_image.size() ? " (scaled to GL_MAX_TEXTURE_SIZE)" : ""); } |