diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 933c8893cf22..01ab0a152500 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -678,8 +678,9 @@ impl WebGLImpl { ctx.gl().clear(mask), WebGLCommand::ClearColor(r, g, b, a) => ctx.gl().clear_color(r, g, b, a), - WebGLCommand::ClearDepth(depth) => - ctx.gl().clear_depth(depth), + WebGLCommand::ClearDepth(depth) => { + ctx.gl().clear_depth(depth.max(0.).min(1.) as f64) + } WebGLCommand::ClearStencil(stencil) => ctx.gl().clear_stencil(stencil), WebGLCommand::ColorMask(r, g, b, a) => diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 55d2843c276d..01e3c49fc3d1 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -170,7 +170,7 @@ pub enum WebGLCommand { BufferSubData(u32, isize, ByteBuf), Clear(u32), ClearColor(f32, f32, f32, f32), - ClearDepth(f64), + ClearDepth(f32), ClearStencil(i32), ColorMask(bool, bool, bool, bool), CullFace(u32), diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 5819b33357ec..81f28ceb1cd6 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -1876,7 +1876,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 fn ClearDepth(&self, depth: f32) { - self.send_command(WebGLCommand::ClearDepth(depth as f64)) + self.send_command(WebGLCommand::ClearDepth(depth)) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3