diff options
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgnode.h | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultcontext.cpp | 10 | ||||
-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 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexturematerial_p.h | 2 |
8 files changed, 23 insertions, 79 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp index 405e2ab100..da5d39db20 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp @@ -473,8 +473,7 @@ void QSGSoftwareInternalImageNode::paint(QPainter *painter) painter->save(); qreal sx = m_targetRect.width()/(m_subSourceRect.width()*pm.width()); qreal sy = m_targetRect.height()/(m_subSourceRect.height()*pm.height()); - QMatrix transform(sx, 0, 0, sy, 0, 0); - painter->setMatrix(transform, true); + painter->setTransform(QTransform::fromScale(sx, sy), true); painter->drawTiledPixmap(QRectF(m_targetRect.x()/sx, m_targetRect.y()/sy, m_targetRect.width()/sx, m_targetRect.height()/sy), pm, QPointF(m_subSourceRect.left()*pm.width(), m_subSourceRect.top()*pm.height())); diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index 854e284c9e..cb677de030 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -96,7 +96,7 @@ public: // Uppermost 8 bits are reserved for internal use. IsVisitableNode = 0x01000000 #ifdef Q_CLANG_QDOC - InternalReserved = 0x01000000 + , InternalReserved = 0x01000000 #endif }; Q_DECLARE_FLAGS(Flags, Flag) diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp index 5813844cd2..70b74b8877 100644 --- a/src/quick/scenegraph/qsgdefaultcontext.cpp +++ b/src/quick/scenegraph/qsgdefaultcontext.cpp @@ -221,8 +221,14 @@ QSurfaceFormat QSGDefaultContext::defaultSurfaceFormat() const static bool useDepth = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER"); static bool useStencil = qEnvironmentVariableIsEmpty("QSG_NO_STENCIL_BUFFER"); static bool enableDebug = qEnvironmentVariableIsSet("QSG_OPENGL_DEBUG"); - format.setDepthBufferSize(useDepth ? 24 : 0); - format.setStencilBufferSize(useStencil ? 8 : 0); + if (useDepth && format.depthBufferSize() == -1) + format.setDepthBufferSize(24); + else if (!useDepth) + format.setDepthBufferSize(0); + if (useStencil && format.stencilBufferSize() == -1) + format.setStencilBufferSize(8); + else if (!useStencil) + format.setStencilBufferSize(0); if (enableDebug) format.setOption(QSurfaceFormat::DebugContext); if (QQuickWindow::hasDefaultAlphaBuffer()) 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 d33bdffe74..042eee19f5 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)" : ""); } diff --git a/src/quick/scenegraph/util/qsgtexturematerial_p.h b/src/quick/scenegraph/util/qsgtexturematerial_p.h index 093d820801..a99e872580 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial_p.h +++ b/src/quick/scenegraph/util/qsgtexturematerial_p.h @@ -72,7 +72,7 @@ protected: int m_matrix_id; }; -class QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader +class Q_QUICK_PRIVATE_EXPORT QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader { public: QSGTextureMaterialShader(); |