RESOLVED FIXED 43718
Canvas: Fast-path for setting the already set color with setStrokeColor() and setFillColor()
https://bugs.webkit.org/show_bug.cgi?id=43718
Summary Canvas: Fast-path for setting the already set color with setStrokeColor() and...
Andreas Kling
Reported 2010-08-09 05:01:19 PDT
Some JS demos, for example "Monster" at Chrome Experiments, use the WebKit-specific color setters of CanvasRenderingContext2D. For this particular demo, roughly 5% of the calls to setFillColor() have the same color as is already set on the context. We should detect this and make an early return before creating any CanvasStyle objects (or calling into GraphicsContext.)
Attachments
Proposed patch (5.07 KB, patch)
2010-08-09 05:06 PDT, Andreas Kling
no flags
Andreas Kling
Comment 1 2010-08-09 05:06:32 PDT
Created attachment 63887 [details] Proposed patch
Andreas Kling
Comment 2 2010-08-09 05:07:01 PDT
The "Monster" demo mentioned in bug description: http://www.chromeexperiments.com/detail/monster/
Antonio Gomes
Comment 3 2010-08-09 06:23:13 PDT
Comment on attachment 63887 [details] Proposed patch Looks good.
Andreas Kling
Comment 4 2010-08-09 06:56:55 PDT
Comment on attachment 63887 [details] Proposed patch Clearing flags on attachment: 63887 Committed r64980: <http://trac.webkit.org/changeset/64980>
Andreas Kling
Comment 5 2010-08-09 06:57:05 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 6 2010-08-09 09:03:55 PDT
A side comment: I think it's dangerous to overload and treat floating point values as RGBA or CMYKA just based on the number of arguments. Thus, these functions should have RGBA and CMYKA in their names. Similarly, the create functions for CanvasStyle should have RGBA and CMYKA and such in their names too. The reason the functions in CanvasStyle used overloading historically is that they were constructors. Tis is one advantage of the create functions over direct calls to the constructors. We can leave the overloading trick to the constructors only. CanvasRenderingContext2D has to do this overloading because that's in the specification, but internally we should not repeat that mistake.
Note You need to log in before you can comment on or make changes to this bug.