mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
script: Remove three duplicated log functions from webgl (#39227)
We have the standard library at our disposal, let's use it. Testing: Covered by existing tests Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
7a28fd786c
commit
406eab4ec2
3 changed files with 6 additions and 18 deletions
|
@ -85,10 +85,6 @@ impl fmt::Display for TexImageValidationError {
|
|||
}
|
||||
}
|
||||
|
||||
fn log2(n: u32) -> u32 {
|
||||
31 - n.leading_zeros()
|
||||
}
|
||||
|
||||
pub(crate) struct CommonTexImage2DValidator<'a> {
|
||||
context: &'a WebGLRenderingContext,
|
||||
target: u32,
|
||||
|
@ -204,7 +200,7 @@ impl WebGLValidator for CommonTexImage2DValidator<'_> {
|
|||
// log_2(max), where max is the returned value of GL_MAX_TEXTURE_SIZE
|
||||
// when target is GL_TEXTURE_2D or GL_MAX_CUBE_MAP_TEXTURE_SIZE when
|
||||
// target is not GL_TEXTURE_2D.
|
||||
if level > log2(max_size) {
|
||||
if level > max_size.ilog2() {
|
||||
self.context.webgl_error(InvalidValue);
|
||||
return Err(TexImageValidationError::LevelTooHigh);
|
||||
}
|
||||
|
@ -772,7 +768,7 @@ impl WebGLValidator for TexStorageValidator<'_> {
|
|||
return Err(TexImageValidationError::InvalidTextureFormat);
|
||||
}
|
||||
|
||||
let max_level = log2(cmp::max(width, height)) + 1;
|
||||
let max_level = cmp::max(width, height).ilog2() + 1;
|
||||
if level > max_level {
|
||||
context.webgl_error(InvalidOperation);
|
||||
return Err(TexImageValidationError::LevelTooHigh);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue