diff --git a/source b/source index 0639bb4821c..82abd48687f 100644 --- a/source +++ b/source @@ -64640,11 +64640,12 @@ callback BlobCallback = undefined (Blob? blob);
The bitmaps of canvas
elements, the bitmaps of ImageBitmap
objects,
as well as some of the bitmaps of rendering contexts, such as those described in the sections on
- the CanvasRenderingContext2D
and ImageBitmapRenderingContext
objects
- below, have an origin-clean flag, which can be
- set to true or false. Initially, when the canvas
element or ImageBitmap
- object is created, its bitmap's origin-clean
- flag must be set to true.
CanvasRenderingContext2D
, OffscreenCanvasRenderingContext2D
, and
+ ImageBitmapRenderingContext
objects below, have an origin-clean flag, which can be set to true or false.
+ Initially, when the canvas
element or ImageBitmap
object is created, its
+ bitmap's origin-clean flag must be set to
+ true.
A canvas
element can have a rendering context bound to it. Initially, it does not
have a bound rendering context. To keep track of whether it has a rendering context or not, and
@@ -65105,9 +65106,8 @@ enum ImageSmoothingQuality { "canvas;
-
- CanvasRenderingContext2DSettings getContextAttributes();
};
+CanvasRenderingContext2D includes CanvasSettings;
CanvasRenderingContext2D includes CanvasState;
CanvasRenderingContext2D includes CanvasTransform;
CanvasRenderingContext2D includes CanvasCompositing;
@@ -65125,6 +65125,11 @@ interface CanvasRenderingContext2D {
CanvasRenderingContext2D includes CanvasTextDrawingStyles;
CanvasRenderingContext2D includes CanvasPath;
+interface mixin CanvasSettings {
+ // settings
+ CanvasRenderingContext2DSettings getContextAttributes();
+};
+
interface mixin CanvasState {
// state
undefined save(); // push state on state stack
@@ -65416,89 +65421,6 @@ interface Path2D {
A CanvasRenderingContext2D
object has an output bitmap that
- is initialized when the object is created.
The output bitmap has an origin-clean flag, which can be set to true or false. - Initially, when one of these bitmaps is created, its origin-clean flag must be set to true.
- -The CanvasRenderingContext2D
object also has an alpha boolean. When a
- CanvasRenderingContext2D
object's alpha is false, then its alpha channel must be fixed to 1.0
- (fully opaque) for all pixels, and attempts to change the alpha component of any pixel must be
- silently ignored.
Thus, the bitmap of such a context starts off as opaque black instead
- of transparent black; clearRect()
- always results in opaque black pixels, every fourth byte from getImageData()
is always 255, the putImageData()
method effectively ignores every
- fourth byte in its input, and so on. However, the alpha component of styles and images drawn
- onto the canvas are still honoured up to the point where they would impact the output
- bitmap's alpha channel; for instance, drawing a 50% transparent white square on a freshly
- created output bitmap with its alpha set
- to false will result in a fully-opaque gray square.
The CanvasRenderingContext2D
object also has a desynchronized boolean. When a
- CanvasRenderingContext2D
object's desynchronized is true, then the user agent may
- optimize the rendering of the canvas to reduce the latency, as measured from input events to
- rasterization, by desynchronizing the canvas paint cycle from the event loop, bypassing the
- ordinary user agent rendering algorithm, or both. Insofar as this mode involves bypassing the
- usual paint mechanisms, rasterization, or both, it might introduce visible tearing artifacts.
The user agent usually renders on a buffer which is not being displayed, quickly - swapping it and the one being scanned out for presentation; the former buffer is called - back buffer and the latter front buffer. A popular technique for reducing latency is called - front buffer rendering, also known as single buffer rendering, where rendering happens in - parallel and racily with the scanning out process. This technique reduces the latency at the price - of potentially introducing tearing artifacts and can be used to implement in total or part of the - desynchronized boolean. - MULTIPLEBUFFERING
- -The desynchronized boolean - can be useful when implementing certain kinds of applications, such as drawing applications, - where the latency between input and rasterization is critical.
- -The CanvasRenderingContext2D
object also has a will read frequently boolean. When a
- CanvasRenderingContext2D
object's will read frequently is true, the user agent
- may optimize the canvas for readback operations.
On most devices the user agent needs to decide whether to store the canvas's
- output bitmap on the GPU (this is also called "hardware accelerated"), or on the CPU
- (also called "software"). Most rendering operations are more performant for accelerated canvases,
- with the major exception being readback with getImageData()
, toDataURL()
, or toBlob()
. CanvasRenderingContext2D
objects with
- will read frequently equal to true tell
- the user agent that the webpage is likely to perform many readback operations and that it is
- advantageous to use a software canvas.
The CanvasRenderingContext2D
object also has a color space setting of type
- PredefinedColorSpace
. The CanvasRenderingContext2D
object's color space indicates the color space for the
- output bitmap.
The getContextAttributes()
method
- steps are to return «[ "alpha
" →
- this's alpha, "desynchronized
" →
- this's desynchronized, "colorSpace
" → this's
- color space, "willReadFrequently
" →
- this's will read frequently
- ]».
The CanvasRenderingContext2D
2D rendering context represents a flat linear
@@ -65553,23 +65475,8 @@ interface Path2D {
data-x="attr-canvas-width">width and height
content attributes.
Set context's alpha to
- settings["alpha
"].
Set context's desynchronized to settings["desynchronized
"].
Set context's color space to
- settings["colorSpace
"].
Set context's will read frequently to
- settings["willReadFrequently
"].
Run the canvas settings output bitmap + initialization algorithm, given context and settings.
Return context.
A CanvasSettings
object has an output bitmap that is initialized when
+ the object is created.
The output bitmap has an origin-clean flag, which can be set to true or false. + Initially, when one of these bitmaps is created, its origin-clean flag must be set to true.
+ +The CanvasSettings
object also has an alpha boolean. When a CanvasSettings
object's
+ alpha is false, then its alpha channel must be fixed to
+ 1.0 (fully opaque) for all pixels, and attempts to change the alpha component of any pixel must be
+ silently ignored.
Thus, the bitmap of such a context starts off as opaque black instead
+ of transparent black; clearRect()
+ always results in opaque black pixels, every fourth byte from getImageData()
is always 255, the putImageData()
method effectively ignores every fourth
+ byte in its input, and so on. However, the alpha component of styles and images drawn onto the
+ canvas are still honoured up to the point where they would impact the output bitmap's
+ alpha channel; for instance, drawing a 50% transparent white square on a freshly created
+ output bitmap with its alpha set to false
+ will result in a fully-opaque gray square.
The CanvasSettings
object also has a desynchronized boolean. When a
+ CanvasSettings
object's desynchronized is true, then the user agent may
+ optimize the rendering of the canvas to reduce the latency, as measured from input events to
+ rasterization, by desynchronizing the canvas paint cycle from the event loop, bypassing the
+ ordinary user agent rendering algorithm, or both. Insofar as this mode involves bypassing the
+ usual paint mechanisms, rasterization, or both, it might introduce visible tearing artifacts.
The user agent usually renders on a buffer which is not being displayed, quickly + swapping it and the one being scanned out for presentation; the former buffer is called back + buffer and the latter front buffer. A popular technique for reducing latency is called + front buffer rendering, also known as single buffer rendering, where rendering happens in + parallel and racily with the scanning out process. This technique reduces the latency at the price + of potentially introducing tearing artifacts and can be used to implement in total or part of the + desynchronized boolean. + MULTIPLEBUFFERING
+ +The desynchronized boolean can + be useful when implementing certain kinds of applications, such as drawing applications, where the + latency between input and rasterization is critical.
+ +The CanvasSettings
object also has a will read frequently boolean. When a
+ CanvasSettings
object's will read
+ frequently is true, the user agent may optimize the canvas for readback operations.
On most devices the user agent needs to decide whether to store the canvas's
+ output bitmap on the GPU (this is also called "hardware accelerated"), or on the CPU
+ (also called "software"). Most rendering operations are more performant for accelerated canvases,
+ with the major exception being readback with getImageData()
, toDataURL()
, or toBlob()
. CanvasSettings
objects with will read frequently equal to true tell the
+ user agent that the webpage is likely to perform many readback operations and that it is
+ advantageous to use a software canvas.
The CanvasSettings
object also has a color space setting of type
+ PredefinedColorSpace
. The CanvasSettings
object's color space indicates the color space for the
+ output bitmap.
To initialize a CanvasSettings
output
+ bitmap, given a CanvasSettings
context and a
+ CanvasRenderingContext2DSettings
settings:
Set context's alpha to
+ settings["alpha
"].
Set context's desynchronized to settings["desynchronized
"].
Set context's color space to
+ settings["colorSpace
"].
Set context's will read
+ frequently to settings["willReadFrequently
"].
The getContextAttributes()
method
+ steps are to return «[ "alpha
" →
+ this's alpha, "desynchronized
" →
+ this's desynchronized, "colorSpace
" → this's
+ color space, "willReadFrequently
" →
+ this's will read frequently
+ ]».
Objects that implement the CanvasState
interface maintain a stack of drawing
@@ -71082,9 +71096,9 @@ interface OffscreenCanvas : EventTarget {
2d
"
Let context be the result of running the offscreen 2D context creation - algorithm given this and options.
Let context be the result of running the + offscreen 2D context creation algorithm given + this and options.
Set this's context mode to 2d.
If this OffscreenCanvas
object's context mode is 2d and the rendering context's bitmap's origin-clean flag is set to false, then return
- a promise rejected with a "SecurityError
"
- DOMException
.
SecurityError
" DOMException
.
If this OffscreenCanvas
object's bitmap has no pixels (i.e., either its horizontal
@@ -71338,7 +71351,7 @@ interface OffscreenCanvas : EventTarget {
data-x="offscreencanvas-bitmap">bitmap to reference a newly created bitmap of the same
dimensions and color space as the previous bitmap, and with its pixels initialized to
transparent black, or opaque black if the rendering context's alpha flag is set to false.
This means that if the rendering context of this OffscreenCanvas
is
a WebGLRenderingContext
, the value of OffscreenCanvasRenderingContext2D {
readonly attribute OffscreenCanvas canvas;
};
+OffscreenCanvasRenderingContext2D includes CanvasSettings;
OffscreenCanvasRenderingContext2D includes CanvasState;
OffscreenCanvasRenderingContext2D includes CanvasTransform;
OffscreenCanvasRenderingContext2D includes CanvasCompositing;
@@ -71398,29 +71412,6 @@ interface OffscreenCanvasRenderingContext2D {
OffscreenCanvas
object rather than a canvas
element;
An OffscreenCanvasRenderingContext2D
object has a bitmap that is initialized when the object is
- created.
The bitmap has an origin-clean flag, which can be set to true or - false. Initially, when one of these bitmaps is created, its origin-clean flag must be set to true.
- -An OffscreenCanvasRenderingContext2D
object also has an alpha flag, which can be set to true or false. Initially,
- when the context is created, its alpha flag must be set to true. When an
- OffscreenCanvasRenderingContext2D
object has its alpha flag set to false, then its alpha channel must be
- fixed to 1.0 (fully opaque) for all pixels, and attempts to change the alpha component of any pixel
- must be silently ignored.
An OffscreenCanvasRenderingContext2D
object also has a color space setting of type
- PredefinedColorSpace
. The color space for the context's bitmap is set to the context's color space.
An OffscreenCanvasRenderingContext2D
object has an associated
OffscreenCanvas
object, which is the OffscreenCanvas
object
from which the OffscreenCanvasRenderingContext2D
object was created.
@@ -71451,24 +71442,18 @@ interface OffscreenCanvasRenderingContext2D {
Set context's associated OffscreenCanvas
object to
target.
If settings["alpha
"] is false, then set
- context's alpha flag to false.
Run the canvas settings output bitmap + initialization algorithm, given context and settings.
Set context's color space
- to settings["colorSpace
"].
Set context's bitmap to a newly
- created bitmap with the dimensions specified by the Set context's output bitmap to a newly created bitmap with the
+ dimensions specified by the width
and width
and height
attributes of target, and set
target's bitmap to the same bitmap (so that they are shared).
If context's alpha flag is set - to true, initialize all the pixels of context's bitmap to transparent black. Otherwise, - initialize the pixels to opaque black.
If context's alpha flag is set to + true, initialize all the pixels of context's output bitmap to + transparent black. Otherwise, initialize the pixels to opaque + black.
Return context.
A CanvasRenderingContext2D
's output bitmap and an
- OffscreenCanvasRenderingContext2D
's bitmap must use premultiplied alpha to represent transparent colors.
OffscreenCanvasRenderingContext2D
's output bitmap must use premultiplied
+ alpha to represent transparent colors.
It is important for canvas bitmaps to represent colors using premultiplied alpha because it affects the range of representable colors. While additive colors cannot currently be