pub(crate) struct Painter {Show 20 fields
pub(crate) rendering_context: Rc<dyn RenderingContext>,
pub(crate) painter_id: PainterId,
pub(crate) webview_renderers: WebViewManager<WebViewRenderer>,
pub(crate) needs_repaint: Cell<RepaintReason>,
pub(crate) pending_frames: Cell<usize>,
refresh_driver: Rc<BaseRefreshDriver>,
animation_refresh_driver_observer: Rc<AnimationRefreshDriverObserver>,
pub(crate) webrender_api: RenderApi,
pub(crate) webrender_document: DocumentId,
pub(crate) webrender: Option<Renderer>,
webrender_gl: Rc<dyn Gl>,
pub(crate) last_mouse_move_position: Option<DevicePoint>,
pub(crate) screenshot_taker: ScreenshotTaker,
pub(crate) frame_delayer: FrameDelayer,
pub(crate) webrender_external_images: Arc<Mutex<WebRenderExternalImageRegistry>>,
pub(crate) webxr_main_thread: MainThreadRegistry,
pub(crate) webgl_threads: WebGLThreads,
pub(crate) webgpu_image_map: WGPUImageMap,
embedder_to_constellation_sender: Sender<EmbedderToConstellationMessage>,
lcp_calculator: LargestContentfulPaintCalculator,
}Expand description
A Painter is responsible for all of the painting to a particular RenderingContext.
This holds all of the WebRender specific data structures and state necessary for painting
and handling events that happen to WebViews that use a particular RenderingContext.
Notable is that a Painter might be responsible for painting more than a single
[WebView] as long as they share the same RenderingContext.
Each Painter also has its own RefreshDriver as well, which may be shared with
other Painters. It’s up to the embedder to decide which RefreshDrivers are associated
with a particular RenderingContext.
Fields§
§rendering_context: Rc<dyn RenderingContext>The RenderingContext instance that webrender targets, which is the viewport.
painter_id: PainterIdThe ID of this painter.
webview_renderers: WebViewManager<WebViewRenderer>Our WebViewRenderers, one for every WebView.
needs_repaint: Cell<RepaintReason>Tracks whether or not the view needs to be repainted.
pending_frames: Cell<usize>The number of frames pending to receive from WebRender.
refresh_driver: Rc<BaseRefreshDriver>The BaseRefreshDriver which manages the painting of WebViews during animations.
animation_refresh_driver_observer: Rc<AnimationRefreshDriverObserver>A [RefreshDriverObserver] for WebView content animations.
webrender_api: RenderApiThe WebRender RenderApi interface used to communicate with WebRender.
webrender_document: DocumentIdThe active webrender document.
webrender: Option<Renderer>The webrender renderer.
webrender_gl: Rc<dyn Gl>The GL bindings for webrender
last_mouse_move_position: Option<DevicePoint>The last position in the rendered view that the mouse moved over. This becomes None
when the mouse leaves the rendered view.
screenshot_taker: ScreenshotTakerA ScreenshotTaker responsible for handling all screenshot requests.
frame_delayer: FrameDelayerA [FrameRequestDelayer] which is used to wait for canvas image updates to
arrive before requesting a new frame, as these happen asynchronously with
ScriptThread display list construction.
webrender_external_images: Arc<Mutex<WebRenderExternalImageRegistry>>The WebRender image registry from this renderer.
webxr_main_thread: MainThreadRegistrySome XR devices want to run on the main thread.
webgl_threads: WebGLThreadsThe WebGLThreads for this renderer.
webgpu_image_map: WGPUImageMapThe WebGPU image map for this renderer.
embedder_to_constellation_sender: Sender<EmbedderToConstellationMessage>The channel on which messages can be sent to the constellation.
lcp_calculator: LargestContentfulPaintCalculatorCalculater for largest-contentful-paint.
Implementations§
Source§impl Painter
impl Painter
pub(crate) fn new( rendering_context: Rc<dyn RenderingContext>, compositor_proxy: CompositorProxy, event_loop_waker: Box<dyn EventLoopWaker>, refresh_driver: Option<Rc<dyn RefreshDriver>>, shader_path: Option<PathBuf>, embedder_to_constellation_sender: Sender<EmbedderToConstellationMessage>, webxr_registry: Box<dyn WebXrRegistry>, ) -> Self
pub(crate) fn perform_updates(&mut self)
pub(crate) fn deinit(&mut self)
fn assert_no_gl_error(&self)
fn assert_gl_framebuffer_complete(&self)
pub(crate) fn webview_renderer( &self, webview_id: WebViewId, ) -> Option<&WebViewRenderer>
pub(crate) fn webview_renderer_mut( &mut self, webview_id: WebViewId, ) -> Option<&mut WebViewRenderer>
Sourcepub(crate) fn has_pending_frames(&self) -> bool
pub(crate) fn has_pending_frames(&self) -> bool
Whether or not the renderer is waiting on a frame, either because it has been sent
to WebRender and is not ready yet or because the FrameDelayer is delaying a frame
waiting for asynchronous (canvas) image updates to complete.
pub(crate) fn set_needs_repaint(&self, reason: RepaintReason)
pub(crate) fn needs_repaint(&self) -> bool
Sourcepub(crate) fn animation_callbacks_running(&self) -> bool
pub(crate) fn animation_callbacks_running(&self) -> bool
Returns true if any animation callbacks (ie requestAnimationFrame) are waiting for a response.
pub(crate) fn animating_webviews(&self) -> Vec<WebViewId>
pub(crate) fn send_to_constellation( &self, message: EmbedderToConstellationMessage, )
pub(crate) fn render(&mut self, time_profiler_channel: &ProfilerChan)
fn clear_background(&self)
Sourcefn send_pending_paint_metrics_messages_after_composite(&mut self)
fn send_pending_paint_metrics_messages_after_composite(&mut self)
Send all pending paint metrics messages after a composite operation, which may advance the epoch for pipelines in the WebRender scene.
If there are pending paint metrics, we check if any of the painted epochs is one of the ones that the paint metrics recorder is expecting. In that case, we get the current time, inform the constellation about it and remove the pending metric from the list.
Sourcepub(crate) fn generate_frame(
&self,
transaction: &mut Transaction,
reason: RenderReasons,
)
pub(crate) fn generate_frame( &self, transaction: &mut Transaction, reason: RenderReasons, )
Queue a new frame in the transaction and increase the pending frames count.
pub(crate) fn hit_test_at_point_with_api_and_document( webrender_api: &RenderApi, webrender_document: DocumentId, point: DevicePoint, ) -> Vec<CompositorHitTestResult>
pub(crate) fn send_transaction(&mut self, transaction: Transaction)
Sourcefn send_root_pipeline_display_list_in_transaction(
&self,
transaction: &mut Transaction,
)
fn send_root_pipeline_display_list_in_transaction( &self, transaction: &mut Transaction, )
Set the root pipeline for our WebRender scene to a display list that consists of an iframe for each visible top-level browsing context, applying a transformation on the root for pinch zoom, page zoom, and HiDPI scaling.
Sourcefn send_root_pipeline_display_list(&mut self)
fn send_root_pipeline_display_list(&mut self)
Set the root pipeline for our WebRender scene to a display list that consists of an iframe for each visible top-level browsing context, applying a transformation on the root for pinch zoom, page zoom, and HiDPI scaling.
Sourcefn update_transaction_with_all_scroll_offsets(
&self,
transaction: &mut Transaction,
)
fn update_transaction_with_all_scroll_offsets( &self, transaction: &mut Transaction, )
Update the given transaction with the scroll offsets of all active scroll nodes in the WebRender scene. This is necessary because WebRender does not preserve scroll offsets between scroll tree modifications. If a display list could potentially modify a scroll tree branch, WebRender needs to have scroll offsets for that branch.
TODO(mrobinson): Could we only send offsets for the branch being modified and not the entire scene?
fn send_zoom_and_scroll_offset_updates( &mut self, need_zoom: bool, scroll_offset_updates: Vec<ScrollResult>, )
pub(crate) fn toggle_webrender_debug(&mut self, option: WebRenderDebugOption)
pub(crate) fn decrement_pending_frames(&self)
pub(crate) fn report_memory(&self) -> MemoryReport
pub(crate) fn change_running_animations_state( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, animation_state: AnimationState, )
pub(crate) fn set_frame_tree_for_webview( &mut self, frame_tree: &SendableFrameTree, )
pub(crate) fn remove_webview(&mut self, webview_id: WebViewId)
pub(crate) fn set_throttled( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, throttled: bool, )
pub(crate) fn notify_pipeline_exited( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, pipeline_exit_source: PipelineExitSource, )
pub(crate) fn send_initial_pipeline_transaction( &mut self, webview_id: WebViewId, pipeline_id: WebRenderPipelineId, )
pub(crate) fn scroll_node_by_delta( &mut self, webview_id: WebViewId, pipeline_id: WebRenderPipelineId, offset: LayoutVector2D, external_scroll_id: ExternalScrollId, )
pub(crate) fn scroll_viewport_by_delta( &mut self, webview_id: WebViewId, delta: LayoutVector2D, )
pub(crate) fn update_epoch( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, epoch: Epoch, )
pub(crate) fn handle_new_display_list( &mut self, webview_id: WebViewId, display_list_descriptor: BuiltDisplayListDescriptor, display_list_receiver: IpcBytesReceiver, )
pub(crate) fn generate_frame_for_script(&mut self)
pub(crate) fn generate_image_key(&self) -> ImageKey
pub(crate) fn generate_image_keys(&self) -> Vec<ImageKey>
pub(crate) fn update_images(&mut self, updates: SmallVec<[ImageUpdate; 1]>)
pub(crate) fn delay_new_frames_for_canvas( &mut self, pipeline_id: PipelineId, canvas_epoch: Epoch, image_keys: Vec<ImageKey>, )
pub(crate) fn add_font( &mut self, font_key: FontKey, data: Arc<IpcSharedMemory>, index: u32, )
pub(crate) fn add_system_font( &mut self, font_key: FontKey, native_handle: NativeFontHandle, )
pub(crate) fn add_font_instance( &mut self, instance_key: FontInstanceKey, font_key: FontKey, size: f32, flags: FontInstanceFlags, variations: Vec<FontVariation>, )
pub(crate) fn remove_fonts( &mut self, keys: Vec<FontKey>, instance_keys: Vec<FontInstanceKey>, )
Sourcepub(crate) fn generate_font_keys(
&self,
number_of_font_keys: usize,
number_of_font_instance_keys: usize,
) -> (Vec<FontKey>, Vec<FontInstanceKey>)
pub(crate) fn generate_font_keys( &self, number_of_font_keys: usize, number_of_font_instance_keys: usize, ) -> (Vec<FontKey>, Vec<FontInstanceKey>)
Generate the font keys and send them to the result_sender.
Currently RenderingGroupId is not used.
pub(crate) fn set_viewport_description( &mut self, webview_id: WebViewId, viewport_description: ViewportDescription, )
pub(crate) fn handle_screenshot_readiness_reply( &self, webview_id: WebViewId, expected_epochs: FxHashMap<PipelineId, Epoch>, )
pub(crate) fn add_webview( &mut self, webview: Box<dyn WebViewTrait>, viewport_details: ViewportDetails, )
pub(crate) fn show_webview( &mut self, webview_id: WebViewId, hide_others: bool, ) -> Result<(), UnknownWebView>
pub(crate) fn hide_webview( &mut self, webview_id: WebViewId, ) -> Result<(), UnknownWebView>
pub(crate) fn raise_webview_to_top( &mut self, webview_id: WebViewId, hide_others: bool, ) -> Result<(), UnknownWebView>
pub(crate) fn move_resize_webview( &mut self, webview_id: WebViewId, rect: DeviceRect, )
pub(crate) fn set_hidpi_scale_factor( &mut self, webview_id: WebViewId, new_scale_factor: Scale<f32, DeviceIndependentPixel, DevicePixel>, )
pub(crate) fn resize_rendering_context(&mut self, new_size: PhysicalSize<u32>)
pub(crate) fn set_page_zoom(&mut self, webview_id: WebViewId, new_zoom: f32)
pub(crate) fn page_zoom(&self, webview_id: WebViewId) -> f32
pub(crate) fn notify_input_event( &mut self, webview_id: WebViewId, event: InputEventAndId, )
pub(crate) fn notify_scroll_event( &mut self, webview_id: WebViewId, scroll: Scroll, point: WebViewPoint, )
pub(crate) fn pinch_zoom( &mut self, webview_id: WebViewId, pinch_zoom_delta: f32, center: DevicePoint, )
pub(crate) fn device_pixels_per_page_pixel( &self, webview_id: WebViewId, ) -> Scale<f32, CSSPixel, DevicePixel>
pub(crate) fn request_screenshot( &self, webview_id: WebViewId, rect: Option<WebViewRect>, callback: Box<dyn FnOnce(Result<RgbaImage, ScreenshotCaptureError>) + 'static>, )
pub(crate) fn notify_input_event_handled( &mut self, webview_id: WebViewId, input_event_id: InputEventId, result: InputEventResult, )
pub(crate) fn refresh_cursor(&self)
pub(crate) fn handle_new_webrender_frame_ready(&self, repaint_needed: bool)
pub(crate) fn webviews_needing_repaint(&self) -> Vec<WebViewId>
pub(crate) fn append_lcp_candidate( &mut self, lcp_candidate: LCPCandidate, webview_id: WebViewId, pipeline_id: PipelineId, epoch: Epoch, )
Sourcefn disable_lcp_calculation_for_webview(&mut self, webview_id: WebViewId)
fn disable_lcp_calculation_for_webview(&mut self, webview_id: WebViewId)
Disable LCP feature when the user interacts with the page.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Painter
impl !RefUnwindSafe for Painter
impl !Send for Painter
impl !Sync for Painter
impl Unpin for Painter
impl !UnwindSafe for Painter
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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