Trait webrender::composite::Compositor

source ·
pub trait Compositor {
Show 18 methods // Required methods fn create_surface( &mut self, device: &mut Device, id: NativeSurfaceId, virtual_offset: DeviceIntPoint, tile_size: DeviceIntSize, is_opaque: bool, ); fn create_external_surface( &mut self, device: &mut Device, id: NativeSurfaceId, is_opaque: bool, ); fn create_backdrop_surface( &mut self, device: &mut Device, id: NativeSurfaceId, color: ColorF, ); fn destroy_surface(&mut self, device: &mut Device, id: NativeSurfaceId); fn create_tile(&mut self, device: &mut Device, id: NativeTileId); fn destroy_tile(&mut self, device: &mut Device, id: NativeTileId); fn attach_external_image( &mut self, device: &mut Device, id: NativeSurfaceId, external_image: ExternalImageId, ); fn bind( &mut self, device: &mut Device, id: NativeTileId, dirty_rect: DeviceIntRect, valid_rect: DeviceIntRect, ) -> NativeSurfaceInfo; fn unbind(&mut self, device: &mut Device); fn begin_frame(&mut self, device: &mut Device); fn add_surface( &mut self, device: &mut Device, id: NativeSurfaceId, transform: CompositorSurfaceTransform, clip_rect: DeviceIntRect, image_rendering: ImageRendering, ); fn end_frame(&mut self, device: &mut Device); fn enable_native_compositor(&mut self, device: &mut Device, enable: bool); fn deinit(&mut self, device: &mut Device); fn get_capabilities(&self, device: &mut Device) -> CompositorCapabilities; fn get_window_visibility(&self, device: &mut Device) -> WindowVisibility; // Provided methods fn invalidate_tile( &mut self, _device: &mut Device, _id: NativeTileId, _valid_rect: DeviceIntRect, ) { ... } fn start_compositing( &mut self, _device: &mut Device, _clear_color: ColorF, _dirty_rects: &[DeviceIntRect], _opaque_rects: &[DeviceIntRect], ) { ... }
}
Expand description

Defines an interface to a native (OS level) compositor. If supplied by the client application, then picture cache slices will be composited by the OS compositor, rather than drawn via WR batches.

Required Methods§

source

fn create_surface( &mut self, device: &mut Device, id: NativeSurfaceId, virtual_offset: DeviceIntPoint, tile_size: DeviceIntSize, is_opaque: bool, )

Create a new OS compositor surface with the given properties.

source

fn create_external_surface( &mut self, device: &mut Device, id: NativeSurfaceId, is_opaque: bool, )

Create a new OS compositor surface that can be used with an existing ExternalImageId, instead of being drawn to by WebRender. Surfaces created by this can only be used with attach_external_image, and not create_tile/destroy_tile/bind/unbind.

source

fn create_backdrop_surface( &mut self, device: &mut Device, id: NativeSurfaceId, color: ColorF, )

Create a new OS backdrop surface that will display a color.

source

fn destroy_surface(&mut self, device: &mut Device, id: NativeSurfaceId)

Destroy the surface with the specified id. WR may call this at any time the surface is no longer required (including during renderer deinit). It’s the responsibility of the embedder to ensure that the surface is only freed once the GPU is no longer using the surface (if this isn’t already handled by the operating system).

source

fn create_tile(&mut self, device: &mut Device, id: NativeTileId)

Create a new OS compositor tile with the given properties.

source

fn destroy_tile(&mut self, device: &mut Device, id: NativeTileId)

Destroy an existing compositor tile.

source

fn attach_external_image( &mut self, device: &mut Device, id: NativeSurfaceId, external_image: ExternalImageId, )

Attaches an ExternalImageId to an OS compositor surface created by create_external_surface, and uses that as the contents of the surface. It is expected that a single surface will have many different images attached (like one for each video frame).

source

fn bind( &mut self, device: &mut Device, id: NativeTileId, dirty_rect: DeviceIntRect, valid_rect: DeviceIntRect, ) -> NativeSurfaceInfo

Bind this surface such that WR can issue OpenGL commands that will target the surface. Returns an (x, y) offset where WR should draw into the surface. This can be set to (0, 0) if the OS doesn’t use texture atlases. The dirty rect is a local surface rect that specifies which part of the surface needs to be updated. If max_update_rects in CompositeConfig is 0, this will always be the size of the entire surface. The returned offset is only relevant to compositors that store surfaces in a texture atlas (that is, WR expects that the dirty rect doesn’t affect the coordinates of the returned origin).

source

fn unbind(&mut self, device: &mut Device)

Unbind the surface. This is called by WR when it has finished issuing OpenGL commands on the current surface.

source

fn begin_frame(&mut self, device: &mut Device)

Begin the frame

source

fn add_surface( &mut self, device: &mut Device, id: NativeSurfaceId, transform: CompositorSurfaceTransform, clip_rect: DeviceIntRect, image_rendering: ImageRendering, )

Add a surface to the visual tree to be composited. Visuals must be added every frame, between the begin/end transaction call. The z-order of the surfaces is determined by the order they are added to the visual tree.

source

fn end_frame(&mut self, device: &mut Device)

Commit any changes in the compositor tree for this frame. WR calls this once when all surface and visual updates are complete, to signal that the OS composite transaction should be applied.

source

fn enable_native_compositor(&mut self, device: &mut Device, enable: bool)

Enable/disable native compositor usage

source

fn deinit(&mut self, device: &mut Device)

Safely deinitialize any remaining resources owned by the compositor.

source

fn get_capabilities(&self, device: &mut Device) -> CompositorCapabilities

Get the capabilities struct for this compositor. This is used to specify what features a compositor supports, depending on the underlying platform

source

fn get_window_visibility(&self, device: &mut Device) -> WindowVisibility

Provided Methods§

source

fn invalidate_tile( &mut self, _device: &mut Device, _id: NativeTileId, _valid_rect: DeviceIntRect, )

Mark a tile as invalid before any surfaces are queued for composition and before it is updated with bind. This is useful for early composition, allowing for dependency tracking of which surfaces can be composited early while others are still updating.

source

fn start_compositing( &mut self, _device: &mut Device, _clear_color: ColorF, _dirty_rects: &[DeviceIntRect], _opaque_rects: &[DeviceIntRect], )

Notify the compositor that all tiles have been invalidated and all native surfaces have been added, thus it is safe to start compositing valid surfaces. The dirty rects array allows native compositors that support partial present to skip copying unchanged areas. Optionally provides a set of rectangles for the areas known to be opaque, this is currently only computed if the caller is SwCompositor.

Implementors§