[whatwg] Canvas performance issue: setting colors

Sjoerd Visscher sjoerd at w3future.com
Tue Sep 30 01:09:45 PDT 2008


I guess this applies to the other methods and attributes of canvas as  
well. The majority of canvas methods are constructed in a way that  
allows an almost direct mapping to a C/C++ call. So when all the  
canvas code is perfectly optimized, the color code will probably still  
be the bottleneck. Unless you say that serializing floats to string  
and concatenating them and then parsing the string again can be done  
just as fast as creating and destructing a color object.

On Sep 30, 2008, at 12:53 AM, Oliver Hunt wrote:

>
>> I think the canvas api should get 2 new methods:
>>
>> CanvasColor createRGBAColor(in float r, in float g, in float b, in  
>> float a)
>> CanvasColor createHSLAColor(in float h, in float s, in float l, in  
>> float a)
>>
>
> WebKit already has a non-standard function -- setFillColor(r, g, b,  
> a) -- that provides a faster mechanism to set the colour, however we  
> believe we can rather easily improve the performance of the standard  
> fillStyle, strokeStyle properties and just have not yet gotten round  
> to it.  Until we have improved this I would be hesitant to go around  
> adding entirely new object types (especially canvas specific ones).
>
> --Oliver
>

--
Sjoerd Visscher
sjoerd at w3future.com






More information about the whatwg mailing list