# HG changeset patch # User Sebastien Jodogne # Date 1603992426 -3600 # Node ID 228a412335408b579faaae4591b11a59ad317001 # Parent 787db80a5a1b0755fa82d31a6dd01d0af8c6819d fix software rendering if empty target canvas diff -r 787db80a5a1b -r 228a41233540 Applications/Platforms/WebAssembly/WebAssemblyCairoViewport.cpp --- a/Applications/Platforms/WebAssembly/WebAssemblyCairoViewport.cpp Thu Oct 29 18:02:03 2020 +0100 +++ b/Applications/Platforms/WebAssembly/WebAssemblyCairoViewport.cpp Thu Oct 29 18:27:06 2020 +0100 @@ -77,18 +77,22 @@ } } - // Execute JavaScript commands to blit the image buffer onto the - // 2D drawing context of the HTML5 canvas - EM_ASM({ - const data = new Uint8ClampedArray(Module.HEAP8.buffer, $1, 4 * $2 * $3); - const img = new ImageData(data, $2, $3); - const ctx = document.getElementById(UTF8ToString($0)).getContext('2d'); - ctx.putImageData(img, 0, 0); - }, - GetCanvasId().c_str(), // $0 - javascript_->GetBuffer(), // $1 - javascript_->GetWidth(), // $2 - javascript_->GetHeight()); // $3 + if (width != 0 && + height != 0) + { + // Execute JavaScript commands to blit the image buffer onto the + // 2D drawing context of the HTML5 canvas + EM_ASM({ + const data = new Uint8ClampedArray(Module.HEAP8.buffer, $1, 4 * $2 * $3); + const img = new ImageData(data, $2, $3); + const ctx = document.getElementById(UTF8ToString($0)).getContext('2d'); + ctx.putImageData(img, 0, 0); + }, + GetCanvasId().c_str(), // $0 + javascript_->GetBuffer(), // $1 + javascript_->GetWidth(), // $2 + javascript_->GetHeight()); // $3 + } }