aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglprogram.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-04-03 00:08:47 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2016-04-03 00:08:47 +0530
commit8b32e63db843b4ac534c33a87ed53a4acf9b6da7 (patch)
treea96e3c8742dae55815e6691369fdd1bc1d91e590 /components/script/dom/webglprogram.rs
parent85f9f9626eaff12b66299eb6190955f2726b432c (diff)
parent3fd7634f545871603577d83a08950ab6f7026f1c (diff)
downloadservo-8b32e63db843b4ac534c33a87ed53a4acf9b6da7.tar.gz
servo-8b32e63db843b4ac534c33a87ed53a4acf9b6da7.zip
Auto merge of #10215 - ConnorGBrewster:webgl_finish, r=emilio
WebGL: Finish, Flush, DetachShader, GenerateMipmap Implements #10212 and #10213 r? @emilio <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10215) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/webglprogram.rs')
-rw-r--r--components/script/dom/webglprogram.rs31
1 files changed, 30 insertions, 1 deletions
diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs
index 338a1e8d46b..378039b03eb 100644
--- a/components/script/dom/webglprogram.rs
+++ b/components/script/dom/webglprogram.rs
@@ -94,7 +94,10 @@ impl WebGLProgram {
let shader_slot = match shader.gl_type() {
constants::FRAGMENT_SHADER => &self.fragment_shader,
constants::VERTEX_SHADER => &self.vertex_shader,
- _ => return Err(WebGLError::InvalidOperation),
+ _ => {
+ error!("detachShader: Unexpected shader type");
+ return Err(WebGLError::InvalidValue);
+ }
};
// TODO(emilio): Differentiate between same shader already assigned and other previous
@@ -110,6 +113,32 @@ impl WebGLProgram {
Ok(())
}
+ /// glDetachShader
+ pub fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
+ let shader_slot = match shader.gl_type() {
+ constants::FRAGMENT_SHADER => &self.fragment_shader,
+ constants::VERTEX_SHADER => &self.vertex_shader,
+ _ => {
+ error!("detachShader: Unexpected shader type");
+ return Err(WebGLError::InvalidValue);
+ }
+ };
+
+ match shader_slot.get() {
+ Some(ref attached_shader) if attached_shader.id() != shader.id() =>
+ return Err(WebGLError::InvalidOperation),
+ None =>
+ return Err(WebGLError::InvalidOperation),
+ _ => {}
+ }
+
+ shader_slot.set(None);
+
+ self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DetachShader(self.id, shader.id()))).unwrap();
+
+ Ok(())
+ }
+
/// glBindAttribLocation
pub fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> {
if name.len() > MAX_UNIFORM_AND_ATTRIBUTE_LEN {