Expand description
The composition renderer.
§Architecture and threading
As upstream, there are two compositors. The Compositor lives on the
UI thread together with the composition objects; the
server::ServerCompositor owns the server-side counterparts of those
objects and renders them. They exchange data in one direction only,
through batches: at commit the UI-thread compositor serializes the
changes of its objects into a transport::CommittedBatch and enqueues
it; at the start of each frame the server compositor applies the queued
batches.
The object model of the UI thread is Rc-based and thread-affine, so
the two sides are kept apart by construction rather than by locks:
- UI-thread objects never hold their server counterpart. They hold a
server::ServerObjectId, a plain value. A server object is created by the server compositor itself, from a factory carried by the batch (Compositor::create_server_object); changes and disposal refer to it by id. Server objects therefore need not beSend: they are created, mutated and dropped on the render thread only. - The batch queue (
server::BatchQueue) is the only crossing point. What may cross is exactly what atransport::BatchObjectcan hold plus plain values. - The few values the UI thread reads back (the clock, the readback
indices, batch completion) are
Send + Synctypes shared throughArc.
Today the server compositor runs on the thread of its compositor in
every configuration: the render loop may tick on any thread (its tasks
are Send + Sync), and a tick that arrives elsewhere is marshalled to
the compositor’s dispatcher. Running the server on a dedicated render
thread is blocked by one thing outside this module: the platform
resource handles carried by batches (std::sync::Arc<dyn IGeometryImpl>,
std::sync::Arc<crate::platform::SharedBitmapImpl>, std::sync::Arc<dyn IGlyphRunImpl>, immutable brushes and
pens) are Rc-based and so are the render contracts the server draws
with. Once those are shareable across threads, the remaining steps are
local: require Send on the Job, Create and Value payloads of
BatchObject, make the batch queue a mutex-protected queue, and
construct the server compositor on the render thread. No unsafe is
used anywhere in the composition renderer.
The browser target has no threads; it uses the same single-thread mode with a UI-thread render timer.
Re-exports§
pub use brushes::CompositionBrush;pub use brushes::CompositionConicGradientBrush;pub use brushes::CompositionGradientBrush;pub use brushes::CompositionLinearGradientBrush;pub use brushes::CompositionRadialGradientBrush;pub use brushes::CompositionSolidColorBrush;pub use server::RenderSurfaces;pub use animations::BooleanKeyFrameAnimation;pub use animations::ColorKeyFrameAnimation;pub use animations::DoubleKeyFrameAnimation;pub use animations::QuaternionKeyFrameAnimation;pub use animations::RelativePointKeyFrameAnimation;pub use animations::RelativeScalarKeyFrameAnimation;pub use animations::ScalarKeyFrameAnimation;pub use animations::Vector2KeyFrameAnimation;pub use animations::Vector3DKeyFrameAnimation;pub use animations::Vector3KeyFrameAnimation;pub use animations::Vector4KeyFrameAnimation;pub use animations::VectorKeyFrameAnimation;
Modules§
- animations
- Composition animations.
- brushes
- The composition brushes and their server-side counterparts.
- drawing
- Render data: the recorded form of what a visual draws, its resources, and the operations on it (replay, bounds, hit testing).
- expressions
- Expressions of composition animations: the variant value type, the expression tree, its parser and the functions callable from expressions.
- generated
- The composition object model generated from the composition schema.
- hit_
testing - Hit testing of the composition visual tree.
- server
- The server (render thread) side of the composition renderer.
- transport
- The transport between the UI-thread compositor and the server compositor: batches of serialized changes.
Structs§
- Compositing
Renderer - A renderer that utilizes a
Compositorto render the visual tree. - Composition
Bitmap Cache - Caches the subtree of a visual in a bitmap.
- Composition
Custom Visual - A container visual that draws through a handler on the render thread.
- Composition
Custom Visual Handler - The state upstream’s abstract
CompositionCustomVisualHandlerkeeps, and its protected members: what a handler class embeds and returns fromICompositionCustomVisualHandler::handler_base. - Composition
Draw List Visual - The composition visual of a visual of the visual tree: draws what the visual rendered.
- Composition
Drawing Surface - A composition surface whose content is set from imported GPU images.
- Composition
Experimental Acrylic Visual - A draw list visual that draws an acrylic rectangle below its content.
- Composition
GpuImported Image Synchronization Capabilities - The ways the access to an imported GPU image can be synchronized.
- Composition
GpuImported Object Base - What upstream’s
CompositionGpuImportedObjectBaseholds on the side of the caller: the compositor, the task of the import and the handle of the server part. - Composition
Gradient Stop - A gradient stop of the composition brushes, with animatable color and offset.
- Composition
Imported GpuImage - A GPU image imported into the compositor.
- Composition
Imported GpuSemaphore - A GPU semaphore imported into the compositor.
- Composition
Interop - The interop of a compositor with the GPU objects of its render interface context.
- Composition
Object - The part every composition object embeds: what upstream’s abstract
CompositionObjectholds. - Composition
Options - Options of the composition renderer.
- Composition
Property Set - Property sets are composition objects that allow storage of key values pairs that can be shared across the application and are not tied to the lifetime of another composition object. Property sets are most commonly used with animations, where they maintain key-value pairs that are referenced to drive portions of composition animations. Property sets provide the ability to insert key-value pairs or retrieve a value for a given key. A property set does not support a delete function – ensure you use property sets to store values that will be shared across the application.
- Composition
Solid Color Visual - A visual that fills its size with a color.
- Composition
Surface - A surface that a surface visual shows. The server-side counterpart provides the bitmap.
- Composition
Surface Visual - A visual that shows a composition surface.
- Composition
Target - The root of a composition visual tree: what a renderer draws to a render target.
- Composition
Tile Mode - Composition
Visual - A node of the composition visual tree.
- Composition
Visual Collection - The children of a composition visual.
- Composition
Visual Snapshot Error - The error of a snapshot that cannot be taken (
InvalidOperationException): seeCompositor::create_composition_visual_snapshot. - Compositor
- The compositor: manages the composition objects of the UI thread and commits their changes to the server compositor in batches.
- Element
Composition - Access to the composition visuals of the visuals of the visual tree.
- Matrix
Utils - Helpers computing the transform of a composition visual.
- Pending
Animations - The animation instances created on the UI thread (as their factories) that have not been sent to the server yet, by the property they animate.
- Render
Interface Feature - A feature of the platform render interface
(
Compositor::try_get_render_interface_feature). - Server
GpuImported Object Base - What the server part of every imported object holds: the context and the feature the object is imported with, and the outcome of the import.
- Server
Imported GpuImage - The server part of an imported GPU image.
- Server
Imported GpuSemaphore - The server part of an imported GPU semaphore.
- Server
JobTask - The outcome of a job run on the render thread: what
Compositor::invoke_server_job_asyncreturns (a task upstream).
Enums§
- Composition
Blend Mode - Composition
GetValue Status - The result of reading a value of a
CompositionPropertySet. - Composition
Gradient Extend Mode - Composition
Stretch - Composition
Transparency Level - The level of transparency a composition target is rendered with.
Traits§
- AsComposition
Object - A composition object as code refers to any composition object: a
reference parameter of an animation, an object stored in a property set
(upstream
CompositionObjectas a parameter type). - IComposition
Custom Visual Handler - The overridable members of a custom visual handler. A handler class
embeds a
CompositionCustomVisualHandlerand implements this trait. - IComposition
Draw List Visual Extension - What a class derived from the draw list visual outside of this module (the custom composition visual of a control) adds to its UI-thread side: the serialization of its own changes.
- IComposition
GpuImported Object - An imported GPU object that’s usable by composition APIs
- IComposition
GpuInterop - The import of GPU objects created outside of the framework into the compositor.
- IComposition
Importable Shared GpuContext Image - An GPU image descriptor obtained from a context from the same share group as one used by the compositor
- IComposition
Importable Shared GpuContext Object - An GPU object descriptor obtained from a context from the same share group as one used by the compositor
- IComposition
Importable Shared GpuContext Semaphore - An GPU semaphore descriptor obtained from a context from the same share group as one used by the compositor
- IComposition
Imported GpuImage - An imported GPU image object that’s usable by composition APIs
- IComposition
Imported GpuSemaphore - An imported GPU semaphore object that’s usable by composition APIs
- IComposition
Object - A UI-thread composition object as other composition objects refer to it: something with a server-side counterpart.
- IComposition
Object Animations - The animation members of
CompositionObject, written against the class that embeds one. - IComposition
Object Host - What a generated client property block needs from the composition
object that embeds it (the members of upstream
CompositionObjectthe generated code uses). - IComposition
Target Debug Events - Receives debugging information from a composition target while it renders a frame.
- ICompositor
Scheduler - Receives the request to commit a compositor’s pending changes; the media context implements it and schedules the commit with the next frame.
- ICompositor
Serializable - An object whose changes are serialized into the next batch of a compositor.
- IServer
GpuImported Object - The server part of an imported object: what the jobs of the render thread import, use and dispose.
Type Aliases§
- Composition
Cache Mode - The cache mode of a composition visual.
- Composition
Container Visual - A visual that can have children: every visual.
- Local
Future - A future of the thread of the compositor: what its asynchronous members
return (a
ValueTaskupstream), awaited on that thread. - Server
JobError - The error of a job run on the render thread: it crosses to the thread that asked for the job.