Filter out webidl files based on special comments, and feature-gate webxr interfaces. (#34348)

* Filter out webidl files based on skip-if directives.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Don't build XR functionality without webxr feature.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix tidy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Adjust imports for file movement.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Clean up webxr module import.

Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Josh Matthews 2024-11-24 13:01:35 -05:00 committed by GitHub
parent e956f3124c
commit 3faed9b921
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
94 changed files with 206 additions and 53 deletions

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![allow(unused_imports)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use std::cell::Cell;
@ -11,6 +13,7 @@ use canvas_traits::webgl::{
};
use dom_struct::dom_struct;
use euclid::Size2D;
#[cfg(feature = "webxr")]
use webxr_api::Viewport;
use crate::dom::bindings::cell::DomRefCell;
@ -22,6 +25,7 @@ use crate::dom::webglobject::WebGLObject;
use crate::dom::webglrenderbuffer::WebGLRenderbuffer;
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
use crate::dom::webgltexture::WebGLTexture;
#[cfg(feature = "webxr")]
use crate::dom::xrsession::XRSession;
pub enum CompleteForRendering {
@ -108,6 +112,7 @@ pub struct WebGLFramebuffer {
is_initialized: Cell<bool>,
// Framebuffers for XR keep a reference to the XR session.
// https://github.com/immersive-web/webxr/issues/856
#[cfg(feature = "webxr")]
xr_session: MutNullableDom<XRSession>,
}
@ -128,6 +133,7 @@ impl WebGLFramebuffer {
color_read_buffer: DomRefCell::new(constants::COLOR_ATTACHMENT0),
color_draw_buffers: DomRefCell::new(vec![constants::COLOR_ATTACHMENT0]),
is_initialized: Cell::new(false),
#[cfg(feature = "webxr")]
xr_session: Default::default(),
}
}
@ -142,6 +148,7 @@ impl WebGLFramebuffer {
// TODO: depth, stencil and alpha
// https://github.com/servo/servo/issues/24498
#[cfg(feature = "webxr")]
pub fn maybe_new_webxr(
session: &XRSession,
context: &WebGLRenderingContext,
@ -167,10 +174,16 @@ impl WebGLFramebuffer {
self.id
}
#[cfg(feature = "webxr")]
fn is_in_xr_session(&self) -> bool {
self.xr_session.get().is_some()
}
#[cfg(not(feature = "webxr"))]
fn is_in_xr_session(&self) -> bool {
false
}
pub fn validate_transparent(&self) -> WebGLResult<()> {
if self.is_in_xr_session() {
Err(WebGLError::InvalidOperation)
@ -445,15 +458,16 @@ impl WebGLFramebuffer {
pub fn check_status(&self) -> u32 {
// For opaque framebuffers, check to see if the XR session is currently processing an rAF
// https://immersive-web.github.io/webxr/#opaque-framebuffer
#[cfg(feature = "webxr")]
if let Some(xr_session) = self.xr_session.get() {
if xr_session.is_outside_raf() {
return if xr_session.is_outside_raf() {
constants::FRAMEBUFFER_UNSUPPORTED
} else {
constants::FRAMEBUFFER_COMPLETE
}
} else {
self.status.get()
};
}
self.status.get()
// TODO: if a framebuffer has an attachment which is invalid due to
// being outside a webxr rAF, should this make the framebuffer incomplete?
// https://github.com/immersive-web/layers/issues/196
@ -467,6 +481,7 @@ impl WebGLFramebuffer {
// XR framebuffers are complete inside an rAF
// https://github.com/immersive-web/webxr/issues/854
#[cfg(feature = "webxr")]
if self.xr_session.get().is_some() {
return CompleteForRendering::Complete;
}