W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2013

Re: [whatwg] Enabling LCD Text and antialiasing in canvas

From: Stephen White <senorblanco@chromium.org>
Date: Mon, 11 Mar 2013 15:23:09 -0400
Message-ID: <CAPeKFTiCBEwcaDBQR60XxQ3Ooj6w_ZAs9o3QXPc7gZN1yNyR2Q@mail.gmail.com>
To: "Robert O'Callahan" <robert@ocallahan.org>
Cc: WHAT Working Group <whatwg@whatwg.org>, Ian Hickson <ian@hixie.ch>, Rik Cabanier <cabanier@gmail.com>
On Mon, Mar 11, 2013 at 2:56 PM, Robert O'Callahan <robert@ocallahan.org>wrote:

> On Tue, Mar 12, 2013 at 7:53 AM, Stephen White <senorblanco@chromium.org>wrote:
>> All other canvas functionality behaves as normal, including operations
>> which modify the alpha values of the backing store.  However, any such
>> transparency values will be ignored when compositing the canvas into the
>> page, and the canvas will be treated as if every pixel has an alpha of 1.0.
> That would mean getImageData can return non-1.0 alpha values, which is
> probably not what you want to implement.

That's what Firefox/Linux does (in fact, it always seems to return 0.0
alpha from getImageData()).

I considered three options:

1)  Prevent non-1.0 alpha ever getting into the canvas.  At a minimum, this
would require the following:

   - For putImageData, apply premultiplication, then write 1.0 alpha into
   the canvas.
   - Change initialization and clearRect() to clear to opaque black instead
   of transparent black.
   - Modify all canvas compositing modes to leave destination alpha

The latter is easy to do in OpenGL and CoreGraphics, but hard to do in
Skia, and hard to do in accelerated CoreGraphics (IOSurfaces don't seem to
support any opaque formats, although I could be wrong -- that was just from
an hour or so of experimentation).  I'm not sure about Cairo.

2)  Same as (1), but force all destination-alpha-referencing compositing
modes to source-over (or raise an exception).  This seems somewhat
draconian, and doesn't match what either Firefox implementation currently

3)  Ignore the canvas per-pixel alpha at page composite time.  This seems
to be what Firefox/Linux does.


> Rob
> --
> Wrfhf pnyyrq gurz gbtrgure naq fnvq, “Lbh xabj gung gur ehyref bs gur
> Tragvyrf ybeq vg bire gurz, naq gurve uvtu bssvpvnyf rkrepvfr nhgubevgl
> bire gurz. Abg fb jvgu lbh. Vafgrnq, jubrire jnagf gb orpbzr terng nzbat
> lbh zhfg or lbhe freinag, naq jubrire jnagf gb or svefg zhfg or lbhe fynir
> — whfg nf gur Fba bs Zna qvq abg pbzr gb or freirq, ohg gb freir, naq gb
> tvir uvf yvsr nf n enafbz sbe znal.” [Znggurj 20:25-28]
Received on Monday, 11 March 2013 19:23:39 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:20 UTC