Skip to main content

ServerCompositionVisualSurface

Struct ServerCompositionVisualSurface 

Source
pub struct ServerCompositionVisualSurface { /* private fields */ }
Expand description

The server-side counterpart of a CompositionVisualSurface: a live image of the subtree of a visual.

The subtree is rendered where the surface is drawn, as the bitmap cache renders it: the visibility, opacity, transform and clip of the source visual itself are ignored, so a hidden source still shows. A surface that shows an ancestor of the visual that draws it would draw itself again inside that drawing; the second drawing is skipped.

The compositor keeps a list of the visual surfaces and, once per frame before the targets are updated, invalidates the surfaces whose source subtree changed (update_live_surfaces), which redraws the visuals that show them.

A frozen surface shows the image of the source taken when it was frozen: the UI-thread surface asks for the freeze with its next batch, and the compositor renders the image in the same pass (freeze).

Implementations§

Source§

impl ServerCompositionVisualSurface

Source

pub fn new( compositor: &Rc<ServerCompositor>, ) -> Rc<ServerCompositionVisualSurface>

Creates the surface, active, and registers it with the compositor for the live updates.

Source

pub fn props(&self) -> &ServerCompositionVisualSurfaceProps

The properties of the surface.

Source

pub fn is_disposed(&self) -> bool

Source

pub fn is_frozen(&self) -> bool

Whether the surface is frozen.

Source

pub fn source_visual(&self) -> Option<Rc<ServerCompositionVisual>>

The visual whose subtree the surface shows.

Source

pub fn source_rect(&self) -> Option<Rect>

The area of the source visual the surface shows, in the coordinates of the source: SourceOffset and SourceSize, where a zero SourceSize is the size of the source visual. None when the area is empty or there is no source.

Source

pub fn request_freeze(&self)

Asks for the surface to be frozen by the next pass of the compositor (what the batch of a UI-thread freeze carries).

Source

pub fn update_live_surfaces( compositor: &ServerCompositor, surfaces: &RefCell<Vec<Weak<ServerCompositionVisualSurface>>>, ) -> bool

The surfaces that were asked to freeze are frozen, and the live surfaces whose source changed since the last update of its target are invalidated, which redraws the visuals that show them. Run once per frame by the compositor, after the own properties of the visuals were recomputed and before the targets are updated. Returns whether a surface changed. Dropped surfaces are removed from surfaces.

Source

pub fn set_follows_source_bounds(&self, value: bool)

Makes a change of the extent of the source subtree a change of the surface (what a redirect visual, whose bounds cover its source, needs; not from upstream).

Source

pub fn render_source_subtree( &self, canvas: &mut dyn IDrawingContextImpl, clip: LtrbRect, )

Renders the whole subtree of the source onto canvas, whose transform maps the coordinates of the source, as the bitmap cache renders it (the visibility, opacity, transform and clip of the source itself are ignored), unless the surface is rendering its source already: what a redirect visual draws (not from upstream). clip is in the coordinates of the device.

Source

pub fn freeze(&self, compositor: &ServerCompositor)

Renders the source into an offscreen layer once, and shows that layer from now on (not a public member in WinUI; the connected animation freezes the image of its source). Runs on the render thread, with the bounds of the source subtree as of the last frame: best effort, a source that was never rendered in a target has no bounds for its children yet.

Source

pub fn is_rendering(&self) -> bool

Whether the source is being rendered by this surface: the drawing of the surface inside it is skipped.

Trait Implementations§

Source§

impl IAnimatedServerObject for ServerCompositionVisualSurface

Source§

fn server_object(&self) -> &ServerObject

The embedded ServerObject part.
Source§

fn get_composition_property( &self, field_name: &str, ) -> Option<&'static CompositionProperty>

The composition property with the given name, if the class has one.
Source§

fn as_server_object_dyn(&self) -> &dyn IServerObject

The object as the base contract (an explicit upcast).
Source§

fn read_property_variant( &self, property: &'static CompositionProperty, ) -> ExpressionVariant

Reads a property of the object as a variant. The default reads the field through CompositionProperty::get_variant; an object with dynamic properties (a property set) reads its own storage.
Source§

fn write_property_variant( &self, property: &'static CompositionProperty, value: ExpressionVariant, )

Writes a variant into a property of the object without notification (what an animation does with the value it evaluated). The default writes the field through CompositionProperty::set_variant; an object with dynamic properties writes its own storage.
Source§

impl IServerAnimatedPropertyHost for ServerCompositionVisualSurface

Source§

fn set_animated_value( &self, property: &'static CompositionProperty, current_value: ExpressionVariant, committed_at: Duration, animation: Rc<dyn IAnimationInstance>, )

SetAnimatedValue(prop, ref field, committedAt, animation): starts animation on the property. current_value is the value of the field as a variant; the animation writes the field through CompositionProperty::set_variant.
Source§

fn remove_animation_for_property(&self, property: &'static CompositionProperty)

The tail of SetAnimatedValue(prop, out field, value): the field has been assigned directly, so the animation of the property, if any, is removed.
Source§

fn notify_animated_value_changed(&self, _property: &'static CompositionProperty)

An animation wrote a new value into the field of property.
Source§

impl IServerCompositionSurface for ServerCompositionVisualSurface

Source§

fn bitmap(&self) -> Option<Arc<SharedBitmapImpl>>

A visual surface has no bitmap: its content is drawn by draw.

Source§

fn draw(&self, canvas: &mut dyn IDrawingContextImpl, dest: Rect, opacity: f64)

Draws the source area of the source visual into dest: the frozen image, or the subtree rendered with the transform that maps the source area onto dest, clipped to dest.

Source§

fn changed(&self) -> &ServerCompositionSurfaceChanged

Raised when the content changed.
Source§

fn natural_size(&self) -> Option<Size>

The size of the content in device independent pixels (the natural size of WinUI’s surfaces), which a surface brush lays out; None while the surface has no content. The default is the size of the bitmap at its DPI.
Source§

impl IServerObject for ServerCompositionVisualSurface

Source§

fn deserialize_changes_core( &self, reader: &mut BatchStreamReader<'_>, committed_at: Duration, )

Reads the changes of the object from a batch.
Source§

fn values_invalidated(&self)

Called after a group of values of the object changed.
Source§

fn dispose(&self)

Releases the object: it has been disposed on the UI thread.
Source§

fn as_render_resource(self: Rc<Self>) -> Option<Rc<dyn IServerRenderResource>>

The object as a render resource, if it is one.
Source§

fn as_surface(self: Rc<Self>) -> Option<Rc<dyn IServerCompositionSurface>>

The object as a composition surface, if it is one.
Source§

fn as_animated(self: Rc<Self>) -> Option<Rc<dyn IAnimatedServerObject>>

The object as an animatable object, if it is one.
Source§

fn get_props(&self, type_id: TypeId) -> Option<&dyn Any>

The generated property block of the given type embedded in the object, if it has one. A class that embeds generated properties forwards to their find_props; composition properties locate their fields through it.
Source§

fn as_any(&self) -> &dyn Any

Source§

fn into_any_rc(self: Rc<Self>) -> Rc<dyn Any>

Source§

fn deserialize_changes( &self, reader: &mut BatchStreamReader<'_>, committed_at: Duration, )

Applies the changes of the object from a batch.
Source§

fn as_brush(self: Rc<Self>) -> Option<Rc<dyn IBrush>>

The object as a brush, if it is a server-side brush.
Source§

fn as_pen(self: Rc<Self>) -> Option<Rc<dyn IPen>>

The object as a pen, if it is a server-side pen.
Source§

fn as_render_data_geometry( self: Rc<Self>, ) -> Option<Rc<dyn IRenderDataGeometry>>

The object as a geometry usable by render data, if it is a server-side geometry.
Source§

fn as_transform(self: Rc<Self>) -> Option<Rc<dyn ITransform>>

The object as a transform, if it is a server-side transform.
Source§

fn as_gradient_stop(self: Rc<Self>) -> Option<Rc<dyn IGradientStop>>

The object as a gradient stop, if it is a server-side gradient stop.
Source§

impl IServerPropertyHost for ServerCompositionVisualSurface

Source§

fn server_compositor(&self) -> Option<Rc<ServerCompositor>>

The compositor of the object, while it is alive. Used to resolve the server objects a batch refers to.
Source§

fn set_value( &self, _property: &'static CompositionProperty, change: ServerValueChange<'_>, )

SetValue(prop, ref field, value) as the class of the object defines it. A plain server object assigns; an animated object also invalidates the subscriptions of the property; a render resource goes through super::ServerRenderResourceCore::set_value.
Source§

impl IServerRenderResource for ServerCompositionVisualSurface

Source§

impl IServerRenderResourceHost for ServerCompositionVisualSurface

Source§

fn compositor(&self) -> Option<Rc<ServerCompositor>>

The compositor of the resource, while it is alive.
Source§

fn as_render_resource_rc(&self) -> Option<Rc<dyn IServerRenderResource>>

The resource as a shared handle, for the invalidation queue.
Source§

fn resource_property_changed(&self)

Called once per group of property changes, before the queued invalidation.
Source§

impl IServerRenderResourceObserver for ServerCompositionVisualSurface

Source§

impl ServerCompositionVisualSurfaceHooks for ServerCompositionVisualSurface

Source§

fn deserialize_changes_extra(&self, reader: &mut BatchStreamReader<'_>)

The request to freeze, written by the UI-thread surface before its properties.

Source§

fn on_fields_deserialized( &self, _changed: CompositionVisualSurfaceChangedFields, )

Source§

fn on_source_visual_changed(&self)

Source§

fn on_source_visual_changing(&self)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.