Struct ul_next::renderer::Renderer

source ·
pub struct Renderer { /* private fields */ }
Expand description

The Renderer manages all Views and coordinates painting, network requests, and event dispatch

You don’t have to create this instance directly if you use the AppCore API. The App struct will automatically create a Renderer and perform all rendering within its run loop.

Implementations§

source§

impl Renderer

source

pub fn create(config: Config) -> Result<Self, CreationError>

Create the Ultralight Renderer directly.

Unlike App::new, this does not use any native windows for drawing and allows you to manage your own runloop and painting. This method is recommended for those wishing to integrate the library into a game.

This instance manages the lifetime of all Views and coordinates all painting, rendering, network requests, and event dispatch.

You should only call this once per process lifetime.

You shoud set up your platform handlers (eg, platform::set_gpu_driver, platform::set_logger, platform::enable_default_logger, platform::enable_platform_filesystem, etc.) before calling this.

You will also need to define a font loader before calling this – currently the only way to do this is platform::enable_platform_fontloader.

You should not call this if you are using App::new, it creates its own renderer and provides default implementations for various platform handlers automatically.

source§

impl Renderer

source

pub fn update(&self)

Update timers and dispatch internal callbacks. You should call this often from your main application loop.

source

pub fn render(&self)

Render all active views to their respective render-targets/surfaces.

You should call this once per frame (usually in synchrony with the monitor’s refresh rate).

Views are only repainted if they actually need painting. (See View::needs_paint)

source

pub fn purge_memory(&self)

Attempt to release as much memory as possible. Don’t call this from any callbacks or driver code.

source

pub fn log_memory_usage(&self)

Print detailed memory usage statistics to the log. (See platform::set_logger or platform::enable_default_logger)

source

pub fn create_session( &self, is_persistent: bool, name: &str ) -> Result<Session, CreationError>

Create a Session to store local data in (such as cookies, local storage, application cache, indexed db, etc).

A default, persistent Session is already created for you. You only need to call this if you want to create private, in-memory session or use a separate session for each View.

§Arguments
  • is_persistent - Whether or not to store the session on disk. Persistent sessions will be written to the path set in ConfigBuilder::cache_path.
  • name - A unique name for this session, this will be used to generate a unique disk path for persistent sessions.
source

pub fn default_session(&self) -> &Session

Get the default Session. This session is persistent (backed to disk) and has the name “default”.

source

pub fn create_view( &self, width: u32, height: u32, view_config: &ViewConfig, session: Option<&Session> ) -> Option<View>

Create a new View.

§Arguments
  • width - The initial width, in pixels.
  • height - The initial height, in pixels.
  • config - The configuration for the view.
  • session - The session to store local data in. Passing None will use the default session.

Trait Implementations§

source§

impl Drop for Renderer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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

§

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

§

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.