title: GWT Canvas pixel manipulation is dreadfully slow
body: <p>Execution time to build a canvas pixel-by-pixel in GWT is extremely slow.  For the following code, the 2D for loop with calls to "cpa.set(...)" is very slow.</p>
  
  <pre><code>...
  RootPanel.get().add(canvas);
  context = canvas.getContext2d();
  ImageData id = context.createImageData(canvasWidth, canvasHeight);
  CanvasPixelArray cpa = id.getData();
  
  for (int y=0; y&lt;canvasHeight; y++){
      for (int x=0; x&lt;canvasWidth; x++){
          cpa.set(y*canvasWidth*4 + x*4 + 0,r);
          cpa.set(y*canvasWidth*4 + x*4 + 1,g);
          cpa.set(y*canvasWidth*4 + x*4 + 2,b);
          cpa.set(y*canvasWidth*4 + x*4 + 3,a);
      }
  }           
  context.putImageData(id, 0, 0); 
  </code></pre>
  
  <p>For example, with a 100x100 canvas, it takes 10 seconds.  I've seen in some other javascript posts <a href="http://www.onaluf.org/en/entry/13" rel="nofollow">here</a> showing that it may be more efficient to use a separate array buffer in the for loop, then just set the ImageData array equal to that buffer, but GWT doesn't seem to allow that with CanvasPixelArray, you can only set a single pixel at a time in GWT, rather than copy an entire pixel array buffer into a CanvasPixelArray or ImageData.</p>
  
  <p>Any ideas for efficient pixel manipulation with GWT canvas?</p>
  
  <p>Thanks. </p>