script/dom/webgl/extensions/ext/
extcolorbufferfloat.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use script_bindings::reflector::{Reflector, reflect_dom_object};
8use servo_canvas_traits::webgl::WebGLVersion;
9
10use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
11use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants;
12use crate::dom::bindings::reflector::DomGlobal;
13use crate::dom::bindings::root::DomRoot;
14use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
15
16pub(crate) const COLOR_RENDERABLE_FORMATS: &[u32] = &[
18 constants::R16F,
19 constants::RG16F,
20 constants::RGBA16F,
21 constants::R32F,
22 constants::RG32F,
23 constants::RGBA32F,
24 constants::R11F_G11F_B10F,
25];
26
27#[dom_struct]
28pub(crate) struct EXTColorBufferFloat {
29 reflector_: Reflector,
30}
31
32impl EXTColorBufferFloat {
33 fn new_inherited() -> EXTColorBufferFloat {
34 Self {
35 reflector_: Reflector::new(),
36 }
37 }
38}
39
40impl WebGLExtension for EXTColorBufferFloat {
41 type Extension = EXTColorBufferFloat;
42 fn new(cx: &mut JSContext, ctx: &WebGLRenderingContext) -> DomRoot<EXTColorBufferFloat> {
43 reflect_dom_object(cx, Box::new(Self::new_inherited()), &*ctx.global())
44 }
45
46 fn spec() -> WebGLExtensionSpec {
47 WebGLExtensionSpec::Specific(WebGLVersion::WebGL2)
48 }
49
50 fn is_supported(ext: &WebGLExtensions) -> bool {
51 !ext.is_gles() || ext.supports_gl_extension("GL_EXT_color_buffer_float")
53 }
54
55 fn enable(_ext: &WebGLExtensions) {}
56
57 fn name() -> &'static str {
58 "EXT_color_buffer_float"
59 }
60}