Struct canvas::webgl_thread::WebGLThread

source ·
pub(crate) struct WebGLThread {
    device: Device,
    webrender_api: RenderApi,
    webrender_doc: DocumentId,
    contexts: FnvHashMap<WebGLContextId, GLContextData>,
    cached_context_info: FnvHashMap<WebGLContextId, WebGLContextInfo>,
    bound_context_id: Option<WebGLContextId>,
    external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
    receiver: Receiver<WebGLMsg>,
    sender: WebGLSender<WebGLMsg>,
    webrender_swap_chains: SwapChains<WebGLContextId, Device>,
    api_type: GlType,
    pub webxr_bridge: WebXRBridge,
}
Expand description

A WebGLThread manages the life cycle and message multiplexing of a set of WebGLContexts living in the same thread.

Fields§

§device: Device

The GPU device.

§webrender_api: RenderApi

Channel used to generate/update or delete ImageKeys.

§webrender_doc: DocumentId§contexts: FnvHashMap<WebGLContextId, GLContextData>

Map of live WebGLContexts.

§cached_context_info: FnvHashMap<WebGLContextId, WebGLContextInfo>

Cached information for WebGLContexts.

§bound_context_id: Option<WebGLContextId>

Current bound context.

§external_images: Arc<Mutex<WebrenderExternalImageRegistry>>

List of registered webrender external images. We use it to get an unique ID for new WebGLContexts.

§receiver: Receiver<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

§api_type: GlType

Whether this context is a GL or GLES context.

§webxr_bridge: 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 handle_webxr_command(&mut self, command: WebXRCommand)

Handles a WebXR message

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, 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 remove_webgl_context(&mut self, context_id: WebGLContextId)

Removes a WebGLContext and releases attached resources.

source

fn handle_swap_buffers( &mut self, context_ids: Vec<WebGLContextId>, completed_sender: WebGLSender<u64>, _sent_time: u64, )

source

fn surface_access(&self) -> SurfaceAccess

Which access mode to use

source

pub(crate) fn make_current_if_needed<'a>( device: &Device, context_id: WebGLContextId, contexts: &'a FnvHashMap<WebGLContextId, GLContextData>, bound_id: &mut Option<WebGLContextId>, ) -> Option<&'a 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<'a>( device: &Device, context_id: WebGLContextId, contexts: &'a mut FnvHashMap<WebGLContextId, GLContextData>, bound_id: &mut Option<WebGLContextId>, ) -> Option<&'a mut GLContextData>

Gets a mutable reference to a GLContextWrapper for a WebGLContextId and makes it current if required.

source

fn create_wr_external_image( webrender_api: &mut RenderApi, webrender_doc: DocumentId, size: Size2D<i32>, alpha: bool, context_id: WebGLContextId, image_buffer_kind: ImageBufferKind, ) -> ImageKey

Creates a webrender_api::ImageKey that uses shared textures.

source

fn update_wr_image_for_context( &mut self, context_id: WebGLContextId, size: Size2D<i32>, has_alpha: bool, )

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 image_descriptor(size: Size2D<i32>, alpha: bool) -> ImageDescriptor

Helper function to create a ImageDescriptor.

source

fn external_image_data( context_id: WebGLContextId, image_buffer_kind: ImageBufferKind, ) -> ImageData

Helper function to create a ImageData::External instance.

source

fn get_glsl_version(gl: &Gl) -> WebGLSLVersion

Gets the GLSL Version supported by a GLContext.

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