Skip to main content

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