azul_webrender

Struct Renderer

Source
pub struct Renderer {
    pub device: Device,
    pub gpu_profiler: GpuProfiler,
    pub renderer_errors: Vec<RendererError>,
    /* private fields */
}
Expand description

The renderer is responsible for submitting to the GPU the work prepared by the RenderBackend.

We have a separate Renderer instance for each instance of WebRender (generally one per OS window), and all instances share the same thread.

Fields§

§device: Device§gpu_profiler: GpuProfiler§renderer_errors: Vec<RendererError>

Implementations§

Source§

impl Renderer

Source

pub fn update_gpu_cache(&mut self)

Source

pub fn prepare_gpu_cache( &mut self, deferred_resolves: &[DeferredResolve], ) -> Result<(), RendererError>

Source

pub fn read_gpu_cache(&mut self) -> (DeviceIntSize, Vec<u8>)

Source§

impl Renderer

Source

pub fn new( gl: Rc<GenericGlContext>, notifier: Box<dyn RenderNotifier>, options: RendererOptions, shaders: Option<&SharedShaders>, ) -> Result<(Self, RenderApiSender), RendererError>

Initializes WebRender and creates a Renderer and RenderApiSender.

§Examples

Initializes a Renderer with some reasonable values. For more information see RendererOptions.

let opts = webrender::RendererOptions {
   device_pixel_ratio: 1.0,
   resource_override_path: None,
   enable_aa: false,
};
let (renderer, sender) = Renderer::new(opts);
Source

pub fn device_size(&self) -> Option<DeviceIntSize>

Source

pub fn set_cursor_position(&mut self, position: DeviceIntPoint)

Update the current position of the debug cursor.

Source

pub fn get_max_texture_size(&self) -> i32

Source

pub fn get_graphics_api_info(&self) -> GraphicsApiInfo

Source

pub fn preferred_color_format(&self) -> ImageFormat

Source

pub fn required_texture_stride_alignment(&self, format: ImageFormat) -> usize

Source

pub fn set_clear_color(&mut self, color: ColorF)

Source

pub fn flush_pipeline_info(&mut self) -> PipelineInfo

Source

pub fn current_epoch( &self, document_id: DocumentId, pipeline_id: PipelineId, ) -> Option<Epoch>

Returns the Epoch of the current frame in a pipeline.

Source

pub fn update(&mut self)

Processes the result queue.

Should be called before render(), as texture cache updates are done here.

Source

pub fn set_external_image_handler( &mut self, handler: Box<dyn ExternalImageHandler>, )

Set a callback for handling external images.

Source

pub fn get_frame_profiles(&mut self) -> (Vec<CpuProfile>, Vec<GpuProfile>)

Retrieve (and clear) the current list of recorded frame profiles.

Source

pub fn force_redraw(&mut self)

Reset the current partial present state. This forces the entire framebuffer to be refreshed next time render is called.

Source

pub fn render( &mut self, device_size: DeviceIntSize, buffer_age: usize, ) -> Result<RenderResults, Vec<RendererError>>

Renders the current frame.

A Frame is supplied by calling [generate_frame()][webrender_api::Transaction::generate_frame]. buffer_age is the age of the current backbuffer. It is only relevant if partial present is active, otherwise 0 should be passed here.

Source

pub fn debug_renderer(&mut self) -> Option<&mut DebugRenderer>

Source

pub fn get_debug_flags(&self) -> DebugFlags

Source

pub fn set_debug_flags(&mut self, flags: DebugFlags)

Source

pub fn set_profiler_ui(&mut self, ui_str: &str)

Source

pub fn read_pixels_into( &mut self, rect: FramebufferIntRect, format: ImageFormat, output: &mut [u8], )

Pass-through to Device::read_pixels_into, used by Gecko’s WR bindings.

Source

pub fn read_pixels_rgba8(&mut self, rect: FramebufferIntRect) -> Vec<u8>

Source

pub fn deinit(self)

Source

pub fn report_memory(&self, swgl: *mut c_void) -> MemoryReport

Collects a memory report.

Source§

impl Renderer

Source

pub fn record_frame( &mut self, image_format: ImageFormat, ) -> Option<(RecordedFrameHandle, DeviceIntSize)>

Record a frame for the Composition Recorder.

The returned handle can be passed to map_recorded_frame to copy it into a buffer. The returned size is the size of the frame.

Source

pub fn map_recorded_frame( &mut self, handle: RecordedFrameHandle, dst_buffer: &mut [u8], dst_stride: usize, ) -> bool

Map a frame captured for the composition recorder into the given buffer.

Source

pub fn release_composition_recorder_structures(&mut self)

Free the data structures used by the composition recorder.

Source

pub fn get_screenshot_async( &mut self, window_rect: DeviceIntRect, buffer_size: DeviceIntSize, image_format: ImageFormat, ) -> (AsyncScreenshotHandle, DeviceIntSize)

Take a screenshot and scale it asynchronously.

The returned handle can be used to access the mapped screenshot data via map_and_recycle_screenshot.

The returned size is the size of the screenshot.

Source

pub fn map_and_recycle_screenshot( &mut self, handle: AsyncScreenshotHandle, dst_buffer: &mut [u8], dst_stride: usize, ) -> bool

Map the contents of the screenshot given by the handle and copy it into the given buffer.

Source

pub fn release_profiler_structures(&mut self)

Release the screenshot grabbing structures that the profiler was using.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.