diff options
Diffstat (limited to 'src/opengl/qopengltexture.cpp')
-rw-r--r-- | src/opengl/qopengltexture.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp index cf8b751648..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) @@ -3253,7 +3251,7 @@ bool QOpenGLTexture::isFixedSamplePositions() const create the mutable storage. You can use the other allocateStorage() overload to specify exactly the pixel format and the pixel type to use when allocating mutable storage; - this is particulary useful under certain OpenGL ES implementations + this is particularly useful under certain OpenGL ES implementations (notably, OpenGL ES 2), where the pixel format and the pixel type used at allocation time must perfectly match the format and the type passed to any subsequent setData() call. @@ -3318,7 +3316,7 @@ bool QOpenGLTexture::isStorageAllocated() const Attempts to create a texture view onto this texture. A texture view is somewhat analogous to a view in SQL in that it presents a restricted or reinterpreted view of the original data. Texture - views do not allocate any more server-side storage, insted relying + views do not allocate any more server-side storage, instead relying on the storage buffer of the source texture. Texture views are only available when using immutable storage. For @@ -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); @@ -4421,7 +4427,7 @@ float QOpenGLTexture::maximumAnisotropy() const } /*! - Sets the wrap (or repeat mode) for all texture dimentions to \a mode. + Sets the wrap (or repeat mode) for all texture dimensions to \a mode. \sa wrapMode() */ |