Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DOM to texture #18592

Merged
merged 1 commit into from Oct 16, 2017
Merged

Implement DOM to texture #18592

merged 1 commit into from Oct 16, 2017

Conversation

@MortimerGoro
Copy link
Contributor

MortimerGoro commented Sep 21, 2017

This is a prototype of the WebGL DOMToTexture feature. The API should be fine as a privileged extension for now due to security concerns. The working group has been investigating the viability of unprivileged usage but the spec is not ready yet.

Demo video: https://www.youtube.com/watch?v=hpZqEM5hPao


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Sep 21, 2017

Heads up! This PR modifies the following files:

  • @asajeffrey: components/constellation/constellation.rs
  • @KiChjang: components/script/dom/webglrenderingcontext.rs, components/script/dom/webidls/WebGLRenderingContext.webidl, components/script/dom/webgltexture.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs
  • @paulrouget: components/constellation/constellation.rs, components/servo/lib.rs
  • @fitzgen: components/script/dom/webglrenderingcontext.rs, components/script/dom/webidls/WebGLRenderingContext.webidl, components/script/dom/webgltexture.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs
  • @emilio: components/canvas/webgl_mode/inprocess.rs, components/script/dom/webglrenderingcontext.rs, components/script/dom/webgltexture.rs, components/canvas/webgl_thread.rs
@highfive
Copy link

highfive commented Sep 21, 2017

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Sep 21, 2017

Related PR in WR: servo/webrender#1687

@bors-servo
Copy link
Contributor

bors-servo commented Sep 24, 2017

The latest upstream changes (presumably #18598) made this pull request unmergeable. Please resolve the merge conflicts.

/// WebGL Commands Implementation
pub struct WebGLImpl;

impl WebGLImpl {
pub fn apply<Native: NativeGLContextMethods>(ctx: &GLContext<Native>, command: WebGLCommand) {
//println!("WebGL::{:?}", command);

This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

nit: remove this.

WebGLCommand::BindTexture(target, id) =>
ctx.gl().bind_texture(target, id.map_or(0, WebGLTextureId::get)),
WebGLCommand::BindTexture(target, id) => {
ctx.gl().bind_texture(target, id.map_or(0, WebGLTextureId::get)) },

This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

nit: revert these changes.

}


This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

nit: revert this change.

@@ -379,6 +391,18 @@ pub trait WebVRRenderHandler: Send {
fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>);
}


This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

nit: remove this extra newline.

@@ -1234,6 +1234,12 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
warn!("Sending reply to get browsing context failed ({:?}).", e);
}
}
FromScriptMsg::GetDocumentId(_pipeline_id, sender) => {

This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

Why is the pipeline id included in the message if it's never used?

let (sender, receiver) = ipc::channel().unwrap();
let global = self.global();
let script_to_constellation_chan = global.script_to_constellation_chan();
script_to_constellation_chan.send(ScriptMsg::GetDocumentId(pipeline_id, sender)).unwrap();

This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

Since the document id is constant after the constellation is created, we could send that information as part of creating a script thread. This would avoid the need for sync IPC.

};

// Get PipelineId from the source
let pipeline_id = match source.pipeline_id() {

This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

let pipeline_id = source.pipeline_id().or_or(Error::InvalidState)?;

}
};

// mark that the texture is attached to DOM.

This comment has been minimized.

@jdm

jdm Sep 27, 2017

Member

I'm not sure that this comment adds anything to the code.

@MortimerGoro MortimerGoro force-pushed the MortimerGoro:dom_texture branch from 5352ac8 to f116561 Sep 28, 2017
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Sep 28, 2017

Done!

Copy link
Member

jdm left a comment

Remaining comments are all minor.

@@ -27,7 +27,7 @@ use servo_url::ServoUrl;
use style_traits::CSSPixel;
use style_traits::cursor::Cursor;
use style_traits::viewport::ViewportConstraints;
use webrender_api::ClipId;
use webrender_api::{ClipId, DocumentId};

This comment has been minimized.

@jdm

jdm Sep 28, 2017

Member

We can remove this now.

@@ -45,6 +46,8 @@ pub struct WebGLTexture {
mag_filter: Cell<Option<u32>>,
#[ignore_heap_size_of = "Defined in ipc-channel"]
renderer: WebGLMsgSender,
// True if this texture is used for the DOMToTexture feature.

This comment has been minimized.

@jdm

jdm Sep 28, 2017

Member

nit: ///

};

let pipeline_id = source.pipeline_id().ok_or(Error::InvalidState)?;
let document_id = self.global().as_window().webrender_document();

This comment has been minimized.

@jdm

jdm Sep 28, 2017

Member

We should return an error if this is invoked from a context which does not have a Window global.

@@ -654,6 +654,9 @@ interface WebGLRenderingContextBase
[Throws]
void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, TexImageSource? source); // May throw DOMException
[Throws, Pref="dom.webgl.dom_to_texture.enabled"]

This comment has been minimized.

@jdm

jdm Sep 28, 2017

Member

This does not actually throw any exceptions, so we can remove the annotation.

This comment has been minimized.

@MortimerGoro

MortimerGoro Oct 16, 2017

Author Contributor

It still throws the let pipeline_id = source.pipeline_id().or_or(Error::InvalidState)?;exception

@@ -86,6 +88,11 @@ impl WebGLMsgSender {
}
}

// Returns the WebGLContextId associated to this sender
pub fn ctx_id(&self) -> WebGLContextId {

This comment has been minimized.

@jdm

jdm Sep 28, 2017

Member

Let's call this context_id.

@@ -86,6 +88,11 @@ impl WebGLMsgSender {
}
}

// Returns the WebGLContextId associated to this sender

This comment has been minimized.

@jdm

jdm Sep 28, 2017

Member

nit: ///

@bors-servo
Copy link
Contributor

bors-servo commented Oct 13, 2017

The latest upstream changes (presumably #18840) made this pull request unmergeable. Please resolve the merge conflicts.

@MortimerGoro MortimerGoro force-pushed the MortimerGoro:dom_texture branch from 26236d8 to 9093c42 Oct 16, 2017
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Oct 16, 2017

Done. Sorry for the delay, I was on a trip ;)

@jdm
Copy link
Member

jdm commented Oct 16, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Oct 16, 2017

📌 Commit 9093c42 has been approved by jdm

@jdm
jdm approved these changes Oct 16, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Oct 16, 2017

🔒 Merge conflict

@bors-servo
Copy link
Contributor

bors-servo commented Oct 16, 2017

The latest upstream changes (presumably #18900) made this pull request unmergeable. Please resolve the merge conflicts.

@MortimerGoro MortimerGoro force-pushed the MortimerGoro:dom_texture branch from 9093c42 to 8ae0739 Oct 16, 2017
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Oct 16, 2017

Merge conflict fixed

@jdm
Copy link
Member

jdm commented Oct 16, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Oct 16, 2017

📌 Commit 8ae0739 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Oct 16, 2017

Testing commit 8ae0739 with merge 3209d22...

bors-servo added a commit that referenced this pull request Oct 16, 2017
Implement DOM to texture

<!-- Please describe your changes on the following line: -->

This is a prototype of the WebGL DOMToTexture feature. The API should be fine as a privileged extension for now due to security concerns. The working group has been investigating the viability of unprivileged usage but the spec is not ready yet.

Demo video: https://www.youtube.com/watch?v=hpZqEM5hPao

---
<!-- 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: -->
- [x] 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. -->

<!-- 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/18592)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Oct 16, 2017

@bors-servo bors-servo merged commit 8ae0739 into servo:master Oct 16, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.