Skip to main content

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