Contact emails
Spec
Feature proposal, not yet in spec: https://wiki.whatwg.org/wiki/CanvasRenderedPixelSize
Summary
rederedPixelWidth and rederedPixelHeight are read-only attributes that indicate the intrinsic size that must be set on a canvas for its pixels to map one-to-one to display device pixels. For applications that wish to render at the device's native resolution.
Motivation
There is high demand for an API that guarantees one-to-one pixel alignment between
a canvas element and the display device. Current hacks that sniff the device pixel ratio tend to be inexact.
Compatibility Risk
This feature does not interfere with any pre-existing functionality, and there is no immediate intent to ship.
Firefox has demonstrated public support for this feature (It's their proposal).
Ongoing technical constraints
There is currently some speculation about implementation issues related to interactions with layout (pixel coordinate snapping and the fact that the intrinsic size is in integers). An experimental implementation will allow us to explore these problems and possibly refine the feature proposal.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes
OWP launch tracking bug?
Link to entry on the feature dashboard
https://www.chromestatus.com/features/5477772331843584
Requesting approval to ship?
No
Can you point to examples of why "Current hacks that sniff the device pixel ratio tend to be inexact"? It would helpful to understand how this differs.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
I agree that this is an important use case, and am glad that you're pursuing it. Two pieces of feedback:1. Going forward we should not add live JavaScript properties. Instead I think it should be two methods: getRenderedPixelWidth() and getRenderedPixelHeight()
2. What interpolation algorithm should the browser apply when the backing does not match pixels, but script has not had time to put up a new frame? For example, consider an animated 3D transform on the canvas. Should the image-rendering CSS property address this question already? (also related)
This seems like this would force a layout, right? In other threads, we have been talking about async versions of all layout-inducing apis, e.g. asyncGetBoundignClientRect so that you can get these things but eventually... that way you avoid layout thrashing.Should we be contemplating this here?
On Wed, Apr 15, 2015 at 1:12 AM, Chris Harrelson <chri...@chromium.org> wrote:I agree that this is an important use case, and am glad that you're pursuing it. Two pieces of feedback:1. Going forward we should not add live JavaScript properties. Instead I think it should be two methods: getRenderedPixelWidth() and getRenderedPixelHeight()Rationale? Is it a policy that we prefer getters over read-only attributes?
2. What interpolation algorithm should the browser apply when the backing does not match pixels, but script has not had time to put up a new frame? For example, consider an animated 3D transform on the canvas. Should the image-rendering CSS property address this question already? (also related)I see two issues here.* When applying a 3D tranform, the browser makes a choice as to the rendered resolution of the transformed layer (the layer backing), so the intrinsic size suggested by renderedPixelWidth and renderedPixelHeight should allow the canvas to match the resolution of the layer backing. I think image-rendering is orthogonal.
* There is a synchronization issue here because a compositor commit may get scheduled between a layout change and the invocation of the renderedsizechanged event handler, so we may end-up rendering a frame in an inconsistent state where the content has not been adapted to the new layout. That is a problem we already have today with code that relies on mutation observers or window.onresize. It is not a problem that this feature aims to fix, but if anyone has any ideas, please share. I don't think it is a good idea to postpone commits when there is a pending renderedsizechanged event, because that could lock-up the main thread if the event handler touches layout.