Skip to main content

PietRenderer

Struct PietRenderer 

Source
pub struct PietRenderer<S: PietSurface> { /* private fields */ }
Expand description

RenderContext implementation backed by piet.

Implementations§

Source§

impl<S: PietSurface> PietRenderer<S>

Source

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>

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 transform(&mut self, layer: usize, affine: Affine)

Applies an affine transform to a layer.
Source§

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

Applies a clipping path to a layer.
Source§

fn restore(&mut self, layer: usize)

Restores the previous graphics state for a layer.
Source§

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)>

Returns the loaded image size, if known.
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 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 image_loaded(&self, path: &str) -> bool

Returns true when the image is available for drawing.
Source§

fn clear(&mut self, layer: usize)

Clears a layer.
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 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.
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_layer_updates(&mut self) -> Vec<ReplayCanvasLayerUpdate>

Returns canvas layer replay work, optionally narrowed to canvas-content regions.
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 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.
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 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)

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.

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>

§

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>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Performs the conversion.
Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Performs the conversion.
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>