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>
impl<Window: WindowMethods + ?Sized> IOCompositor<Window>
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
pub fn deinit(self)
fn update_cursor(&mut self, result: CompositorHitTestResult)
pub fn maybe_start_shutting_down(&mut self)
fn start_shutting_down(&mut self)
fn finish_shutting_down(&mut self)
sourcepub fn invalidate_native_surface(&mut self)
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.
sourcepub fn replace_native_surface(
&mut self,
native_widget: *mut c_void,
coords: DeviceIntSize,
)
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.
fn handle_browser_message(&mut self, msg: CompositorMsg) -> bool
sourcefn handle_cross_process_message(&mut self, msg: CrossProcessCompositorMessage)
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.
sourcefn handle_browser_message_while_shutting_down(
&mut self,
msg: CompositorMsg,
) -> bool
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.
sourcefn generate_frame(
&mut self,
transaction: &mut Transaction,
reason: RenderReasons,
)
fn generate_frame( &mut self, transaction: &mut Transaction, reason: RenderReasons, )
Queue a new frame in the transaction and increase the pending frames count.
sourcefn change_running_animations_state(
&mut self,
pipeline_id: PipelineId,
animation_state: AnimationState,
)
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.
fn pipeline_details(&mut self, pipeline_id: PipelineId) -> &mut PipelineDetails
pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline>
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 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 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 set_frame_tree_for_webview(&mut self, frame_tree: &SendableFrameTree)
fn remove_webview( &mut self, top_level_browsing_context_id: TopLevelBrowsingContextId, )
pub fn move_resize_webview( &mut self, webview_id: TopLevelBrowsingContextId, rect: DeviceRect, )
pub fn show_webview( &mut self, webview_id: WebViewId, hide_others: bool, ) -> Result<(), UnknownWebView>
pub fn hide_webview( &mut self, webview_id: WebViewId, ) -> Result<(), UnknownWebView>
pub fn raise_webview_to_top( &mut self, webview_id: WebViewId, hide_others: bool, ) -> Result<(), UnknownWebView>
fn send_window_size_message_for_top_level_browser_context( &self, rect: DeviceRect, top_level_browsing_context_id: TopLevelBrowsingContextId, )
fn reset_scroll_tree_for_unattached_pipelines( &mut self, frame_tree: &SendableFrameTree, )
fn create_or_update_pipeline_details_with_frame_tree( &mut self, frame_tree: &SendableFrameTree, parent_pipeline_id: Option<PipelineId>, )
fn remove_pipeline_details_recursively(&mut self, pipeline_id: PipelineId)
fn remove_pipeline_root_layer(&mut self, pipeline_id: PipelineId)
pub fn on_resize_window_event(&mut self) -> bool
pub fn on_mouse_window_event_class( &mut self, mouse_window_event: MouseWindowEvent, )
fn dispatch_mouse_window_event_class( &mut self, mouse_window_event: MouseWindowEvent, )
fn hit_test_at_point( &self, point: DevicePoint, ) -> Option<CompositorHitTestResult>
fn hit_test_at_point_with_flags_and_pipeline( &self, point: DevicePoint, flags: HitTestFlags, pipeline_id: Option<WebRenderPipelineId>, ) -> Vec<CompositorHitTestResult>
pub fn on_mouse_window_move_event_class(&mut self, cursor: DevicePoint)
fn dispatch_mouse_window_move_event_class(&mut self, cursor: DevicePoint)
fn send_touch_event( &self, event_type: TouchEventType, identifier: TouchId, point: DevicePoint, )
pub fn send_wheel_event(&mut self, delta: WheelDelta, point: DevicePoint)
pub fn on_touch_event( &mut self, event_type: TouchEventType, identifier: TouchId, location: DevicePoint, )
fn on_touch_down(&mut self, identifier: TouchId, point: DevicePoint)
fn on_touch_move(&mut self, identifier: TouchId, point: DevicePoint)
fn on_touch_up(&mut self, identifier: TouchId, point: DevicePoint)
fn on_touch_cancel(&mut self, identifier: TouchId, point: DevicePoint)
sourcefn simulate_mouse_click(&mut self, p: DevicePoint)
fn simulate_mouse_click(&mut self, p: DevicePoint)
pub fn on_wheel_event(&mut self, delta: WheelDelta, p: DevicePoint)
pub fn on_scroll_event( &mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint, phase: TouchEventType, )
fn on_scroll_window_event( &mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint, )
fn process_pending_scroll_events(&mut self)
sourcefn scroll_node_at_device_point(
&mut self,
cursor: DevicePoint,
scroll_location: ScrollLocation,
) -> Option<(PipelineId, ExternalScrollId, LayoutVector2D)>
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.
sourcefn process_animations(&mut self, force: bool)
fn process_animations(&mut self, force: bool)
If there are any animations running, dispatches appropriate messages to the constellation.
fn tick_animations_for_pipeline(&mut self, pipeline_id: PipelineId)
fn hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel>
fn device_pixels_per_page_pixel(&self) -> Scale<f32, CSSPixel, DevicePixel>
fn device_pixels_per_page_pixel_not_including_page_zoom( &self, ) -> Scale<f32, CSSPixel, DevicePixel>
pub fn on_zoom_reset_window_event(&mut self)
pub fn on_zoom_window_event(&mut self, magnification: f32)
fn update_after_zoom_or_hidpi_change(&mut self)
sourcepub fn on_pinch_zoom_window_event(&mut self, magnification: f32)
pub fn on_pinch_zoom_window_event(&mut self, magnification: f32)
Simulate a pinch zoom
fn send_scroll_positions_to_layout_for_pipeline(&self, pipeline_id: &PipelineId)
fn animations_active(&self) -> bool
sourcefn animation_callbacks_active(&self) -> bool
fn animation_callbacks_active(&self) -> bool
Returns true if any animation callbacks (ie requestAnimationFrame
) are waiting for a response.
sourcefn is_ready_to_paint_image_output(&mut self) -> Result<(), NotReadyToPaint>
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.
pub fn composite(&mut self)
sourcefn composite_specific_target(
&mut self,
target: CompositeTarget,
page_rect: Option<Rect<f32, CSSPixel>>,
) -> Result<Option<Image>, UnableToComposite>
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).
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 fn offscreen_framebuffer_id(&self) -> Option<GLuint>
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.
pub fn present(&mut self)
fn composite_if_necessary(&mut self, reason: CompositingReason)
fn clear_background(&self)
fn assert_no_gl_error(&self)
fn assert_gl_framebuffer_complete(&self)
pub fn receive_messages(&mut self) -> bool
pub fn perform_updates(&mut self) -> bool
sourcepub fn repaint_synchronously(&mut self)
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.
pub fn pinch_zoom_level(&self) -> Scale<f32, DevicePixel, DevicePixel>
fn set_pinch_zoom_level(&mut self, zoom: f32) -> bool
pub fn toggle_webrender_debug(&mut self, option: WebRenderDebugOption)
pub fn capture_webrender(&mut self)
fn add_font_instance( &mut self, instance_key: FontInstanceKey, font_key: FontKey, size: f32, flags: FontInstanceFlags, )
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> 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