[whatwg] [canvas] request for {create, get, put}ImageDataHD and ctx.backingStorePixelRatio

Tab Atkins Jr. jackalmage at gmail.com
Tue Mar 20 10:53:17 PDT 2012

On Tue, Mar 20, 2012 at 10:29 AM, Edward O'Connor <eoconnor at apple.com> wrote:
> Unfortunately, lots of <canvas> content (especially content which calls
> {create,get,put}ImageData methods) assumes that the <canvas>'s backing
> store pixels correspond 1:1 to CSS pixels, even though the spec has been
> written to allow for the backing store to be at a different scale
> factor.
> Especially problematic is that developers have to round trip image data
> through a <canvas> in order to detect that a different scale factor is
> being used.
> I'd like to propose the addition of a backingStorePixelRatio property to
> the 2D context object. Just as window.devicePixelRatio expresses the
> ratio of device pixels to CSS pixels, ctx.backingStorePixelRatio would
> express the ratio of backing store pixels to CSS pixels. This allows
> developers to easily branch to handle different backing store scale
> factors.
> Additionally, I think the existing {create,get,put}ImageData API needs
> to be defined to be in terms of CSS pixels, since that's what existing
> content assumes. I propose the addition of a new set of methods for
> working directly with backing store image data. (New methods are easier
> to feature detect than adding optional arguments to the existing
> methods.) At the moment I'm calling these {create,get,put}ImageDataHD,
> but I'm not wedded to the names. (Nor do I want to bikeshed them.)

Given that the modern iPhones (and I suspect the iPad 3, though I
haven't tested it yet) aren't exposing their high-res backing stores
(they give back ImageData with CSS px resolution), it seems likely
that the original goal of get/putImageData to seamlessly adapt has
failed.  So, I support adding an alternate API that explicitly returns
a high-res store.  If people fuck *that* up, then we're just screwed.

I'm not as sure about the backingStorePixelRatio bit.  What's the
use-case for it?  Why do devs need to detect this, and what will they
do different in the multiple code paths?


More information about the whatwg mailing list