script/dom/webgl/
webgluniformlocation.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
5// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
6use canvas_traits::webgl::{WebGLContextId, WebGLProgramId};
7use dom_struct::dom_struct;
8
9use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::window::Window;
12use crate::script_runtime::CanGc;
13
14#[dom_struct]
15pub(crate) struct WebGLUniformLocation {
16    reflector_: Reflector,
17    id: i32,
18    #[no_trace]
19    context_id: WebGLContextId,
20    #[no_trace]
21    program_id: WebGLProgramId,
22    link_generation: u64,
23    size: Option<i32>,
24    type_: u32,
25}
26
27impl WebGLUniformLocation {
28    fn new_inherited(
29        id: i32,
30        context_id: WebGLContextId,
31        program_id: WebGLProgramId,
32        link_generation: u64,
33        size: Option<i32>,
34        type_: u32,
35    ) -> Self {
36        Self {
37            reflector_: Reflector::new(),
38            id,
39            context_id,
40            program_id,
41            link_generation,
42            size,
43            type_,
44        }
45    }
46
47    #[allow(clippy::too_many_arguments)]
48    pub(crate) fn new(
49        window: &Window,
50        id: i32,
51        context_id: WebGLContextId,
52        program_id: WebGLProgramId,
53        link_generation: u64,
54        size: Option<i32>,
55        type_: u32,
56        can_gc: CanGc,
57    ) -> DomRoot<Self> {
58        reflect_dom_object(
59            Box::new(Self::new_inherited(
60                id,
61                context_id,
62                program_id,
63                link_generation,
64                size,
65                type_,
66            )),
67            window,
68            can_gc,
69        )
70    }
71
72    pub(crate) fn id(&self) -> i32 {
73        self.id
74    }
75
76    pub(crate) fn program_id(&self) -> WebGLProgramId {
77        self.program_id
78    }
79
80    pub(crate) fn context_id(&self) -> WebGLContextId {
81        self.context_id
82    }
83
84    pub(crate) fn link_generation(&self) -> u64 {
85        self.link_generation
86    }
87
88    pub(crate) fn size(&self) -> Option<i32> {
89        self.size
90    }
91
92    pub(crate) fn type_(&self) -> u32 {
93        self.type_
94    }
95}