webgl: Don't dirty canvas element while in immersive mode.

This commit is contained in:
Josh Matthews 2020-03-31 14:21:55 -04:00
parent 148c24c29c
commit ab75808b8c
3 changed files with 18 additions and 0 deletions

View file

@ -59,6 +59,10 @@ impl Navigator {
pub fn new(window: &Window) -> DomRoot<Navigator> { pub fn new(window: &Window) -> DomRoot<Navigator> {
reflect_dom_object(Box::new(Navigator::new_inherited()), window) reflect_dom_object(Box::new(Navigator::new_inherited()), window)
} }
pub fn xr(&self) -> Option<DomRoot<XRSystem>> {
self.xr.get()
}
} }
impl NavigatorMethods for Navigator { impl NavigatorMethods for Navigator {

View file

@ -502,6 +502,12 @@ impl WebGLRenderingContext {
return; return;
} }
// Dirtying the canvas is unnecessary if we're actively displaying immersive
// XR content right now.
if self.global().as_window().in_immersive_xr_session() {
return;
}
self.canvas self.canvas
.upcast::<Node>() .upcast::<Node>()
.dirty(NodeDamage::OtherNodeDamage); .dirty(NodeDamage::OtherNodeDamage);

View file

@ -2225,6 +2225,14 @@ impl Window {
pub fn webrender_document(&self) -> DocumentId { pub fn webrender_document(&self) -> DocumentId {
self.webrender_document self.webrender_document
} }
pub fn in_immersive_xr_session(&self) -> bool {
self.navigator
.get()
.as_ref()
.and_then(|nav| nav.xr())
.map_or(false, |xr| xr.pending_or_active_session())
}
} }
impl Window { impl Window {