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
109
110
111
112
113
//! Native surfaces the OS compositor shows beside the framework's picture: the capability a
//! host with a compositor hands out, and the surface a producer feeds from a thread of its
//! own. The Core Animation host's `os/apple/composition` module, in `inset-embedder-winit`, says
//! why it is shaped as it is. A producer that paces by the screen's refreshes waits on the
//! platform's [`VsyncWaiter`](crate::VsyncWaiter).
//!
//! Surfaces make one tree rooted at each view, as every compositor's layers do (Core Animation's
//! sublayers, Wayland's subsurfaces, Android's `SurfaceControl` parents, DirectComposition's
//! visuals), with one rule at every level: a surface is opened under a parent
//! ([`SurfaceParent::open_child`]), and placed when that parent's next frame is applied. A view's
//! frame is its [`Scene`](crate::Scene), whose `surfaces` place the surfaces opened under the
//! view's root ([`Compositor::root`]); a surface's frame is its [`SurfaceFrame`], whose
//! `children` place the surfaces opened under it, in its buffer's pixels, beneath its buffer.
//! Both list [`SurfacePlacement`]s, and the host lands each frame in the one transaction its
//! compositor has for it (a `CATransaction`, a parent's `wl_surface.commit`,
//! `IDCompositionDevice::Commit`, a `SurfaceControl.Transaction`). A program whose picture is
//! itself a surface in another app's window opens its own surfaces under that picture so, and
//! the placement of the picture moves, clips and scales the whole group as one.
//!
//! The invariant: a surface is on screen only where its parent's last frame placed it, and the
//! host, not the framework, owns the native object behind it.
use Any;
use fmt;
use Arc;
use crate::;
/// The host's compositor, as an app reaches it.
/// What surfaces open under: a view's root, or another surface. Every method may be called from
/// any thread.
/// One surface, and the parent of the surfaces opened under it. Every method may be called from
/// any thread.
///
/// The handle is the surface's identity: a frame places the `Arc` itself, so only a surface
/// that exists can be placed, and it lives while anything shows it. A host gets its own
/// type back from a placed surface by downcasting through `Any`.
/// What one present of a surface shows: a buffer, and the surface's children placed beneath it,
/// bottom-most first, as a [`Scene`](crate::Scene) is what one frame of a view shows. What a
/// later present needs beyond these, such as the part of the buffer that changed, joins them
/// here.
/// What a producer draws into and hands over: the platform's own type.
pub type Buffer = CFRetained;
/// A platform with no host that composites: no buffer can exist, so
/// [`Surface::present`] cannot be called, and [`Platform::compositor`](crate::Platform::compositor)
/// answers `None`.