Add Qt::Orientations based flip and flipped functions
Is easier to read and more bool-trap safe. Old form header deprecated from 6.10 Fixes: QTBUG-129575 Change-Id: Id785b9ce159007ce745c04120b2112c8bb9b0802 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
7539b659d9
commit
577946c1f0
@ -298,7 +298,7 @@ void HelloWindow::ensureFullscreenTexture(const QSize &pixelSize, QRhiResourceUp
|
|||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
if (m_rhi->isYUpInNDC())
|
if (m_rhi->isYUpInNDC())
|
||||||
image = image.mirrored();
|
image.flip();
|
||||||
|
|
||||||
//! [ensure-texture-2]
|
//! [ensure-texture-2]
|
||||||
u->uploadTexture(m_texture.get(), image);
|
u->uploadTexture(m_texture.get(), image);
|
||||||
|
@ -103,7 +103,7 @@ void MainWidget::initShaders()
|
|||||||
void MainWidget::initTextures()
|
void MainWidget::initTextures()
|
||||||
{
|
{
|
||||||
// Load cube.png image
|
// Load cube.png image
|
||||||
texture = new QOpenGLTexture(QImage(":/cube.png").mirrored());
|
texture = new QOpenGLTexture(QImage(":/cube.png").flipped());
|
||||||
|
|
||||||
// Set nearest filtering mode for texture minification
|
// Set nearest filtering mode for texture minification
|
||||||
texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
||||||
|
@ -144,7 +144,7 @@ void GLWindow::initializeGL()
|
|||||||
QImage img(":/qtlogo.png");
|
QImage img(":/qtlogo.png");
|
||||||
Q_ASSERT(!img.isNull());
|
Q_ASSERT(!img.isNull());
|
||||||
delete m_texture;
|
delete m_texture;
|
||||||
m_texture = new QOpenGLTexture(img.scaled(32, 36).mirrored());
|
m_texture = new QOpenGLTexture(img.scaled(32, 36).flipped());
|
||||||
|
|
||||||
delete m_program;
|
delete m_program;
|
||||||
m_program = new QOpenGLShaderProgram;
|
m_program = new QOpenGLShaderProgram;
|
||||||
|
@ -152,7 +152,7 @@ void GLWidget::makeObject()
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int j = 0; j < 6; ++j)
|
for (int j = 0; j < 6; ++j)
|
||||||
textures[j] = new QOpenGLTexture(QImage(QString(":/images/side%1.png").arg(j + 1)).mirrored());
|
textures[j] = new QOpenGLTexture(QImage(QString(":/images/side%1.png").arg(j + 1)).flipped());
|
||||||
|
|
||||||
QList<GLfloat> vertData;
|
QList<GLfloat> vertData;
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
@ -142,7 +142,7 @@ int main(int argc, char **argv)
|
|||||||
readbackResult.pixelSize.height(),
|
readbackResult.pixelSize.height(),
|
||||||
QImage::Format_RGBA8888_Premultiplied);
|
QImage::Format_RGBA8888_Premultiplied);
|
||||||
if (rhi->isYUpInFramebuffer())
|
if (rhi->isYUpInFramebuffer())
|
||||||
image = image.mirrored();
|
image.flip();
|
||||||
image.save(QString::asprintf("frame%d.png", frame));
|
image.save(QString::asprintf("frame%d.png", frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3293,6 +3293,7 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const
|
|||||||
/*!
|
/*!
|
||||||
\fn QImage QImage::mirrored(bool horizontal = false, bool vertical = true) const &
|
\fn QImage QImage::mirrored(bool horizontal = false, bool vertical = true) const &
|
||||||
\fn QImage QImage::mirrored(bool horizontal = false, bool vertical = true) &&
|
\fn QImage QImage::mirrored(bool horizontal = false, bool vertical = true) &&
|
||||||
|
\deprecated [6.9] Use flipped(Qt::Orientations) instead.
|
||||||
|
|
||||||
Returns a mirror of the image, mirrored in the horizontal and/or
|
Returns a mirror of the image, mirrored in the horizontal and/or
|
||||||
the vertical direction depending on whether \a horizontal and \a
|
the vertical direction depending on whether \a horizontal and \a
|
||||||
@ -3306,6 +3307,7 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const
|
|||||||
/*!
|
/*!
|
||||||
\fn void QImage::mirror(bool horizontal = false, bool vertical = true)
|
\fn void QImage::mirror(bool horizontal = false, bool vertical = true)
|
||||||
\since 6.0
|
\since 6.0
|
||||||
|
\deprecated [6.9] Use flip(Qt::Orientations) instead.
|
||||||
|
|
||||||
Mirrors of the image in the horizontal and/or the vertical direction depending
|
Mirrors of the image in the horizontal and/or the vertical direction depending
|
||||||
on whether \a horizontal and \a vertical are set to true or false.
|
on whether \a horizontal and \a vertical are set to true or false.
|
||||||
@ -3313,6 +3315,29 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const
|
|||||||
\sa mirrored(), {QImage#Image Transformations}{Image Transformations}
|
\sa mirrored(), {QImage#Image Transformations}{Image Transformations}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QImage QImage::flipped(Qt::Orientations orient) const &
|
||||||
|
\fn QImage QImage::flipped(Qt::Orientations orient) &&
|
||||||
|
\since 6.9
|
||||||
|
|
||||||
|
Returns a flipped or mirror version of the image, mirrored in the horizontal and/or
|
||||||
|
the vertical direction depending on \a orient.
|
||||||
|
|
||||||
|
Note that the original image is not changed.
|
||||||
|
|
||||||
|
\sa flip(Qt::Orientations), {QImage#Image Transformations}{Image Transformations}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void QImage::flip(Qt::Orientations orient)
|
||||||
|
\since 6.9
|
||||||
|
|
||||||
|
Flips or mirrors the image in the horizontal and/or the vertical direction depending
|
||||||
|
on \a orient.
|
||||||
|
|
||||||
|
\sa flipped(Qt::Orientations), {QImage#Image Transformations}{Image Transformations}
|
||||||
|
*/
|
||||||
|
|
||||||
template<class T> inline void do_mirror_data(QImageData *dst, QImageData *src,
|
template<class T> inline void do_mirror_data(QImageData *dst, QImageData *src,
|
||||||
int dstX0, int dstY0,
|
int dstX0, int dstY0,
|
||||||
int dstXIncr, int dstYIncr,
|
int dstXIncr, int dstYIncr,
|
||||||
@ -4739,7 +4764,7 @@ static QImage rotated180(const QImage &image)
|
|||||||
{
|
{
|
||||||
const MemRotateFunc memrotate = qMemRotateFunctions[qPixelLayouts[image.format()].bpp][1];
|
const MemRotateFunc memrotate = qMemRotateFunctions[qPixelLayouts[image.format()].bpp][1];
|
||||||
if (!memrotate)
|
if (!memrotate)
|
||||||
return image.mirrored(true, true);
|
return image.flipped(Qt::Horizontal | Qt::Vertical);
|
||||||
|
|
||||||
QImage out(image.width(), image.height(), image.format());
|
QImage out(image.width(), image.height(), image.format());
|
||||||
if (out.isNull())
|
if (out.isNull())
|
||||||
@ -4889,11 +4914,11 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::transformed(const QTransform &matrix, Q
|
|||||||
) {
|
) {
|
||||||
QImage scaledImage;
|
QImage scaledImage;
|
||||||
if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip
|
if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip
|
||||||
scaledImage = smoothScaled(wd, hd).mirrored(true, true);
|
scaledImage = smoothScaled(wd, hd).flipped(Qt::Horizontal | Qt::Vertical);
|
||||||
} else if (mat.m11() < 0.0F) { // horizontal flip
|
} else if (mat.m11() < 0.0F) { // horizontal flip
|
||||||
scaledImage = smoothScaled(wd, hd).mirrored(true, false);
|
scaledImage = smoothScaled(wd, hd).flipped(Qt::Horizontal);
|
||||||
} else if (mat.m22() < 0.0F) { // vertical flip
|
} else if (mat.m22() < 0.0F) { // vertical flip
|
||||||
scaledImage = smoothScaled(wd, hd).mirrored(false, true);
|
scaledImage = smoothScaled(wd, hd).flipped(Qt::Vertical);
|
||||||
} else { // no flipping
|
} else { // no flipping
|
||||||
scaledImage = smoothScaled(wd, hd);
|
scaledImage = smoothScaled(wd, hd);
|
||||||
}
|
}
|
||||||
@ -6440,6 +6465,16 @@ QImage::Format QImage::toImageFormat(QPixelFormat format) noexcept
|
|||||||
return Format_Invalid;
|
return Format_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Qt::Orientations toOrientations(QImageIOHandler::Transformations orient)
|
||||||
|
{
|
||||||
|
Qt::Orientations orients = {};
|
||||||
|
if (orient.testFlag(QImageIOHandler::TransformationMirror))
|
||||||
|
orients |= Qt::Horizontal;
|
||||||
|
if (orient.testFlag(QImageIOHandler::TransformationFlip))
|
||||||
|
orients |= Qt::Vertical;
|
||||||
|
return orients;
|
||||||
|
}
|
||||||
|
|
||||||
Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient)
|
Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient)
|
||||||
{
|
{
|
||||||
if (orient == QImageIOHandler::TransformationNone)
|
if (orient == QImageIOHandler::TransformationNone)
|
||||||
@ -6447,8 +6482,7 @@ Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformation
|
|||||||
if (orient == QImageIOHandler::TransformationRotate270) {
|
if (orient == QImageIOHandler::TransformationRotate270) {
|
||||||
src = rotated270(src);
|
src = rotated270(src);
|
||||||
} else {
|
} else {
|
||||||
src = std::move(src).mirrored(orient & QImageIOHandler::TransformationMirror,
|
src.flip(toOrientations(orient));
|
||||||
orient & QImageIOHandler::TransformationFlip);
|
|
||||||
if (orient & QImageIOHandler::TransformationRotate90)
|
if (orient & QImageIOHandler::TransformationRotate90)
|
||||||
src = rotated90(src);
|
src = rotated90(src);
|
||||||
}
|
}
|
||||||
|
@ -215,17 +215,27 @@ public:
|
|||||||
[[nodiscard]] QImage scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
[[nodiscard]] QImage scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
||||||
[[nodiscard]] QImage transformed(const QTransform &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
[[nodiscard]] QImage transformed(const QTransform &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
||||||
static QTransform trueMatrix(const QTransform &, int w, int h);
|
static QTransform trueMatrix(const QTransform &, int w, int h);
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 10)
|
||||||
|
QT_DEPRECATED_VERSION_X_6_10("Use flipped(Qt::Orientations) instead")
|
||||||
[[nodiscard]] QImage mirrored(bool horizontally = false, bool vertically = true) const &
|
[[nodiscard]] QImage mirrored(bool horizontally = false, bool vertically = true) const &
|
||||||
{ return mirrored_helper(horizontally, vertically); }
|
{ return mirrored_helper(horizontally, vertically); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_10("Use flipped(Qt::Orientations) instead")
|
||||||
[[nodiscard]] QImage mirrored(bool horizontally = false, bool vertically = true) &&
|
[[nodiscard]] QImage mirrored(bool horizontally = false, bool vertically = true) &&
|
||||||
{ mirrored_inplace(horizontally, vertically); return std::move(*this); }
|
{ mirrored_inplace(horizontally, vertically); return std::move(*this); }
|
||||||
|
QT_DEPRECATED_VERSION_X_6_10("Use flip(Qt::Orientations) instead")
|
||||||
|
void mirror(bool horizontally = false, bool vertically = true)
|
||||||
|
{ mirrored_inplace(horizontally, vertically); }
|
||||||
|
#endif
|
||||||
[[nodiscard]] QImage rgbSwapped() const &
|
[[nodiscard]] QImage rgbSwapped() const &
|
||||||
{ return rgbSwapped_helper(); }
|
{ return rgbSwapped_helper(); }
|
||||||
[[nodiscard]] QImage rgbSwapped() &&
|
[[nodiscard]] QImage rgbSwapped() &&
|
||||||
{ rgbSwapped_inplace(); return std::move(*this); }
|
{ rgbSwapped_inplace(); return std::move(*this); }
|
||||||
void mirror(bool horizontally = false, bool vertically = true)
|
[[nodiscard]] QImage flipped(Qt::Orientations orient = Qt::Vertical) const &
|
||||||
{ mirrored_inplace(horizontally, vertically); }
|
{ return mirrored_helper(orient.testFlag(Qt::Horizontal), orient.testFlag(Qt::Vertical)); }
|
||||||
|
[[nodiscard]] QImage flipped(Qt::Orientations orient = Qt::Vertical) &&
|
||||||
|
{ mirrored_inplace(orient.testFlag(Qt::Horizontal), orient.testFlag(Qt::Vertical)); return std::move(*this); }
|
||||||
|
void flip(Qt::Orientations orient = Qt::Vertical)
|
||||||
|
{ mirrored_inplace(orient.testFlag(Qt::Horizontal), orient.testFlag(Qt::Vertical)); }
|
||||||
void rgbSwap()
|
void rgbSwap()
|
||||||
{ rgbSwapped_inplace(); }
|
{ rgbSwapped_inplace(); }
|
||||||
void invertPixels(InvertMode = InvertRgb);
|
void invertPixels(InvertMode = InvertRgb);
|
||||||
|
@ -1418,30 +1418,31 @@ static QImage qt_gl_read_framebuffer(const QSize &size, GLenum internal_format,
|
|||||||
if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST)
|
if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Qt::Orientations orient = flip ? Qt::Vertical : Qt::Orientations{};
|
||||||
switch (internal_format) {
|
switch (internal_format) {
|
||||||
case GL_RGB:
|
case GL_RGB:
|
||||||
case GL_RGB8:
|
case GL_RGB8:
|
||||||
return qt_gl_read_framebuffer_rgba8(size, false, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba8(size, false, ctx).flipped(orient);
|
||||||
case GL_RGB10:
|
case GL_RGB10:
|
||||||
return qt_gl_read_framebuffer_rgb10a2(size, false, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgb10a2(size, false, ctx).flipped(orient);
|
||||||
case GL_RGB10_A2:
|
case GL_RGB10_A2:
|
||||||
return qt_gl_read_framebuffer_rgb10a2(size, include_alpha, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgb10a2(size, include_alpha, ctx).flipped(orient);
|
||||||
case GL_RGB16:
|
case GL_RGB16:
|
||||||
return qt_gl_read_framebuffer_rgba16(size, false, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba16(size, false, ctx).flipped(orient);
|
||||||
case GL_RGBA16:
|
case GL_RGBA16:
|
||||||
return qt_gl_read_framebuffer_rgba16(size, include_alpha, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba16(size, include_alpha, ctx).flipped(orient);
|
||||||
case GL_RGB16F:
|
case GL_RGB16F:
|
||||||
return qt_gl_read_framebuffer_rgba16f(size, false, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba16f(size, false, ctx).flipped(orient);
|
||||||
case GL_RGBA16F:
|
case GL_RGBA16F:
|
||||||
return qt_gl_read_framebuffer_rgba16f(size, include_alpha, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba16f(size, include_alpha, ctx).flipped(orient);
|
||||||
case GL_RGB32F:
|
case GL_RGB32F:
|
||||||
return qt_gl_read_framebuffer_rgba32f(size, false, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba32f(size, false, ctx).flipped(orient);
|
||||||
case GL_RGBA32F:
|
case GL_RGBA32F:
|
||||||
return qt_gl_read_framebuffer_rgba32f(size, include_alpha, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba32f(size, include_alpha, ctx).flipped(orient);
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
case GL_RGBA8:
|
case GL_RGBA8:
|
||||||
default:
|
default:
|
||||||
return qt_gl_read_framebuffer_rgba8(size, include_alpha, ctx).mirrored(false, flip);
|
return qt_gl_read_framebuffer_rgba8(size, include_alpha, ctx).flipped(orient);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_UNREACHABLE_RETURN(QImage());
|
Q_UNREACHABLE_RETURN(QImage());
|
||||||
|
@ -2059,7 +2059,7 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target
|
|||||||
|
|
||||||
\code
|
\code
|
||||||
// Prepare texture
|
// Prepare texture
|
||||||
QOpenGLTexture *texture = new QOpenGLTexture(QImage(fileName).mirrored());
|
QOpenGLTexture *texture = new QOpenGLTexture(QImage(fileName).flipped());
|
||||||
texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
|
texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
|
||||||
texture->setMagnificationFilter(QOpenGLTexture::Linear);
|
texture->setMagnificationFilter(QOpenGLTexture::Linear);
|
||||||
...
|
...
|
||||||
@ -2068,7 +2068,7 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target
|
|||||||
glDrawArrays(...);
|
glDrawArrays(...);
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
Note that the QImage is mirrored vertically to account for the fact that
|
Note that the QImage is flipped vertically to account for the fact that
|
||||||
OpenGL and QImage use opposite directions for the y axis. Another option
|
OpenGL and QImage use opposite directions for the y axis. Another option
|
||||||
would be to transform your texture coordinates.
|
would be to transform your texture coordinates.
|
||||||
*/
|
*/
|
||||||
|
@ -674,7 +674,7 @@ void QOpenGLTextureBlitter::setOpacity(float opacity)
|
|||||||
\a texture corresponds to a texture attached to an FBO pass
|
\a texture corresponds to a texture attached to an FBO pass
|
||||||
OriginBottomLeft. On the other hand, when \a texture is based on
|
OriginBottomLeft. On the other hand, when \a texture is based on
|
||||||
unflipped image data, pass OriginTopLeft. This is more efficient
|
unflipped image data, pass OriginTopLeft. This is more efficient
|
||||||
than using QImage::mirrored().
|
than using QImage::flipped().
|
||||||
|
|
||||||
\sa targetTransform(), Origin, bind()
|
\sa targetTransform(), Origin, bind()
|
||||||
*/
|
*/
|
||||||
|
@ -978,8 +978,13 @@ bool QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(QWindowsThemeData
|
|||||||
rotMatrix.rotate(themeData.rotate);
|
rotMatrix.rotate(themeData.rotate);
|
||||||
imgCopy = imgCopy.transformed(rotMatrix);
|
imgCopy = imgCopy.transformed(rotMatrix);
|
||||||
}
|
}
|
||||||
|
Qt::Orientations orient = {};
|
||||||
|
if (themeData.mirrorHorizontally)
|
||||||
|
orient |= Qt::Horizontal;
|
||||||
|
if (themeData.mirrorVertically)
|
||||||
|
orient |= Qt::Vertical;
|
||||||
if (themeData.mirrorHorizontally || themeData.mirrorVertically)
|
if (themeData.mirrorHorizontally || themeData.mirrorVertically)
|
||||||
imgCopy = imgCopy.mirrored(themeData.mirrorHorizontally, themeData.mirrorVertically);
|
imgCopy.flip(orient);
|
||||||
painter->drawImage(themeData.rect, imgCopy);
|
painter->drawImage(themeData.rect, imgCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ QImage QRhiWidgetPrivate::grabFramebuffer()
|
|||||||
imageFormat);
|
imageFormat);
|
||||||
QImage result;
|
QImage result;
|
||||||
if (rhi->isYUpInFramebuffer())
|
if (rhi->isYUpInFramebuffer())
|
||||||
result = wrapperImage.mirrored();
|
result = wrapperImage.flipped();
|
||||||
else
|
else
|
||||||
result = wrapperImage.copy();
|
result = wrapperImage.copy();
|
||||||
result.setDevicePixelRatio(q->devicePixelRatio());
|
result.setDevicePixelRatio(q->devicePixelRatio());
|
||||||
|
@ -5545,7 +5545,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti
|
|||||||
switch (sp) {
|
switch (sp) {
|
||||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||||
if (d->rtl(option)) {
|
if (d->rtl(option)) {
|
||||||
auto im = QImage(tb_extension_arrow_h_xpm).convertToFormat(QImage::Format_ARGB32).mirrored(true, false);
|
auto im = QImage(tb_extension_arrow_h_xpm).convertToFormat(QImage::Format_ARGB32).flipped(Qt::Horizontal);
|
||||||
return QPixmap::fromImage(std::move(im));
|
return QPixmap::fromImage(std::move(im));
|
||||||
}
|
}
|
||||||
return cachedPixmapFromXPM(tb_extension_arrow_h_xpm);
|
return cachedPixmapFromXPM(tb_extension_arrow_h_xpm);
|
||||||
|
@ -148,6 +148,8 @@ private slots:
|
|||||||
|
|
||||||
void mirrored_data();
|
void mirrored_data();
|
||||||
void mirrored();
|
void mirrored();
|
||||||
|
void flipped_data();
|
||||||
|
void flipped();
|
||||||
|
|
||||||
void inplaceRgbSwapped_data();
|
void inplaceRgbSwapped_data();
|
||||||
void inplaceRgbSwapped();
|
void inplaceRgbSwapped();
|
||||||
@ -2766,6 +2768,7 @@ void tst_QImage::mirrored_data()
|
|||||||
QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 21 << 16;
|
QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 21 << 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 10)
|
||||||
void tst_QImage::mirrored()
|
void tst_QImage::mirrored()
|
||||||
{
|
{
|
||||||
QFETCH(QImage::Format, format);
|
QFETCH(QImage::Format, format);
|
||||||
@ -2823,6 +2826,83 @@ void tst_QImage::mirrored()
|
|||||||
QCOMPARE(image.pixel(j,i), imageMirrored.pixel(j,i));
|
QCOMPARE(image.pixel(j,i), imageMirrored.pixel(j,i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void tst_QImage::flipped_data()
|
||||||
|
{
|
||||||
|
mirrored_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QImage::flipped()
|
||||||
|
{
|
||||||
|
QFETCH(QImage::Format, format);
|
||||||
|
QFETCH(bool, swap_vertical);
|
||||||
|
QFETCH(bool, swap_horizontal);
|
||||||
|
QFETCH(int, width);
|
||||||
|
QFETCH(int, height);
|
||||||
|
Q_ASSERT(swap_vertical | swap_horizontal);
|
||||||
|
|
||||||
|
QImage image(width, height, format);
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case QImage::Format_Mono:
|
||||||
|
case QImage::Format_MonoLSB:
|
||||||
|
for (int i = 0; i < image.height(); ++i) {
|
||||||
|
ushort* scanLine = (ushort*)image.scanLine(i);
|
||||||
|
*scanLine = (i % 2) ? 0x5555U : 0xCCCCU;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QImage::Format_Indexed8:
|
||||||
|
for (int i = 0; i < image.height(); ++i) {
|
||||||
|
for (int j = 0; j < image.width(); ++j) {
|
||||||
|
image.setColor(i*16+j, qRgb(j*16, i*16, 0));
|
||||||
|
image.setPixel(j, i, i*16+j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
for (int i = 0; i < image.height(); ++i)
|
||||||
|
for (int j = 0; j < image.width(); ++j)
|
||||||
|
image.setPixel(j, i, qRgb(j*16, i*16, 0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage imageMirrored;
|
||||||
|
if (swap_vertical && swap_horizontal)
|
||||||
|
imageMirrored = image.flipped(Qt::Horizontal | Qt::Vertical);
|
||||||
|
else if (swap_horizontal)
|
||||||
|
imageMirrored = image.flipped(Qt::Horizontal);
|
||||||
|
else
|
||||||
|
imageMirrored = image.flipped(Qt::Vertical);
|
||||||
|
|
||||||
|
for (int i = 0; i < image.height(); ++i) {
|
||||||
|
int mirroredI = swap_vertical ? (image.height() - i - 1) : i;
|
||||||
|
for (int j = 0; j < image.width(); ++j) {
|
||||||
|
QRgb referenceColor = image.pixel(j, i);
|
||||||
|
int mirroredJ = swap_horizontal ? (image.width() - j - 1) : j;
|
||||||
|
QRgb mirroredColor = imageMirrored.pixel(mirroredJ, mirroredI);
|
||||||
|
QCOMPARE(mirroredColor, referenceColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (swap_vertical && swap_horizontal)
|
||||||
|
imageMirrored.flip(Qt::Horizontal | Qt::Vertical);
|
||||||
|
else if (swap_horizontal)
|
||||||
|
imageMirrored.flip(Qt::Horizontal);
|
||||||
|
else
|
||||||
|
imageMirrored.flip(Qt::Vertical);
|
||||||
|
|
||||||
|
QCOMPARE(image, imageMirrored);
|
||||||
|
|
||||||
|
if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB)
|
||||||
|
QCOMPARE(memcmp(image.constBits(), imageMirrored.constBits(), image.sizeInBytes()), 0);
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < image.height(); ++i)
|
||||||
|
for (int j = 0; j < image.width(); ++j)
|
||||||
|
QCOMPARE(image.pixel(j,i), imageMirrored.pixel(j,i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void tst_QImage::inplaceRgbSwapped_data()
|
void tst_QImage::inplaceRgbSwapped_data()
|
||||||
{
|
{
|
||||||
@ -2897,8 +2977,7 @@ void tst_QImage::inplaceRgbSwapped()
|
|||||||
void tst_QImage::inplaceMirrored_data()
|
void tst_QImage::inplaceMirrored_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QImage::Format>("format");
|
QTest::addColumn<QImage::Format>("format");
|
||||||
QTest::addColumn<bool>("swap_vertical");
|
QTest::addColumn<Qt::Orientations>("swap_orient");
|
||||||
QTest::addColumn<bool>("swap_horizontal");
|
|
||||||
|
|
||||||
for (int i = QImage::Format_Mono; i < QImage::NImageFormats; ++i) {
|
for (int i = QImage::Format_Mono; i < QImage::NImageFormats; ++i) {
|
||||||
if (i == QImage::Format_Alpha8
|
if (i == QImage::Format_Alpha8
|
||||||
@ -2910,20 +2989,20 @@ void tst_QImage::inplaceMirrored_data()
|
|||||||
continue;
|
continue;
|
||||||
const auto fmt = formatToString(QImage::Format(i));
|
const auto fmt = formatToString(QImage::Format(i));
|
||||||
QTest::addRow("%s, vertical", fmt.data())
|
QTest::addRow("%s, vertical", fmt.data())
|
||||||
<< QImage::Format(i) << true << false;
|
<< QImage::Format(i) << Qt::Orientations(Qt::Vertical);
|
||||||
QTest::addRow("%s, horizontal", fmt.data())
|
QTest::addRow("%s, horizontal", fmt.data())
|
||||||
<< QImage::Format(i) << false << true;
|
<< QImage::Format(i) << Qt::Orientations(Qt::Horizontal);
|
||||||
QTest::addRow("%s, horizontal+vertical", fmt.data())
|
QTest::addRow("%s, horizontal+vertical", fmt.data())
|
||||||
<< QImage::Format(i) << true << true;
|
<< QImage::Format(i) << (Qt::Vertical | Qt::Horizontal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QImage::inplaceMirrored()
|
void tst_QImage::inplaceMirrored()
|
||||||
{
|
{
|
||||||
#if defined(Q_COMPILER_REF_QUALIFIERS)
|
|
||||||
QFETCH(QImage::Format, format);
|
QFETCH(QImage::Format, format);
|
||||||
QFETCH(bool, swap_vertical);
|
QFETCH(Qt::Orientations, swap_orient);
|
||||||
QFETCH(bool, swap_horizontal);
|
bool swap_horizontal = swap_orient.testFlag(Qt::Horizontal);
|
||||||
|
bool swap_vertical = swap_orient.testFlag(Qt::Vertical);
|
||||||
|
|
||||||
QImage image(16, 16, format);
|
QImage image(16, 16, format);
|
||||||
|
|
||||||
@ -2951,7 +3030,7 @@ void tst_QImage::inplaceMirrored()
|
|||||||
|
|
||||||
const uchar* originalPtr = image.constScanLine(0);
|
const uchar* originalPtr = image.constScanLine(0);
|
||||||
|
|
||||||
QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical);
|
QImage imageMirrored = std::move(image).flipped(swap_orient);
|
||||||
if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB) {
|
if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB) {
|
||||||
for (int i = 0; i < imageMirrored.height(); ++i) {
|
for (int i = 0; i < imageMirrored.height(); ++i) {
|
||||||
int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
|
int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
|
||||||
@ -2996,43 +3075,40 @@ void tst_QImage::inplaceMirrored()
|
|||||||
if (orig.colorCount())
|
if (orig.colorCount())
|
||||||
dataImage.setColorTable(orig.colorTable());
|
dataImage.setColorTable(orig.colorTable());
|
||||||
|
|
||||||
dataSwapped = std::move(dataImage).mirrored(swap_horizontal, swap_vertical);
|
dataSwapped = std::move(dataImage).flipped(swap_orient);
|
||||||
QVERIFY(!dataSwapped.isNull());
|
QVERIFY(!dataSwapped.isNull());
|
||||||
delete[] volatileData;
|
delete[] volatileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVERIFY2(dataSwapped.constBits() != volatileData, rw ? "non-const" : "const");
|
QVERIFY2(dataSwapped.constBits() != volatileData, rw ? "non-const" : "const");
|
||||||
QCOMPARE(dataSwapped, orig.mirrored(swap_horizontal, swap_vertical));
|
QCOMPARE(dataSwapped, orig.flipped(swap_orient));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QImage::inplaceMirroredOdd_data()
|
void tst_QImage::inplaceMirroredOdd_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QImage::Format>("format");
|
QTest::addColumn<QImage::Format>("format");
|
||||||
QTest::addColumn<bool>("swap_vertical");
|
QTest::addColumn<Qt::Orientations>("swap_orient");
|
||||||
QTest::addColumn<bool>("swap_horizontal");
|
|
||||||
|
|
||||||
QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false;
|
QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << Qt::Orientations(Qt::Vertical);
|
||||||
QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false;
|
QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << Qt::Orientations(Qt::Vertical);
|
||||||
QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false;
|
QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << Qt::Orientations(Qt::Vertical);
|
||||||
|
|
||||||
QTest::newRow("Format_ARGB32, horizontal") << QImage::Format_ARGB32 << false << true;
|
QTest::newRow("Format_ARGB32, horizontal") << QImage::Format_ARGB32 << Qt::Orientations(Qt::Horizontal);
|
||||||
QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true;
|
QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << Qt::Orientations(Qt::Horizontal);
|
||||||
QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true;
|
QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << Qt::Orientations(Qt::Horizontal);
|
||||||
|
|
||||||
QTest::newRow("Format_ARGB32, horizontal+vertical") << QImage::Format_ARGB32 << true << true;
|
QTest::newRow("Format_ARGB32, horizontal+vertical") << QImage::Format_ARGB32 << (Qt::Vertical | Qt::Horizontal);
|
||||||
QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true;
|
QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << (Qt::Vertical | Qt::Horizontal);
|
||||||
QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true;
|
QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << (Qt::Vertical | Qt::Horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QImage::inplaceMirroredOdd()
|
void tst_QImage::inplaceMirroredOdd()
|
||||||
{
|
{
|
||||||
#if defined(Q_COMPILER_REF_QUALIFIERS)
|
|
||||||
QFETCH(QImage::Format, format);
|
QFETCH(QImage::Format, format);
|
||||||
QFETCH(bool, swap_vertical);
|
QFETCH(Qt::Orientations, swap_orient);
|
||||||
QFETCH(bool, swap_horizontal);
|
bool swap_horizontal = swap_orient.testFlag(Qt::Horizontal);
|
||||||
|
bool swap_vertical = swap_orient.testFlag(Qt::Vertical);
|
||||||
|
|
||||||
QImage image(15, 15, format);
|
QImage image(15, 15, format);
|
||||||
|
|
||||||
@ -3042,7 +3118,7 @@ void tst_QImage::inplaceMirroredOdd()
|
|||||||
|
|
||||||
const uchar* originalPtr = image.constScanLine(0);
|
const uchar* originalPtr = image.constScanLine(0);
|
||||||
|
|
||||||
QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical);
|
QImage imageMirrored = std::move(image).flipped(swap_orient);
|
||||||
for (int i = 0; i < imageMirrored.height(); ++i) {
|
for (int i = 0; i < imageMirrored.height(); ++i) {
|
||||||
int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
|
int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
|
||||||
for (int j = 0; j < imageMirrored.width(); ++j) {
|
for (int j = 0; j < imageMirrored.width(); ++j) {
|
||||||
@ -3053,12 +3129,10 @@ void tst_QImage::inplaceMirroredOdd()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QCOMPARE(imageMirrored.constScanLine(0), originalPtr);
|
QCOMPARE(imageMirrored.constScanLine(0), originalPtr);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QImage::inplaceRgbMirrored()
|
void tst_QImage::inplaceRgbMirrored()
|
||||||
{
|
{
|
||||||
#if defined(Q_COMPILER_REF_QUALIFIERS)
|
|
||||||
QImage image1(32, 32, QImage::Format_ARGB32);
|
QImage image1(32, 32, QImage::Format_ARGB32);
|
||||||
QImage image2(32, 32, QImage::Format_ARGB32);
|
QImage image2(32, 32, QImage::Format_ARGB32);
|
||||||
image1.fill(0);
|
image1.fill(0);
|
||||||
@ -3066,9 +3140,8 @@ void tst_QImage::inplaceRgbMirrored()
|
|||||||
const uchar* originalPtr1 = image1.constScanLine(0);
|
const uchar* originalPtr1 = image1.constScanLine(0);
|
||||||
const uchar* originalPtr2 = image2.constScanLine(0);
|
const uchar* originalPtr2 = image2.constScanLine(0);
|
||||||
|
|
||||||
QCOMPARE(std::move(image1).rgbSwapped().mirrored().constScanLine(0), originalPtr1);
|
QCOMPARE(std::move(image1).rgbSwapped().flipped().constScanLine(0), originalPtr1);
|
||||||
QCOMPARE(std::move(image2).mirrored().rgbSwapped().constScanLine(0), originalPtr2);
|
QCOMPARE(std::move(image2).flipped().rgbSwapped().constScanLine(0), originalPtr2);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QImage::genericRgbConversion_data()
|
void tst_QImage::genericRgbConversion_data()
|
||||||
@ -4013,7 +4086,7 @@ void tst_QImage::metadataPassthrough()
|
|||||||
QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
|
QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio());
|
||||||
QCOMPARE(scaled.colorSpace(), a.colorSpace());
|
QCOMPARE(scaled.colorSpace(), a.colorSpace());
|
||||||
|
|
||||||
QImage mirrored = a.mirrored();
|
QImage mirrored = a.flipped();
|
||||||
QCOMPARE(mirrored.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
|
QCOMPARE(mirrored.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
|
||||||
QCOMPARE(mirrored.dotsPerMeterX(), a.dotsPerMeterX());
|
QCOMPARE(mirrored.dotsPerMeterX(), a.dotsPerMeterX());
|
||||||
QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY());
|
QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY());
|
||||||
|
@ -3864,7 +3864,7 @@ void tst_QPainter::linearGradientSymmetry()
|
|||||||
pb.fillRect(b.rect(), inverseGradient(gradient));
|
pb.fillRect(b.rect(), inverseGradient(gradient));
|
||||||
pb.end();
|
pb.end();
|
||||||
|
|
||||||
b = b.mirrored(true);
|
b = b.flipped(Qt::Horizontal | Qt::Vertical);
|
||||||
QCOMPARE(a, b);
|
QCOMPARE(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2286,7 +2286,7 @@ void tst_QRhi::renderToTextureTexturedQuad()
|
|||||||
// just happens to give correct results with our OpenGL-targeted vertex and
|
// just happens to give correct results with our OpenGL-targeted vertex and
|
||||||
// UV data.
|
// UV data.
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// check a few points that are expected to match regardless of the implementation
|
// check a few points that are expected to match regardless of the implementation
|
||||||
QRgb white = qRgba(255, 255, 255, 255);
|
QRgb white = qRgba(255, 255, 255, 255);
|
||||||
@ -2412,7 +2412,7 @@ void tst_QRhi::renderToTextureSampleWithSeparateTextureAndSampler()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
QRgb white = qRgba(255, 255, 255, 255);
|
QRgb white = qRgba(255, 255, 255, 255);
|
||||||
QCOMPARE(result.pixel(79, 77), white);
|
QCOMPARE(result.pixel(79, 77), white);
|
||||||
@ -2556,7 +2556,7 @@ void tst_QRhi::renderToTextureArrayOfTexturedQuad()
|
|||||||
// just happens to give correct results with our OpenGL-targeted vertex and
|
// just happens to give correct results with our OpenGL-targeted vertex and
|
||||||
// UV data.
|
// UV data.
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// we added the input image + red + green together, so red and green must be all 1
|
// we added the input image + red + green together, so red and green must be all 1
|
||||||
for (int y = 0; y < result.height(); ++y) {
|
for (int y = 0; y < result.height(); ++y) {
|
||||||
@ -2721,8 +2721,8 @@ void tst_QRhi::renderToTextureTexturedQuadAndUniformBuffer()
|
|||||||
QVERIFY(!result1.isNull());
|
QVERIFY(!result1.isNull());
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC()) {
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC()) {
|
||||||
result0 = std::move(result0).mirrored();
|
result0.flip();
|
||||||
result1 = std::move(result1).mirrored();
|
result1.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl == QRhi::Null)
|
if (impl == QRhi::Null)
|
||||||
@ -2928,8 +2928,8 @@ void tst_QRhi::renderToTextureTexturedQuadAllDynamicBuffers()
|
|||||||
QVERIFY(!result1.isNull());
|
QVERIFY(!result1.isNull());
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC()) {
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC()) {
|
||||||
result0 = std::move(result0).mirrored();
|
result0.flip();
|
||||||
result1 = std::move(result1).mirrored();
|
result1.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl == QRhi::Null)
|
if (impl == QRhi::Null)
|
||||||
@ -3089,7 +3089,7 @@ void tst_QRhi::renderToTextureDeferredSrb()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// opacity 0.5 (premultiplied)
|
// opacity 0.5 (premultiplied)
|
||||||
static const auto checkSemiWhite = [](const QRgb &c) {
|
static const auto checkSemiWhite = [](const QRgb &c) {
|
||||||
@ -3230,7 +3230,7 @@ void tst_QRhi::renderToTextureDeferredUpdateSamplerInSrb()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// opacity 0.5 (premultiplied)
|
// opacity 0.5 (premultiplied)
|
||||||
static const auto checkSemiWhite = [](const QRgb &c) {
|
static const auto checkSemiWhite = [](const QRgb &c) {
|
||||||
@ -3393,7 +3393,7 @@ void tst_QRhi::renderToTextureMultipleUniformBuffersAndDynamicOffset()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// opacity 0.5 (premultiplied)
|
// opacity 0.5 (premultiplied)
|
||||||
static const auto checkSemiWhite = [](const QRgb &c) {
|
static const auto checkSemiWhite = [](const QRgb &c) {
|
||||||
@ -3542,7 +3542,7 @@ void tst_QRhi::renderToTextureSrbReuse()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// opacity 0.5 (premultiplied)
|
// opacity 0.5 (premultiplied)
|
||||||
static const auto checkSemiWhite = [](const QRgb &c) {
|
static const auto checkSemiWhite = [](const QRgb &c) {
|
||||||
@ -3848,13 +3848,13 @@ void tst_QRhi::renderToTextureArrayMultiView()
|
|||||||
readResult[0].pixelSize.width(), readResult[0].pixelSize.height(),
|
readResult[0].pixelSize.width(), readResult[0].pixelSize.height(),
|
||||||
QImage::Format_RGBA8888);
|
QImage::Format_RGBA8888);
|
||||||
if (rhi->isYUpInFramebuffer()) // note that we used clipSpaceCorrMatrix
|
if (rhi->isYUpInFramebuffer()) // note that we used clipSpaceCorrMatrix
|
||||||
image0 = image0.mirrored();
|
image0.flip();
|
||||||
|
|
||||||
QImage image1 = QImage(reinterpret_cast<const uchar *>(readResult[1].data.constData()),
|
QImage image1 = QImage(reinterpret_cast<const uchar *>(readResult[1].data.constData()),
|
||||||
readResult[1].pixelSize.width(), readResult[1].pixelSize.height(),
|
readResult[1].pixelSize.width(), readResult[1].pixelSize.height(),
|
||||||
QImage::Format_RGBA8888);
|
QImage::Format_RGBA8888);
|
||||||
if (rhi->isYUpInFramebuffer())
|
if (rhi->isYUpInFramebuffer())
|
||||||
image1 = image1.mirrored();
|
image1.flip();
|
||||||
|
|
||||||
QVERIFY(!image0.isNull());
|
QVERIFY(!image0.isNull());
|
||||||
QVERIFY(!image1.isNull());
|
QVERIFY(!image1.isNull());
|
||||||
@ -3964,7 +3964,7 @@ void tst_QRhi::renderToWindowSimple()
|
|||||||
if (readResult.format == QRhiTexture::RGBA8)
|
if (readResult.format == QRhiTexture::RGBA8)
|
||||||
wrapperImage = wrapperImage.rgbSwapped();
|
wrapperImage = wrapperImage.rgbSwapped();
|
||||||
if (rhi->isYUpInFramebuffer() == rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() == rhi->isYUpInNDC())
|
||||||
result = wrapperImage.mirrored();
|
result = wrapperImage.flipped();
|
||||||
else
|
else
|
||||||
result = wrapperImage.copy();
|
result = wrapperImage.copy();
|
||||||
};
|
};
|
||||||
@ -6069,7 +6069,7 @@ void tst_QRhi::renderToFloatTexture()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// Now we have a red rectangle on blue background.
|
// Now we have a red rectangle on blue background.
|
||||||
const int y = 100;
|
const int y = 100;
|
||||||
@ -6158,7 +6158,7 @@ void tst_QRhi::renderToRgb10Texture()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC())
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
// Now we have a red rectangle on blue background.
|
// Now we have a red rectangle on blue background.
|
||||||
const int y = 100;
|
const int y = 100;
|
||||||
@ -6300,7 +6300,7 @@ void tst_QRhi::tessellation()
|
|||||||
rhi->endOffscreenFrame();
|
rhi->endOffscreenFrame();
|
||||||
|
|
||||||
if (rhi->isYUpInFramebuffer()) // we used clipSpaceCorrMatrix so this is different from many other tests
|
if (rhi->isYUpInFramebuffer()) // we used clipSpaceCorrMatrix so this is different from many other tests
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
QCOMPARE(result.size(), rt->pixelSize());
|
QCOMPARE(result.size(), rt->pixelSize());
|
||||||
|
|
||||||
@ -6490,7 +6490,7 @@ void tst_QRhi::tessellationInterfaceBlocks()
|
|||||||
|
|
||||||
if (rhi->isYUpInFramebuffer()) // we used clipSpaceCorrMatrix so this is different from many
|
if (rhi->isYUpInFramebuffer()) // we used clipSpaceCorrMatrix so this is different from many
|
||||||
// other tests
|
// other tests
|
||||||
result = std::move(result).mirrored();
|
result.flip();
|
||||||
|
|
||||||
QCOMPARE(result.size(), rt->pixelSize());
|
QCOMPARE(result.size(), rt->pixelSize());
|
||||||
|
|
||||||
|
@ -8368,7 +8368,7 @@ void tst_QWidget::renderRTL()
|
|||||||
menu.setLayoutDirection(Qt::RightToLeft);
|
menu.setLayoutDirection(Qt::RightToLeft);
|
||||||
QImage imageRTL(menu.size(), QImage::Format_ARGB32);
|
QImage imageRTL(menu.size(), QImage::Format_ARGB32);
|
||||||
menu.render(&imageRTL);
|
menu.render(&imageRTL);
|
||||||
imageRTL = imageRTL.mirrored(true, false);
|
imageRTL.flip(Qt::Horizontal);
|
||||||
//imageRTL.save("/tmp/rendered_2.png");
|
//imageRTL.save("/tmp/rendered_2.png");
|
||||||
|
|
||||||
QCOMPARE(imageLTR.height(), imageRTL.height());
|
QCOMPARE(imageLTR.height(), imageRTL.height());
|
||||||
|
@ -398,7 +398,7 @@ void tst_QRhiWidget::simple()
|
|||||||
readResult.pixelSize.width(), readResult.pixelSize.height(),
|
readResult.pixelSize.width(), readResult.pixelSize.height(),
|
||||||
QImage::Format_RGBA8888);
|
QImage::Format_RGBA8888);
|
||||||
if (rhi->isYUpInFramebuffer())
|
if (rhi->isYUpInFramebuffer())
|
||||||
resultOne = wrapperImage.mirrored();
|
resultOne = wrapperImage.flipped();
|
||||||
else
|
else
|
||||||
resultOne = wrapperImage.copy();
|
resultOne = wrapperImage.copy();
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ void tst_QRhiWidget::msaa()
|
|||||||
QImage::Format_RGBA8888);
|
QImage::Format_RGBA8888);
|
||||||
QImage result;
|
QImage result;
|
||||||
if (rhi->isYUpInFramebuffer())
|
if (rhi->isYUpInFramebuffer())
|
||||||
result = wrapperImage.mirrored();
|
result = wrapperImage.flipped();
|
||||||
else
|
else
|
||||||
result = wrapperImage.copy();
|
result = wrapperImage.copy();
|
||||||
|
|
||||||
@ -726,7 +726,7 @@ void tst_QRhiWidget::grabFramebufferWhileStillInvisible()
|
|||||||
readResult.pixelSize.width(), readResult.pixelSize.height(),
|
readResult.pixelSize.width(), readResult.pixelSize.height(),
|
||||||
QImage::Format_RGBA8888);
|
QImage::Format_RGBA8888);
|
||||||
if (w.rhi()->isYUpInFramebuffer())
|
if (w.rhi()->isYUpInFramebuffer())
|
||||||
image = wrapperImage.mirrored();
|
image = wrapperImage.flipped();
|
||||||
else
|
else
|
||||||
image = wrapperImage.copy();
|
image = wrapperImage.copy();
|
||||||
QRgb c = image.pixel(image.width() / 2, image.height() / 2);
|
QRgb c = image.pixel(image.width() / 2, image.height() / 2);
|
||||||
@ -810,7 +810,7 @@ void tst_QRhiWidget::mirror()
|
|||||||
QImage::Format_RGBA8888);
|
QImage::Format_RGBA8888);
|
||||||
QImage image;
|
QImage image;
|
||||||
if (rhi->isYUpInFramebuffer())
|
if (rhi->isYUpInFramebuffer())
|
||||||
image = wrapperImage.mirrored();
|
image = wrapperImage.flipped();
|
||||||
else
|
else
|
||||||
image = wrapperImage.copy();
|
image = wrapperImage.copy();
|
||||||
|
|
||||||
|
@ -2328,7 +2328,7 @@ void tst_QTextEdit::noWrapBackgrounds()
|
|||||||
topLevel.show();
|
topLevel.show();
|
||||||
|
|
||||||
const QImage img = edit.viewport()->grab().toImage();
|
const QImage img = edit.viewport()->grab().toImage();
|
||||||
QCOMPARE(img, img.mirrored(true, false));
|
QCOMPARE(img, img.flipped(Qt::Horizontal));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QTextEdit::preserveCharFormatAfterUnchangingSetPosition()
|
void tst_QTextEdit::preserveCharFormatAfterUnchangingSetPosition()
|
||||||
|
@ -271,7 +271,7 @@ void GLWindow::initializeGL()
|
|||||||
QImage img(":/Qt-logo-medium.png");
|
QImage img(":/Qt-logo-medium.png");
|
||||||
Q_ASSERT(!img.isNull());
|
Q_ASSERT(!img.isNull());
|
||||||
delete m_texImageInput;
|
delete m_texImageInput;
|
||||||
m_texImageInput = new QOpenGLTexture(img.convertToFormat(QImage::Format_RGBA8888).mirrored());
|
m_texImageInput = new QOpenGLTexture(img.convertToFormat(QImage::Format_RGBA8888).flipped());
|
||||||
|
|
||||||
delete m_texImageTmp;
|
delete m_texImageTmp;
|
||||||
m_texImageTmp = new QOpenGLTexture(QOpenGLTexture::Target2D);
|
m_texImageTmp = new QOpenGLTexture(QOpenGLTexture::Target2D);
|
||||||
|
@ -123,7 +123,7 @@ public:
|
|||||||
|
|
||||||
// paint the image flipped
|
// paint the image flipped
|
||||||
p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
|
p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
|
||||||
p.drawPixmap(0, 0, QPixmap::fromImage(scaled.toImage().mirrored(false, true)));
|
p.drawPixmap(0, 0, QPixmap::fromImage(scaled.toImage().flipped()));
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
painter->drawPixmap(reflection, tmp);
|
painter->drawPixmap(reflection, tmp);
|
||||||
|
@ -148,6 +148,6 @@ void QOpenGLTextureBlitWindow::resizeEvent(QResizeEvent *event)
|
|||||||
|
|
||||||
p.drawRect(QRectF(2.5,2.5,dWidth() - 5, dHeight() - 5));
|
p.drawRect(QRectF(2.5,2.5,dWidth() - 5, dHeight() - 5));
|
||||||
|
|
||||||
m_image_mirrord = m_image.mirrored(false,true);
|
m_image_mirrord = m_image.flipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void MainWidget::initShaders()
|
|||||||
void MainWidget::initTextures()
|
void MainWidget::initTextures()
|
||||||
{
|
{
|
||||||
// Load cube.png image
|
// Load cube.png image
|
||||||
texture = new QOpenGLTexture(QImage(":/cube.png").mirrored());
|
texture = new QOpenGLTexture(QImage(":/cube.png").flipped());
|
||||||
|
|
||||||
// Set nearest filtering mode for texture minification
|
// Set nearest filtering mode for texture minification
|
||||||
texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
||||||
|
@ -34,7 +34,7 @@ void Window::customInit()
|
|||||||
d.initialUpdates = m_r->nextResourceUpdateBatch();
|
d.initialUpdates = m_r->nextResourceUpdateBatch();
|
||||||
d.initialUpdates->uploadStaticBuffer(d.vbuf, cube);
|
d.initialUpdates->uploadStaticBuffer(d.vbuf, cube);
|
||||||
|
|
||||||
QImage img = QImage(":/c.png").mirrored().convertToFormat(QImage::Format_RGBA8888);
|
QImage img = QImage(":/c.png").flipped().convertToFormat(QImage::Format_RGBA8888);
|
||||||
// just use the same image for all faces for now
|
// just use the same image for all faces for now
|
||||||
QRhiTextureSubresourceUploadDescription subresDesc(img);
|
QRhiTextureSubresourceUploadDescription subresDesc(img);
|
||||||
QRhiTextureUploadDescription desc({
|
QRhiTextureUploadDescription desc({
|
||||||
|
@ -45,7 +45,7 @@ void Window::customInit()
|
|||||||
d.initialUpdates = m_r->nextResourceUpdateBatch();
|
d.initialUpdates = m_r->nextResourceUpdateBatch();
|
||||||
d.initialUpdates->uploadStaticBuffer(d.vbuf, cube);
|
d.initialUpdates->uploadStaticBuffer(d.vbuf, cube);
|
||||||
|
|
||||||
QImage img = QImage(":/c.png").mirrored().convertToFormat(QImage::Format_RGBA8888);
|
QImage img = QImage(":/c.png").flipped().convertToFormat(QImage::Format_RGBA8888);
|
||||||
// just use the same image for all faces for now
|
// just use the same image for all faces for now
|
||||||
QRhiTextureSubresourceUploadDescription subresDesc(img);
|
QRhiTextureSubresourceUploadDescription subresDesc(img);
|
||||||
QRhiTextureUploadDescription desc({
|
QRhiTextureUploadDescription desc({
|
||||||
|
@ -36,7 +36,7 @@ void Window::customInit()
|
|||||||
float opacity = 1.0f;
|
float opacity = 1.0f;
|
||||||
d.initialUpdates->updateDynamicBuffer(d.ubuf, 64, 4, &opacity);
|
d.initialUpdates->updateDynamicBuffer(d.ubuf, 64, 4, &opacity);
|
||||||
|
|
||||||
QImage image = QImage(QLatin1String(":/qt256.png")).convertToFormat(QImage::Format_RGBA8888).mirrored();
|
QImage image = QImage(QLatin1String(":/qt256.png")).convertToFormat(QImage::Format_RGBA8888).flipped();
|
||||||
d.tex = m_r->newTexture(QRhiTexture::RGBA8, QSize(image.width(), image.height()), 1, {});
|
d.tex = m_r->newTexture(QRhiTexture::RGBA8, QSize(image.width(), image.height()), 1, {});
|
||||||
d.releasePool << d.tex;
|
d.releasePool << d.tex;
|
||||||
d.tex->create();
|
d.tex->create();
|
||||||
|
@ -275,7 +275,7 @@ int main(int argc, char **argv)
|
|||||||
fn = QFileInfo(fn).absoluteFilePath();
|
fn = QFileInfo(fn).absoluteFilePath();
|
||||||
qDebug("Saving into %s", qPrintable(fn));
|
qDebug("Saving into %s", qPrintable(fn));
|
||||||
if (r->isYUpInFramebuffer())
|
if (r->isYUpInFramebuffer())
|
||||||
image.mirrored().save(fn);
|
image.flipped().save(fn);
|
||||||
else
|
else
|
||||||
image.save(fn);
|
image.save(fn);
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,7 +41,7 @@ void TriangleOnCubeRenderer::initResources(QRhiRenderPassDescriptor *rp)
|
|||||||
if (IMAGE_UNDER_OFFSCREEN_RENDERING) {
|
if (IMAGE_UNDER_OFFSCREEN_RENDERING) {
|
||||||
m_image = QImage(QLatin1String(":/qt256.png")).scaled(OFFSCREEN_SIZE).convertToFormat(QImage::Format_RGBA8888);
|
m_image = QImage(QLatin1String(":/qt256.png")).scaled(OFFSCREEN_SIZE).convertToFormat(QImage::Format_RGBA8888);
|
||||||
if (m_r->isYUpInFramebuffer())
|
if (m_r->isYUpInFramebuffer())
|
||||||
m_image = m_image.mirrored(); // just cause we'll flip texcoord Y when y up so accommodate our static background image as well
|
m_image.flip(); // just cause we'll flip texcoord Y when y up so accommodate our static background image as well
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tex = m_r->newTexture(QRhiTexture::RGBA8, OFFSCREEN_SIZE, 1, QRhiTexture::RenderTarget);
|
m_tex = m_r->newTexture(QRhiTexture::RGBA8, OFFSCREEN_SIZE, 1, QRhiTexture::RenderTarget);
|
||||||
|
@ -224,7 +224,7 @@ void Window::customRender()
|
|||||||
fn = QFileInfo(fn).absoluteFilePath();
|
fn = QFileInfo(fn).absoluteFilePath();
|
||||||
qDebug("Saving into %s", qPrintable(fn));
|
qDebug("Saving into %s", qPrintable(fn));
|
||||||
if (m_r->isYUpInFramebuffer())
|
if (m_r->isYUpInFramebuffer())
|
||||||
image.mirrored().save(fn);
|
image.flipped().save(fn);
|
||||||
else
|
else
|
||||||
image.save(fn);
|
image.save(fn);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ void Window::customInit()
|
|||||||
d.ubuf->create();
|
d.ubuf->create();
|
||||||
d.releasePool << d.ubuf;
|
d.releasePool << d.ubuf;
|
||||||
|
|
||||||
QImage image = QImage(QLatin1String(":/qt256.png")).convertToFormat(QImage::Format_RGBA8888).mirrored();
|
QImage image = QImage(QLatin1String(":/qt256.png")).convertToFormat(QImage::Format_RGBA8888).flipped();
|
||||||
d.tex = m_r->newTexture(QRhiTexture::RGBA8, QSize(image.width(), image.height()), 1, {});
|
d.tex = m_r->newTexture(QRhiTexture::RGBA8, QSize(image.width(), image.height()), 1, {});
|
||||||
d.releasePool << d.tex;
|
d.releasePool << d.tex;
|
||||||
d.tex->create();
|
d.tex->create();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user