Correctly update the texture in qwasmbackingstore

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 <morten.sorvig@qt.io>
This commit is contained in:
Mikolaj Boc 2023-03-29 15:31:23 +02:00
parent b8f40af176
commit ecd7ddcc3e

View File

@ -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<void>("set", imageMemory);
m_webImageDataArray["data"].call<void>("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<void>("set", scanlineMemory,
(r * dirtyRect.width() + dirtyRect.x())
* BytesPerColor);
(dirtyRect.y() + r) * m_image.width()
* BytesPerColor
+ dirtyRect.x() * BytesPerColor);
}
}
}