Struct compositing::compositor::IOCompositor

source ·
pub struct IOCompositor<Window: WindowMethods + ?Sized> {
Show 38 fields pub window: Rc<Window>, port: CompositorReceiver, webviews: WebViewManager<WebView>, pipeline_details: HashMap<PipelineId, PipelineDetails>, viewport_zoom: PinchZoomFactor, min_viewport_zoom: Option<PinchZoomFactor>, max_viewport_zoom: Option<PinchZoomFactor>, page_zoom: Scale<f32, CSSPixel, DeviceIndependentPixel>, composite_target: CompositeTarget, composition_request: CompositionRequest, pub shutdown_state: ShutdownState, zoom_action: bool, zoom_time: f64, frame_tree_id: FrameTreeId, constellation_chan: Sender<ConstellationMsg>, time_profiler_chan: ProfilerChan, touch_handler: TouchHandler, pending_scroll_zoom_events: Vec<ScrollZoomEvent>, ready_to_save_state: ReadyState, webrender: Renderer, webrender_document: DocumentId, webrender_api: RenderApi, rendering_context: RenderingContext, webrender_gl: Rc<dyn Gl>, pub webxr_main_thread: MainThreadRegistry, pending_paint_metrics: HashMap<PipelineId, Vec<Epoch>>, embedder_coordinates: EmbedderCoordinates, cursor: Cursor, cursor_pos: DevicePoint, next_offscreen_framebuffer: OnceCell<RenderTargetInfo>, prev_offscreen_framebuffer: Option<RenderTargetInfo>, invalidate_prev_offscreen_framebuffer: bool, exit_after_load: bool, convert_mouse_to_touch: bool, pending_frames: usize, waiting_on_present: bool, last_animation_tick: Instant, version_string: String,
}
Expand description

NB: Never block on the constellation, because sometimes the constellation blocks on us.

Fields§

§window: Rc<Window>

The application window.

§port: CompositorReceiver

The port on which we receive messages.

§webviews: WebViewManager<WebView>

Our top-level browsing contexts.

§pipeline_details: HashMap<PipelineId, PipelineDetails>

Tracks details about each active pipeline that the compositor knows about.

§viewport_zoom: PinchZoomFactor

“Mobile-style” zoom that does not reflow the page.

§min_viewport_zoom: Option<PinchZoomFactor>

Viewport zoom constraints provided by @viewport.

§max_viewport_zoom: Option<PinchZoomFactor>§page_zoom: Scale<f32, CSSPixel, DeviceIndependentPixel>

“Desktop-style” zoom that resizes the viewport to fit the window.

§composite_target: CompositeTarget

The type of composition to perform

§composition_request: CompositionRequest

Tracks whether we should composite this frame.

§shutdown_state: ShutdownState

Tracks whether we are in the process of shutting down, or have shut down and should close the compositor.

§zoom_action: bool

Tracks whether the zoom action has happened recently.

§zoom_time: f64

The time of the last zoom action has started.

§frame_tree_id: FrameTreeId

The current frame tree ID (used to reject old paint buffers)

§constellation_chan: Sender<ConstellationMsg>

The channel on which messages can be sent to the constellation.

§time_profiler_chan: ProfilerChan

The channel on which messages can be sent to the time profiler.

§touch_handler: TouchHandler

Touch input state machine

§pending_scroll_zoom_events: Vec<ScrollZoomEvent>

Pending scroll/zoom events.

§ready_to_save_state: ReadyState

Used by the logic that determines when it is safe to output an image for the reftest framework.

§webrender: Renderer

The webrender renderer.

§webrender_document: DocumentId

The active webrender document.

§webrender_api: RenderApi

The webrender interface, if enabled.

§rendering_context: RenderingContext

The surfman instance that webrender targets

§webrender_gl: Rc<dyn Gl>

The GL bindings for webrender

§webxr_main_thread: MainThreadRegistry

Some XR devices want to run on the main thread.

§pending_paint_metrics: HashMap<PipelineId, Vec<Epoch>>

A per-pipeline queue of display lists that have not yet been rendered by WebRender. Layout expects WebRender to paint each given epoch. Once the compositor paints a frame with that epoch’s display list, it will be removed from the queue and the paint time will be recorded as a metric. In case new display lists come faster than painting a metric might never be recorded.

§embedder_coordinates: EmbedderCoordinates

The coordinates of the native window, its view and the screen.

§cursor: Cursor

Current mouse cursor.

§cursor_pos: DevicePoint

Current cursor position.

§next_offscreen_framebuffer: OnceCell<RenderTargetInfo>

Offscreen framebuffer object to render our next frame to. We use this and prev_offscreen_framebuffer for double buffering when compositing to CompositeTarget::Fbo.

§prev_offscreen_framebuffer: Option<RenderTargetInfo>

Offscreen framebuffer object for our most-recently-completed frame. We use this and next_offscreen_framebuffer for double buffering when compositing to CompositeTarget::Fbo.

§invalidate_prev_offscreen_framebuffer: bool

Whether to invalidate prev_offscreen_framebuffer at the end of the next frame.

§exit_after_load: bool

True to exit after page load (‘-x’).

§convert_mouse_to_touch: bool

True to translate mouse input into touch events.

§pending_frames: usize

The number of frames pending to receive from WebRender.

§waiting_on_present: bool

Waiting for external code to call present.

§last_animation_tick: Instant

The Instant of the last animation tick, used to avoid flooding the Constellation and ScriptThread with a deluge of animation ticks.

§version_string: String

The string representing the version of Servo that is running. This is used to tag WebRender capture output.

Implementations§

source§

impl<Window: WindowMethods + ?Sized> IOCompositor<Window>

source

pub fn new( window: Rc<Window>, state: InitialCompositorState, composite_target: CompositeTarget, exit_after_load: bool, convert_mouse_to_touch: bool, top_level_browsing_context_id: TopLevelBrowsingContextId, version_string: String, ) -> Self

source

pub fn deinit(self)

source

fn update_cursor(&mut self, result: CompositorHitTestResult)

source

pub fn maybe_start_shutting_down(&mut self)

source

fn start_shutting_down(&mut self)

source

fn finish_shutting_down(&mut self)

source

pub fn invalidate_native_surface(&mut self)

The underlying native surface can be lost during servo’s lifetime. On Android, for example, this happens when the app is sent to background. We need to unbind the surface so that we don’t try to use it again.

source

pub fn replace_native_surface( &mut self, native_widget: *mut c_void, coords: DeviceIntSize, )

On Android, this function will be called when the app moves to foreground and the system creates a new native surface that needs to bound to the current context.

source

fn handle_browser_message(&mut self, msg: CompositorMsg) -> bool

source

fn handle_cross_process_message(&mut self, msg: CrossProcessCompositorMessage)

Accept messages from content processes that need to be relayed to the WebRender instance in the parent process.

source

fn handle_browser_message_while_shutting_down( &mut self, msg: CompositorMsg, ) -> bool

Handle messages sent to the compositor during the shutdown process. In general, the things the compositor can do in this state are limited. It’s very important to answer any synchronous messages though as other threads might be waiting on the results to finish their own shut down process. We try to do as little as possible during this time.

When that involves generating WebRender ids, our approach here is to simply generate them, but assume they will never be used, since once shutting down the compositor no longer does any WebRender frame generation.

source

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

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

source

fn change_running_animations_state( &mut self, pipeline_id: PipelineId, animation_state: AnimationState, )

Sets or unsets the animations-running flag for the given pipeline, and schedules a recomposite if necessary.

source

fn pipeline_details(&mut self, pipeline_id: PipelineId) -> &mut PipelineDetails

source

pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline>

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 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 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 set_frame_tree_for_webview(&mut self, frame_tree: &SendableFrameTree)

source

fn remove_webview( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, )

source

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

source

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

source

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

source

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

source

fn send_window_size_message_for_top_level_browser_context( &self, rect: DeviceRect, top_level_browsing_context_id: TopLevelBrowsingContextId, )

source

fn reset_scroll_tree_for_unattached_pipelines( &mut self, frame_tree: &SendableFrameTree, )

source

fn create_or_update_pipeline_details_with_frame_tree( &mut self, frame_tree: &SendableFrameTree, parent_pipeline_id: Option<PipelineId>, )

source

fn remove_pipeline_details_recursively(&mut self, pipeline_id: PipelineId)

source

fn remove_pipeline_root_layer(&mut self, pipeline_id: PipelineId)

source

pub fn on_resize_window_event(&mut self) -> bool

source

pub fn on_mouse_window_event_class( &mut self, mouse_window_event: MouseWindowEvent, )

source

fn dispatch_mouse_window_event_class( &mut self, mouse_window_event: MouseWindowEvent, )

source

fn hit_test_at_point( &self, point: DevicePoint, ) -> Option<CompositorHitTestResult>

source

fn hit_test_at_point_with_flags_and_pipeline( &self, point: DevicePoint, flags: HitTestFlags, pipeline_id: Option<WebRenderPipelineId>, ) -> Vec<CompositorHitTestResult>

source

pub fn on_mouse_window_move_event_class(&mut self, cursor: DevicePoint)

source

fn dispatch_mouse_window_move_event_class(&mut self, cursor: DevicePoint)

source

fn send_touch_event( &self, event_type: TouchEventType, identifier: TouchId, point: DevicePoint, )

source

pub fn send_wheel_event(&mut self, delta: WheelDelta, point: DevicePoint)

source

pub fn on_touch_event( &mut self, event_type: TouchEventType, identifier: TouchId, location: DevicePoint, )

source

fn on_touch_down(&mut self, identifier: TouchId, point: DevicePoint)

source

fn on_touch_move(&mut self, identifier: TouchId, point: DevicePoint)

source

fn on_touch_up(&mut self, identifier: TouchId, point: DevicePoint)

source

fn on_touch_cancel(&mut self, identifier: TouchId, point: DevicePoint)

source

fn simulate_mouse_click(&mut self, p: DevicePoint)

source

pub fn on_wheel_event(&mut self, delta: WheelDelta, p: DevicePoint)

source

pub fn on_scroll_event( &mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint, phase: TouchEventType, )

source

fn on_scroll_window_event( &mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint, )

source

fn process_pending_scroll_events(&mut self)

source

fn scroll_node_at_device_point( &mut self, cursor: DevicePoint, scroll_location: ScrollLocation, ) -> Option<(PipelineId, ExternalScrollId, LayoutVector2D)>

Perform a hit test at the given DevicePoint and apply the ScrollLocation scrolling to the applicable scroll node under that point. If a scroll was performed, returns the PipelineId of the node scrolled, the id, and the final scroll delta.

source

fn process_animations(&mut self, force: bool)

If there are any animations running, dispatches appropriate messages to the constellation.

source

fn tick_animations_for_pipeline(&mut self, pipeline_id: PipelineId)

source

fn hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel>

source

fn device_pixels_per_page_pixel(&self) -> Scale<f32, CSSPixel, DevicePixel>

source

fn device_pixels_per_page_pixel_not_including_page_zoom( &self, ) -> Scale<f32, CSSPixel, DevicePixel>

source

pub fn on_zoom_reset_window_event(&mut self)

source

pub fn on_zoom_window_event(&mut self, magnification: f32)

source

fn update_after_zoom_or_hidpi_change(&mut self)

source

pub fn on_pinch_zoom_window_event(&mut self, magnification: f32)

Simulate a pinch zoom

source

pub fn on_vsync(&mut self)

On a Window refresh tick (e.g. vsync)

source

fn send_scroll_positions_to_layout_for_pipeline(&self, pipeline_id: &PipelineId)

source

fn animations_active(&self) -> bool

source

fn animation_callbacks_active(&self) -> bool

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

source

fn is_ready_to_paint_image_output(&mut self) -> Result<(), NotReadyToPaint>

Query the constellation to see if the current compositor output matches the current frame tree output, and if the associated script threads are idle.

source

pub fn composite(&mut self)

source

fn composite_specific_target( &mut self, target: CompositeTarget, page_rect: Option<Rect<f32, CSSPixel>>, ) -> Result<Option<Image>, UnableToComposite>

Composite to the given target if any, or the current target otherwise. Returns Ok if composition was performed or Err if it was not possible to composite for some reason. When the target is CompositeTarget::SharedMemory, the image is read back from the GPU and returned as Ok(Some(png::Image)), otherwise we return Ok(None).

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 fn offscreen_framebuffer_id(&self) -> Option<GLuint>

Return the OpenGL framebuffer name of the most-recently-completed frame when compositing to CompositeTarget::Fbo, or None otherwise.

source

pub fn present(&mut self)

source

fn composite_if_necessary(&mut self, reason: CompositingReason)

source

fn clear_background(&self)

source

fn assert_no_gl_error(&self)

source

fn assert_gl_framebuffer_complete(&self)

source

pub fn receive_messages(&mut self) -> bool

source

pub fn perform_updates(&mut self) -> bool

source

pub fn repaint_synchronously(&mut self)

Repaints and recomposites synchronously. You must be careful when calling this, as if a paint is not scheduled the compositor will hang forever.

This is used when resizing the window.

source

pub fn pinch_zoom_level(&self) -> Scale<f32, DevicePixel, DevicePixel>

source

fn set_pinch_zoom_level(&mut self, zoom: f32) -> bool

source

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

source

pub fn capture_webrender(&mut self)

source

fn add_font_instance( &mut self, instance_key: FontInstanceKey, font_key: FontKey, size: f32, flags: FontInstanceFlags, )

source

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

Auto Trait Implementations§

§

impl<Window> !Freeze for IOCompositor<Window>

§

impl<Window> !RefUnwindSafe for IOCompositor<Window>

§

impl<Window> !Send for IOCompositor<Window>

§

impl<Window> !Sync for IOCompositor<Window>

§

impl<Window> Unpin for IOCompositor<Window>
where Window: ?Sized,

§

impl<Window> !UnwindSafe for IOCompositor<Window>

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

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

§

type Output = T

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