script/dom/webgl/extensions/ext/
oestexturefloatlinear.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;
6
7use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions, constants as webgl};
8use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
9use crate::dom::bindings::root::DomRoot;
10use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
11use crate::script_runtime::CanGc;
12
13#[dom_struct]
14pub(crate) struct OESTextureFloatLinear {
15    reflector_: Reflector,
16}
17
18impl OESTextureFloatLinear {
19    fn new_inherited() -> OESTextureFloatLinear {
20        Self {
21            reflector_: Reflector::new(),
22        }
23    }
24}
25
26impl WebGLExtension for OESTextureFloatLinear {
27    type Extension = OESTextureFloatLinear;
28    fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureFloatLinear> {
29        reflect_dom_object(
30            Box::new(OESTextureFloatLinear::new_inherited()),
31            &*ctx.global(),
32            can_gc,
33        )
34    }
35
36    fn spec() -> WebGLExtensionSpec {
37        WebGLExtensionSpec::All
38    }
39
40    fn is_supported(ext: &WebGLExtensions) -> bool {
41        ext.supports_any_gl_extension(&["GL_OES_texture_float_linear", "GL_ARB_texture_float"])
42    }
43
44    fn enable(ext: &WebGLExtensions) {
45        ext.enable_filterable_tex_type(webgl::FLOAT);
46    }
47
48    fn name() -> &'static str {
49        "OES_texture_float_linear"
50    }
51}