[whatwg] Enabling LCD Text in 2D canvases.
junov at chromium.org
Wed Nov 14 13:14:09 PST 2012
On Wed, Nov 14, 2012 at 3:51 PM, Robert O'Callahan <robert at ocallahan.org>wrote:
> On Wed, Nov 14, 2012 at 12:48 PM, Justin Novosad <junov at chromium.org>wrote:
>> On Wed, Nov 14, 2012 at 2:51 PM, Robert O'Callahan <robert at ocallahan.org>wrote:
>>> We could keep two copies of the canvas buffer: one rendered with
>>> subpixel AA and one without, and use the latter for rendering if we think
>>> it might be resampled. Of course, this isn't going to perform very well.
>> Hmmm... you might be on to something here. Performance may not be that
>> bad if the buffers are lazily resolved.
> What do you mean "lazily resolved"?
There is a recent improvement in Chrome called "deferred 2D canvas
rendering" (enabled by default as of Chrome 23). It is a mechanism that
records 2d canvas commands during JS execution, and only executes them for
real when the render buffer needs to be resolved (draw to screen,
getImageData, toDataURL, etc.). If you want to check it out, the guts are
in Skia: SkGPipe is a sort of FIFO for graphics commands, SkDeferredCanvas
is a wrapper that manages the GPipe and automatically flushes it and
applies some command culling optimizations.
So to come back to the problem of with and without subpixel AA buffers: if
rendering is deferred, the non-AA buffer would never get rasterized (and
possibly never even allocated), unless it needs to be. Obviously there are
practical limitations, for example we cannot store an unlimited stream of
recorded commands, so if the canvas draws indefinitely without ever being
cleared, at some point we have to rasterize the non-AA buffer just so that
we can safely discard the recording data. Also, if at record time the
necessary conditions for subpixel AA are not met, perhaps we just forget
I admit this is a complex solution for implementors, but it makes the
management of subpixel-AA safety transparent to web authors.
>> And if it is an opt-in option, then everyone is a fast as possible by
> Yes. If your use-cases are willing to sacrifice some performance for this,
> it could work.
> Jesus called them together and said, “You know that the rulers of the
> Gentiles lord it over them, and their high officials exercise authority
> over them. Not so with you. Instead, whoever wants to become great among
> you must be your servant, and whoever wants to be first must be your
> slave — just as the Son of Man did not come to be served, but to serve,
> and to give his life as a ransom for many.” [Matthew 20:25-28]
More information about the whatwg