[webkit-dev] New web-facing canvas feature: "opaque" attribute

Noam Rosenthal noam at webkit.org
Fri Mar 15 01:34:55 PDT 2013

On Fri, Mar 15, 2013 at 9:19 AM, Gregg Tavares <gman at google.com> wrote:

> I don't understand the opposition to "alpha"
> You set colors in Canvas2d with rgb or rgba. That 'a' in rgba stands for
> alpha.
> You can set a global alpha for drawing with context.globalAlpha
> You read data from getImageData that returns red, green, blue, alpha
> You write data to putImageData wit red, green, blue, alpha
> So why name an option that effectively removes the alpha something not
> called "alpha"?  I have no better idea what "opaque" means. As far as I
> know it just means blending won't happen during compositing but alpha still
> exists when I draw and when I read from the canvas. That seems more
> confusing to me.
> I also don't understand why if getContext("webgl", { alpha: false }) has
> been shipping for 3 years there's a need to make it different on canvas 2d?
> Picking a different name or picking a different method (a function, an
> attribute on canvas or context) seems like bikeshedding rather than some
> functional objection. There's a solution, it has existed and been shipping
> in WebKit for 3 years. Can't we just go with that? Developers will be no
> more confused by this than whether drawImage is drawImage(img, x, y) or
> drawImage(x, y, img). You look up once in a while.
> As far as the spec goes, the effect of setting alpha:false is as if every
> draw operation ended with
>    dest = RGBA | 0x000000FF
> That means everything works as speced. getImageData will pull out RGBA but
> A will always be 255. Every draw call including putImageData follows the
> rule above.  How that effects compositing is not a normative part of the
> spec. It's just something UAs happen to know they can do.

For what it's worth, I'm with Greg on this.
First of all, this is not needed for other elements, only canvas - other
elements have enough information about whether or not they're opaque since
they're fully declarative. So I don't see value in trying to extend the
solution to areas where the problem doesn't exist.
Second, having an "alpha" option and other options on drawing buffers is
really a standard feature in toolkits, libraries, windowing systems etc. -
it feels natural and not like an optimization hack.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130315/34197543/attachment.html>

More information about the webkit-dev mailing list