pub struct PietRenderer<S: PietSurface> { /* private fields */ }Expand description
RenderContext implementation backed by piet.
Implementations§
Source§impl<S: PietSurface> PietRenderer<S>
impl<S: PietSurface> PietRenderer<S>
Sourcepub fn new(
layer_factory: impl Fn(usize) -> (PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>) + 'static,
) -> Self
pub fn new( layer_factory: impl Fn(usize) -> (PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>) + 'static, ) -> Self
Create a piet renderer with a chassis-provided logical layer factory.
Trait Implementations§
Source§impl<S: PietSurface> RenderContext for PietRenderer<S>
impl<S: PietSurface> RenderContext for PietRenderer<S>
Source§fn 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.
Source§fn 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.
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,
)
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 load_image(&mut self, path: &str, buf: &[u8], width: usize, height: usize)
fn load_image(&mut self, path: &str, buf: &[u8], width: usize, height: usize)
Loads raw RGBA image bytes under an identifier.
Source§fn 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.
Source§fn 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.
Source§fn 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.Source§fn image_loaded(&self, path: &str) -> bool
fn image_loaded(&self, path: &str) -> bool
Returns true when the image is available for drawing.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn refresh_layers(&mut self, layers: &[usize])
fn refresh_layers(&mut self, layers: &[usize])
Requests refresh of specific layers.
Source§fn 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.
Source§fn take_ready_canvas_layers(&mut self) -> Vec<usize>
fn take_ready_canvas_layers(&mut self) -> Vec<usize>
Returns canvas layers ready to present.
Source§fn 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.
Source§fn retains_canvas_nodes(&self) -> bool
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
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
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
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 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§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_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,
)
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,
)
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
fn supports_alpha_source_capture(&self) -> bool
Whether alpha sources can use ordinary retained vector rendering.
Source§fn 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.Source§fn 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.Source§fn 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.
Source§fn 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.Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Auto Trait Implementations§
impl<S> !RefUnwindSafe for PietRenderer<S>
impl<S> !Send for PietRenderer<S>
impl<S> !Sync for PietRenderer<S>
impl<S> !UnwindSafe for PietRenderer<S>
impl<S> Freeze for PietRenderer<S>where
Vec<(PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>)>: Freeze,
HashMap<String, ImgData<<S as PietSurface>::Context>>: Freeze,
Box<dyn Fn(usize) -> (PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>)>: Freeze,
impl<S> Unpin for PietRenderer<S>where
Vec<(PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>)>: Unpin,
HashMap<String, ImgData<<S as PietSurface>::Context>>: Unpin,
Box<dyn Fn(usize) -> (PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>)>: Unpin,
impl<S> UnsafeUnpin for PietRenderer<S>where
Vec<(PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>)>: UnsafeUnpin,
HashMap<String, ImgData<<S as PietSurface>::Context>>: UnsafeUnpin,
Box<dyn Fn(usize) -> (PietLayerTarget<S>, Box<dyn Fn() -> LayerSurfaceLayout>)>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
Source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.