From ecd7ddcc3e7ccf7750190b4aedd3ad683dd4f97d Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Wed, 29 Mar 2023 15:31:23 +0200 Subject: [PATCH] Correctly update the texture in qwasmbackingstore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both the full-width and partial-width paths in QWasmBackingStore::updateTexture now correctly compute source and target rects. Task-number: QTBUG-112414 Change-Id: I30b0952609960f521119d3d628d2a8036f8b1fe5 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmbackingstore.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp index e9625928620..f6d219dbde8 100644 --- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp +++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp @@ -87,7 +87,8 @@ void QWasmBackingStore::updateTexture(QWasmWindow *window) auto imageMemory = emscripten::typed_memory_view(dirtyRect.width() * dirtyRect.height() * BytesPerColor, m_image.constScanLine(dirtyRect.y())); - m_webImageDataArray["data"].call("set", imageMemory); + m_webImageDataArray["data"].call("set", imageMemory, + dirtyRect.y() * m_image.width() * BytesPerColor); } else { // Go through the scanlines manually to set the individual lines in bulk. This is // marginally less performant than the above. @@ -98,11 +99,12 @@ void QWasmBackingStore::updateTexture(QWasmWindow *window) // ............... for (int r = 0; r < dirtyRect.height(); ++r) { auto scanlineMemory = emscripten::typed_memory_view( - dirtyRect.width() * 4, - m_image.constScanLine(r) + BytesPerColor * dirtyRect.x()); + dirtyRect.width() * BytesPerColor, + m_image.constScanLine(r + dirtyRect.y()) + BytesPerColor * dirtyRect.x()); m_webImageDataArray["data"].call("set", scanlineMemory, - (r * dirtyRect.width() + dirtyRect.x()) - * BytesPerColor); + (dirtyRect.y() + r) * m_image.width() + * BytesPerColor + + dirtyRect.x() * BytesPerColor); } } }