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

Maciej Stachowiak mjs at apple.com
Wed Mar 13 21:56:20 PDT 2013


On Mar 13, 2013, at 9:49 PM, Gregg Tavares <gman at google.com> wrote:

> 
> 
> 
> On Wed, Mar 13, 2013 at 9:20 PM, Maciej Stachowiak <mjs at apple.com> wrote:
> 
> Two questions/comments:
> 
> 1) What happens if I do:
>     gl = canvas.getContext("experimental-webgl", { alpha: false });
> and then later, in an unrelated piece of code I do the following on the same canvas:
>     gl = canvas.getContext("experimental-webgl");
> 
> Will the canvas remain opaque? Will the buffer be wiped? Will it turn non-opaque without wiping the buffer? Based on my guesses of the answers to these questions, I feel like this approach is dangerous because you have to remember to pass the right parameters each time you retrieve the context. But really you should be able to set it once and then retrieve the context an arbitrary number of times without repeating yourself.
> 
> 
> The parameters are ignored the second time. The spec already says you get the same context that was create the first time you called getContext.

You're right, the spec does seem to say that. So there's no way to change this parameter once set for a given canvas, even if it's passed explicitly? That is strange API design but I guess it doesn't have the hazard I suggested.

> 
> 2) I think alpha: false is a particularly bad name for the reasons Elliott stated - it sounds like it would disable all alpha compositing for all drawing operations done within the canvas, whereas what it actually does is force the composited results of canvas drawing to have alpha of 1.0. Is WebGL locked into the "alpha: false" syntax?
> 
> "alpha: false" means there is no alpha channel, effectively making it 1.0. You can't write to it. If you try to read it (readPixels, getImageData) all the alpha data will be 255.  It says nothing about compositing. But, the fact that the UA knows this guarantees there is either no alpha or that alpha is 1.0 through the entire surface means that UA and choose to render without blending when appropriate.

I understand what it does, I'm just saying that it's a confusing way to describe the concept.

Regards,
Maciej


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130313/e84203fd/attachment.html>


More information about the webkit-dev mailing list