pub(crate) struct WebGLThread {
device_map: HashMap<PainterId, Rc<Device>>,
compositor_api: CrossProcessCompositorApi,
contexts: FxHashMap<WebGLContextId, GLContextData>,
cached_context_info: FxHashMap<WebGLContextId, WebGLContextInfo>,
bound_context_id: Option<WebGLContextId>,
external_image_id_manager: WebRenderExternalImageIdManager,
receiver: RoutedReceiver<WebGLMsg>,
sender: WebGLSender<WebGLMsg>,
webrender_swap_chains: SwapChains<WebGLContextId, Device>,
painter_surfman_details_map: PainterSurfmanDetailsMap,
busy_webgl_context_map: WebGLContextBusyMap,
pub webxr_bridge: Option<WebXRBridge>,
}Expand description
A WebGLThread manages the life cycle and message multiplexing of a set of WebGLContexts living in the same thread.
Fields§
§device_map: HashMap<PainterId, Rc<Device>>The GPU device.
compositor_api: CrossProcessCompositorApiChannel used to generate/update or delete ImageKeys.
contexts: FxHashMap<WebGLContextId, GLContextData>Map of live WebGLContexts.
cached_context_info: FxHashMap<WebGLContextId, WebGLContextInfo>Cached information for WebGLContexts.
bound_context_id: Option<WebGLContextId>Current bound context.
external_image_id_manager: WebRenderExternalImageIdManagerA WebRenderExternalImageIdManager used to generate new ExternalImageIds for our
WebGL contexts.
receiver: RoutedReceiver<WebGLMsg>The receiver that will be used for processing WebGL messages.
sender: WebGLSender<WebGLMsg>The receiver that should be used to send WebGL messages for processing.
webrender_swap_chains: SwapChains<WebGLContextId, Device>The swap chains used by webrender
painter_surfman_details_map: PainterSurfmanDetailsMapThe per-painter details of the underlying surfman connection.
busy_webgl_context_map: WebGLContextBusyMapA usage map used to delay the deletion of WebGL contexts until all WebRender
rendering is finished, so that any existing Surfaces can be properly released.
webxr_bridge: Option<WebXRBridge>The bridge to WebXR
Implementations§
Source§impl WebGLThread
impl WebGLThread
Sourcepub(crate) fn new(_: WebGLThreadInit) -> Self
pub(crate) fn new(_: WebGLThreadInit) -> Self
Create a new instance of WebGLThread.
Sourcepub(crate) fn run_on_own_thread(init: WebGLThreadInit)
pub(crate) fn run_on_own_thread(init: WebGLThreadInit)
Perform all initialization required to run an instance of WebGLThread in parallel on its own dedicated thread.
fn process(&mut self)
Sourcefn handle_msg(&mut self, msg: WebGLMsg, webgl_chan: &WebGLChan) -> bool
fn handle_msg(&mut self, msg: WebGLMsg, webgl_chan: &WebGLChan) -> bool
Handles a generic WebGLMsg message
fn get_or_create_device_for_painter( &mut self, painter_id: PainterId, ) -> Rc<Device>
Sourcefn handle_webxr_command(&mut self, command: WebXRCommand)
fn handle_webxr_command(&mut self, command: WebXRCommand)
Handles a WebXR message
fn device_for_context(&self, context_id: WebGLContextId) -> Rc<Device>
Sourcepub(crate) fn maybe_device_for_context(
&self,
context_id: WebGLContextId,
) -> Option<Rc<Device>>
pub(crate) fn maybe_device_for_context( &self, context_id: WebGLContextId, ) -> Option<Rc<Device>>
A function like Self::device_for_context, except that it does not panic if the context
cannot be found. This is useful for WebXR, which might try to access WebGL contexts after
they have been cleaned up.
Sourcefn handle_webgl_command(
&mut self,
context_id: WebGLContextId,
command: WebGLCommand,
backtrace: WebGLCommandBacktrace,
)
fn handle_webgl_command( &mut self, context_id: WebGLContextId, command: WebGLCommand, backtrace: WebGLCommandBacktrace, )
Handles a WebGLCommand for a specific WebGLContext
Sourcefn create_webgl_context(
&mut self,
painter_id: PainterId,
webgl_version: WebGLVersion,
requested_size: Size2D<u32>,
attributes: GLContextAttributes,
) -> Result<(WebGLContextId, GLLimits), String>
fn create_webgl_context( &mut self, painter_id: PainterId, webgl_version: WebGLVersion, requested_size: Size2D<u32>, attributes: GLContextAttributes, ) -> Result<(WebGLContextId, GLLimits), String>
Creates a new WebGLContext
Sourcefn resize_webgl_context(
&mut self,
context_id: WebGLContextId,
requested_size: Size2D<u32>,
) -> Result<(), String>
fn resize_webgl_context( &mut self, context_id: WebGLContextId, requested_size: Size2D<u32>, ) -> Result<(), String>
Resizes a WebGLContext
Sourcefn handle_finished_rendering_to_context(&mut self, context_id: WebGLContextId)
fn handle_finished_rendering_to_context(&mut self, context_id: WebGLContextId)
Note that rendering has finished in WebRender for this context. If the context is marked for deletion, it will now be deleted.
Sourcefn remove_webgl_context(&mut self, context_id: WebGLContextId)
fn remove_webgl_context(&mut self, context_id: WebGLContextId)
Removes a WebGLContext and releases attached resources.
fn handle_swap_buffers( &mut self, canvas_epoch: Option<Epoch>, context_ids: Vec<WebGLContextId>, _sent_time: u64, )
Sourcefn surface_access(&self) -> SurfaceAccess
fn surface_access(&self) -> SurfaceAccess
Which access mode to use
Sourcepub(crate) fn make_current_if_needed(
&mut self,
context_id: WebGLContextId,
) -> Option<&GLContextData>
pub(crate) fn make_current_if_needed( &mut self, context_id: WebGLContextId, ) -> Option<&GLContextData>
Gets a reference to a Context for a given WebGLContextId and makes it current if required.
Sourcepub(crate) fn make_current_if_needed_mut(
&mut self,
context_id: WebGLContextId,
) -> Option<&mut GLContextData>
pub(crate) fn make_current_if_needed_mut( &mut self, context_id: WebGLContextId, ) -> Option<&mut GLContextData>
Gets a mutable reference to a GLContextWrapper for a WebGLContextId and makes it current if required.
Sourcefn update_webrender_image_for_context(
&mut self,
context_id: WebGLContextId,
size: Size2D<i32>,
has_alpha: bool,
canvas_epoch: Option<Epoch>,
)
fn update_webrender_image_for_context( &mut self, context_id: WebGLContextId, size: Size2D<i32>, has_alpha: bool, canvas_epoch: Option<Epoch>, )
Tell WebRender to invalidate any cached tiles for a given WebGLContextId
when the underlying surface has changed e.g due to resize or buffer swap
Sourcefn external_image_data(
&self,
context_id: WebGLContextId,
) -> SerializableImageData
fn external_image_data( &self, context_id: WebGLContextId, ) -> SerializableImageData
Helper function to create a ImageData::External instance.
Sourcefn get_glsl_version(gl: &Gl) -> WebGLSLVersion
fn get_glsl_version(gl: &Gl) -> WebGLSLVersion
Gets the GLSL Version supported by a GLContext.
fn handle_set_image_key( &mut self, context_id: WebGLContextId, image_key: ImageKey, )
Trait Implementations§
Source§impl GLContexts<SurfmanGL> for WebGLThread
impl GLContexts<SurfmanGL> for WebGLThread
Auto Trait Implementations§
impl Freeze for WebGLThread
impl !RefUnwindSafe for WebGLThread
impl !Send for WebGLThread
impl !Sync for WebGLThread
impl Unpin for WebGLThread
impl !UnwindSafe for WebGLThread
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