diff options
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmbackingstore.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmbackingstore.cpp | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp index f6d219dbde..c14d1f59e4 100644 --- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp +++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp @@ -4,6 +4,7 @@ #include "qwasmbackingstore.h" #include "qwasmwindow.h" #include "qwasmcompositor.h" +#include "qwasmdom.h" #include <QtGui/qpainter.h> #include <QtGui/qbackingstore.h> @@ -38,11 +39,12 @@ QPaintDevice *QWasmBackingStore::paintDevice() void QWasmBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(window); - Q_UNUSED(region); - Q_UNUSED(offset); - m_dirty |= region; - m_compositor->handleBackingStoreFlush(window); + + QRect updateRect = region.boundingRect(); + updateRect.translate(offset); + + m_compositor->handleBackingStoreFlush(this->window(), updateRect); } void QWasmBackingStore::updateTexture(QWasmWindow *window) @@ -75,39 +77,8 @@ void QWasmBackingStore::updateTexture(QWasmWindow *window) clippedDpiScaledRegion |= r; } - for (const QRect &dirtyRect : clippedDpiScaledRegion) { - constexpr int BytesPerColor = 4; - if (dirtyRect.width() == imageRect.width()) { - // Copy a contiguous chunk of memory - // ............... - // OOOOOOOOOOOOOOO - // OOOOOOOOOOOOOOO -> image data - // OOOOOOOOOOOOOOO - // ............... - auto imageMemory = emscripten::typed_memory_view(dirtyRect.width() * dirtyRect.height() - * BytesPerColor, - m_image.constScanLine(dirtyRect.y())); - 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. - // ............... - // ...OOOOOOOOO... r = 0 -> image data - // ...OOOOOOOOO... r = 1 -> image data - // ...OOOOOOOOO... r = 2 -> image data - // ............... - for (int r = 0; r < dirtyRect.height(); ++r) { - auto scanlineMemory = emscripten::typed_memory_view( - dirtyRect.width() * BytesPerColor, - m_image.constScanLine(r + dirtyRect.y()) + BytesPerColor * dirtyRect.x()); - m_webImageDataArray["data"].call<void>("set", scanlineMemory, - (dirtyRect.y() + r) * m_image.width() - * BytesPerColor - + dirtyRect.x() * BytesPerColor); - } - } - } + for (const QRect &dirtyRect : clippedDpiScaledRegion) + dom::drawImageToWebImageDataArray(m_image, m_webImageDataArray, dirtyRect); m_dirty = QRegion(); } |