diff options
Diffstat (limited to 'src/opengl/qopengltexture.cpp')
-rw-r--r-- | src/opengl/qopengltexture.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp index 8dc30cca61..3b8e14490b 100644 --- a/src/opengl/qopengltexture.cpp +++ b/src/opengl/qopengltexture.cpp @@ -431,8 +431,7 @@ static bool isSizedTextureFormat(QOpenGLTexture::TextureFormat internalFormat) return false; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } static bool isTextureTargetMultisample(QOpenGLTexture::Target target) @@ -456,8 +455,7 @@ static bool isTextureTargetMultisample(QOpenGLTexture::Target target) return false; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } bool QOpenGLTexturePrivate::isUsingImmutableStorage() const @@ -756,8 +754,7 @@ static QOpenGLTexture::PixelFormat pixelFormatCompatibleWithInternalFormat(QOpen return QOpenGLTexture::LuminanceAlpha; } - Q_UNREACHABLE(); - return QOpenGLTexture::NoSourceFormat; + Q_UNREACHABLE_RETURN(QOpenGLTexture::NoSourceFormat); } static QOpenGLTexture::PixelType pixelTypeCompatibleWithInternalFormat(QOpenGLTexture::TextureFormat internalFormat) @@ -936,8 +933,7 @@ static QOpenGLTexture::PixelType pixelTypeCompatibleWithInternalFormat(QOpenGLTe return QOpenGLTexture::UInt8; } - Q_UNREACHABLE(); - return QOpenGLTexture::NoPixelType; + Q_UNREACHABLE_RETURN(QOpenGLTexture::NoPixelType); } static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat) @@ -1080,8 +1076,7 @@ static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat) return false; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType) @@ -2461,6 +2456,9 @@ QOpenGLTexture::QOpenGLTexture(Target target) This does create the underlying OpenGL texture object. Therefore, construction using this constructor does require a valid current OpenGL context. + + \note \a image is automatically converted to QImage::Format_RGBA8888 which + may have performance implications for large images with a different format. */ QOpenGLTexture::QOpenGLTexture(const QImage& image, MipMapGeneration genMipMaps) : QOpenGLTexture(QOpenGLTexture::Target2D) @@ -3615,6 +3613,9 @@ void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, The pixel data is contained in \a image. Mipmaps are generated by default. Set \a genMipMaps to \l DontGenerateMipMaps to turn off mipmap generation. + \note \a image is automatically converted to QImage::Format_RGBA8888 which + may have performance implications for large images with a different format. + \overload */ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps) @@ -3630,6 +3631,12 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps) return; } + QImage glImage = image.convertToFormat(QImage::Format_RGBA8888); + if (glImage.isNull()) { + qWarning("QOpenGLTexture::setData() failed to convert image"); + return; + } + if (context->isOpenGLES() && context->format().majorVersion() < 3) setFormat(QOpenGLTexture::RGBAFormat); else @@ -3640,7 +3647,6 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps) allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8); // Upload pixel data and generate mipmaps - QImage glImage = image.convertToFormat(QImage::Format_RGBA8888); QOpenGLPixelTransferOptions uploadOptions; uploadOptions.setAlignment(1); setData(0, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, glImage.constBits(), &uploadOptions); |