[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] How to set a canvas backing store to display units?





On Sat, Jun 16, 2012 at 1:36 PM, Florian BÃsch <pyalot@gmail.com> wrote:
On Sat, Jun 16, 2012 at 10:30 PM, Gregg Tavares (çç) <gman@google.com> wrote:
It will break because you have to test. That's what I mean by automatic. Lots of programmers will add "allowHighRes" either by using a library, by copying boilerplate code or just by not understanding theÂimplications. They won't personally have an HD-DPI machine so their app will work. They'll have no idea of all the rules they broke. Hence, it will break automatically when put on an HD-DPI machine.Â

The exact same will be true for those same programmers who copy&paste or use an engine that does the window.devicePixelRatio for you, their apps will break if they are not aware that their canvas size != backing store size.Â

I don't know why I can't convey this in way that sticks.

What I'm suggesting is

   Âcanvas.size == backing store size

Period. Always. No Options. ÂThat's what it is today and I want to see that added to the spec that HD-DPI machine don't change that.

   Âcanvas.size = desiredSize * window.devicePixelRatioÂ

is still

   Âcanvas.size == backing store size

You ask for a certain size, you get it.

That's separate from the size it's displayed. That's true today, it was true 2 years ago. It will be true tomorrow

   <canvas width="4" height="3" style="width: 400px; height: 300px" id="foo"/>

   gl = document.getElementById("foo").getContext("webgl");

requested size = 4x3
canvas size = 4x3
backing store size = 4x3
display size = 400x300




Â
The effort to make your app compatible is identical in either case, and the breakage is identical in either case as well. Both are an opt-in mechanism and both dismarry canvas dimensions from backingstore dimensions withoutÂnecessarilyÂthe average developer being aware of it. Even the educational effort is the same, I really don't think it matters. I also think I don't care:

Option #1: Slap Apple on the wrist never to do the automatic thing, and add an addendum to the specification stating that backingstore == canvas dimension and that devicePixelRatio has to be queryable for everybody who implements webgl.ÂÂÂ

This. Â
Â
Option #2: add this "allow this or that" attributeÂ
Option #3: allow both (that could get kinda confusing)