mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Simplify GetShaderPrecisionFormat
This commit is contained in:
parent
7e5160b79e
commit
bdd53f35af
3 changed files with 23 additions and 29 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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>>),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue