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 js::context::JSContext;
7use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
8
9use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
10use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants;
11use crate::dom::bindings::reflector::DomGlobal;
12use crate::dom::bindings::root::DomRoot;
13use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
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(cx: &mut JSContext, ctx: &WebGLRenderingContext) -> DomRoot<OESTextureHalfFloatLinear> {
31        reflect_dom_object_with_cx(Box::new(Self::new_inherited()), &*ctx.global(), cx)
32    }
33
34    fn spec() -> WebGLExtensionSpec {
35        WebGLExtensionSpec::All
36    }
37
38    fn is_supported(ext: &WebGLExtensions) -> bool {
39        ext.supports_any_gl_extension(&[
40            "GL_OES_texture_float_linear",
41            "GL_ARB_half_float_pixel",
42            "GL_NV_half_float",
43        ])
44    }
45
46    fn enable(ext: &WebGLExtensions) {
47        ext.enable_filterable_tex_type(OESTextureHalfFloatConstants::HALF_FLOAT_OES);
48    }
49
50    fn name() -> &'static str {
51        "OES_texture_half_float_linear"
52    }
53}