W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2012

[whatwg] [canvas] request for {create, get, put}ImageDataHD and ctx.backingStorePixelRatio

From: Maciej Stachowiak <mjs@apple.com>
Date: Thu, 19 Apr 2012 21:28:16 -0700
Message-ID: <A489A12E-88FC-4CC3-A84C-13C8B97B180A@apple.com>

On Apr 17, 2012, at 3:32 PM, Darin Fisher wrote:
> 
> ^^^ This got me thinking...
> 
> In Chrome at least, getImageData() doesn't actually block to fetch pixels.  The thread is only blocked when the first dereference of the pixel buffer occurs.  I believe this is done so that a getImageData() followed by putImageData() call will not need to block the calling thread.
> 
> The above suggests that making getImageData() asynchronous would not actually provide any benefit for cases where the page does not dereference the pixel buffer.  Another use case where this comes up is passing the ImageData to a web worker.  If the web worker is the first to dereference the ImageData, then only the web worker thread should block.
> 
> I think this becomes an argument for keeping getImageData() as is.  It assumes that ImageData is just a handle, and we could find another way to discourage dereferencing the pixel buffer on the UI thread.
> 
> Hmm...

You could also address this by adding a way to be notified when the contents of an ImageData are available without blocking. That would work with both vanilla getImageData and the proposed getImageDataHD. It would also give the author the alternative of just blocking (e.g. if they know the buffer is small) or of sending the data off to a worker for processing.

Regards,
Maciej
Received on Thursday, 19 April 2012 21:28:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:07 GMT