script/dom/webgl/extensions/ext/
webglcompressedtextureetc1.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
8use servo_canvas_traits::webgl::{TexFormat, WebGLVersion};
9
10use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
11use crate::dom::bindings::reflector::DomGlobal;
12use crate::dom::bindings::root::DomRoot;
13use crate::dom::webgl::webglrenderingcontext::WebGLRenderingContext;
14use crate::dom::webgl::webgltexture::{TexCompression, TexCompressionValidation};
15
16#[dom_struct]
17pub(crate) struct WEBGLCompressedTextureETC1 {
18 reflector_: Reflector,
19}
20
21impl WEBGLCompressedTextureETC1 {
22 fn new_inherited() -> WEBGLCompressedTextureETC1 {
23 Self {
24 reflector_: Reflector::new(),
25 }
26 }
27}
28
29impl WebGLExtension for WEBGLCompressedTextureETC1 {
30 type Extension = WEBGLCompressedTextureETC1;
31 fn new(cx: &mut JSContext, ctx: &WebGLRenderingContext) -> DomRoot<WEBGLCompressedTextureETC1> {
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.supports_gl_extension("GL_OES_compressed_ETC1_RGB8_texture")
41 }
42
43 fn enable(ext: &WebGLExtensions) {
44 ext.add_tex_compression_formats(&[TexCompression {
45 format: TexFormat::CompressedRgbEtc1,
46 bytes_per_block: 8,
47 block_width: 4,
48 block_height: 4,
49 validation: TexCompressionValidation::None,
50 }]);
51 }
52
53 fn name() -> &'static str {
54 "WEBGL_compressed_texture_etc1"
55 }
56}