Struct Renderer

Source
pub struct Renderer { /* private fields */ }
Available on crate feature wgpu only.
Expand description

Renders a scene into a texture or surface.

Currently, each renderer only supports a single surface format, if it supports drawing to surfaces at all. This is an assumption which is known to be limiting, and is planned to change.

Implementations§

Source§

impl Renderer

Source

pub fn new(device: &Device, options: RendererOptions) -> Result<Self, Error>

Creates a new renderer for the specified device.

Source

pub fn render_to_texture( &mut self, device: &Device, queue: &Queue, scene: &Scene, texture: &TextureView, params: &RenderParams, ) -> Result<(), Error>

Renders a scene to the target texture.

The texture is assumed to be of the specified dimensions and have been created with the wgpu::TextureFormat::Rgba8Unorm format and the wgpu::TextureUsages::STORAGE_BINDING flag set.

If you want to render Vello content to a surface (such as in a UI toolkit), you have two options:

  1. Render to an intermediate texture, which is the same size as the surface. You would then use TextureBlitter to blit the rendered result from that texture to the surface. This pattern is supported by the util module.
  2. Call render_to_texture directly on the SurfaceTexture’s texture, if it has the right usages. This should generally be avoided, as some GPUs assume that you will not be rendering to the surface using a compute pipeline, and optimise accordingly.
Source

pub fn override_image( &mut self, image: &Image, texture: Option<TexelCopyTextureInfoBase<Texture>>, ) -> Option<TexelCopyTextureInfoBase<Texture>>

Overwrite image with texture.

Whenever image would be rendered, instead the given Texture will be used.

Correct behaviour is not guaranteed if the texture does not have the same dimensions as the image, nor if an image which uses the same data but different dimensions would be rendered.

Auto Trait Implementations§

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, 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> WasmNotSend for T
where T: Send,