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

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

From: Edward O'Connor <eoconnor@apple.com>
Date: Tue, 20 Mar 2012 13:42:01 -0700
Message-ID: <m2k42fdmxy.fsf@eoconnor.apple.com>
Tab wrote:

> So, I support adding an alternate API that explicitly returns a
> high-res store. If people fuck *that* up, then we're just screwed.

Yup.

> 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?

Suppose you're a clever developer who basically does something like this
to handle both an iPhone 3GS and an iPhone 4:

if (window.devicePixelRatio == 1) {
 // create a 100x100 canvas
} else if (window.devicePixelRatio == 2) {
 // create a 200x200 canvas and scale it down to 100x100 with CSS
} // etc.

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.

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.


Ted
Received on Tuesday, 20 March 2012 13:42:01 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:40 UTC