W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2009

[whatwg] Canvas pixel manipulation and performance

From: Kenneth Russell <kbr@google.com>
Date: Sat, 28 Nov 2009 20:42:29 -0800
Message-ID: <921bb10911282042s4dedc524xa07099c51e3e62ef@mail.gmail.com>
On Sat, Nov 28, 2009 at 12:44 PM, Jason Oster <parasyte at kodewerx.org> wrote:
>
> Once again, I agree. ?My confusion on the type-specific arrays for WebGL is
> that they were specific and general enough to use in other cases. ?If they
> should not be used in 2D canvas implementations (or elsewhere) then a
> 2D-canvas-specific array or object would be the way forward.

I and other members of the WebGL working group are hoping that the new
array-like types being introduced with this specification will be
general enough to repurpose in other areas. The first public draft of
the spec will be released in the next week or two, and we're hoping
that will enable discussion with the broader web community.

>From a technical standpoint, it would be feasible to use the
"WebGLUnsignedIntArray" to access the Canvas's pixel data, and
assemble RGBA pixels into integer values using just JavaScript logical
operators. To keep things sane, the specification would need to state
something along the lines that the high (logical, not addressing) 8
bits are the red bits and the low 8 bits are the alpha bits. This
means that implementations on big-endian and little-endian machines
would need to store the data differently internally so that the
behavior at the JavaScript level is identical; the WebGL array types
currently deliberately do no byte swapping.

-Ken
Received on Saturday, 28 November 2009 20:42:29 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:19 UTC