Skip to main content

script/dom/webgl/extensions/ext/
oeselementindexuint.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::webglrenderingcontext::WebGLRenderingContext;
13use crate::script_runtime::CanGc;
14
15#[dom_struct]
16pub(crate) struct OESElementIndexUint {
17    reflector_: Reflector,
18}
19
20impl OESElementIndexUint {
21    fn new_inherited() -> Self {
22        Self {
23            reflector_: Reflector::new(),
24        }
25    }
26}
27
28impl WebGLExtension for OESElementIndexUint {
29    type Extension = Self;
30
31    fn new(ctx: &WebGLRenderingContext, can_gc: CanGc) -> DomRoot<Self> {
32        reflect_dom_object(
33            Box::new(OESElementIndexUint::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        // This extension is always available in desktop OpenGL.
45        !ext.is_gles() || ext.supports_gl_extension("GL_OES_element_index_uint")
46    }
47
48    fn enable(ext: &WebGLExtensions) {
49        ext.enable_element_index_uint();
50    }
51
52    fn name() -> &'static str {
53        "OES_element_index_uint"
54    }
55}