9#include <private/qopenglcontext_p.h>
10#include <private/qopenglextensions_p.h>
13#define GL_HALF_FLOAT 0x140B
21#define GL_GREEN 0x1904
29#define GL_RGB10_A2 0x8059
33#define GL_RGBA16 0x805B
44#ifndef GL_UNSIGNED_INT_8_8_8_8_REV
45#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
48#ifndef GL_UNSIGNED_INT_2_10_10_10_REV
49#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
53#define GL_RGBA16F 0x881A
57#define GL_RGBA32F 0x8814
60#ifndef GL_TEXTURE_SWIZZLE_R
61#define GL_TEXTURE_SWIZZLE_R 0x8E42
64#ifndef GL_TEXTURE_SWIZZLE_G
65#define GL_TEXTURE_SWIZZLE_G 0x8E43
68#ifndef GL_TEXTURE_SWIZZLE_B
69#define GL_TEXTURE_SWIZZLE_B 0x8E44
72#ifndef GL_TEXTURE_SWIZZLE_A
73#define GL_TEXTURE_SWIZZLE_A 0x8E45
80#define GL_SRGB_ALPHA 0x8C42
95 const bool isOpenGL12orBetter = !
context->isOpenGLES() && (
context->format().majorVersion() >= 2 ||
context->format().minorVersion() >= 2);
96 const bool isOpenGLES3orBetter =
context->isOpenGLES() &&
context->format().majorVersion() >= 3;
101 switch (
image.format()) {
105 if (isOpenGL12orBetter) {
109#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
122#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
137 targetFormat =
image.format();
144 }
else if (isOpenGL12orBetter || isOpenGLES3orBetter) {
148 targetFormat =
image.format();
156 }
else if (isOpenGL12orBetter) {
160 targetFormat =
image.format();
167 targetFormat =
image.format();
173 if (isOpenGL12orBetter ||
context->isOpenGLES()) {
186 if (isOpenGL12orBetter) {
204 targetFormat =
image.format();
210 if (isOpenGL12orBetter || (
context->isOpenGLES() &&
context->format().majorVersion() >= 3))
212 pixelType = GL_UNSIGNED_SHORT;
213 targetFormat =
image.format();
218 if (
context->format().majorVersion() >= 3) {
222 targetFormat =
image.format();
229 if (
context->format().majorVersion() >= 3)
232 targetFormat =
image.format();
241 targetFormat =
image.format();
251 targetFormat =
image.format();
255 targetFormat =
image.format();
263 targetFormat =
image.format();
273 targetFormat =
image.format();
277 targetFormat =
image.format();
285 targetFormat =
image.format();
294 pixelType = GL_UNSIGNED_SHORT;
295 targetFormat =
image.format();
298 pixelType = GL_UNSIGNED_SHORT;
299 targetFormat =
image.format();
306 pixelType = GL_UNSIGNED_SHORT;
307 targetFormat =
image.format();
318 if (!
image.hasAlphaChannel())
350 if (
image.hasAlphaChannel())
356 if (
image.format() != targetFormat)
357 tx =
image.convertToFormat(targetFormat);
369 if (newSize != tx.
size())
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
QSize size() const
Returns the size of the image, i.e.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
Format
The following image formats are available in Qt.
@ Format_RGBA32FPx4_Premultiplied
@ Format_RGBA64_Premultiplied
@ Format_RGBA8888_Premultiplied
@ Format_RGBA16FPx4_Premultiplied
@ Format_A2BGR30_Premultiplied
@ Format_ARGB32_Premultiplied
@ Format_A2RGB30_Premultiplied
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
const uchar * constBits() const
Returns a pointer to the first pixel data.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
@ PremultipliedAlphaBindOption
@ UseRedForAlphaAndLuminanceBindOption
static qsizetype textureImage(GLenum target, const QImage &image, BindOptions options, QSize maxSize=QSize())
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
static VulkanServerBufferGlFunctions * funcs
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
constexpr quint32 qNextPowerOfTwo(quint32 v)
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLsizei GLenum internalFormat
#define GL_TEXTURE_SWIZZLE_G
#define GL_TEXTURE_SWIZZLE_A
#define GL_TEXTURE_SWIZZLE_B
#define GL_UNSIGNED_INT_8_8_8_8_REV
#define GL_UNSIGNED_SHORT_5_6_5
#define GL_TEXTURE_SWIZZLE_R
static qsizetype cost(const QPixmap &pixmap)