mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Correctly clamp ivfov and depth values
This commit is contained in:
parent
f52a6f0e8f
commit
3414c8d22d
2 changed files with 23 additions and 7 deletions
|
@ -46,6 +46,7 @@ use ipc_channel::router::ROUTER;
|
||||||
use metrics::ToMs;
|
use metrics::ToMs;
|
||||||
use profile_traits::ipc;
|
use profile_traits::ipc;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::f64::consts::{FRAC_PI_2, PI};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use webxr_api::{
|
use webxr_api::{
|
||||||
|
@ -116,7 +117,6 @@ impl XRSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, session: Session, mode: XRSessionMode) -> DomRoot<XRSession> {
|
pub fn new(global: &GlobalScope, session: Session, mode: XRSessionMode) -> DomRoot<XRSession> {
|
||||||
use std::f64::consts::FRAC_PI_2;
|
|
||||||
let ivfov = if mode == XRSessionMode::Inline {
|
let ivfov = if mode == XRSessionMode::Inline {
|
||||||
Some(FRAC_PI_2)
|
Some(FRAC_PI_2)
|
||||||
} else {
|
} else {
|
||||||
|
@ -470,13 +470,33 @@ impl XRSessionMethods for XRSession {
|
||||||
.pending_render_state
|
.pending_render_state
|
||||||
.or_init(|| self.active_render_state.get().clone_object());
|
.or_init(|| self.active_render_state.get().clone_object());
|
||||||
if let Some(near) = init.depthNear {
|
if let Some(near) = init.depthNear {
|
||||||
pending.set_depth_near(*near);
|
let mut near = *near;
|
||||||
|
// Step 8 from #apply-the-pending-render-state
|
||||||
|
// this may need to be changed if backends wish to impose
|
||||||
|
// further constraints
|
||||||
|
if near < 0. {
|
||||||
|
near = 0.;
|
||||||
|
}
|
||||||
|
pending.set_depth_near(near);
|
||||||
}
|
}
|
||||||
if let Some(far) = init.depthFar {
|
if let Some(far) = init.depthFar {
|
||||||
|
// Step 9 from #apply-the-pending-render-state
|
||||||
|
// this may need to be changed if backends wish to impose
|
||||||
|
// further constraints
|
||||||
|
// currently the maximum is infinity, so we do nothing
|
||||||
pending.set_depth_far(*far);
|
pending.set_depth_far(*far);
|
||||||
}
|
}
|
||||||
if let Some(fov) = init.inlineVerticalFieldOfView {
|
if let Some(fov) = init.inlineVerticalFieldOfView {
|
||||||
pending.set_inline_vertical_fov(*fov);
|
let mut fov = *fov;
|
||||||
|
// Step 10 from #apply-the-pending-render-state
|
||||||
|
// this may need to be changed if backends wish to impose
|
||||||
|
// further constraints
|
||||||
|
if fov < 0. {
|
||||||
|
fov = 0.0001;
|
||||||
|
} else if fov > PI {
|
||||||
|
fov = PI - 0.0001;
|
||||||
|
}
|
||||||
|
pending.set_inline_vertical_fov(fov);
|
||||||
}
|
}
|
||||||
if let Some(ref layer) = init.baseLayer {
|
if let Some(ref layer) = init.baseLayer {
|
||||||
pending.set_layer(Some(&layer))
|
pending.set_layer(Some(&layer))
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[render_state_vertical_fov_inline.https.html]
|
|
||||||
[inlineVerticalFieldOfView is set appropriately on inline sessions]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue