aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-06-15 14:22:21 -0400
committerGitHub <noreply@github.com>2020-06-15 14:22:21 -0400
commitabc3ed40c9daf8c7a68d82a2d5fb40ad632eb27f (patch)
tree4f3d3d6f91d4b140db7d1d40eb28051228b09f8d /components/script/dom/document.rs
parent24cc72ba85fdec01ecc135313b09ae78d7b9b5f8 (diff)
parent2c95df73a4d74b24db451e5ff1d3ccc5ced10fe2 (diff)
downloadservo-abc3ed40c9daf8c7a68d82a2d5fb40ad632eb27f.tar.gz
servo-abc3ed40c9daf8c7a68d82a2d5fb40ad632eb27f.zip
Auto merge of #26872 - kunalmohan:gpu-canvas-context, r=kvark,jdm
Implement GPUSwapChain and GPUCanvasContext and interface with Webrender <!-- Please describe your changes on the following line: --> r?@kvark --- <!-- 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 - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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. -->
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 385f7c2139e..1d0aabc3d51 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -53,6 +53,7 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable, EventDefault, Even
use crate::dom::eventtarget::EventTarget;
use crate::dom::focusevent::FocusEvent;
use crate::dom::globalscope::GlobalScope;
+use crate::dom::gpucanvascontext::{GPUCanvasContext, WebGPUContextId};
use crate::dom::hashchangeevent::HashChangeEvent;
use crate::dom::htmlanchorelement::HTMLAnchorElement;
use crate::dom::htmlareaelement::HTMLAreaElement;
@@ -387,6 +388,8 @@ pub struct Document {
media_controls: DomRefCell<HashMap<String, Dom<ShadowRoot>>>,
/// List of all WebGL context IDs that need flushing.
dirty_webgl_contexts: DomRefCell<HashMap<WebGLContextId, Dom<WebGLRenderingContext>>>,
+ /// List of all WebGPU context IDs that need flushing.
+ dirty_webgpu_contexts: DomRefCell<HashMap<WebGPUContextId, Dom<GPUCanvasContext>>>,
/// https://html.spec.whatwg.org/multipage/#concept-document-csp-list
#[ignore_malloc_size_of = "Defined in rust-content-security-policy"]
csp_list: DomRefCell<Option<CspList>>,
@@ -2685,14 +2688,14 @@ impl Document {
}
}
- pub fn add_dirty_canvas(&self, context: &WebGLRenderingContext) {
+ pub fn add_dirty_webgl_canvas(&self, context: &WebGLRenderingContext) {
self.dirty_webgl_contexts
.borrow_mut()
.entry(context.context_id())
.or_insert_with(|| Dom::from_ref(context));
}
- pub fn flush_dirty_canvases(&self) {
+ pub fn flush_dirty_webgl_canvases(&self) {
let dirty_context_ids: Vec<_> = self
.dirty_webgl_contexts
.borrow_mut()
@@ -2720,6 +2723,21 @@ impl Document {
receiver.recv().unwrap();
}
+ pub fn add_dirty_webgpu_canvas(&self, context: &GPUCanvasContext) {
+ self.dirty_webgpu_contexts
+ .borrow_mut()
+ .entry(context.context_id())
+ .or_insert_with(|| Dom::from_ref(context));
+ }
+
+ #[allow(unrooted_must_root)]
+ pub fn flush_dirty_webgpu_canvases(&self) {
+ self.dirty_webgpu_contexts
+ .borrow_mut()
+ .drain()
+ .for_each(|(_, context)| context.send_swap_chain_present());
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
// (This takes the filter as a method so the window named getter can use it too)
pub fn supported_property_names_impl(
@@ -3081,6 +3099,7 @@ impl Document {
shadow_roots_styles_changed: Cell::new(false),
media_controls: DomRefCell::new(HashMap::new()),
dirty_webgl_contexts: DomRefCell::new(HashMap::new()),
+ dirty_webgpu_contexts: DomRefCell::new(HashMap::new()),
csp_list: DomRefCell::new(None),
selection: MutNullableDom::new(None),
animation_timeline: if pref!(layout.animations.test.enabled) {