[whatwg] [canvas] request for {create, get, put}ImageDataHD and ctx.backingStorePixelRatio
Charles Pritchard
chuck at jumis.com
Tue Mar 20 15:22:56 PDT 2012
On Mar 20, 2012, at 3:05 PM, Edward O'Connor <eoconnor at apple.com> wrote:
> Charles Pritchard wrote:
>
>>> But now run through this logic when the <canvas> is making a high res
>>> backing store automatically: by doing the clever thing, you're now
>>> quadrupling the size of the canvas, and you're paying an exorbitant
>>> storage cost for doing so.
>>
>> Which (a): never happens
>
> Sorry, what never happens?
The backing store itself is never set by 2x in the implementation. Not in any public implementations I've seen. It's always 1:1 with height and width units.
> Developers commonly double the size of their
> <canvas>es (and scale them down with CSS) to support both the iPhone 3GS
> and iPhone 4. Which means such code would use 4 times as much memory as
> intended when <canvas> uses such a backing store.
It would do that, but it doesn't, because none of the implementations use a larger backing store.
And yes, in preparing for some future break in implementations, it may be wise for authors to run a check on getImageData. I don't, I've not seen it done, but it may be prudent.
>
>> and (b) can be detected via 1x1 pixel canvas.
>
> Having to round-trip image data through a <canvas> in order to detect
> its backing store size is one of the problems I'm trying to solve here.
It's a 1:1 fetch, it doesn't take any time to do getImageData(0,0,1,1);
I don't mean to be pushing back on this issue. I'm more focused on the fact that other obvious issues have not been addressed by vendors, and now we're examining an issue that does not yet exist.
>
>>> You really only want to do the "make it twice as big and then scale
>>> it down with CSS" trick when backing store pixels are 1:1 to CSS
>>> pixels.
>>
>> I do "tricks" to support browser zoom. They are increments; .5,.7,
>> 1.1, 1.2, 1.3, etc.
>
> Huh? I'm not sure what you mean by "browser zoom," nor do I know what it
> has to do with my proposed additions to the <canvas> 2D Context API.
I know, and it'd be swell if we could sit down some time and I could walk you through the Canvas API an WCAG.
In the meantime, perhaps you could go over to the link I sent (A canvas button) on Jumis.com.
By browser zoom, I mean on a desktop, when I use CTRL + to change the pixel ratio on the page.
I've posted links to MS docs, and to a live example, on this thread.
-Charles
More information about the whatwg
mailing list