summaryrefslogtreecommitdiffstats
path: root/src/opengl/qopengltexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qopengltexture.cpp')
-rw-r--r--src/opengl/qopengltexture.cpp79
1 files changed, 26 insertions, 53 deletions
diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp
index 8e8f57d0fc..3b8e14490b 100644
--- a/src/opengl/qopengltexture.cpp
+++ b/src/opengl/qopengltexture.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qopengltexture.h"
#include "qopengltexture_p.h"
@@ -467,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)
@@ -492,8 +455,7 @@ static bool isTextureTargetMultisample(QOpenGLTexture::Target target)
return false;
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool QOpenGLTexturePrivate::isUsingImmutableStorage() const
@@ -792,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)
@@ -972,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)
@@ -1116,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)
@@ -2497,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)
@@ -3289,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.
@@ -3354,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
@@ -3651,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)
@@ -3666,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
@@ -3676,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);
@@ -4262,6 +4232,7 @@ QOpenGLTexture::DepthStencilMode QOpenGLTexture::depthStencilMode() const
\value CompareAlways Equivalent to GL_ALWAYS.
\value CompareNever Equivalent to GL_NEVER.
+ \omitvalue CommpareNotEqual
*/
/*!
@@ -4456,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()
*/
@@ -4871,3 +4842,5 @@ QDebug operator<<(QDebug debug, const QOpenGLTexture *t)
#endif // QT_NO_DEBUG_STREAM
QT_END_NAMESPACE
+
+#include "moc_qopengltexture.cpp"