script/dom/webgl/extensions/ext/
extshadertexturelod.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use canvas_traits::webgl::WebGLVersion;
6use dom_struct::dom_struct;
7
8use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
9use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
12use crate::script_runtime::CanGc;
13
14#[dom_struct]
15pub(crate) struct EXTShaderTextureLod {
16    reflector_: Reflector,
17}
18
19impl EXTShaderTextureLod {
20    fn new_inherited() -> Self {
21        Self {
22            reflector_: Reflector::new(),
23        }
24    }
25}
26
27impl WebGLExtension for EXTShaderTextureLod {
28    type Extension = Self;
29
30    fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
31        reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global(), can_gc)
32    }
33
34    fn spec() -> WebGLExtensionSpec {
35        WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
36    }
37
38    fn is_supported(ext: &WebGLExtensions) -> bool {
39        // This extension is always available on desktop GL.
40        !ext.is_gles() || ext.supports_gl_extension("GL_EXT_shader_texture_lod")
41    }
42
43    fn enable(_ext: &WebGLExtensions) {}
44
45    fn name() -> &'static str {
46        "EXT_shader_texture_lod"
47    }
48}