Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer<'a> { /* private fields */ }
Expand description

The renderer for the Grafo library. This is the main struct used to render shapes and images.

Implementations§

Source§

impl<'a> Renderer<'a>

Source

pub async fn new( window: impl Into<SurfaceTarget<'static>>, physical_size: (u32, u32), scale_factor: f64, vsync: bool, transparent: bool, msaa_samples: u32, ) -> Self

Source

pub fn print_memory_usage_info(&self)

Source

pub async fn new_transparent( window: impl Into<SurfaceTarget<'static>>, physical_size: (u32, u32), scale_factor: f64, vsync: bool, msaa_samples: u32, ) -> Self

Source

pub async fn try_new_headless( physical_size: (u32, u32), scale_factor: f64, ) -> Result<Self, RendererCreationError>

Creates a headless renderer without a window surface.

Use render_to_buffer() or render_to_argb32() to read back rendered pixels. Calling render() on a headless renderer will panic.

Returns an error if no suitable GPU adapter is available, the device cannot be created, or the scale_factor is invalid.

Source

pub async fn new_headless(physical_size: (u32, u32), scale_factor: f64) -> Self

Creates a headless renderer without a window surface, panicking on any error from Self::try_new_headless (e.g. no suitable GPU adapter, invalid scale factor, device/queue creation failure).

Use render_to_buffer() or render_to_argb32() to read back rendered pixels. Calling render() on a headless renderer will panic.

For a non-panicking alternative (e.g. in tests), use Self::try_new_headless instead.

Source§

impl<'a> Renderer<'a>

Source

pub fn add_shape( &mut self, shape: impl Into<Shape>, clip_to_shape: Option<usize>, cache_key: Option<u64>, ) -> usize

Source

pub fn load_shape( &mut self, shape: impl AsRef<Shape>, cache_key: u64, tessellation_cache_key: Option<u64>, )

Source

pub fn add_cached_shape_to_the_render_queue( &mut self, cache_key: u64, clip_to_shape: Option<usize>, ) -> usize

Source

pub fn texture_manager(&self) -> &TextureManager

Source

pub fn clear_draw_queue(&mut self)

Source

pub fn set_shape_transform_cols(&mut self, node_id: usize, cols: [[f32; 4]; 4])

Source

pub fn set_shape_transform( &mut self, node_id: usize, transform: impl Into<InstanceTransform>, )

Source

pub fn set_shape_texture(&mut self, node_id: usize, texture_id: Option<u64>)

Source

pub fn set_shape_texture_layer( &mut self, node_id: usize, layer: usize, texture_id: Option<u64>, )

Source

pub fn set_shape_texture_on( &mut self, node_id: usize, layer: TextureLayer, texture_id: Option<u64>, )

Source

pub fn set_shape_color(&mut self, node_id: usize, color: Option<Color>)

Source§

impl<'a> Renderer<'a>

Source

pub fn load_effect( &mut self, effect_id: u64, pass_sources: &[&str], ) -> Result<(), EffectError>

Source

pub fn set_group_effect( &mut self, node_id: usize, effect_id: u64, params: &[u8], ) -> Result<(), EffectError>

Source

pub fn update_group_effect_params( &mut self, node_id: usize, params: &[u8], ) -> Result<(), EffectError>

Source

pub fn remove_group_effect(&mut self, node_id: usize)

Source

pub fn set_shape_backdrop_effect( &mut self, node_id: usize, effect_id: u64, params: &[u8], ) -> Result<(), EffectError>

Source

pub fn update_backdrop_effect_params( &mut self, node_id: usize, params: &[u8], ) -> Result<(), EffectError>

Source

pub fn remove_backdrop_effect(&mut self, node_id: usize)

Source

pub fn unload_effect(&mut self, effect_id: u64)

Source§

impl<'a> Renderer<'a>

Source

pub fn render_to_buffer(&mut self, buffer: &mut Vec<u8>)

Source

pub fn render_to_argb32(&mut self, out_pixels: &mut [u32])

Source§

impl<'a> Renderer<'a>

Source

pub fn render(&mut self) -> Result<(), SurfaceError>

Source§

impl<'a> Renderer<'a>

Source

pub fn size(&self) -> (u32, u32)

Source

pub fn change_scale_factor(&mut self, new_scale_factor: f64)

Source

pub fn scale_factor(&self) -> f64

Source

pub fn set_fringe_width(&mut self, fringe_width: f32)

Source

pub fn fringe_width(&self) -> f32

Source

pub fn resize(&mut self, new_physical_size: (u32, u32))

Source

pub fn msaa_samples(&self) -> u32

Source

pub fn set_msaa_samples(&mut self, samples: u32)

Source

pub fn set_surface(&mut self, window: impl Into<SurfaceTarget<'static>>)

Source

pub fn set_vsync(&mut self, vsync: bool)

Auto Trait Implementations§

§

impl<'a> !Freeze for Renderer<'a>

§

impl<'a> !RefUnwindSafe for Renderer<'a>

§

impl<'a> Send for Renderer<'a>

§

impl<'a> Sync for Renderer<'a>

§

impl<'a> Unpin for Renderer<'a>

§

impl<'a> UnsafeUnpin for Renderer<'a>

§

impl<'a> !UnwindSafe for Renderer<'a>

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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> Upcast<T> for T

Source§

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,