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
impl Renderer
pub fn update_gpu_cache(&mut self)
pub fn prepare_gpu_cache( &mut self, deferred_resolves: &[DeferredResolve], ) -> Result<(), RendererError>
pub fn read_gpu_cache(&mut self) -> (DeviceIntSize, Vec<u8>)
Source§impl Renderer
impl Renderer
Sourcepub fn new(
gl: Rc<GenericGlContext>,
notifier: Box<dyn RenderNotifier>,
options: RendererOptions,
shaders: Option<&SharedShaders>,
) -> Result<(Self, RenderApiSender), RendererError>
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);
pub fn device_size(&self) -> Option<DeviceIntSize>
Sourcepub fn set_cursor_position(&mut self, position: DeviceIntPoint)
pub fn set_cursor_position(&mut self, position: DeviceIntPoint)
Update the current position of the debug cursor.
pub fn get_max_texture_size(&self) -> i32
pub fn get_graphics_api_info(&self) -> GraphicsApiInfo
pub fn preferred_color_format(&self) -> ImageFormat
pub fn required_texture_stride_alignment(&self, format: ImageFormat) -> usize
pub fn set_clear_color(&mut self, color: ColorF)
pub fn flush_pipeline_info(&mut self) -> PipelineInfo
Sourcepub fn current_epoch(
&self,
document_id: DocumentId,
pipeline_id: PipelineId,
) -> Option<Epoch>
pub fn current_epoch( &self, document_id: DocumentId, pipeline_id: PipelineId, ) -> Option<Epoch>
Returns the Epoch of the current frame in a pipeline.
Sourcepub fn update(&mut self)
pub fn update(&mut self)
Processes the result queue.
Should be called before render()
, as texture cache updates are done here.
Sourcepub fn set_external_image_handler(
&mut self,
handler: Box<dyn ExternalImageHandler>,
)
pub fn set_external_image_handler( &mut self, handler: Box<dyn ExternalImageHandler>, )
Set a callback for handling external images.
Sourcepub fn get_frame_profiles(&mut self) -> (Vec<CpuProfile>, Vec<GpuProfile>)
pub fn get_frame_profiles(&mut self) -> (Vec<CpuProfile>, Vec<GpuProfile>)
Retrieve (and clear) the current list of recorded frame profiles.
Sourcepub fn force_redraw(&mut self)
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.
Sourcepub fn render(
&mut self,
device_size: DeviceIntSize,
buffer_age: usize,
) -> Result<RenderResults, Vec<RendererError>>
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.
pub fn debug_renderer(&mut self) -> Option<&mut DebugRenderer>
pub fn get_debug_flags(&self) -> DebugFlags
pub fn set_debug_flags(&mut self, flags: DebugFlags)
pub fn set_profiler_ui(&mut self, ui_str: &str)
Sourcepub fn read_pixels_into(
&mut self,
rect: FramebufferIntRect,
format: ImageFormat,
output: &mut [u8],
)
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.
pub fn read_pixels_rgba8(&mut self, rect: FramebufferIntRect) -> Vec<u8> ⓘ
pub fn deinit(self)
Sourcepub fn report_memory(&self, swgl: *mut c_void) -> MemoryReport
pub fn report_memory(&self, swgl: *mut c_void) -> MemoryReport
Collects a memory report.
Source§impl Renderer
impl Renderer
Sourcepub fn record_frame(
&mut self,
image_format: ImageFormat,
) -> Option<(RecordedFrameHandle, DeviceIntSize)>
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.
Sourcepub fn map_recorded_frame(
&mut self,
handle: RecordedFrameHandle,
dst_buffer: &mut [u8],
dst_stride: usize,
) -> bool
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.
Sourcepub fn release_composition_recorder_structures(&mut self)
pub fn release_composition_recorder_structures(&mut self)
Free the data structures used by the composition recorder.
Sourcepub fn get_screenshot_async(
&mut self,
window_rect: DeviceIntRect,
buffer_size: DeviceIntSize,
image_format: ImageFormat,
) -> (AsyncScreenshotHandle, DeviceIntSize)
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.
Sourcepub fn map_and_recycle_screenshot(
&mut self,
handle: AsyncScreenshotHandle,
dst_buffer: &mut [u8],
dst_stride: usize,
) -> bool
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.
Sourcepub fn release_profiler_structures(&mut self)
pub fn release_profiler_structures(&mut self)
Release the screenshot grabbing structures that the profiler was using.
Auto Trait Implementations§
impl !Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl !Send for Renderer
impl !Sync for Renderer
impl Unpin for Renderer
impl !UnwindSafe for Renderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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