[whatwg] Processing the zoom level - MS extensions to window.screen
Charles Pritchard
chuck at jumis.com
Mon Nov 22 01:48:05 PST 2010
On 11/22/10 12:30 AM, Robert O'Callahan wrote:
> On Mon, Nov 22, 2010 at 8:49 PM, Charles Pritchard <chuck at jumis.com
> <mailto:chuck at jumis.com>> wrote:
>
> On 11/21/10 10:51 PM, Robert O'Callahan wrote:
>> On Mon, Nov 22, 2010 at 6:22 PM, Charles Pritchard
>> <chuck at jumis.com <mailto:chuck at jumis.com>> wrote:
>>
>> I've a deep and detailed understanding of the SVG, HTML, DOM
>> and CSS specs.
>>
>>
>> Just out of interest, why aren't you using SVG?
> Many thanks for the SVG Filter Effect CSS extension.
> I'd like to see that catch on with other vendors.
>
> Implementations of SVG are uneven and/or slow:
>
> Example: SVG Filter Effect + with an animated rotate in FF 3
> (excuse me if this is dated)
> was quite slow, though the SVG FE implementation is faster than
> CanvasPixelArray.
> It's also tricky, getting SVG FE turned on (for me anyway), with
> the xhtml mime requirements.
>
>
> That doesn't really explain why you're using canvas, if SVG is faster
> than canvas for your effect.
I wasn't able to "freeze" the composition of the SVG layer. Upon
rotation, the SVG layer re-filters the image,
it re-runs the filter effect on each rotation. With canvas, I simply
re-draw the filtered image
into the rotation.
I don't mean to get caught up in particular platform quirks. It's been a
few months since I've
addressed SVG ones. SVG FE afaik, was only in FF 3.6 w/ strict reqs.
We target several browsers; so regardless of the merits of SVG in FF
3.6, we still try to support
FF 3.0 and other legacy browsers and non-gecko browsers.
Simply, Canvas is less expensive to implement, and I'm sure far fewer
LOC than SVG,
so it's uptake was reasonably quick, and adding it to a new platform is
reasonably quick.
>
> For both performance and compatibility reasons, we've had to write
> low level code anyway.
> Actual display calls (be they SVG-able or not) are a relatively
> small part of our app.
>
> I'm currently focused on interchangeability of our HTML and Canvas
> profiles.
> Many SVG features are available via CSS now: paint servers and
> gradients,
> rounded rectangles, some text effects.
>
> Because of that, we're focused on HTML.
> SVG FE is definitely in our code base as a rendering option.
> We store our iconography in SVG, and some basic glyphs.
> We use canvas to render the glyphs, and we pre-render our
> iconography into png.
>
>
> It's important to separate the issues that are fixable implementation
> limitations from those issues that are fundamental to the design of
> Web standards. There is no point in adding new platform features to
> work around implementation limitations; we get a simpler platform if
> implementors just fix the existing features.
>
> So, for example, I wouldn't want to add canvas features to address
> use-cases for which SVG would work well if it was a bit better
> implemented.
My attention is still on exposing metrics so I can repaint to the device
resolution, fully within the existing standard. I don't want to change a
thing about CSS/Canvas; just looking for some data to be available in
the DOM.
It's a DOM deficiency in relation to the canvas tag.
Google Books demonstrates a use case apart from Canvas. They don't need
to override the browser's zoom. They do provide their own icon. If the
browser did provide
information, about zoom, they could send a higher resolution image to
the browser for that portion.
Here's a good, short, example of an SVG/WebGL+Canvas+HTML+CSS profile:
[canvas style="filter: url(#myPixelFilter); scale(.5,.5)"]
Everything is doing exactly what it should.
My only active proposal for the canvas spec is exposing a baseline
property in TextMetrics. textBaseline is insufficient on its own.
>
>> I understand the need to make canvas backing store pixels map to
>> device pixels when possible. Suppose that, on clearing the canvas
>> (e.g. by setting the width or height attribute), the browser
>> automatically set the canvas backing store density so that canvas
>> backing store pixels map to device pixels (taking into account
>> the current zoom settings). Suppose further that browsers fired
>> the 'resize' event when they zoom in a way that changes the
>> window size (as they should, even if they currently don't). Then
>> on 'resize' you could clear your canvas and redraw it, and
>> automatically get a canvas backing store with the right
>> resolution with no further code changes. Would that address your
>> use case?
> I appreciate your understanding, and your brainstorming.
>
> We currently use downsampled images within our application, and
> this proposal would override them We use them where filter effects
> are live, and are too expensive for the host to process quickly.
> Sampling is also useful as a memory management technique. On a
> resource constrained device, for whatever reason, it can make
> sense to draw the canvas at a smaller size, even though upscaling
> is noticable.
>
> With a complex gui / canvas drawing, redrawing the image may take
> some time. During zoom events, I can use a setTimeout to wait for
> the browser to settle before redrawing at higher resolution. CSS
> automates everything for me. It works wonderfully.
>
> Generally, with Canvas, things should not be automated. It's the
> CSS that's automated.
> Think of CSS as sending GPU instructions, and Canvas as simply
> updating a texture within the GPU.
>
...
>
> I was able to support resolution scaling on a complex application
> with less than an hour of work. It took me longer to test
> compatibility between browsers,
> for the hacks I used to try and get the DPI Scale values.
>
> It sounds to me like the approach I described would work for you.
It would be a non-standard extension to canvas that I would have to
write additional code to support. It would create more complexity for
the other browsers to add to their implementations. It may alter
ImageData or otherwise require more overhead for CanvasPixelArray
manipulation, slowing things down.
I would have to check my backing size before redrawing, to gain control
again. It would effectively require more data lookups and a storage
table (in script) so I know which elements have which backing
resolution. We do have cases where we want our backing store to be
different than the native resolution; these are typically related to
rendering speed/responsiveness. Some use cases are related to memory
management.
Your proposal would 'fix' existing apps written in canvas, ones at least
that weren't designed with pixel ratio in mind. But I don't think it's
necessary, and it would create more work for apps that do want to use
pixel ratio data, as well as suggesting more work to canvas implementers
in other browsers. It does make some sense as a CSS extension, which
would be turned off by default. Having a toggle, and having it off by
default would address all of my concerns about the proposal.
The method you've proposed is something that should be brought up to the
SVG working group in relation to future SVG + Canvas interoperability.
They're looking to extend the SVG standard, to bring in lessons from
Canvas. Within the context of an SVG scene graph and a new draft of SVG,
I think a dynamic backing store would work wonderfully. SVG has many
additional use cases not related to browser zoom, and I think it'd be
the best place to try out the technique. Another area to try it out
might be with getCSSCanvasContext, as it has different semantics than
getContext, and it seems like a great fit:
http://webkit.org/blog/176/css-canvas-drawing/
I do feel like this proposal is a new idea, it's a good one. It's a bit
more work on browser vendors, to address zoom, than the short-term work
of making sure that they actually expose css pixel metrics to the
scripting environment. Like many css options, I'm sure it'd be easier on
some code bases than others.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20101122/92e48c77/attachment-0002.htm>
More information about the whatwg
mailing list