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 ImageKey
s.
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
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
sourcefn handle_webxr_command(&mut self, command: WebXRCommand)
fn handle_webxr_command(&mut self, command: WebXRCommand)
Handles a WebXR message
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,
webgl_version: WebGLVersion,
requested_size: Size2D<u32>,
attributes: GLContextAttributes,
) -> Result<(WebGLContextId, GLLimits), String>
fn create_webgl_context( &mut self, 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 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, context_ids: Vec<WebGLContextId>, completed_sender: WebGLSender<u64>, _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<'a>(
device: &Device,
context_id: WebGLContextId,
contexts: &'a FnvHashMap<WebGLContextId, GLContextData>,
bound_id: &mut Option<WebGLContextId>,
) -> Option<&'a GLContextData>
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.
sourcepub(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>
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.
sourcefn create_wr_external_image(
webrender_api: &mut RenderApi,
webrender_doc: DocumentId,
size: Size2D<i32>,
alpha: bool,
context_id: WebGLContextId,
image_buffer_kind: ImageBufferKind,
) -> ImageKey
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.
sourcefn update_wr_image_for_context(
&mut self,
context_id: WebGLContextId,
size: Size2D<i32>,
has_alpha: bool,
)
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
sourcefn image_descriptor(size: Size2D<i32>, alpha: bool) -> ImageDescriptor
fn image_descriptor(size: Size2D<i32>, alpha: bool) -> ImageDescriptor
Helper function to create a ImageDescriptor
.
sourcefn external_image_data(
context_id: WebGLContextId,
image_buffer_kind: ImageBufferKind,
) -> ImageData
fn external_image_data( context_id: WebGLContextId, image_buffer_kind: ImageBufferKind, ) -> ImageData
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.
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