Skip to main content

RenderContext

Trait RenderContext 

Source
pub trait RenderContext {
Show 46 methods // Required methods fn fill_with_opacity( &mut self, layer: usize, path: BezPath, fill: &Paint, opacity: f64, ); fn stroke_with_opacity( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, opacity: f64, ); fn stroke_with_draw_range_and_material_and_opacity( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, material: &ResolvedMaterial, opacity: f64, draw_start: f64, draw_end: f64, ); fn save(&mut self, layer: usize); fn restore(&mut self, layer: usize); fn clip(&mut self, layer: usize, path: BezPath); fn transform(&mut self, layer: usize, affine: Affine); fn load_image( &mut self, identifier: &str, image: &[u8], width: usize, height: usize, ); fn draw_image_with_opacity( &mut self, layer: usize, image_path: &str, rect: Rect, opacity: f64, ); fn get_image_size(&mut self, image_path: &str) -> Option<(usize, usize)>; fn image_loaded(&self, image_path: &str) -> bool; fn layers(&self) -> usize; fn resize_layers_to( &mut self, layer_count: usize, dirty_canvases: Rc<RefCell<Vec<bool>>>, ); fn clear(&mut self, layer: usize); fn flush(&mut self, layer: usize, dirty_canvases: Rc<RefCell<Vec<bool>>>); fn resize(&mut self, width: usize, height: usize); fn refresh_layers(&mut self, layers: &[usize]); // Provided methods fn fill(&mut self, layer: usize, path: BezPath, fill: &Paint) { ... } fn fill_with_material_and_opacity( &mut self, layer: usize, path: BezPath, fill: &Paint, _material: &ResolvedMaterial, opacity: f64, ) { ... } fn fill_with_material_and_opacity_and_smoothing( &mut self, layer: usize, path: BezPath, fill: &Paint, material: &ResolvedMaterial, opacity: f64, smoothing: PathSmoothing, ) { ... } fn stroke(&mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke) { ... } fn stroke_with_material_and_opacity( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, _material: &ResolvedMaterial, opacity: f64, ) { ... } fn stroke_with_material_and_opacity_and_smoothing( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, material: &ResolvedMaterial, opacity: f64, smoothing: PathSmoothing, ) { ... } fn stroke_with_draw_range_and_material_and_opacity_and_smoothing( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, material: &ResolvedMaterial, opacity: f64, draw_start: f64, draw_end: f64, smoothing: PathSmoothing, ) { ... } fn clip_alpha( &mut self, _layer: usize, _paints: &[AlphaMaskPaint], _feather: f64, ) { ... } fn supports_alpha_source_capture(&self) -> bool { ... } fn alpha_source_layer(&self) -> Option<usize> { ... } fn begin_alpha_source( &mut self, _layer: usize, _world_to_surface: Affine, _inherited_scopes: usize, _feather: f64, ) { ... } fn end_alpha_source(&mut self, _layer: usize) { ... } fn draw_image(&mut self, layer: usize, image_path: &str, rect: Rect) { ... } fn set_scene_lighting(&mut self, _layer: usize, _lighting: &SceneLighting) { ... } fn clear_targeted_replay(&mut self, _layer: usize) { ... } fn take_ready_canvas_layers(&mut self) -> Vec<usize> { ... } fn take_replay_canvas_layers(&mut self) -> Vec<usize> { ... } fn take_replay_canvas_layer_updates( &mut self, ) -> Vec<ReplayCanvasLayerUpdate> { ... } fn request_layer_screenshot(&mut self, _layer: usize, _request_id: u32) { ... } fn take_layer_screenshot( &mut self, _layer: usize, _request_id: u32, ) -> Option<ScreenshotData> { ... } fn take_layer_surface_screenshots( &mut self, layer: usize, request_id: u32, ) -> Vec<LayerSurfaceScreenshotData> { ... } fn retains_canvas_nodes(&self) -> bool { ... } fn begin_node( &mut self, _layer: usize, _node_id: u32, _z_index: i32, _light_mask: u32, ) -> bool { ... } fn begin_node_with_bounds( &mut self, layer: usize, node_id: u32, z_index: i32, _coverage_bounds: Rect, light_mask: u32, ) -> bool { ... } fn take_clean_skipped_node(&mut self, _layer: usize, _node_id: u32) -> bool { ... } fn supports_subtree_opacity(&self) -> bool { ... } fn set_node_opacity_scopes( &mut self, _layer: usize, _node_id: u32, _scopes: &[OpacityScope], ) { ... } fn end_node(&mut self, _layer: usize, _node_id: u32) -> bool { ... } fn remove_node(&mut self, _layer: usize, _node_id: u32) -> bool { ... }
}
Expand description

The drawing contract shared by Pax runtime backends.

Required Methods§

Source

fn fill_with_opacity( &mut self, layer: usize, path: BezPath, fill: &Paint, opacity: f64, )

Fills a path with an explicit opacity multiplier.

Source

fn stroke_with_opacity( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, opacity: f64, )

Strokes a path with an explicit opacity multiplier.

Source

fn stroke_with_draw_range_and_material_and_opacity( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, material: &ResolvedMaterial, opacity: f64, draw_start: f64, draw_end: f64, )

Strokes a path with a normalized visible range over the path’s total length.

Source

fn save(&mut self, layer: usize)

Saves the current graphics state for a layer.

Source

fn restore(&mut self, layer: usize)

Restores the previous graphics state for a layer.

Source

fn clip(&mut self, layer: usize, path: BezPath)

Applies a clipping path to a layer.

Source

fn transform(&mut self, layer: usize, affine: Affine)

Applies an affine transform to a layer.

Source

fn load_image( &mut self, identifier: &str, image: &[u8], width: usize, height: usize, )

Loads raw RGBA image bytes under an identifier.

Source

fn draw_image_with_opacity( &mut self, layer: usize, image_path: &str, rect: Rect, opacity: f64, )

Draws an image with an opacity multiplier, in addition to source pixel alpha. Backends must apply this at draw time without changing the cached source image.

Source

fn get_image_size(&mut self, image_path: &str) -> Option<(usize, usize)>

Returns the loaded image size, if known.

Source

fn image_loaded(&self, image_path: &str) -> bool

Returns true when the image is available for drawing.

Source

fn layers(&self) -> usize

Returns the current number of render layers.

Source

fn resize_layers_to( &mut self, layer_count: usize, dirty_canvases: Rc<RefCell<Vec<bool>>>, )

Resizes the backend layer set to layer_count.

Source

fn clear(&mut self, layer: usize)

Clears a layer.

Source

fn flush(&mut self, layer: usize, dirty_canvases: Rc<RefCell<Vec<bool>>>)

Flushes a layer to its presentation target.

Source

fn resize(&mut self, width: usize, height: usize)

Resizes the render surface.

Source

fn refresh_layers(&mut self, layers: &[usize])

Requests refresh of specific layers.

Provided Methods§

Source

fn fill(&mut self, layer: usize, path: BezPath, fill: &Paint)

Fills a path at full opacity.

Source

fn fill_with_material_and_opacity( &mut self, layer: usize, path: BezPath, fill: &Paint, _material: &ResolvedMaterial, opacity: f64, )

Fills a path with a material and explicit opacity multiplier.

Source

fn fill_with_material_and_opacity_and_smoothing( &mut self, layer: usize, path: BezPath, fill: &Paint, material: &ResolvedMaterial, opacity: f64, smoothing: PathSmoothing, )

Fills a path after optional geometry smoothing.

Source

fn stroke(&mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke)

Strokes a path at full opacity.

Source

fn stroke_with_material_and_opacity( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, _material: &ResolvedMaterial, opacity: f64, )

Strokes a path with a material and explicit opacity multiplier.

Source

fn stroke_with_material_and_opacity_and_smoothing( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, material: &ResolvedMaterial, opacity: f64, smoothing: PathSmoothing, )

Strokes a path after optional geometry smoothing.

Source

fn stroke_with_draw_range_and_material_and_opacity_and_smoothing( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, material: &ResolvedMaterial, opacity: f64, draw_start: f64, draw_end: f64, smoothing: PathSmoothing, )

Strokes a draw-ranged path after optional geometry smoothing.

Source

fn clip_alpha( &mut self, _layer: usize, _paints: &[AlphaMaskPaint], _feather: f64, )

Clips canvas drawing by source-over vector paint alpha, optionally feathered with a Gaussian of this standard deviation in logical pixels.

Source

fn supports_alpha_source_capture(&self) -> bool

Whether alpha sources can use ordinary retained vector rendering.

Source

fn alpha_source_layer(&self) -> Option<usize>

Destination layer while recording a detached alpha source. Source coordinates are world coordinates; begin_alpha_source supplies the mapping to the destination surface.

Source

fn begin_alpha_source( &mut self, _layer: usize, _world_to_surface: Affine, _inherited_scopes: usize, _feather: f64, )

Isolates source draws from visible content and inherited clips. The currently open node owns the result. Scopes before inherited_scopes belong to the consumer, not the source.

Source

fn end_alpha_source(&mut self, _layer: usize)

Completes the source and installs its captured alpha in the consumer’s clip stack.

Source

fn draw_image(&mut self, layer: usize, image_path: &str, rect: Rect)

Draws a previously loaded image into rect at full opacity.

Source

fn set_scene_lighting(&mut self, _layer: usize, _lighting: &SceneLighting)

Installs resolved lighting for a logical canvas layer.

Source

fn clear_targeted_replay(&mut self, _layer: usize)

Cancels any narrowed replay scope for a layer so subsequent work targets all surfaces.

Source

fn take_ready_canvas_layers(&mut self) -> Vec<usize>

Returns canvas layers ready to present.

Source

fn take_replay_canvas_layers(&mut self) -> Vec<usize>

Returns canvas layers that should replay prior draw commands.

Source

fn take_replay_canvas_layer_updates(&mut self) -> Vec<ReplayCanvasLayerUpdate>

Returns canvas layer replay work, optionally narrowed to canvas-content regions.

Source

fn request_layer_screenshot(&mut self, _layer: usize, _request_id: u32)

Requests a screenshot for one render layer.

Source

fn take_layer_screenshot( &mut self, _layer: usize, _request_id: u32, ) -> Option<ScreenshotData>

Returns a previously requested layer screenshot, if ready.

Source

fn take_layer_surface_screenshots( &mut self, layer: usize, request_id: u32, ) -> Vec<LayerSurfaceScreenshotData>

Returns ready screenshots for the physical surfaces backing one logical layer.

Source

fn retains_canvas_nodes(&self) -> bool

Returns whether the backend retains individual canvas nodes across frames.

Source

fn begin_node( &mut self, _layer: usize, _node_id: u32, _z_index: i32, _light_mask: u32, ) -> bool

Begins rendering a node and returns false when the backend can skip it.

Source

fn begin_node_with_bounds( &mut self, layer: usize, node_id: u32, z_index: i32, _coverage_bounds: Rect, light_mask: u32, ) -> bool

Begins rendering a node with conservative canvas-space coverage bounds.

Source

fn take_clean_skipped_node(&mut self, _layer: usize, _node_id: u32) -> bool

Returns true when a bounded node skipped by begin_node_with_bounds is clean for now.

Source

fn supports_subtree_opacity(&self) -> bool

Whether canvas opacity is applied after composing each subtree’s canvas content. This does not imply that the backend caches content across frames.

Source

fn set_node_opacity_scopes( &mut self, _layer: usize, _node_id: u32, _scopes: &[OpacityScope], )

Assigns stable opacity ancestry to the currently recorded canvas node.

Source

fn end_node(&mut self, _layer: usize, _node_id: u32) -> bool

Ends rendering a node and returns true when the node was recorded.

Source

fn remove_node(&mut self, _layer: usize, _node_id: u32) -> bool

Removes a node from backend retained state, if any.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§