pub struct Renderer {
pub device: Device,
pub gpu_profile: GpuProfiler<GpuProfileTag>,
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_profile: GpuProfiler<GpuProfileTag>
§renderer_errors: Vec<RendererError>
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn new(
gl: Rc<dyn Gl>,
notifier: Box<dyn RenderNotifier>,
options: RendererOptions,
shaders: Option<&mut WrShaders>,
start_size: DeviceIntSize,
) -> Result<(Self, RenderApiSender), RendererError>
pub fn new( gl: Rc<dyn Gl>, notifier: Box<dyn RenderNotifier>, options: RendererOptions, shaders: Option<&mut WrShaders>, start_size: DeviceIntSize, ) -> 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 optimal_texture_stride_alignment(&self) -> usize
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.
pub fn update_program_cache(&mut self, cached_programs: Rc<ProgramCache>)
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 set_output_image_handler(&mut self, handler: Box<dyn OutputImageHandler>)
pub fn set_output_image_handler(&mut self, handler: Box<dyn OutputImageHandler>)
Set a callback for handling external outputs.
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.
pub fn notify_slow_frame(&mut self)
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,
) -> Result<RenderResults, Vec<RendererError>>
pub fn render( &mut self, device_size: DeviceIntSize, ) -> Result<RenderResults, Vec<RendererError>>
Renders the current frame.
A Frame is supplied by calling [generate_frame()
][webrender_api::Transaction::generate_frame].
Sourcepub fn init_pixel_local_storage(
&mut self,
task_rect: DeviceIntRect,
projection: &Transform3D<f32>,
stats: &mut RendererStats,
)
pub fn init_pixel_local_storage( &mut self, task_rect: DeviceIntRect, projection: &Transform3D<f32>, stats: &mut RendererStats, )
Initialize the PLS block, by reading the current framebuffer color.
Sourcepub fn resolve_pixel_local_storage(
&mut self,
task_rect: DeviceIntRect,
projection: &Transform3D<f32>,
stats: &mut RendererStats,
)
pub fn resolve_pixel_local_storage( &mut self, task_rect: DeviceIntRect, projection: &Transform3D<f32>, stats: &mut RendererStats, )
Resolve the current PLS structure, writing it to a fragment color output.
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 save_cpu_profile(&self, filename: &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 read_gpu_cache(&mut self) -> (DeviceIntSize, Vec<u8>)
pub fn deinit(self)
Sourcepub fn report_memory(&self) -> MemoryReport
pub fn report_memory(&self) -> 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