QOpenGLTexture: avoid a QImage detach when uploading texture data from it

If the image is already in the right format, converting it to RGBA8888
will be just a refcount increment; but calling bits() will then cause
an unnecessary detach.

Change-Id: I3b06139cd86b74a9082bd0b401a9a14bd4992a10
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
bb10
Giuseppe D'Angelo 2014-01-31 17:23:47 +01:00 committed by The Qt Project
parent c5ee652278
commit bc91dc4895
1 changed files with 1 additions and 1 deletions

View File

@ -2253,7 +2253,7 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps)
QImage glImage = image.convertToFormat(QImage::Format_RGBA8888);
QOpenGLPixelTransferOptions uploadOptions;
uploadOptions.setAlignment(1);
setData(0, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, glImage.bits(), &uploadOptions);
setData(0, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, glImage.constBits(), &uploadOptions);
}
/*!