[webkit-dev] New web-facing canvas feature: "opaque" attribute
Gregg Tavares
gman at google.com
Thu Mar 14 14:06:44 PDT 2013
On Thu, Mar 14, 2013 at 2:00 PM, Dean Jackson <dino at apple.com> wrote:
>
> On 15/03/2013, at 7:55 AM, Gregg Tavares <gman at google.com> wrote:
>
>
>
>
> On Thu, Mar 14, 2013 at 1:38 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
>
>> On Thu, Mar 14, 2013 at 12:55 PM, Dean Jackson <dino at apple.com> wrote:
>>
>>>
>>> On 15/03/2013, at 6:50 AM, Dana Jansens <danakj at chromium.org> wrote:
>>>
>>> On Thu, Mar 14, 2013 at 3:46 PM, Dean Jackson <dino at apple.com> wrote:
>>>
>>>> I'm not sure I like this proposal. Why is canvas special? Why doesn't
>>>> <img> get an opaque attribute (or flag)? Why not every element?
>>>>
>>>
>>> There is ongoing work to infer opaqueness in every other kind of element
>>> when possible. See for example
>>> https://bugs.webkit.org/show_bug.cgi?id=70634
>>>
>>>
>>> Yes, I'd prefer to infer it rather than specify it. For example, I could
>>> infer that a canvas is opaque if it has a non-transparent CSS
>>> background-color.
>>>
>>
> The content of the canvas has to be blended with the background color so
> that doesn't help optimization. If there's a background color you first
> have to do a full blend of the contents of the canvas with the background
> color. Where as if the canvas has no alpha then that step can be avoided.
>
>
> We're probably getting a bit off the general topic here, but why don't you
> consider the background color as a fillRect(0, 0, width, height) on the
> empty canvas?
>
Because it's not the same as fillRect(0, 0, width, height) on an empty
canvas. The canvas itself has alpha (unless we add the option to not have
it as has been proposed). The contents of the canvas has to stay as the
user created it. If I draw with rgba(255,255,0, 0.5) I expect if I read
data out of the canvas or draw that canvas into another canvas I'll get
that color, not the color blended with the css background. So, the canvas
has to be blended if there's alpha. There's no magic getting around that.
The only way around it is to give the user a way to say "no alpha".
> As has been said, this doesn't change the behaviour of the
> painting/blending operations in the canvas itself, just how it is
> composited into the document.
>
> I guess we should take this conversation to the HTML list.
>
> Dean
>
>
>
>
>>
>> I like this approach. It means that developers don't have to explicitly
>> use this feature to get the performance benefits.
>>
>> In fact, this is the preferred performance optimization approach on the
>> Web. We don't provide explicit APIs to optimize performance. We make
>> sensible APIs which allows us to implement more optimizations on common
>> cases behind the scene.
>>
>> - R. Niwa
>>
>>
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130314/99e3c144/attachment.html>
More information about the webkit-dev
mailing list