mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use surfman with glow bindings (take II) (#35422)
* Reapply "Use surfman with glow bindings (#34328)" (#35402)
This reverts commit 0fed99590a
.
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* update surfman
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
48e38bcaa2
commit
610a1c2303
13 changed files with 69 additions and 97 deletions
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
use canvas_traits::webgl::{
|
||||
webgl_channel, WebGLContextId, WebGLMsg, WebGLSender, WebXRCommand, WebXRLayerManagerId,
|
||||
|
@ -25,7 +26,7 @@ use crate::webgl_thread::{GLContextData, WebGLThread};
|
|||
pub(crate) struct WebXRBridge {
|
||||
factory_receiver: crossbeam_channel::Receiver<WebXRLayerManagerFactory<WebXRSurfman>>,
|
||||
managers: HashMap<WebXRLayerManagerId, Box<dyn WebXRLayerManagerAPI<WebXRSurfman>>>,
|
||||
next_manager_id: u32,
|
||||
next_manager_id: NonZeroU32,
|
||||
}
|
||||
|
||||
impl WebXRBridge {
|
||||
|
@ -34,7 +35,7 @@ impl WebXRBridge {
|
|||
factory_receiver, ..
|
||||
} = init;
|
||||
let managers = HashMap::new();
|
||||
let next_manager_id = 1;
|
||||
let next_manager_id = NonZeroU32::MIN;
|
||||
WebXRBridge {
|
||||
factory_receiver,
|
||||
managers,
|
||||
|
@ -55,8 +56,11 @@ impl WebXRBridge {
|
|||
.recv()
|
||||
.map_err(|_| WebXRError::CommunicationError)?;
|
||||
let manager = factory.build(device, contexts)?;
|
||||
let manager_id = unsafe { WebXRLayerManagerId::new(self.next_manager_id) };
|
||||
self.next_manager_id += 1;
|
||||
let manager_id = WebXRLayerManagerId::new(self.next_manager_id);
|
||||
self.next_manager_id = self
|
||||
.next_manager_id
|
||||
.checked_add(1)
|
||||
.expect("next_manager_id should not overflow");
|
||||
self.managers.insert(manager_id, manager);
|
||||
Ok(manager_id)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue