I've got an application window using JavaFX. This window contains a simple WebView to display a HTML document. Inside the HTML document, there is a script tag, executing a Java function, which returns the pixels as int[]. I'm using the following code to draw the image onto the canvas:
var context = canvas.getContext('2d');
var imageData = context.createImageData(canvas.width, canvas.height);
var buffer8 = new Uint8ClampedArray(imageData.data.buffer);
var buffer32 = new Uint32Array(imageData.data.buffer);
buffer32.set(pixels);
context.putImageData(imageData, 0, 0);
This works, however performance is about 0.07 seconds per frame, giving me a total of ~ 15 FPS, using a 640x480 canvas currently. My goal is to get at last 30fps for 1920x1080 (currently 5 FPS), and even higher values. The only solution i come up with is to create/populate the whole buffer at once on the java side, but i have no idea how to manage that. Any help would be appreciated.