mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #23785 - asajeffrey:script-webxr-dirty-canvas, r=Manishearth
Dirty the canvas when WebXR draws to its GL context <!-- Please describe your changes on the following line: --> When webxr draws to a WebGL rendering context backed by a canvas that's attached to the DOM, we should repaint the DOM. (At least that's my reading of the spec!) --- <!-- 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 I'm not sure how we'd test this <!-- 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/23785) <!-- Reviewable:end -->
This commit is contained in:
commit
cef98d2e51
1 changed files with 17 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
|||
use crate::compartments::InCompartment;
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionMode;
|
||||
use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenceSpaceType;
|
||||
use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateInit;
|
||||
|
@ -22,6 +23,8 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
|||
use crate::dom::bindings::root::{Dom, DomRoot, MutDom, MutNullableDom};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::node::Node;
|
||||
use crate::dom::node::NodeDamage;
|
||||
use crate::dom::promise::Promise;
|
||||
use crate::dom::xrframe::XRFrame;
|
||||
use crate::dom::xrinputsource::XRInputSource;
|
||||
|
@ -130,9 +133,10 @@ impl XRSession {
|
|||
}
|
||||
|
||||
// Step 2
|
||||
if self.active_render_state.get().GetBaseLayer().is_none() {
|
||||
return;
|
||||
}
|
||||
let base_layer = match self.active_render_state.get().GetBaseLayer() {
|
||||
Some(layer) => layer,
|
||||
None => return,
|
||||
};
|
||||
|
||||
// Step 3: XXXManishearth handle inline session
|
||||
|
||||
|
@ -153,6 +157,16 @@ impl XRSession {
|
|||
|
||||
// Step 9: XXXManishearth unset `active` bool on `frame`
|
||||
self.session.borrow_mut().render_animation_frame();
|
||||
|
||||
// If the canvas element is attached to the DOM, it is now dirty,
|
||||
// and we need to trigger a reflow.
|
||||
if let Some(webgl_layer) = base_layer.downcast::<XRWebGLLayer>() {
|
||||
webgl_layer
|
||||
.Context()
|
||||
.Canvas()
|
||||
.upcast::<Node>()
|
||||
.dirty(NodeDamage::OtherNodeDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue