Skip to content

Commit

Permalink
Add lowLatency flag to CanvasRenderingContext2DSettings.
Browse files Browse the repository at this point in the history
Developers of stylus-based drawing applications (e.g. Google Keep)
have found this hint to be critical in order to be competitive with
native applications. It has been prototyped in Chromium and yields
significant latency improvements there.

Partial fix for whatwg#4087.
  • Loading branch information
kenrussell committed Dec 11, 2018
1 parent edc1e95 commit 1cd5b24
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -59862,6 +59862,7 @@ enum <dfn>CanvasFillRule</dfn> { "<span data-x="dom-context-2d-fillRule-nonzero"

dictionary <dfn>CanvasRenderingContext2DSettings</dfn> {
boolean <span data-x="dom-CanvasRenderingContext2DSettings-alpha">alpha</span> = true;
boolean <span data-x="dom-CanvasRenderingContext2DSettings-lowLatency">lowLatency</span> = false;
};

enum <dfn>ImageSmoothingQuality</dfn> { "<span data-x="dom-context-2d-imageSmoothingQuality-low">low</span>", "<span data-x="dom-context-2d-imageSmoothingQuality-medium">medium</span>", "<span data-x="dom-context-2d-imageSmoothingQuality-high">high</span>" };
Expand Down Expand Up @@ -60123,6 +60124,12 @@ interface <dfn>Path2D</dfn> {
<p>If the <code data-x="dom-CanvasRenderingContext2DSettings-alpha">alpha</code> setting is
provided and set to false, then the canvas is forced to always be opaque.</p>

<p>If the <code data-x="dom-CanvasRenderingContext2DSettings-lowLatency">lowLatency</code>
setting is provided and set to true, then the user agent will attempt to optimize the rendering
of the canvas to reduce latency, including potentially rendering from the front buffer. This
might desynchronize the canvas's display from the rest of the page and induce tearing on some
displays.</p>

</dd>

<dt><var>context</var> . <code subdfn data-x="dom-context-2d-canvas">canvas</code></dt>
Expand Down Expand Up @@ -60166,6 +60173,20 @@ interface <dfn>Path2D</dfn> {
created <span>output bitmap</span> with its <span data-x="concept-canvas-alpha">alpha</span>
flag set to false will result in a fully-opaque gray square.</p>

<p>The <code>CanvasRenderingContext2D</code> object also has a <dfn
data-x="concept-canvas-lowLatency">lowLatency</dfn> flag, which can be set to true or false.
Initially, when the context is created, its <span
data-x="concept-canvas-lowLatency">lowLatency</span> flag must be set to false. When a
<code>CanvasRenderingContext2D</code> object has its <span
data-x="concept-canvas-lowLatency">lowLatency</span> flag set to true, then the user agent will
attempt to optimize the rendering of the canvas to reduce latency, including potentially rendering
from the front buffer. This might desynchronize the canvas's display from the rest of the page and
induce tearing on some displays.</p>

<p class="note">The <code data-x="concept-canvas-lowLatency">lowLatency</code> setting is useful
and necessary when implementing certain kinds of applications, such as drawing applications, where
the delay between input and rasterization is critical.</p>

<hr>

<p>The <code>CanvasRenderingContext2D</code> 2D rendering context represents a flat linear
Expand Down Expand Up @@ -60227,6 +60248,11 @@ interface <dfn>Path2D</dfn> {
<dt><dfn><code data-x="dom-CanvasRenderingContext2DSettings-alpha">alpha</code></dfn></dt>
<dd>If false, then set <var>context</var>'s <span data-x="concept-canvas-alpha">alpha</span>
flag to false.</dd>

<dt><dfn><code
data-x="dom-CanvasRenderingContext2DSettings-lowLatency">lowLatency</code></dfn></dt>
<dd>If true, then set <var>context</var>'s <span
data-x="concept-canvas-lowLatency">lowLatency</span> flag to true.</dd>
</dl>
</li>

Expand Down

0 comments on commit 1cd5b24

Please sign in to comment.