Auto merge of #22528 - Manishearth:webxr, r=jdm,MortimerGoro

Preliminary WebXR support

This implements just enough WebXR to display to 3DOF devices in
immersive mode only.

Couple missing things:

 - [ ] Handling reference spaces (even if just supporting eye-level spaces)
 - [x] Spec links
 - [ ] We enter immersive mode when baseLayer is set, but it seems like
we're supposed to do this when requestSession is called (https://github.com/immersive-web/webxr/issues/453)
 - [ ] VR/XR should block less (https://github.com/servo/servo/issues/22505)
 - [x] More pref-gating
 - [x] `views` is a method instead of an attribute because we don't support FrozenArray

<s>Once I add spec links and pref gating</s> this can be landed as-is for further experimentation.

r? @jdm @MortimerGoro

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22528)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-01-04 02:54:16 -05:00 committed by GitHub
commit c4a6dcfe4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 1092 additions and 71 deletions

View file

@ -157,6 +157,7 @@ pub struct WebGLRenderingContext {
current_scissor: Cell<(i32, i32, u32, u32)>,
#[ignore_malloc_size_of = "Because it's small"]
current_clear_color: Cell<(f32, f32, f32, f32)>,
size: Cell<Size2D<u32>>,
extension_manager: WebGLExtensions,
capabilities: Capabilities,
default_vao: DomOnceCell<WebGLVertexArrayObjectOES>,
@ -211,6 +212,9 @@ impl WebGLRenderingContext {
current_program: MutNullableDom::new(None),
current_vertex_attrib_0: Cell::new((0f32, 0f32, 0f32, 1f32)),
current_scissor: Cell::new((0, 0, size.width, size.height)),
// FIXME(#21718) The backend is allowed to choose a size smaller than
// what was requested
size: Cell::new(size),
current_clear_color: Cell::new((0.0, 0.0, 0.0, 0.0)),
extension_manager: WebGLExtensions::new(webgl_version),
capabilities: Default::default(),
@ -266,6 +270,9 @@ impl WebGLRenderingContext {
pub fn recreate(&self, size: Size2D<u32>) {
let (sender, receiver) = webgl_channel().unwrap();
self.webgl_sender.send_resize(size, sender).unwrap();
// FIXME(#21718) The backend is allowed to choose a size smaller than
// what was requested
self.size.set(size);
if let Err(msg) = receiver.recv().unwrap() {
error!("Error resizing WebGLContext: {}", msg);
@ -340,6 +347,10 @@ impl WebGLRenderingContext {
}
}
pub fn size(&self) -> Size2D<u32> {
self.size.get()
}
// Helper function for validating framebuffer completeness in
// calls touching the framebuffer. From the GLES 2.0.25 spec,
// page 119: