Skip to main content

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