[whatwg] Image resize API proposal
cmarrin at apple.com
Sun May 23 09:07:05 PDT 2010
On May 22, 2010, at 3:03 AM, Robert O'Callahan wrote:
> On Sat, May 22, 2010 at 10:12 AM, David Levin <levin at google.com> wrote:
> There are a few issues here:
> This only applies when you can accelerate with a GPU. Not all devices may support this.
> This only applies to browsers that implement the acceleration with a GPU. When Mike Shaver mentioned this, he referred to a Windows version of Firefox. It is unclear if Firefox supports this on any other platform nor does it seem that all other browsers will support the accelerated canvas in the near-ish future.
> The gpu results are due to the fact that the operation is done async from the call (which is great as far as not hanging the UI until you try to get the data out of the canvas, which leads to...).
> Even with gpu acceleration, in order to use the result in an xhr, one has to get back the result from the gpu and this is a more expensive operation (because getting the data out of the gpu is slow) as indicated by the indirect copy results from Firefox and forces the completion of all of the operations that were being done async.
> 1. Phones have GPUs now. You won't see new devices being built that can run real Web browsers but don't have some kind of GPU, because the limiting factor on hardware now is not silicon but power.
> 2. Your proposal depends on browsers that implement your new API. As a browser developer, I would rather make canvas faster across the board than implement new API.
> 3. The GPU results are largely because GPUs are massively parallel.
> 4. The Firefox results include time to unpremultiply data and premultiply it again, all on the CPU. They don't indicate how long readback from the GPU actually takes on that machine. Also:
> 4a) the cost of readback is proportional to the size of the scaled image, so if your use case is scaling down images to small sizes, readback is cheap.
> 4b) you can easily read back and send one chunk of the scaled image at a time
Just to be clear, readback is never "cheap". The cost of readback isn't so much the image size, but the fact that you need to stall the pipeline, do the read and then fill the pipeline again. So anything happening on the GPU (not just in your app, but systemwide) will slow down the readback and the readback will slow everything else.
Readback is just generally evil and should be avoided at all costs :-)
cmarrin at apple.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the whatwg