1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! Canvas 2D: `CanvasRenderingContext2D`, `OffscreenCanvas` and friends
//! (HTML ยง4.12.5), over a raster backend the embedder may replace.
//!
//! ## Layers
//!
//! * [`context`]: the JS classes and every HTML rule โ state and its stack,
//! transforms, the current path, argument handling, image sources. It
//! RECORDS: each draw becomes a [`cmd::Cmd`].
//! * [`cmd`]: the command stream, the contract with a backend. Backend-neutral
//! (kurbo geometry, straight sRGB colours, premultiplied images with ids).
//! * [`surface`]: one canvas bitmap โ a [`Backend`] plus the commands not yet
//! given to it, flushed when something needs the pixels.
//! * `cpu`: the built-in backend, vello_cpu. An embedder may install another
//! through [`set_host`] while keeping the same command stream
//! and the context does not change.
//!
//! ## What an embedder gets
//!
//! * `OffscreenCanvas` is complete as a 2D canvas. Without a `<canvas>`
//! element of its own, an embedder builds one from the hidden natives
//! (`__rjs_canvas_context`, `_resize`, `_data_url`, `_blob`,
//! `_source_hook`, `_info`; see `context.rs`), and paints it from
//! [`present`] under the key it registered. [`take_presented_changed`]
//! tells its frame loop that some presented canvas drew since the last
//! frame, so an idle canvas costs one atomic load a frame.
//!
//! ## Text and effects
//!
//! `fillText` and `strokeText` shape platform or registered CSS fonts into
//! ordinary fill/stroke paths. `measureText` uses shaped advances, font metrics
//! and actual ink bounds. Alignment, baselines, spacing, kerning, direction and
//! `maxWidth` use the same layout; no separate glyph backend is required.
//! Embedders register decoded web fonts with [`text::register_font`] before
//! applying private family renames. Registrations and layout caches belong to
//! one JS context and are released with it. Colour-only glyphs use an outline
//! fallback; this is not a colour-emoji rasterizer.
//!
//! The built-in CPU backend applies `shadowColor`, `shadowBlur`, offsets and
//! lists of CSS `blur(<px>)` filters in bitmap space, before the final canvas
//! clip. Other CSS filters emit an advisory. Replacement backends must honour
//! [`cmd::Draw::effects`] as well as the existing paint/composite/clip state.
//!
//! ## Remaining limits
//!
//! `{ alpha: false }` keeps an alpha channel, and a canvas is never tainted
//! (the origin-clean flag is tracked, see `Surface::readable`).
use c_void;
use HashSet;
use ;
pub use ;
/// Says `msg` once per `key`, for the process.
pub
/// Every canvas advisory said so far, in order.
pub unsafe
pub
/// The pixels of a canvas source (OffscreenCanvas, a context, or what the
/// embedder's source hook maps the value to), straight RGBA โ for
/// `createImageBitmap` and the other pixel readers in `image.rs`.
pub unsafe
pub unsafe