[webkit-dev] Canvas performance and memory usage

David Hyatt hyatt at apple.com
Tue Aug 10 15:50:24 PDT 2010

On Aug 10, 2010, at 2:49 PM, David Hyatt wrote:

> Yeah, I think an even better way of abstracting it might be to make ImageBuffer:drawIntoContext(GraphicsContext*, ...).  I think that would be simpler for people implementing something special.  If we did that, then the image() accessor on ImageBuffer could probably just always be a deep copy (or copy-on-write).
> Getting rid of the graphicsContext->drawImage(imageBuffer->image()....) pattern would definitely be good though.
> I'm just really curious about the performance of canvas and whether it's better to have slower get/PutImageData or faster rendering otherwise.   It all comes down to how people are using canvas.  I suspect that get/PutImageData are really really popular.

I implemented ImageBuffer::drawIntoContext on Mac, and I switched the implementation of ImageBuffer to dynamically swap to a CGLayer (throwing away the bitmap context) if it can do so.  Preliminary tests look very very good.

This benchmark for example:


Jumped from 37fps to 85fps.

I'll need to see what happens with intensive get/PutImageData examples though before I declare victory, but it definitely looks like slowing down get/PutImageData is worth it if we can get performance gains like this!

(hyatt at apple.com)

More information about the webkit-dev mailing list