I have a Shark sample (generated from the testcase in bug 19312) that shows that GraphicsContext::save() and restore() are pretty expensive; in this test. they take 11.7% and 23% of the entire sample (of which 87% is in painting). Focusing on GraphicsContext::restore(), GraphicsContext::operator= is 65%, including 58% from Font::operator=. Vector::removeLast is 19%, and restorePlatformState() is 14%. Of the Font::operator= cost, almost all is in the GlyphPageTreeNode hash table copy. Inside GraphicsContext::save(), 62% is in the Font constructor, and 22% is savePlatformState.
Testcase in the URL field.
Created attachment 26358 [details] Shark session
My initial analysis was done on a debug build (stupid!). In a release build, things aren't nearly as bad. In the attached Shark profile of the testcase, GraphicsContext::restore() is 1.4%, and GraphicsContext::save() 0.6%. However, Font::operator= is still 39% of the time spent in GraphicsContext::restore(), so I think there's still a win to be had here.
Another good testcase: http://www.bel.fi/~alankila/plasma.html
Obviated by http://trac.webkit.org/changeset/40007