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

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

From: Rik Cabanier <cabanier@gmail.com>
Date: Sat, 16 Feb 2013 03:08:16 +1100
Message-ID: <CAGN7qDAUNVsuA6_8tW56EqtijTTwjxc5uRjYCM4bw+FvVDbeQA@mail.gmail.com>
To: robert@ocallahan.org
Cc: whatwg@whatwg.org, Ian Hickson <ian@hixie.ch>, Stephen White <senorblanco@chromium.org>
As an other alternative, we could also introduce a 'matteColor' attribute.
It's default would be 'transparent'.

If it's set to a css color, the canvas will be matted to that color. In
addition if you use putImageData or a compositing operator that changes
alpha, you always matte with that color afterwards (if needed).

This is actually pretty close to the 'opaque' keyword except
- it's on the canvas context
- you can specify a color
- it doesn't force reallocation of the canvas

On Fri, Feb 15, 2013 at 2:44 PM, Rik Cabanier <cabanier@gmail.com> wrote:

> On Fri, Feb 15, 2013 at 2:21 PM, Robert O'Callahan <robert@ocallahan.org>wrote:
>> On Thu, Feb 14, 2013 at 11:59 PM, Stephen White <senorblanco@chromium.org
>> > wrote:
>>> I think this is difficult to do in the general case, such as
>>> putImageData() or drawImage() or patterns, since you would need to examine
>>> all the pixels of the source image to determine if they contain non-1
>>> alpha.  This would be cost-prohibitive.
>>> If it's just for the purposes of optimization, you could be conservative
>>> and simply clear the flag when there's the potential for (but not certainty
>>> of) non-1 alpha.  But if you're also using that flag to allow subpixel AA,
>>> the behaviour becomes quite unpredictable for the web developer and hard to
>>> spec crisply.
>> What if we just said
>> a) non-over operators clear the subpixel AA flag
>> b) putImageData clears the subpixel AA flag
>> Both of these are infrequently used AFAIK. Authors could work around most
>> cases of b) by doing putImageData to another canvas and compositing it into
>> the destination with 'over'.
> Yes, that's pretty much my proposal. Except putImageData could detect it
> but that might be too hard for authors to figure out.
>> How bad would that be? Would it help if we added an attribute to the
>> canvas to let authors detect whether the subpixel AA flag is set?
> I think that would be very helpful.
> So, if you clear (or matte) the canvas, the flag becomes true but if you
> do an operator that removes alpha, it will become false.
>> 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 Friday, 15 February 2013 16:08:43 UTC

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