diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-03-09 08:05:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 08:05:59 -0400 |
commit | d867994dfba504c5293104d7fed2aaca60c1af3a (patch) | |
tree | b28247640a9879ca37a5c4a9855bb06901b3ae05 /components/script/dom | |
parent | e1f6dfd7165d89246b35233fffe159352884b477 (diff) | |
parent | ced67af6b2519c577f7830ea76e0426ff44a9a2a (diff) | |
download | servo-d867994dfba504c5293104d7fed2aaca60c1af3a.tar.gz servo-d867994dfba504c5293104d7fed2aaca60c1af3a.zip |
Auto merge of #25915 - mmatyas:webgl_fns_getfragdataloc, r=jdm
Add support for WebGL2 GetFragDataLocation
Adds support for the `GetFragDataLocation` WebGL2 call.
See: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.7
<!-- Please describe your changes on the following line: -->
Depends on https://github.com/servo/sparkle/pull/25
No test updates yet due to #25908.
cc @jdm @zakorgy
---
<!-- 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] There are tests for these changes
<!-- 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')
-rw-r--r-- | components/script/dom/webgl2renderingcontext.rs | 6 | ||||
-rw-r--r-- | components/script/dom/webglprogram.rs | 24 | ||||
-rw-r--r-- | components/script/dom/webidls/WebGL2RenderingContext.webidl | 2 |
3 files changed, 31 insertions, 1 deletions
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index ec2741c44dd..d6452a88043 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -1467,6 +1467,12 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { self.base.GetAttribLocation(program, name) } + /// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.7 + fn GetFragDataLocation(&self, program: &WebGLProgram, name: DOMString) -> i32 { + handle_potential_webgl_error!(self.base, self.base.validate_ownership(program), return -1); + handle_potential_webgl_error!(self.base, program.get_frag_data_location(name), -1) + } + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 fn GetProgramInfoLog(&self, program: &WebGLProgram) -> Option<DOMString> { self.base.GetProgramInfoLog(program) diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 556573aae2e..4bb59fb1428 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -365,6 +365,30 @@ impl WebGLProgram { Ok(location) } + /// glGetFragDataLocation + pub fn get_frag_data_location(&self, name: DOMString) -> WebGLResult<i32> { + if !self.is_linked() || self.is_deleted() { + return Err(WebGLError::InvalidOperation); + } + + if !validate_glsl_name(&name)? { + return Ok(-1); + } + if name.starts_with("gl_") { + return Ok(-1); + } + + let (sender, receiver) = webgl_channel().unwrap(); + self.upcast::<WebGLObject>() + .context() + .send_command(WebGLCommand::GetFragDataLocation( + self.id, + name.into(), + sender, + )); + Ok(receiver.recv().unwrap()) + } + /// glGetUniformLocation pub fn get_uniform_location( &self, diff --git a/components/script/dom/webidls/WebGL2RenderingContext.webidl b/components/script/dom/webidls/WebGL2RenderingContext.webidl index 21ddea415da..157fe38f892 100644 --- a/components/script/dom/webidls/WebGL2RenderingContext.webidl +++ b/components/script/dom/webidls/WebGL2RenderingContext.webidl @@ -422,7 +422,7 @@ interface mixin WebGL2RenderingContextBase // optional GLuint srcLengthOverride = 0); /* Programs and shaders */ - // [WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram program, DOMString name); + [WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram program, DOMString name); /* Uniforms */ void uniform1ui(WebGLUniformLocation? location, GLuint v0); |