Skip to content

Commit

Permalink
Simplify GetShaderPrecisionFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
gootorov committed Mar 20, 2018
1 parent 7e5160b commit bdd53f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
17 changes: 2 additions & 15 deletions components/canvas/webgl_thread.rs
Expand Up @@ -1156,21 +1156,8 @@ impl WebGLImpl {
fn shader_precision_format(gl: &gl::Gl,
shader_type: u32,
precision_type: u32,
chan: WebGLSender<WebGLResult<(i32, i32, i32)>>) {
let result = match precision_type {
gl::LOW_FLOAT |
gl::MEDIUM_FLOAT |
gl::HIGH_FLOAT |
gl::LOW_INT |
gl::MEDIUM_INT |
gl::HIGH_INT => {
Ok(gl.get_shader_precision_format(shader_type, precision_type))
},
_=> {
Err(WebGLError::InvalidEnum)
}
};

chan: WebGLSender<(i32, i32, i32)>) {
let result = gl.get_shader_precision_format(shader_type, precision_type);
chan.send(result).unwrap();
}

Expand Down
2 changes: 1 addition & 1 deletion components/canvas_traits/webgl.rs
Expand Up @@ -210,7 +210,7 @@ pub enum WebGLCommand {
GetTexParameter(u32, u32, WebGLSender<i32>),
GetProgramParameter(WebGLProgramId, u32, WebGLSender<WebGLResult<WebGLParameter>>),
GetShaderParameter(WebGLShaderId, u32, WebGLSender<WebGLResult<WebGLParameter>>),
GetShaderPrecisionFormat(u32, u32, WebGLSender<WebGLResult<(i32, i32, i32)>>),
GetShaderPrecisionFormat(u32, u32, WebGLSender<(i32, i32, i32)>),
GetActiveAttrib(WebGLProgramId, u32, WebGLSender<WebGLResult<(i32, u32, String)>>),
GetActiveUniform(WebGLProgramId, u32, WebGLSender<WebGLResult<(i32, u32, String)>>),
GetAttribLocation(WebGLProgramId, String, WebGLSender<Option<i32>>),
Expand Down
33 changes: 20 additions & 13 deletions components/script/dom/webglrenderingcontext.rs
Expand Up @@ -2357,24 +2357,31 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}

// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetShaderPrecisionFormat(&self,
shader_type: u32,
precision_type: u32)
-> Option<DomRoot<WebGLShaderPrecisionFormat>> {
fn GetShaderPrecisionFormat(
&self,
shader_type: u32,
precision_type: u32
) -> Option<DomRoot<WebGLShaderPrecisionFormat>> {
match precision_type {
constants::LOW_FLOAT |
constants::MEDIUM_FLOAT |
constants::HIGH_FLOAT |
constants::LOW_INT |
constants::MEDIUM_INT |
constants::HIGH_INT => (),
_ => {
self.webgl_error(InvalidEnum);
return None;
},
}

let (sender, receiver) = webgl_channel().unwrap();
self.send_command(WebGLCommand::GetShaderPrecisionFormat(shader_type,
precision_type,
sender));

match receiver.recv().unwrap() {
Ok((range_min, range_max, precision)) => {
Some(WebGLShaderPrecisionFormat::new(self.global().as_window(), range_min, range_max, precision))
},
Err(error) => {
self.webgl_error(error);
None
}
}
let (range_min, range_max, precision) = receiver.recv().unwrap();
Some(WebGLShaderPrecisionFormat::new(self.global().as_window(), range_min, range_max, precision))
}

// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
Expand Down

0 comments on commit bdd53f3

Please sign in to comment.