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§
Sourcefn fill_with_opacity(
&mut self,
layer: usize,
path: BezPath,
fill: &Paint,
opacity: f64,
)
fn fill_with_opacity( &mut self, layer: usize, path: BezPath, fill: &Paint, opacity: f64, )
Fills a path with an explicit opacity multiplier.
Sourcefn stroke_with_opacity(
&mut self,
layer: usize,
path: BezPath,
stroke: &ResolvedStroke,
opacity: f64,
)
fn stroke_with_opacity( &mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke, opacity: f64, )
Strokes a path with an explicit opacity multiplier.
Sourcefn 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 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.
Sourcefn load_image(
&mut self,
identifier: &str,
image: &[u8],
width: usize,
height: usize,
)
fn load_image( &mut self, identifier: &str, image: &[u8], width: usize, height: usize, )
Loads raw RGBA image bytes under an identifier.
Sourcefn draw_image_with_opacity(
&mut self,
layer: usize,
image_path: &str,
rect: Rect,
opacity: f64,
)
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.
Sourcefn get_image_size(&mut self, image_path: &str) -> Option<(usize, usize)>
fn get_image_size(&mut self, image_path: &str) -> Option<(usize, usize)>
Returns the loaded image size, if known.
Sourcefn image_loaded(&self, image_path: &str) -> bool
fn image_loaded(&self, image_path: &str) -> bool
Returns true when the image is available for drawing.
Sourcefn resize_layers_to(
&mut self,
layer_count: usize,
dirty_canvases: Rc<RefCell<Vec<bool>>>,
)
fn resize_layers_to( &mut self, layer_count: usize, dirty_canvases: Rc<RefCell<Vec<bool>>>, )
Resizes the backend layer set to layer_count.
Sourcefn flush(&mut self, layer: usize, dirty_canvases: Rc<RefCell<Vec<bool>>>)
fn flush(&mut self, layer: usize, dirty_canvases: Rc<RefCell<Vec<bool>>>)
Flushes a layer to its presentation target.
Sourcefn refresh_layers(&mut self, layers: &[usize])
fn refresh_layers(&mut self, layers: &[usize])
Requests refresh of specific layers.
Provided Methods§
Sourcefn fill_with_material_and_opacity(
&mut self,
layer: usize,
path: BezPath,
fill: &Paint,
_material: &ResolvedMaterial,
opacity: f64,
)
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.
Sourcefn fill_with_material_and_opacity_and_smoothing(
&mut self,
layer: usize,
path: BezPath,
fill: &Paint,
material: &ResolvedMaterial,
opacity: f64,
smoothing: PathSmoothing,
)
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.
Sourcefn stroke(&mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke)
fn stroke(&mut self, layer: usize, path: BezPath, stroke: &ResolvedStroke)
Strokes a path at full opacity.
Sourcefn stroke_with_material_and_opacity(
&mut self,
layer: usize,
path: BezPath,
stroke: &ResolvedStroke,
_material: &ResolvedMaterial,
opacity: f64,
)
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.
Sourcefn stroke_with_material_and_opacity_and_smoothing(
&mut self,
layer: usize,
path: BezPath,
stroke: &ResolvedStroke,
material: &ResolvedMaterial,
opacity: f64,
smoothing: PathSmoothing,
)
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.
Sourcefn 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 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.
Sourcefn clip_alpha(
&mut self,
_layer: usize,
_paints: &[AlphaMaskPaint],
_feather: f64,
)
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.
Sourcefn supports_alpha_source_capture(&self) -> bool
fn supports_alpha_source_capture(&self) -> bool
Whether alpha sources can use ordinary retained vector rendering.
Sourcefn alpha_source_layer(&self) -> Option<usize>
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.
Sourcefn begin_alpha_source(
&mut self,
_layer: usize,
_world_to_surface: Affine,
_inherited_scopes: usize,
_feather: f64,
)
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.
Sourcefn end_alpha_source(&mut self, _layer: usize)
fn end_alpha_source(&mut self, _layer: usize)
Completes the source and installs its captured alpha in the consumer’s clip stack.
Sourcefn draw_image(&mut self, layer: usize, image_path: &str, rect: Rect)
fn draw_image(&mut self, layer: usize, image_path: &str, rect: Rect)
Draws a previously loaded image into rect at full opacity.
Sourcefn set_scene_lighting(&mut self, _layer: usize, _lighting: &SceneLighting)
fn set_scene_lighting(&mut self, _layer: usize, _lighting: &SceneLighting)
Installs resolved lighting for a logical canvas layer.
Sourcefn clear_targeted_replay(&mut self, _layer: usize)
fn clear_targeted_replay(&mut self, _layer: usize)
Cancels any narrowed replay scope for a layer so subsequent work targets all surfaces.
Sourcefn take_ready_canvas_layers(&mut self) -> Vec<usize>
fn take_ready_canvas_layers(&mut self) -> Vec<usize>
Returns canvas layers ready to present.
Sourcefn take_replay_canvas_layers(&mut self) -> Vec<usize>
fn take_replay_canvas_layers(&mut self) -> Vec<usize>
Returns canvas layers that should replay prior draw commands.
Sourcefn take_replay_canvas_layer_updates(&mut self) -> Vec<ReplayCanvasLayerUpdate>
fn take_replay_canvas_layer_updates(&mut self) -> Vec<ReplayCanvasLayerUpdate>
Returns canvas layer replay work, optionally narrowed to canvas-content regions.
Sourcefn request_layer_screenshot(&mut self, _layer: usize, _request_id: u32)
fn request_layer_screenshot(&mut self, _layer: usize, _request_id: u32)
Requests a screenshot for one render layer.
Sourcefn take_layer_screenshot(
&mut self,
_layer: usize,
_request_id: u32,
) -> Option<ScreenshotData>
fn take_layer_screenshot( &mut self, _layer: usize, _request_id: u32, ) -> Option<ScreenshotData>
Returns a previously requested layer screenshot, if ready.
Sourcefn take_layer_surface_screenshots(
&mut self,
layer: usize,
request_id: u32,
) -> Vec<LayerSurfaceScreenshotData>
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.
Sourcefn retains_canvas_nodes(&self) -> bool
fn retains_canvas_nodes(&self) -> bool
Returns whether the backend retains individual canvas nodes across frames.
Sourcefn begin_node(
&mut self,
_layer: usize,
_node_id: u32,
_z_index: i32,
_light_mask: u32,
) -> bool
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.
Sourcefn begin_node_with_bounds(
&mut self,
layer: usize,
node_id: u32,
z_index: i32,
_coverage_bounds: Rect,
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
Begins rendering a node with conservative canvas-space coverage bounds.
Sourcefn take_clean_skipped_node(&mut self, _layer: usize, _node_id: u32) -> bool
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.
Sourcefn supports_subtree_opacity(&self) -> bool
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.
Sourcefn set_node_opacity_scopes(
&mut self,
_layer: usize,
_node_id: u32,
_scopes: &[OpacityScope],
)
fn set_node_opacity_scopes( &mut self, _layer: usize, _node_id: u32, _scopes: &[OpacityScope], )
Assigns stable opacity ancestry to the currently recorded canvas node.
Sourcefn end_node(&mut self, _layer: usize, _node_id: u32) -> bool
fn end_node(&mut self, _layer: usize, _node_id: u32) -> bool
Ends rendering a node and returns true when the node was recorded.
Sourcefn remove_node(&mut self, _layer: usize, _node_id: u32) -> bool
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".