Skip to main content

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 dom_struct::dom_struct;
6use script_bindings::reflector::{Reflector, reflect_dom_object};
7use servo_canvas_traits::webgl::WebGLVersion;
8
9use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
10use crate::dom::bindings::reflector::DomGlobal;
11use crate::dom::bindings::root::DomRoot;
12use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
13use crate::script_runtime::CanGc;
14
15#[dom_struct]
16pub(crate) struct EXTShaderTextureLod {
17    reflector_: Reflector,
18}
19
20impl EXTShaderTextureLod {
21    fn new_inherited() -> Self {
22        Self {
23            reflector_: Reflector::new(),
24        }
25    }
26}
27
28impl WebGLExtension for EXTShaderTextureLod {
29    type Extension = Self;
30
31    fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
32        reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global(), can_gc)
33    }
34
35    fn spec() -> WebGLExtensionSpec {
36        WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
37    }
38
39    fn is_supported(ext: &WebGLExtensions) -> bool {
40        // This extension is always available on desktop GL.
41        !ext.is_gles() || ext.supports_gl_extension("GL_EXT_shader_texture_lod")
42    }
43
44    fn enable(_ext: &WebGLExtensions) {}
45
46    fn name() -> &'static str {
47        "EXT_shader_texture_lod"
48    }
49}