summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-23 12:50:36 +0200
committerLiang Qi <liang.qi@qt.io>2018-08-23 17:32:20 +0000
commited557c037847e343caa010562952b398f806adcd (patch)
tree43009b06628f6be576af6ba93abb1ee0390cb0ee /src
parent2ab804c4520a8fa8e5aa69cebcf2f2f4441057c1 (diff)
Handle uploading of faked sub-images
One trick that is possible to do with QImage is to make it be sub image of its imagedata by manipulating the data start and bytes-per-line, we can not upload that directly and need to detect the case and create a clean copy to upload. Task-number: QTBUG-70105 Change-Id: I7ce184a0892fb4071b6dcc1a1fd3881a4e0703cd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/opengl/qopengltextureuploader.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gui/opengl/qopengltextureuploader.cpp b/src/gui/opengl/qopengltextureuploader.cpp
index 1147c81471..2428baed93 100644
--- a/src/gui/opengl/qopengltextureuploader.cpp
+++ b/src/gui/opengl/qopengltextureuploader.cpp
@@ -313,6 +313,11 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
if (newSize != tx.size())
tx = tx.scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ // Handle cases where the QImage is actually a sub image of its image data:
+ qsizetype naturalBpl = ((qsizetype(tx.width()) * tx.depth() + 31) >> 5) << 2;
+ if (tx.bytesPerLine() != naturalBpl)
+ tx = tx.copy(tx.rect());
+
funcs->glTexImage2D(target, 0, internalFormat, tx.width(), tx.height(), 0, externalFormat, pixelType, tx.constBits());
qsizetype cost = qint64(tx.width()) * tx.height() * tx.depth() / 8;