mirror of
https://github.com/servo/servo.git
synced 2025-09-30 16:49: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
|
@ -37,10 +37,6 @@ pub(crate) enum CompleteForRendering {
|
|||
MissingColorAttachment,
|
||||
}
|
||||
|
||||
fn log2(n: u32) -> u32 {
|
||||
31 - n.leading_zeros()
|
||||
}
|
||||
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||
enum WebGLFramebufferAttachment {
|
||||
|
@ -786,7 +782,7 @@ impl WebGLFramebuffer {
|
|||
} else {
|
||||
context.limits().max_tex_size
|
||||
};
|
||||
if level < 0 || level as u32 > log2(max_tex_size) {
|
||||
if level < 0 || level as u32 > max_tex_size.ilog2() {
|
||||
return Err(WebGLError::InvalidValue);
|
||||
}
|
||||
}
|
||||
|
@ -856,11 +852,11 @@ impl WebGLFramebuffer {
|
|||
Some(texture) => {
|
||||
let (max_level, max_layer) = match texture.target() {
|
||||
Some(constants::TEXTURE_3D) => (
|
||||
log2(context.limits().max_3d_texture_size),
|
||||
context.limits().max_3d_texture_size.ilog2(),
|
||||
context.limits().max_3d_texture_size - 1,
|
||||
),
|
||||
Some(constants::TEXTURE_2D) => (
|
||||
log2(context.limits().max_tex_size),
|
||||
context.limits().max_tex_size.ilog2(),
|
||||
context.limits().max_array_texture_layers - 1,
|
||||
),
|
||||
_ => return Err(WebGLError::InvalidOperation),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue