diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-07-28 10:28:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-28 10:28:34 -0400 |
commit | eb4f2d150af353ecbae3eacb23b32b4ac0970ce8 (patch) | |
tree | 4fe481624e923877875b43882119aefca876568e /components/script/dom | |
parent | b52bfbe68aed9b0abb39a6e994c5dad37cf7d33c (diff) | |
parent | c757a9c009b55e7c548ee25f5cd5499f2a61d36c (diff) | |
download | servo-eb4f2d150af353ecbae3eacb23b32b4ac0970ce8.tar.gz servo-eb4f2d150af353ecbae3eacb23b32b4ac0970ce8.zip |
Auto merge of #23857 - asajeffrey:webxr-sessions-track-draw-texture, r=Manishearth
WebXR sessions track draw texture
<!-- Please describe your changes on the following line: -->
Send the XR framebuffer texture to the XR session.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because we don't have webxr reftests
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- 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/23857)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/xrsession.rs | 20 | ||||
-rw-r--r-- | components/script/dom/xrwebgllayer.rs | 4 |
2 files changed, 20 insertions, 4 deletions
diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 0a9712bb92b..60d93d4e5e0 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -6,6 +6,7 @@ use crate::compartments::InCompartment; use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods; +use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionMode; @@ -29,6 +30,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::node::Node; use crate::dom::node::NodeDamage; use crate::dom::promise::Promise; +use crate::dom::webglframebuffer::WebGLFramebufferAttachmentRoot; use crate::dom::xrframe::XRFrame; use crate::dom::xrinputsource::XRInputSource; use crate::dom::xrreferencespace::XRReferenceSpace; @@ -38,6 +40,7 @@ use crate::dom::xrspace::XRSpace; use crate::dom::xrwebgllayer::XRWebGLLayer; use crate::task_source::TaskSource; use dom_struct::dom_struct; +use euclid::default::Size2D; use euclid::RigidTransform3D; use ipc_channel::ipc::IpcSender; use ipc_channel::router::ROUTER; @@ -182,10 +185,19 @@ impl XRSession { // Step 6-7: XXXManishearth handle inlineVerticalFieldOfView // XXXManishearth handle inline sessions and composition disabled flag - let context = pending - .GetBaseLayer() - .map(|layer| layer.Context().context_id().0); - self.session.borrow_mut().set_webgl_context(context); + if let Some(layer) = pending.GetBaseLayer() { + let attachment = layer.framebuffer().attachment(constants::COLOR_ATTACHMENT0); + if let Some(WebGLFramebufferAttachmentRoot::Texture(texture)) = attachment { + let context = layer.Context().context_id().0; + let texture_id = texture.id().get(); + if let Some((width, height)) = layer.framebuffer().size() { + let size = Size2D::new(width, height); + self.session + .borrow_mut() + .set_texture(context, texture_id, size); + } + } + } } // Step 2 diff --git a/components/script/dom/xrwebgllayer.rs b/components/script/dom/xrwebgllayer.rs index 148d773fe6f..713546e1129 100644 --- a/components/script/dom/xrwebgllayer.rs +++ b/components/script/dom/xrwebgllayer.rs @@ -149,6 +149,10 @@ impl XRWebGLLayer { pub fn session(&self) -> &XRSession { &self.session } + + pub fn framebuffer(&self) -> &WebGLFramebuffer { + &self.framebuffer + } } impl XRWebGLLayerMethods for XRWebGLLayer { |