WebGLThread

Struct WebGLThread 

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

Channel 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: WebRenderExternalImageIdManager

A 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: PainterSurfmanDetailsMap

The per-painter details of the underlying surfman connection.

§busy_webgl_context_map: WebGLContextBusyMap

A 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

Source

pub(crate) fn new(_: WebGLThreadInit) -> Self

Create a new instance of WebGLThread.

Source

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.

Source

fn process(&mut self)

Source

fn handle_msg(&mut self, msg: WebGLMsg, webgl_chan: &WebGLChan) -> bool

Handles a generic WebGLMsg message

Source

fn get_or_create_device_for_painter( &mut self, painter_id: PainterId, ) -> Rc<Device>

Source

fn handle_webxr_command(&mut self, command: WebXRCommand)

Handles a WebXR message

Source

fn device_for_context(&self, context_id: WebGLContextId) -> Rc<Device>

Source

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.

Source

fn handle_webgl_command( &mut self, context_id: WebGLContextId, command: WebGLCommand, backtrace: WebGLCommandBacktrace, )

Handles a WebGLCommand for a specific WebGLContext

Source

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

Source

fn resize_webgl_context( &mut self, context_id: WebGLContextId, requested_size: Size2D<u32>, ) -> Result<(), String>

Resizes a WebGLContext

Source

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.

Source

fn remove_webgl_context(&mut self, context_id: WebGLContextId)

Removes a WebGLContext and releases attached resources.

Source

fn handle_swap_buffers( &mut self, canvas_epoch: Option<Epoch>, context_ids: Vec<WebGLContextId>, _sent_time: u64, )

Source

fn surface_access(&self) -> SurfaceAccess

Which access mode to use

Source

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.

Source

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.

Source

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

Source

fn external_image_data( &self, context_id: WebGLContextId, ) -> SerializableImageData

Helper function to create a ImageData::External instance.

Source

fn get_glsl_version(gl: &Gl) -> WebGLSLVersion

Gets the GLSL Version supported by a GLContext.

Source

fn handle_set_image_key( &mut self, context_id: WebGLContextId, image_key: ImageKey, )

Trait Implementations§

Source§

impl GLContexts<SurfmanGL> for WebGLThread

Source§

fn device(&self, context_id: WebXRContextId) -> Option<Rc<Device>>

Source§

fn context(&mut self, context_id: WebXRContextId) -> Option<&mut Context>

Source§

fn bindings(&mut self, context_id: WebXRContextId) -> Option<&Context>

Auto Trait Implementations§

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