mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #26077 - jdm:xr-canvas-dirty, r=asajeffrey
webgl: Don't dirty canvas element while in immersive mode. There are various WebGL APIs that are supposed to trigger a frame composite at the end of the event loop when they're used. We enforce this via dirtying the canvas element and ensuring that reflow occurs for normal content. This is redundant when we're using immersive mode and incurs extra work by the layout thread and compositor that inhibits the immersive rendering performance. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix (part of) #26019 - [x] These changes do not require tests because we do not have infrastructure to test immersive mode on CI.
This commit is contained in:
commit
2c0bbcf2aa
3 changed files with 18 additions and 0 deletions
|
@ -59,6 +59,10 @@ impl Navigator {
|
|||
pub fn new(window: &Window) -> DomRoot<Navigator> {
|
||||
reflect_dom_object(Box::new(Navigator::new_inherited()), window)
|
||||
}
|
||||
|
||||
pub fn xr(&self) -> Option<DomRoot<XRSystem>> {
|
||||
self.xr.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl NavigatorMethods for Navigator {
|
||||
|
|
|
@ -502,6 +502,12 @@ impl WebGLRenderingContext {
|
|||
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
|
||||
.upcast::<Node>()
|
||||
.dirty(NodeDamage::OtherNodeDamage);
|
||||
|
|
|
@ -2252,6 +2252,14 @@ impl Window {
|
|||
pub fn webrender_document(&self) -> DocumentId {
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue