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
use super::composition::{Compositor, LocalFuture, RenderInterfaceFeature};
use super::{RendererDiagnostics, SceneInvalidatedEventArgs};
use crate::reactive::IDisposable;
use crate::{Rect, Size, Visual};
use std::any::TypeId;
use std::rc::Rc;
/// Defines the interface for a renderer.
pub trait IRenderer {
/// A value controlling the renderer's diagnostics.
fn diagnostics(&self) -> Rc<RendererDiagnostics>;
/// Subscribes to the notification raised when a portion of the scene
/// has been invalidated.
///
/// Indicates that the underlying low-level scene information has been
/// updated. Used to signal that an update to the current pointer-over
/// state may be required.
fn scene_invalidated(&self, handler: Rc<dyn Fn(&SceneInvalidatedEventArgs)>) -> Rc<dyn IDisposable>;
/// Mark a visual as dirty and needing re-rendering.
fn add_dirty(&self, visual: &Visual);
/// Informs the renderer that the z-ordering of a visual's children has
/// changed.
fn recalculate_children(&self, visual: &Visual);
/// Called when a resize notification is received by the control being
/// rendered.
fn resized(&self, size: Size);
/// Called when a paint notification is received by the control being
/// rendered.
fn paint(&self, rect: Rect);
/// Starts the renderer.
fn start(&self);
/// Stops the renderer.
fn stop(&self);
/// Attempts to query for a feature from the platform render interface:
/// a future awaited on the thread of the renderer, which completes with
/// the feature or `None` (see `Compositor::try_get_render_interface_feature`:
/// asynchronous because the render interface may live on the render
/// thread). The feature is an object of the server side: what is handed
/// out lends it inside the compositor lock.
fn try_get_render_interface_feature(&self, feature_type: TypeId) -> LocalFuture<Option<RenderInterfaceFeature>>;
/// The compositor of the renderer, if it renders through one
/// (upstream: the `IRendererWithCompositor` interface).
fn compositor(&self) -> Option<Rc<Compositor>> {
None
}
/// Releases the renderer's resources.
fn dispose(&self);
}