script/dom/webgl/extensions/ext/
oestexturehalffloatlinear.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};
8use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants;
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 OESTextureHalfFloatLinear {
16    reflector_: Reflector,
17}
18
19impl OESTextureHalfFloatLinear {
20    fn new_inherited() -> OESTextureHalfFloatLinear {
21        Self {
22            reflector_: Reflector::new(),
23        }
24    }
25}
26
27impl WebGLExtension for OESTextureHalfFloatLinear {
28    type Extension = OESTextureHalfFloatLinear;
29    fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<OESTextureHalfFloatLinear> {
30        reflect_dom_object(
31            Box::new(OESTextureHalfFloatLinear::new_inherited()),
32            &*ctx.global(),
33            can_gc,
34        )
35    }
36
37    fn spec() -> WebGLExtensionSpec {
38        WebGLExtensionSpec::All
39    }
40
41    fn is_supported(ext: &WebGLExtensions) -> bool {
42        ext.supports_any_gl_extension(&[
43            "GL_OES_texture_float_linear",
44            "GL_ARB_half_float_pixel",
45            "GL_NV_half_float",
46        ])
47    }
48
49    fn enable(ext: &WebGLExtensions) {
50        ext.enable_filterable_tex_type(OESTextureHalfFloatConstants::HALF_FLOAT_OES);
51    }
52
53    fn name() -> &'static str {
54        "OES_texture_half_float_linear"
55    }
56}