Struct webrender::Renderer

source ·
pub struct Renderer {
Show 63 fields result_rx: Receiver<ResultMsg>, api_tx: Sender<ApiMsg>, pub device: Device, pending_texture_updates: Vec<TextureUpdateList>, pending_texture_cache_updates: bool, pending_native_surface_updates: Vec<NativeSurfaceOperation>, pending_gpu_cache_updates: Vec<GpuCacheUpdateList>, pending_gpu_cache_clear: bool, pending_shader_updates: Vec<PathBuf>, active_documents: FastHashMap<DocumentId, RenderedDocument>, shaders: Rc<RefCell<Shaders>>, max_recorded_profiles: usize, clear_color: ColorF, enable_clear_scissor: bool, enable_advanced_blend_barriers: bool, clear_caches_with_quads: bool, clear_alpha_targets_with_quads: bool, debug: LazyInitializedDebugRenderer, debug_flags: DebugFlags, profile: TransactionProfile, frame_counter: u64, resource_upload_time: f64, gpu_cache_upload_time: f64, profiler: Profiler, last_time: u64, pub gpu_profiler: GpuProfiler, vaos: RendererVAOs, gpu_cache_texture: GpuCacheTexture, vertex_data_textures: Vec<VertexDataTextures>, current_vertex_data_textures: usize, gpu_cache_debug_chunks: Vec<Vec<GpuCacheDebugChunk>>, gpu_cache_frame_id: FrameId, gpu_cache_overflow: bool, pipeline_info: PipelineInfo, texture_resolver: TextureResolver, texture_upload_pbo_pool: UploadPBOPool, staging_texture_pool: UploadTexturePool, dither_matrix_texture: Option<Texture>, external_image_handler: Option<Box<dyn ExternalImageHandler>>, size_of_ops: Option<MallocSizeOfOps>, pub renderer_errors: Vec<RendererError>, pub(crate) async_frame_recorder: Option<AsyncScreenshotGrabber>, pub(crate) async_screenshots: Option<AsyncScreenshotGrabber>, cpu_profiles: VecDeque<CpuProfile>, gpu_profiles: VecDeque<GpuProfile>, notifications: Vec<NotificationRequest>, device_size: Option<DeviceIntSize>, zoom_debug_texture: Option<Texture>, cursor_position: DeviceIntPoint, shared_texture_cache_cleared: bool, documents_seen: HashSet<DocumentId, BuildHasherDefault<FxHasher>>, read_fbo: FBOId, compositor_config: CompositorConfig, current_compositor_kind: CompositorKind, allocated_native_surfaces: HashSet<NativeSurfaceId, BuildHasherDefault<FxHasher>>, force_redraw: bool, debug_overlay_state: DebugOverlayState, buffer_damage_tracker: BufferDamageTracker, max_primitive_instance_count: usize, enable_instancing: bool, consecutive_oom_frames: u32, target_frame_publish_id: Option<FramePublishId>, pending_result_msg: Option<ResultMsg>,
}
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§

§result_rx: Receiver<ResultMsg>§api_tx: Sender<ApiMsg>§device: Device§pending_texture_updates: Vec<TextureUpdateList>§pending_texture_cache_updates: bool

True if there are any TextureCacheUpdate pending.

§pending_native_surface_updates: Vec<NativeSurfaceOperation>§pending_gpu_cache_updates: Vec<GpuCacheUpdateList>§pending_gpu_cache_clear: bool§pending_shader_updates: Vec<PathBuf>§active_documents: FastHashMap<DocumentId, RenderedDocument>§shaders: Rc<RefCell<Shaders>>§max_recorded_profiles: usize§clear_color: ColorF§enable_clear_scissor: bool§enable_advanced_blend_barriers: bool§clear_caches_with_quads: bool§clear_alpha_targets_with_quads: bool§debug: LazyInitializedDebugRenderer§debug_flags: DebugFlags§profile: TransactionProfile§frame_counter: u64§resource_upload_time: f64§gpu_cache_upload_time: f64§profiler: Profiler§last_time: u64§gpu_profiler: GpuProfiler§vaos: RendererVAOs§gpu_cache_texture: GpuCacheTexture§vertex_data_textures: Vec<VertexDataTextures>§current_vertex_data_textures: usize§gpu_cache_debug_chunks: Vec<Vec<GpuCacheDebugChunk>>

When the GPU cache debugger is enabled, we keep track of the live blocks in the GPU cache so that we can use them for the debug display. This member stores those live blocks, indexed by row.

§gpu_cache_frame_id: FrameId§gpu_cache_overflow: bool§pipeline_info: PipelineInfo§texture_resolver: TextureResolver§texture_upload_pbo_pool: UploadPBOPool§staging_texture_pool: UploadTexturePool§dither_matrix_texture: Option<Texture>§external_image_handler: Option<Box<dyn ExternalImageHandler>>

Optional trait object that allows the client application to provide external buffers for image data.

§size_of_ops: Option<MallocSizeOfOps>

Optional function pointers for measuring memory used by a given heap-allocated pointer.

§renderer_errors: Vec<RendererError>§async_frame_recorder: Option<AsyncScreenshotGrabber>§async_screenshots: Option<AsyncScreenshotGrabber>§cpu_profiles: VecDeque<CpuProfile>

List of profile results from previous frames. Can be retrieved via get_frame_profiles().

§gpu_profiles: VecDeque<GpuProfile>§notifications: Vec<NotificationRequest>

Notification requests to be fulfilled after rendering.

§device_size: Option<DeviceIntSize>§zoom_debug_texture: Option<Texture>

A lazily created texture for the zoom debugging widget.

§cursor_position: DeviceIntPoint

The current mouse position. This is used for debugging functionality only, such as the debug zoom widget.

§shared_texture_cache_cleared: bool

Guards to check if we might be rendering a frame with expired texture cache entries.

§documents_seen: HashSet<DocumentId, BuildHasherDefault<FxHasher>>

The set of documents which we’ve seen a publish for since last render.

§read_fbo: FBOId§compositor_config: CompositorConfig

The compositing config, affecting how WR composites into the final scene.

§current_compositor_kind: CompositorKind§allocated_native_surfaces: HashSet<NativeSurfaceId, BuildHasherDefault<FxHasher>>

Maintains a set of allocated native composite surfaces. This allows any currently allocated surfaces to be cleaned up as soon as deinit() is called (the normal bookkeeping for native surfaces exists in the render backend thread).

§force_redraw: bool

If true, partial present state has been reset and everything needs to be drawn on the next render.

§debug_overlay_state: DebugOverlayState

State related to the debug / profiling overlays

§buffer_damage_tracker: BufferDamageTracker

Tracks the dirty rectangles from previous frames. Used on platforms that require keeping the front buffer fully correct when doing partial present (e.g. unix desktop with EGL_EXT_buffer_age).

§max_primitive_instance_count: usize§enable_instancing: bool§consecutive_oom_frames: u32

Count consecutive oom frames to detectif we are stuck unable to render in a loop.

§target_frame_publish_id: Option<FramePublishId>

update() defers processing of ResultMsg, if frame_publish_id of ResultMsg::PublishDocument exceeds target_frame_publish_id.

§pending_result_msg: Option<ResultMsg>

Hold a next ResultMsg that will be handled by update().

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

fn get_next_result_msg(&mut self) -> Option<ResultMsg>

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_target_frame_publish_id(&mut self, publish_id: FramePublishId)

update() defers processing of ResultMsg, if frame_publish_id of ResultMsg::PublishDocument exceeds target_frame_publish_id.

source

fn handle_debug_command(&mut self, command: DebugCommand)

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

fn update_debug_overlay( &mut self, framebuffer_size: DeviceIntSize, has_debug_items: bool, )

Update the state of any debug / profiler overlays. This is currently only needed when running with the native compositor enabled.

source

fn bind_debug_overlay( &mut self, device_size: DeviceIntSize, ) -> Option<DrawTarget>

Bind a draw target for the debug / profiler overlays, if required.

source

fn unbind_debug_overlay(&mut self)

Unbind the draw target for debug / profiler overlays, if required.

source

fn render_impl( &mut self, doc_id: DocumentId, active_doc: &mut RenderedDocument, device_size: Option<DeviceIntSize>, buffer_age: usize, ) -> Result<RenderResults, Vec<RendererError>>

source

fn update_gpu_profile(&mut self, device_size: DeviceIntSize)

source

fn update_texture_cache(&mut self)

source

fn check_gl_errors(&mut self)

source

fn bind_textures(&mut self, textures: &BatchTextures)

source

fn draw_instanced_batch<T: Clone>( &mut self, data: &[T], vertex_array_kind: VertexArrayKind, textures: &BatchTextures, stats: &mut RendererStats, )

source

fn handle_readback_composite( &mut self, draw_target: DrawTarget, uses_scissor: bool, backdrop: &RenderTask, readback: &RenderTask, )

source

fn handle_resolves( &mut self, resolve_ops: &[ResolveOp], render_tasks: &RenderTaskGraph, draw_target: DrawTarget, )

source

fn handle_prims( &mut self, draw_target: &DrawTarget, prim_instances: &[FastHashMap<TextureSource, Vec<PrimitiveInstanceData>>], prim_instances_with_scissor: &FastHashMap<(DeviceIntRect, PatternKind), FastHashMap<TextureSource, Vec<PrimitiveInstanceData>>>, projection: &Transform3D<f32>, stats: &mut RendererStats, )

source

fn handle_clips( &mut self, draw_target: &DrawTarget, masks: &ClipMaskInstanceList, projection: &Transform3D<f32>, stats: &mut RendererStats, )

source

fn handle_blits( &mut self, blits: &[BlitJob], render_tasks: &RenderTaskGraph, draw_target: DrawTarget, )

source

fn handle_scaling( &mut self, scalings: &FastHashMap<TextureSource, Vec<ScalingInstance>>, projection: &Transform3D<f32>, stats: &mut RendererStats, )

source

fn handle_svg_filters( &mut self, textures: &BatchTextures, svg_filters: &[SvgFilterInstance], projection: &Transform3D<f32>, stats: &mut RendererStats, )

source

fn handle_svg_nodes( &mut self, textures: &BatchTextures, svg_filters: &[SVGFEFilterInstance], projection: &Transform3D<f32>, stats: &mut RendererStats, )

source

fn handle_resolve( &mut self, resolve_op: &ResolveOp, render_tasks: &RenderTaskGraph, draw_target: DrawTarget, )

source

fn draw_picture_cache_target( &mut self, target: &PictureCacheTarget, draw_target: DrawTarget, projection: &Transform3D<f32>, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )

source

fn draw_alpha_batch_container( &mut self, alpha_batch_container: &AlphaBatchContainer, draw_target: DrawTarget, framebuffer_kind: FramebufferKind, projection: &Transform3D<f32>, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )

Draw an alpha batch container into a given draw target. This is used by both color and picture cache target kinds.

source

fn update_external_native_surfaces( &mut self, external_surfaces: &[ResolvedExternalSurface], results: &mut RenderResults, )

Rasterize any external compositor surfaces that require updating

source

fn draw_tile_list<'a, I: Iterator<Item = &'a Item>>( &mut self, tiles_iter: I, composite_state: &CompositeState, external_surfaces: &[ResolvedExternalSurface], projection: &Transform3D<f32>, stats: &mut RendererStats, )

Draw a list of tiles to the framebuffer

source

fn composite_simple( &mut self, composite_state: &CompositeState, draw_target: DrawTarget, projection: &Transform3D<f32>, results: &mut RenderResults, partial_present_mode: Option<PartialPresentMode>, )

Composite picture cache tiles into the framebuffer. This is currently the only way that picture cache tiles get drawn. In future, the tiles will often be handed to the OS compositor, and this method will be rarely used.

source

fn draw_color_target( &mut self, draw_target: DrawTarget, target: &ColorRenderTarget, clear_depth: Option<f32>, render_tasks: &RenderTaskGraph, projection: &Transform3D<f32>, stats: &mut RendererStats, )

source

fn draw_blurs( &mut self, blurs: &FastHashMap<TextureSource, Vec<BlurInstance>>, stats: &mut RendererStats, )

source

fn draw_clip_batch_list( &mut self, list: &ClipBatchList, projection: &Transform3D<f32>, stats: &mut RendererStats, )

Draw all the instances in a clip batcher list to the current target.

source

fn draw_alpha_target( &mut self, draw_target: DrawTarget, target: &AlphaRenderTarget, projection: &Transform3D<f32>, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )

source

fn draw_texture_cache_target( &mut self, texture: &CacheTextureId, target: &TextureCacheRenderTarget, render_tasks: &RenderTaskGraph, stats: &mut RendererStats, )

source

fn update_deferred_resolves( &mut self, deferred_resolves: &[DeferredResolve], ) -> Option<GpuCacheUpdateList>

source

fn unlock_external_images(&mut self, deferred_resolves: &[DeferredResolve])

source

fn calculate_dirty_rects( &mut self, buffer_age: usize, composite_state: &CompositeState, draw_target_dimensions: DeviceIntSize, results: &mut RenderResults, ) -> Option<PartialPresentMode>

Update the dirty rects based on current compositing mode and config

source

fn bind_frame_data(&mut self, frame: &mut Frame)

source

fn update_native_surfaces(&mut self)

source

fn create_gpu_buffer_texture<T: Texel>( &mut self, buffer: &GpuBuffer<T>, sampler: TextureSampler, ) -> Option<Texture>

source

fn draw_frame( &mut self, frame: &mut Frame, device_size: Option<DeviceIntSize>, buffer_age: usize, results: &mut RenderResults, )

source

fn composite_frame( &mut self, frame: &mut Frame, device_size: Option<DeviceIntSize>, results: &mut RenderResults, present_mode: Option<PartialPresentMode>, )

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

fn draw_frame_debug_items(&mut self, items: &[DebugItem])

source

fn draw_render_target_debug(&mut self, draw_target: &DrawTarget)

source

fn draw_zoom_debug(&mut self, device_size: DeviceIntSize)

source

fn draw_texture_cache_debug(&mut self, draw_target: &DrawTarget)

source

fn do_debug_blit( device: &mut Device, debug_renderer: &mut DebugRenderer, textures: Vec<&Texture>, draw_target: &DrawTarget, bottom: i32, select_color: &dyn Fn(&Texture) -> [f32; 4], )

source

fn draw_epoch_debug(&mut self)

source

fn draw_window_visibility_debug(&mut self)

source

fn draw_gpu_cache_debug(&mut self, device_size: DeviceIntSize)

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

fn size_of<T>(&self, ptr: *const T) -> usize

source

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

Collects a memory report.

source

fn set_blend(&mut self, blend: bool, framebuffer_kind: FramebufferKind)

source

fn set_blend_mode_multiply(&mut self, framebuffer_kind: FramebufferKind)

source

fn set_blend_mode_premultiplied_alpha( &mut self, framebuffer_kind: FramebufferKind, )

source

fn clear_texture(&mut self, texture: &Texture, color: [f32; 4])

Clears the texture with a given color.

source§

impl Renderer

source

fn save_texture( texture: &Texture, category: Option<TextureCacheCategory>, name: &str, root: &PathBuf, device: &mut Device, ) -> PlainTexture

source

fn save_capture( &mut self, config: CaptureConfig, deferred_images: Vec<ExternalCaptureImage>, )

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.
§

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

§

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.