diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2024-04-30 11:52:34 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2024-05-03 12:39:40 +0200 |
commit | 690bb2e0c471e43d408f79c8e23126e2113da938 (patch) | |
tree | d2529aebe0a1dd1124e603b3c3382a9c66730fa1 /src/gui/rhi | |
parent | d6bc7613ac91e663f573486135946039eeccf8d7 (diff) |
rhi: gl: Avoid a copy in partial texture uploads
Pick-to: 6.7 6.6 6.5
Task-number: QTBUG-120565
Change-Id: I7f1f8c42b98c5743708c4ff80e401070d8ab24ac
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index f54371da66..dcaa87a5ff 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2377,7 +2377,15 @@ void QRhiGles2::enqueueSubresUpload(QGles2Texture *texD, QGles2CommandBuffer *cb const QPoint sp = subresDesc.sourceTopLeft(); if (!subresDesc.sourceSize().isEmpty()) size = subresDesc.sourceSize(); - img = img.copy(sp.x(), sp.y(), size.width(), size.height()); + + if (caps.unpackRowLength) { + cbD->retainImage(img); + // create a non-owning wrapper for the subimage + const uchar *data = img.constBits() + sp.y() * img.bytesPerLine() + sp.x() * (qMax(1, img.depth() / 8)); + img = QImage(data, size.width(), size.height(), img.bytesPerLine(), img.format()); + } else { + img = img.copy(sp.x(), sp.y(), size.width(), size.height()); + } } setCmdByNotCompressedData(cbD->retainImage(img), size, img.bytesPerLine()); |