script/dom/webgl/extensions/ext/
oesstandardderivatives.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
8use servo_canvas_traits::webgl::WebGLVersion;
9
10use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
11use crate::dom::bindings::codegen::Bindings::OESStandardDerivativesBinding::OESStandardDerivativesConstants;
12use crate::dom::bindings::reflector::DomGlobal;
13use crate::dom::bindings::root::DomRoot;
14use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
15
16#[dom_struct]
17pub(crate) struct OESStandardDerivatives {
18 reflector_: Reflector,
19}
20
21impl OESStandardDerivatives {
22 fn new_inherited() -> OESStandardDerivatives {
23 Self {
24 reflector_: Reflector::new(),
25 }
26 }
27}
28
29impl WebGLExtension for OESStandardDerivatives {
30 type Extension = OESStandardDerivatives;
31 fn new(cx: &mut JSContext, ctx: &WebGLRenderingContext) -> DomRoot<OESStandardDerivatives> {
32 reflect_dom_object_with_cx(Box::new(Self::new_inherited()), &*ctx.global(), cx)
33 }
34
35 fn spec() -> WebGLExtensionSpec {
36 WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
37 }
38
39 fn is_supported(ext: &WebGLExtensions) -> bool {
40 !ext.is_gles() || ext.supports_any_gl_extension(&["GL_OES_standard_derivatives"])
42 }
43
44 fn enable(ext: &WebGLExtensions) {
45 ext.enable_hint_target(
46 OESStandardDerivativesConstants::FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
47 );
48 ext.enable_get_parameter_name(
49 OESStandardDerivativesConstants::FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
50 );
51 }
52
53 fn name() -> &'static str {
54 "OES_standard_derivatives"
55 }
56}