aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-07-18 10:36:44 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-07-18 13:40:49 +0000
commit5cf4253fa3802e3c2efbecd0f7f4fb822252d811 (patch)
tree5b1dd426c540ec5c6483c994f01912fffd7b4083 /src/quick
parentd140614a1df7d9563acef5092f92e9f31c14723b (diff)
Remove custom swizzle implementations
The QtGui one is heavily optimized, so don't duplicate it. Change-Id: I32d5987b36bda084e98ffc6c86a22414569bad14 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/scenegraph/util/qsgatlastexture.cpp15
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp13
2 files changed, 2 insertions, 26 deletions
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
index 7608a81ddc..97203db867 100644
--- a/src/quick/scenegraph/util/qsgatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgatlastexture.cpp
@@ -351,19 +351,6 @@ Texture *Atlas::create(const QImage &image)
return nullptr;
}
-static void swizzleBGRAToRGBA(QImage *image)
-{
- const int width = image->width();
- const int height = image->height();
- uint *p = (uint *) image->bits();
- int stride = image->bytesPerLine() / 4;
- for (int i = 0; i < height; ++i) {
- for (int x = 0; x < width; ++x)
- p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
- p += stride;
- }
-}
-
void Atlas::upload(Texture *texture)
{
const QImage &image = texture->image();
@@ -395,7 +382,7 @@ void Atlas::upload(Texture *texture)
}
if (m_externalFormat == GL_RGBA)
- swizzleBGRAToRGBA(&tmp);
+ tmp = std::move(tmp).convertToFormat(QImage::Format_RGBA8888_Premultiplied);
QOpenGLContext::currentContext()->functions()->glTexSubImage2D(GL_TEXTURE_2D, 0,
r.x(), r.y(), r.width(), r.height(),
m_externalFormat, GL_UNSIGNED_BYTE, tmp.constBits());
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index fea92a5121..982d05691d 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -659,17 +659,6 @@ QSGPlainTexture::~QSGPlainTexture()
#endif
}
-void qsg_swizzleBGRAToRGBA(QImage *image)
-{
- const int width = image->width();
- const int height = image->height();
- for (int i = 0; i < height; ++i) {
- uint *p = (uint *) image->scanLine(i);
- for (int x = 0; x < width; ++x)
- p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
- }
-}
-
void QSGPlainTexture::setImage(const QImage &image)
{
m_image = image;
@@ -841,7 +830,7 @@ void QSGPlainTexture::bind()
internalFormat = GL_RGBA;
#endif
} else {
- qsg_swizzleBGRAToRGBA(&tmp);
+ tmp = std::move(tmp).convertToFormat(QImage::Format_RGBA8888_Premultiplied);
}
qint64 swizzleTime = 0;