Simplify GetShaderPrecisionFormat

This commit is contained in:
Igor Gutorov 2018-03-20 21:44:08 +02:00
parent 7e5160b79e
commit bdd53f35af
3 changed files with 23 additions and 29 deletions

View file

@ -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