servo: Merge #10379 - Implement GetActiveAttrib (from dzbarsky:getActiveAttrib); r=emilio
authorDavid Zbarsky <dzbarsky@gmail.com>
Tue, 12 Apr 2016 14:48:58 +0500
changeset 338489 f1bf7ef7ba23ab500bcf02e471cd345fdfd83762
parent 338488 d135e99d5d13f6bb173773e70eddd009d4f4ffcc
child 338490 b2e8ff170055ad9d1c802d6554839f51be8e3424
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
servo: Merge #10379 - Implement GetActiveAttrib (from dzbarsky:getActiveAttrib); r=emilio @emilio Source-Repo: https://github.com/servo/servo Source-Revision: 376980fb570c8f68c04eaed0b22e9046856aaaa0
servo/components/script/dom/webglprogram.rs
servo/components/script/dom/webglrenderingcontext.rs
servo/components/script/dom/webidls/WebGLRenderingContext.webidl
--- a/servo/components/script/dom/webglprogram.rs
+++ b/servo/components/script/dom/webglprogram.rs
@@ -162,16 +162,27 @@ impl WebGLProgram {
         self.renderer
             .send(CanvasMsg::WebGL(WebGLCommand::GetActiveUniform(self.id, index, sender)))
             .unwrap();
 
         receiver.recv().unwrap().map(|(size, ty, name)|
             WebGLActiveInfo::new(self.global().r(), size, ty, DOMString::from(name)))
     }
 
+    /// glGetActiveAttrib
+    pub fn get_active_attrib(&self, index: u32) -> WebGLResult<Root<WebGLActiveInfo>> {
+        let (sender, receiver) = ipc::channel().unwrap();
+        self.renderer
+            .send(CanvasMsg::WebGL(WebGLCommand::GetActiveAttrib(self.id, index, sender)))
+            .unwrap();
+
+        receiver.recv().unwrap().map(|(size, ty, name)|
+            WebGLActiveInfo::new(self.global().r(), size, ty, DOMString::from(name)))
+    }
+
     /// glGetAttribLocation
     pub fn get_attrib_location(&self, name: DOMString) -> WebGLResult<Option<i32>> {
         if name.len() > MAX_UNIFORM_AND_ATTRIBUTE_LEN {
             return Err(WebGLError::InvalidValue);
         }
 
         // Check if the name is reserved
         if name.starts_with("webgl") || name.starts_with("_webgl_") {
--- a/servo/components/script/dom/webglrenderingcontext.rs
+++ b/servo/components/script/dom/webglrenderingcontext.rs
@@ -823,16 +823,27 @@ impl WebGLRenderingContextMethods for We
             Err(error) => {
                 self.webgl_error(error);
                 None
             },
         })
     }
 
     // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+    fn GetActiveAttrib(&self, program: Option<&WebGLProgram>, index: u32) -> Option<Root<WebGLActiveInfo>> {
+        program.and_then(|p| match p.get_active_attrib(index) {
+            Ok(ret) => Some(ret),
+            Err(error) => {
+                self.webgl_error(error);
+                None
+            },
+        })
+    }
+
+    // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
     fn GetAttribLocation(&self, program: Option<&WebGLProgram>, name: DOMString) -> i32 {
         if let Some(program) = program {
             handle_potential_webgl_error!(self, program.get_attrib_location(name), None).unwrap_or(-1)
         } else {
             -1
         }
     }
 
--- a/servo/components/script/dom/webidls/WebGLRenderingContext.webidl
+++ b/servo/components/script/dom/webidls/WebGLRenderingContext.webidl
@@ -562,17 +562,17 @@ interface WebGLRenderingContextBase
     //                             GLenum renderbuffertarget,
     //                             WebGLRenderbuffer? renderbuffer);
     //void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget,
     //                          WebGLTexture? texture, GLint level);
     void frontFace(GLenum mode);
 
     void generateMipmap(GLenum target);
 
-    //WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index);
+    WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index);
     WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index);
     //sequence<WebGLShader>? getAttachedShaders(WebGLProgram? program);
 
     [WebGLHandlesContextLoss] GLint getAttribLocation(WebGLProgram? program, DOMString name);
 
     any getBufferParameter(GLenum target, GLenum pname);
     any getParameter(GLenum pname);