Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement DOM to texture #18592
Implement DOM to texture #18592
Conversation
highfive
commented
Sep 21, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
Sep 21, 2017
|
Related PR in WR: servo/webrender#1687 |
|
|
| /// 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.
This comment has been minimized.
| 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.
This comment has been minimized.
| @@ -379,6 +391,18 @@ pub trait WebVRRenderHandler: Send { | |||
| fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>); | |||
| } | |||
|
|
|||
|
|
|||
This comment has been minimized.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
| 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.
This comment has been minimized.
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.
This comment has been minimized.
| } | ||
| }; | ||
|
|
||
| // mark that the texture is attached to DOM. |
This comment has been minimized.
This comment has been minimized.
|
Done! |
|
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.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
| }; | ||
|
|
||
| let pipeline_id = source.pipeline_id().ok_or(Error::InvalidState)?; | ||
| let document_id = self.global().as_window().webrender_document(); |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
jdm
Sep 28, 2017
Member
This does not actually throw any exceptions, so we can remove the annotation.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
| @@ -86,6 +88,11 @@ impl WebGLMsgSender { | |||
| } | |||
| } | |||
|
|
|||
| // Returns the WebGLContextId associated to this sender | |||
This comment has been minimized.
This comment has been minimized.
|
|
|
Done. Sorry for the delay, I was on a trip ;) |
|
@bors-servo: r+ |
|
|
|
|
|
|
|
Merge conflict fixed |
|
@bors-servo: r+ |
|
|
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 -->
|
|
MortimerGoro commentedSep 21, 2017
•
edited by SimonSapin
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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is