[whatwg] Canvas pixel manipulation and performance

Kenneth Russell kbr at google.com
Sun Nov 29 10:59:22 PST 2009


On Sat, Nov 28, 2009 at 9:47 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> On 11/29/09 12:15 AM, Kenneth Russell wrote:
>>>
>>> I assume you meant JS bitwise operators?  Do we have any indication that
>>> this would be faster than four array property sets?  The bitwise ops in
>>> JS
>>> are not necessarily particulary fast.
>>
>> Yes, that's what I meant. I don't have any data on whether this would
>> currently be faster than the four separate byte stores.
>
> Are they even byte stores, necessarily?  I know in Gecko imagedata is just a
> JS array at the moment; it stores each of R,G,B,A as a JS Number (with the
> usual "if it's an integer store as an integer" optimization arrays do).
>  That might well change in the future, and I hope it does, but that's the
> current code.
>
> I can't speak to what the behavior is in Webkit, and in particular whether
> it's even the same when using V8 vs Nitro.

In Chromium (WebKit + V8), CanvasPixelArray property stores write
individual bytes to memory. WebGLByteArray and WebGLUnsignedByteArray
behave similarly but have simpler clamping semantics.

-Ken



More information about the whatwg mailing list