pub struct Paint { /* private fields */ }Expand description
Paint is Servo’s rendering subsystem. It has a few responsibilities:
- Maintain a WebRender instance for each
RenderingContextthat Servo knows about.RenderingContexts are per-WebView, but more than oneWebViewcan use the sameRenderingContext. This allows multipleWebViews to share the same WebRender instance which is more efficient. This is useful for tabbed web browsers. - Receive display lists from the layout of all of the currently active
Pipelines (frames). These display lists are sent to WebRender, and new frames are generated. Once the frame is ready the [Painter] for the WebRender instance will ask libservo to inform the embedder that a new frame is ready so that it can trigger a paint. - Drive animation and animation callback updates. Animation updates should ideally be
coordinated with the system vsync signal, so the
RefreshDriveris exposed in the API to allow the embedder to do this. The [Painter] then asks itsWebViews to update their rendering, which triggers layouts. - Eagerly handle scrolling and touch events. In order to avoid latency when handling
these kind of actions, each [
Painter] will eagerly process touch events and perform panning and zooming operations on their WebRender contents – informing the WebView contents asynchronously.
Paint and all of its contained structs should never block on the Constellation,
because sometimes the Constellation blocks on us.
Implementations§
Source§impl Paint
impl Paint
pub fn new(state: InitialPaintState) -> Rc<RefCell<Self>>
pub fn register_rendering_context( &mut self, rendering_context: Rc<dyn RenderingContext>, ) -> PainterId
pub fn painter_id(&self) -> PainterId
pub fn rendering_context_size( &self, painter_id: PainterId, ) -> Size2D<u32, DevicePixel>
pub fn webgl_threads(&self) -> WebGLThreads
pub fn webrender_external_image_id_manager( &self, ) -> WebRenderExternalImageIdManager
pub fn webxr_running(&self) -> bool
pub fn webviews_needing_repaint(&self) -> Vec<WebViewId>
pub fn finish_shutting_down(&self)
pub fn remove_webview(&mut self, webview_id: WebViewId)
pub fn add_webview( &self, webview: Box<dyn WebViewTrait>, viewport_details: ViewportDetails, )
pub fn show_webview(&self, webview_id: WebViewId) -> Result<(), UnknownWebView>
pub fn hide_webview(&self, webview_id: WebViewId) -> Result<(), UnknownWebView>
pub fn set_hidpi_scale_factor( &self, webview_id: WebViewId, new_scale_factor: Scale<f32, DeviceIndependentPixel, DevicePixel>, )
pub fn resize_rendering_context( &self, webview_id: WebViewId, new_size: PhysicalSize<u32>, )
pub fn set_page_zoom(&self, webview_id: WebViewId, new_zoom: f32)
pub fn page_zoom(&self, webview_id: WebViewId) -> f32
Sourcepub fn render(&self, webview_id: WebViewId)
pub fn render(&self, webview_id: WebViewId)
Render the WebRender scene to the active RenderingContext.
Sourcepub fn receiver(&self) -> &RoutedReceiver<PaintMessage>
pub fn receiver(&self) -> &RoutedReceiver<PaintMessage>
Get the message receiver for this Paint.
pub fn handle_messages(&self, messages: Vec<PaintMessage>)
pub fn perform_updates(&self) -> bool
pub fn toggle_webrender_debug(&self, option: WebRenderDebugOption)
pub fn capture_webrender(&self, webview_id: WebViewId)
Sourcepub fn notify_input_event(
&self,
webview_id: WebViewId,
event: InputEventAndId,
) -> bool
pub fn notify_input_event( &self, webview_id: WebViewId, event: InputEventAndId, ) -> bool
Returning false means this is not going to reach the Constellation,
and we need to directly notify the embedder that input event is handled.
pub fn notify_scroll_event( &self, webview_id: WebViewId, scroll: Scroll, point: WebViewPoint, )
pub fn adjust_pinch_zoom( &self, webview_id: WebViewId, pinch_zoom_delta: f32, center: DevicePoint, )
pub fn pinch_zoom(&self, webview_id: WebViewId) -> f32
pub fn device_pixels_per_page_pixel( &self, webview_id: WebViewId, ) -> Scale<f32, CSSPixel, DevicePixel>
pub fn request_screenshot( &self, webview_id: WebViewId, rect: Option<WebViewRect>, callback: Box<dyn FnOnce(Result<RgbaImage, ScreenshotCaptureError>) + 'static>, )
pub fn notify_input_event_handled( &self, webview_id: WebViewId, input_event_id: InputEventId, result: InputEventResult, )
Auto Trait Implementations§
impl !RefUnwindSafe for Paint
impl !Send for Paint
impl !Sync for Paint
impl !UnwindSafe for Paint
impl Freeze for Paint
impl Unpin for Paint
impl UnsafeUnpin for Paint
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
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
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>
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 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>
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert