Painter

Struct Painter 

Source
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: PainterId

The 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: RenderApi

The WebRender RenderApi interface used to communicate with WebRender.

§webrender_document: DocumentId

The 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: ScreenshotTaker

A ScreenshotTaker responsible for handling all screenshot requests.

§frame_delayer: FrameDelayer

A [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: MainThreadRegistry

Some XR devices want to run on the main thread.

§webgl_threads: WebGLThreads

The WebGLThreads for this renderer.

§webgpu_image_map: WGPUImageMap

The 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: LargestContentfulPaintCalculator

Calculater for largest-contentful-paint.

Implementations§

Source§

impl Painter

Source

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

Source

pub(crate) fn perform_updates(&mut self)

Source

pub(crate) fn deinit(&mut self)

Source

fn assert_no_gl_error(&self)

Source

fn assert_gl_framebuffer_complete(&self)

Source

pub(crate) fn webview_renderer( &self, webview_id: WebViewId, ) -> Option<&WebViewRenderer>

Source

pub(crate) fn webview_renderer_mut( &mut self, webview_id: WebViewId, ) -> Option<&mut WebViewRenderer>

Source

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.

Source

pub(crate) fn set_needs_repaint(&self, reason: RepaintReason)

Source

pub(crate) fn needs_repaint(&self) -> bool

Source

pub(crate) fn animation_callbacks_running(&self) -> bool

Returns true if any animation callbacks (ie requestAnimationFrame) are waiting for a response.

Source

pub(crate) fn animating_webviews(&self) -> Vec<WebViewId>

Source

pub(crate) fn send_to_constellation( &self, message: EmbedderToConstellationMessage, )

Source

pub(crate) fn render(&mut self, time_profiler_channel: &ProfilerChan)

Source

fn clear_background(&self)

Source

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.

Source

pub(crate) fn generate_frame( &self, transaction: &mut Transaction, reason: RenderReasons, )

Queue a new frame in the transaction and increase the pending frames count.

Source

pub(crate) fn hit_test_at_point_with_api_and_document( webrender_api: &RenderApi, webrender_document: DocumentId, point: DevicePoint, ) -> Vec<CompositorHitTestResult>

Source

pub(crate) fn send_transaction(&mut self, transaction: Transaction)

Source

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.

Source

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.

Source

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?

Source

fn send_zoom_and_scroll_offset_updates( &mut self, need_zoom: bool, scroll_offset_updates: Vec<ScrollResult>, )

Source

pub(crate) fn toggle_webrender_debug(&mut self, option: WebRenderDebugOption)

Source

pub(crate) fn decrement_pending_frames(&self)

Source

pub(crate) fn report_memory(&self) -> MemoryReport

Source

pub(crate) fn change_running_animations_state( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, animation_state: AnimationState, )

Source

pub(crate) fn set_frame_tree_for_webview( &mut self, frame_tree: &SendableFrameTree, )

Source

pub(crate) fn remove_webview(&mut self, webview_id: WebViewId)

Source

pub(crate) fn set_throttled( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, throttled: bool, )

Source

pub(crate) fn notify_pipeline_exited( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, pipeline_exit_source: PipelineExitSource, )

Source

pub(crate) fn send_initial_pipeline_transaction( &mut self, webview_id: WebViewId, pipeline_id: WebRenderPipelineId, )

Source

pub(crate) fn scroll_node_by_delta( &mut self, webview_id: WebViewId, pipeline_id: WebRenderPipelineId, offset: LayoutVector2D, external_scroll_id: ExternalScrollId, )

Source

pub(crate) fn scroll_viewport_by_delta( &mut self, webview_id: WebViewId, delta: LayoutVector2D, )

Source

pub(crate) fn update_epoch( &mut self, webview_id: WebViewId, pipeline_id: PipelineId, epoch: Epoch, )

Source

pub(crate) fn handle_new_display_list( &mut self, webview_id: WebViewId, display_list_descriptor: BuiltDisplayListDescriptor, display_list_receiver: IpcBytesReceiver, )

Source

pub(crate) fn generate_frame_for_script(&mut self)

Source

pub(crate) fn generate_image_key(&self) -> ImageKey

Source

pub(crate) fn generate_image_keys(&self) -> Vec<ImageKey>

Source

pub(crate) fn update_images(&mut self, updates: SmallVec<[ImageUpdate; 1]>)

Source

pub(crate) fn delay_new_frames_for_canvas( &mut self, pipeline_id: PipelineId, canvas_epoch: Epoch, image_keys: Vec<ImageKey>, )

Source

pub(crate) fn add_font( &mut self, font_key: FontKey, data: Arc<IpcSharedMemory>, index: u32, )

Source

pub(crate) fn add_system_font( &mut self, font_key: FontKey, native_handle: NativeFontHandle, )

Source

pub(crate) fn add_font_instance( &mut self, instance_key: FontInstanceKey, font_key: FontKey, size: f32, flags: FontInstanceFlags, variations: Vec<FontVariation>, )

Source

pub(crate) fn remove_fonts( &mut self, keys: Vec<FontKey>, instance_keys: Vec<FontInstanceKey>, )

Source

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.

Source

pub(crate) fn set_viewport_description( &mut self, webview_id: WebViewId, viewport_description: ViewportDescription, )

Source

pub(crate) fn handle_screenshot_readiness_reply( &self, webview_id: WebViewId, expected_epochs: FxHashMap<PipelineId, Epoch>, )

Source

pub(crate) fn add_webview( &mut self, webview: Box<dyn WebViewTrait>, viewport_details: ViewportDetails, )

Source

pub(crate) fn show_webview( &mut self, webview_id: WebViewId, hide_others: bool, ) -> Result<(), UnknownWebView>

Source

pub(crate) fn hide_webview( &mut self, webview_id: WebViewId, ) -> Result<(), UnknownWebView>

Source

pub(crate) fn raise_webview_to_top( &mut self, webview_id: WebViewId, hide_others: bool, ) -> Result<(), UnknownWebView>

Source

pub(crate) fn move_resize_webview( &mut self, webview_id: WebViewId, rect: DeviceRect, )

Source

pub(crate) fn set_hidpi_scale_factor( &mut self, webview_id: WebViewId, new_scale_factor: Scale<f32, DeviceIndependentPixel, DevicePixel>, )

Source

pub(crate) fn resize_rendering_context(&mut self, new_size: PhysicalSize<u32>)

Source

pub(crate) fn set_page_zoom(&mut self, webview_id: WebViewId, new_zoom: f32)

Source

pub(crate) fn page_zoom(&self, webview_id: WebViewId) -> f32

Source

pub(crate) fn notify_input_event( &mut self, webview_id: WebViewId, event: InputEventAndId, )

Source

pub(crate) fn notify_scroll_event( &mut self, webview_id: WebViewId, scroll: Scroll, point: WebViewPoint, )

Source

pub(crate) fn pinch_zoom( &mut self, webview_id: WebViewId, pinch_zoom_delta: f32, center: DevicePoint, )

Source

pub(crate) fn device_pixels_per_page_pixel( &self, webview_id: WebViewId, ) -> Scale<f32, CSSPixel, DevicePixel>

Source

pub(crate) fn request_screenshot( &self, webview_id: WebViewId, rect: Option<WebViewRect>, callback: Box<dyn FnOnce(Result<RgbaImage, ScreenshotCaptureError>) + 'static>, )

Source

pub(crate) fn notify_input_event_handled( &mut self, webview_id: WebViewId, input_event_id: InputEventId, result: InputEventResult, )

Source

pub(crate) fn refresh_cursor(&self)

Source

pub(crate) fn handle_new_webrender_frame_ready(&self, repaint_needed: bool)

Source

pub(crate) fn webviews_needing_repaint(&self) -> Vec<WebViewId>

Source

pub(crate) fn append_lcp_candidate( &mut self, lcp_candidate: LCPCandidate, webview_id: WebViewId, pipeline_id: PipelineId, epoch: Epoch, )

Source

fn disable_lcp_calculation_for_webview(&mut self, webview_id: WebViewId)

Disable LCP feature when the user interacts with the page.

Trait Implementations§

Source§

impl Drop for Painter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T