aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webgl_extensions/ext
diff options
context:
space:
mode:
authoryvt <i@yvt.jp>2021-07-10 17:24:27 +0900
committeryvt <i@yvt.jp>2021-07-10 17:55:42 +0900
commit01a7de50ab1843d85295f9dccad7f4c099e7208c (patch)
treeee53fb6e8889deb7b880ee969e6c662e6128d210 /components/script/dom/webgl_extensions/ext
parentff8d2cdbbfc7a9dc7f38b7dd47cb350fde39388f (diff)
parent94b613fbdaa2b98f2179fc0bbda13c64e6fa0d38 (diff)
downloadservo-01a7de50ab1843d85295f9dccad7f4c099e7208c.tar.gz
servo-01a7de50ab1843d85295f9dccad7f4c099e7208c.zip
Merge remote-tracking branch 'upstream/master' into feat-cow-infra
`tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` was reverted to the upstream version.
Diffstat (limited to 'components/script/dom/webgl_extensions/ext')
-rw-r--r--components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs92
-rw-r--r--components/script/dom/webgl_extensions/ext/extblendminmax.rs47
-rw-r--r--components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs48
-rw-r--r--components/script/dom/webgl_extensions/ext/extfragdepth.rs62
-rw-r--r--components/script/dom/webgl_extensions/ext/extshadertexturelod.rs46
-rw-r--r--components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs53
-rw-r--r--components/script/dom/webgl_extensions/ext/mod.rs23
-rw-r--r--components/script/dom/webgl_extensions/ext/oeselementindexuint.rs51
-rw-r--r--components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs56
-rw-r--r--components/script/dom/webgl_extensions/ext/oestexturefloat.rs63
-rw-r--r--components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs48
-rw-r--r--components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs65
-rw-r--r--components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs53
-rw-r--r--components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs80
-rw-r--r--components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs48
-rw-r--r--components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs56
-rw-r--r--components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs84
17 files changed, 975 insertions, 0 deletions
diff --git a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs
new file mode 100644
index 00000000000..4d03f25781b
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs
@@ -0,0 +1,92 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants;
+use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysMethods;
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::{Dom, DomRoot};
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct ANGLEInstancedArrays {
+ reflector_: Reflector,
+ ctx: Dom<WebGLRenderingContext>,
+}
+
+impl ANGLEInstancedArrays {
+ fn new_inherited(ctx: &WebGLRenderingContext) -> Self {
+ Self {
+ reflector_: Reflector::new(),
+ ctx: Dom::from_ref(ctx),
+ }
+ }
+}
+
+impl WebGLExtension for ANGLEInstancedArrays {
+ type Extension = Self;
+
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
+ reflect_dom_object(
+ Box::new(ANGLEInstancedArrays::new_inherited(ctx)),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_any_gl_extension(&[
+ "GL_ANGLE_instanced_arrays",
+ "GL_ARB_instanced_arrays",
+ "GL_EXT_instanced_arrays",
+ "GL_NV_instanced_arrays",
+ ])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_get_vertex_attrib_name(
+ ANGLEInstancedArraysConstants::VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE,
+ );
+ }
+
+ fn name() -> &'static str {
+ "ANGLE_instanced_arrays"
+ }
+}
+
+impl ANGLEInstancedArraysMethods for ANGLEInstancedArrays {
+ // https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/
+ fn DrawArraysInstancedANGLE(&self, mode: u32, first: i32, count: i32, primcount: i32) {
+ handle_potential_webgl_error!(
+ self.ctx,
+ self.ctx
+ .draw_arrays_instanced(mode, first, count, primcount)
+ )
+ }
+
+ // https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/
+ fn DrawElementsInstancedANGLE(
+ &self,
+ mode: u32,
+ count: i32,
+ type_: u32,
+ offset: i64,
+ primcount: i32,
+ ) {
+ handle_potential_webgl_error!(
+ self.ctx,
+ self.ctx
+ .draw_elements_instanced(mode, count, type_, offset, primcount)
+ )
+ }
+
+ fn VertexAttribDivisorANGLE(&self, index: u32, divisor: u32) {
+ self.ctx.vertex_attrib_divisor(index, divisor);
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/extblendminmax.rs b/components/script/dom/webgl_extensions/ext/extblendminmax.rs
new file mode 100644
index 00000000000..122aac6c861
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/extblendminmax.rs
@@ -0,0 +1,47 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct EXTBlendMinmax {
+ reflector_: Reflector,
+}
+
+impl EXTBlendMinmax {
+ fn new_inherited() -> Self {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for EXTBlendMinmax {
+ type Extension = Self;
+
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
+ reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global())
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_gl_extension("GL_EXT_blend_minmax")
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_blend_minmax();
+ }
+
+ fn name() -> &'static str {
+ "EXT_blend_minmax"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs
new file mode 100644
index 00000000000..bb4a630d537
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs
@@ -0,0 +1,48 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webgl_extensions::ext::oestexturehalffloat::OESTextureHalfFloat;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct EXTColorBufferHalfFloat {
+ reflector_: Reflector,
+}
+
+impl EXTColorBufferHalfFloat {
+ fn new_inherited() -> EXTColorBufferHalfFloat {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for EXTColorBufferHalfFloat {
+ type Extension = EXTColorBufferHalfFloat;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<EXTColorBufferHalfFloat> {
+ reflect_dom_object(
+ Box::new(EXTColorBufferHalfFloat::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ OESTextureHalfFloat::is_supported(ext)
+ }
+
+ fn enable(_ext: &WebGLExtensions) {}
+
+ fn name() -> &'static str {
+ "EXT_color_buffer_half_float"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/extfragdepth.rs b/components/script/dom/webgl_extensions/ext/extfragdepth.rs
new file mode 100644
index 00000000000..182b30bf754
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/extfragdepth.rs
@@ -0,0 +1,62 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::{WebGLSLVersion, WebGLVersion};
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct EXTFragDepth {
+ reflector_: Reflector,
+}
+
+impl EXTFragDepth {
+ fn new_inherited() -> EXTFragDepth {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for EXTFragDepth {
+ type Extension = Self;
+
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
+ reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global())
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ let min_glsl_version = if ext.is_gles() {
+ WebGLSLVersion { major: 3, minor: 0 }
+ } else {
+ WebGLSLVersion {
+ major: 1,
+ minor: 10,
+ }
+ };
+ match (
+ ext.is_gles(),
+ ext.is_min_glsl_version_satisfied(min_glsl_version),
+ ) {
+ // ANGLE's shader translator can't translate ESSL1 exts to ESSL3. (bug
+ // 1524804)
+ (true, true) => false,
+ (true, false) => ext.supports_gl_extension("GL_EXT_frag_depth"),
+ (false, is_min_glsl_version_satisfied) => is_min_glsl_version_satisfied,
+ }
+ }
+
+ fn enable(_ext: &WebGLExtensions) {}
+
+ fn name() -> &'static str {
+ "EXT_frag_depth"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs
new file mode 100644
index 00000000000..ea68b518dac
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs
@@ -0,0 +1,46 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct EXTShaderTextureLod {
+ reflector_: Reflector,
+}
+
+impl EXTShaderTextureLod {
+ fn new_inherited() -> Self {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for EXTShaderTextureLod {
+ type Extension = Self;
+
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
+ reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global())
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ // This extension is always available on desktop GL.
+ !ext.is_gles() || ext.supports_gl_extension("GL_EXT_shader_texture_lod")
+ }
+
+ fn enable(_ext: &WebGLExtensions) {}
+
+ fn name() -> &'static str {
+ "EXT_shader_texture_lod"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs
new file mode 100644
index 00000000000..89a4d3ed6a4
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs
@@ -0,0 +1,53 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding::EXTTextureFilterAnisotropicConstants;
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct EXTTextureFilterAnisotropic {
+ reflector_: Reflector,
+}
+
+impl EXTTextureFilterAnisotropic {
+ fn new_inherited() -> EXTTextureFilterAnisotropic {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for EXTTextureFilterAnisotropic {
+ type Extension = EXTTextureFilterAnisotropic;
+
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
+ reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global())
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_gl_extension("GL_EXT_texture_filter_anisotropic")
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_get_tex_parameter_name(
+ EXTTextureFilterAnisotropicConstants::TEXTURE_MAX_ANISOTROPY_EXT,
+ );
+ ext.enable_get_parameter_name(
+ EXTTextureFilterAnisotropicConstants::MAX_TEXTURE_MAX_ANISOTROPY_EXT,
+ );
+ }
+
+ fn name() -> &'static str {
+ "EXT_texture_filter_anisotropic"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/mod.rs b/components/script/dom/webgl_extensions/ext/mod.rs
new file mode 100644
index 00000000000..229d09d56f5
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/mod.rs
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
+
+pub mod angleinstancedarrays;
+pub mod extblendminmax;
+pub mod extcolorbufferhalffloat;
+pub mod extfragdepth;
+pub mod extshadertexturelod;
+pub mod exttexturefilteranisotropic;
+pub mod oeselementindexuint;
+pub mod oesstandardderivatives;
+pub mod oestexturefloat;
+pub mod oestexturefloatlinear;
+pub mod oestexturehalffloat;
+pub mod oestexturehalffloatlinear;
+pub mod oesvertexarrayobject;
+pub mod webglcolorbufferfloat;
+pub mod webglcompressedtextureetc1;
+pub mod webglcompressedtextures3tc;
diff --git a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs
new file mode 100644
index 00000000000..096c22d3dc5
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs
@@ -0,0 +1,51 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct OESElementIndexUint {
+ reflector_: Reflector,
+}
+
+impl OESElementIndexUint {
+ fn new_inherited() -> Self {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for OESElementIndexUint {
+ type Extension = Self;
+
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
+ reflect_dom_object(
+ Box::new(OESElementIndexUint::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ // This extension is always available in desktop OpenGL.
+ !ext.is_gles() || ext.supports_gl_extension("GL_OES_element_index_uint")
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_element_index_uint();
+ }
+
+ fn name() -> &'static str {
+ "OES_element_index_uint"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs
new file mode 100644
index 00000000000..dfafa7051a5
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs
@@ -0,0 +1,56 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::codegen::Bindings::OESStandardDerivativesBinding::OESStandardDerivativesConstants;
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct OESStandardDerivatives {
+ reflector_: Reflector,
+}
+
+impl OESStandardDerivatives {
+ fn new_inherited() -> OESStandardDerivatives {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for OESStandardDerivatives {
+ type Extension = OESStandardDerivatives;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESStandardDerivatives> {
+ reflect_dom_object(
+ Box::new(OESStandardDerivatives::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ // The standard derivatives are always available in desktop OpenGL.
+ !ext.is_gles() || ext.supports_any_gl_extension(&["GL_OES_standard_derivatives"])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_hint_target(
+ OESStandardDerivativesConstants::FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
+ );
+ ext.enable_get_parameter_name(
+ OESStandardDerivativesConstants::FRAGMENT_SHADER_DERIVATIVE_HINT_OES,
+ );
+ }
+
+ fn name() -> &'static str {
+ "OES_standard_derivatives"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs
new file mode 100644
index 00000000000..e286095b7c7
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs
@@ -0,0 +1,63 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::{TexFormat, WebGLVersion};
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct OESTextureFloat {
+ reflector_: Reflector,
+}
+
+impl OESTextureFloat {
+ fn new_inherited() -> OESTextureFloat {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for OESTextureFloat {
+ type Extension = OESTextureFloat;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureFloat> {
+ reflect_dom_object(Box::new(OESTextureFloat::new_inherited()), &*ctx.global())
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_any_gl_extension(&[
+ "GL_OES_texture_float",
+ "GL_ARB_texture_float",
+ "GL_EXT_color_buffer_float",
+ ])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_tex_type(webgl::FLOAT);
+ ext.add_effective_tex_internal_format(TexFormat::RGBA, webgl::FLOAT, TexFormat::RGBA32f);
+ ext.add_effective_tex_internal_format(TexFormat::RGB, webgl::FLOAT, TexFormat::RGB32f);
+ ext.add_effective_tex_internal_format(
+ TexFormat::Luminance,
+ webgl::FLOAT,
+ TexFormat::Luminance32f,
+ );
+ ext.add_effective_tex_internal_format(TexFormat::Alpha, webgl::FLOAT, TexFormat::Alpha32f);
+ ext.add_effective_tex_internal_format(
+ TexFormat::LuminanceAlpha,
+ webgl::FLOAT,
+ TexFormat::LuminanceAlpha32f,
+ );
+ }
+
+ fn name() -> &'static str {
+ "OES_texture_float"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs
new file mode 100644
index 00000000000..9e5c021f0ef
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs
@@ -0,0 +1,48 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct OESTextureFloatLinear {
+ reflector_: Reflector,
+}
+
+impl OESTextureFloatLinear {
+ fn new_inherited() -> OESTextureFloatLinear {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for OESTextureFloatLinear {
+ type Extension = OESTextureFloatLinear;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureFloatLinear> {
+ reflect_dom_object(
+ Box::new(OESTextureFloatLinear::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::All
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_any_gl_extension(&["GL_OES_texture_float_linear", "GL_ARB_texture_float"])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_filterable_tex_type(webgl::FLOAT);
+ }
+
+ fn name() -> &'static str {
+ "OES_texture_float_linear"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs
new file mode 100644
index 00000000000..4f2ef41c651
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs
@@ -0,0 +1,65 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants;
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::{TexFormat, WebGLVersion};
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct OESTextureHalfFloat {
+ reflector_: Reflector,
+}
+
+impl OESTextureHalfFloat {
+ fn new_inherited() -> OESTextureHalfFloat {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for OESTextureHalfFloat {
+ type Extension = OESTextureHalfFloat;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureHalfFloat> {
+ reflect_dom_object(
+ Box::new(OESTextureHalfFloat::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_any_gl_extension(&[
+ "GL_OES_texture_half_float",
+ "GL_ARB_half_float_pixel",
+ "GL_NV_half_float",
+ "GL_EXT_color_buffer_half_float",
+ ])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ let hf = OESTextureHalfFloatConstants::HALF_FLOAT_OES;
+ ext.enable_tex_type(hf);
+ ext.add_effective_tex_internal_format(TexFormat::RGBA, hf, TexFormat::RGBA16f);
+ ext.add_effective_tex_internal_format(TexFormat::RGB, hf, TexFormat::RGB16f);
+ ext.add_effective_tex_internal_format(TexFormat::Luminance, hf, TexFormat::Luminance16f);
+ ext.add_effective_tex_internal_format(TexFormat::Alpha, hf, TexFormat::Alpha16f);
+ ext.add_effective_tex_internal_format(
+ TexFormat::LuminanceAlpha,
+ hf,
+ TexFormat::LuminanceAlpha16f,
+ );
+ }
+
+ fn name() -> &'static str {
+ "OES_texture_half_float"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs
new file mode 100644
index 00000000000..a1e5f3bf15d
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs
@@ -0,0 +1,53 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants;
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct OESTextureHalfFloatLinear {
+ reflector_: Reflector,
+}
+
+impl OESTextureHalfFloatLinear {
+ fn new_inherited() -> OESTextureHalfFloatLinear {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for OESTextureHalfFloatLinear {
+ type Extension = OESTextureHalfFloatLinear;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureHalfFloatLinear> {
+ reflect_dom_object(
+ Box::new(OESTextureHalfFloatLinear::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::All
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_any_gl_extension(&[
+ "GL_OES_texture_float_linear",
+ "GL_ARB_half_float_pixel",
+ "GL_NV_half_float",
+ ])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_filterable_tex_type(OESTextureHalfFloatConstants::HALF_FLOAT_OES);
+ }
+
+ fn name() -> &'static str {
+ "OES_texture_half_float_linear"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs
new file mode 100644
index 00000000000..57a68142609
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs
@@ -0,0 +1,80 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants;
+use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectMethods;
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::{Dom, DomRoot};
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use crate::dom::webglvertexarrayobjectoes::WebGLVertexArrayObjectOES;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct OESVertexArrayObject {
+ reflector_: Reflector,
+ ctx: Dom<WebGLRenderingContext>,
+}
+
+impl OESVertexArrayObject {
+ fn new_inherited(ctx: &WebGLRenderingContext) -> OESVertexArrayObject {
+ Self {
+ reflector_: Reflector::new(),
+ ctx: Dom::from_ref(ctx),
+ }
+ }
+}
+
+impl OESVertexArrayObjectMethods for OESVertexArrayObject {
+ // https://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/
+ fn CreateVertexArrayOES(&self) -> Option<DomRoot<WebGLVertexArrayObjectOES>> {
+ self.ctx.create_vertex_array()
+ }
+
+ // https://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/
+ fn DeleteVertexArrayOES(&self, vao: Option<&WebGLVertexArrayObjectOES>) {
+ self.ctx.delete_vertex_array(vao);
+ }
+
+ // https://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/
+ fn IsVertexArrayOES(&self, vao: Option<&WebGLVertexArrayObjectOES>) -> bool {
+ self.ctx.is_vertex_array(vao)
+ }
+
+ // https://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/
+ fn BindVertexArrayOES(&self, vao: Option<&WebGLVertexArrayObjectOES>) {
+ self.ctx.bind_vertex_array(vao);
+ }
+}
+
+impl WebGLExtension for OESVertexArrayObject {
+ type Extension = OESVertexArrayObject;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESVertexArrayObject> {
+ reflect_dom_object(
+ Box::new(OESVertexArrayObject::new_inherited(ctx)),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_any_gl_extension(&[
+ "GL_OES_vertex_array_object",
+ "GL_ARB_vertex_array_object",
+ "GL_APPLE_vertex_array_object",
+ ])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.enable_get_parameter_name(OESVertexArrayObjectConstants::VERTEX_ARRAY_BINDING_OES);
+ }
+
+ fn name() -> &'static str {
+ "OES_vertex_array_object"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs
new file mode 100644
index 00000000000..c0d8dc13776
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs
@@ -0,0 +1,48 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webgl_extensions::ext::oestexturefloat::OESTextureFloat;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use canvas_traits::webgl::WebGLVersion;
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct WEBGLColorBufferFloat {
+ reflector_: Reflector,
+}
+
+impl WEBGLColorBufferFloat {
+ fn new_inherited() -> WEBGLColorBufferFloat {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for WEBGLColorBufferFloat {
+ type Extension = WEBGLColorBufferFloat;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<WEBGLColorBufferFloat> {
+ reflect_dom_object(
+ Box::new(WEBGLColorBufferFloat::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ OESTextureFloat::is_supported(ext)
+ }
+
+ fn enable(_ext: &WebGLExtensions) {}
+
+ fn name() -> &'static str {
+ "WEBGL_color_buffer_float"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs
new file mode 100644
index 00000000000..749c38abd82
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs
@@ -0,0 +1,56 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use crate::dom::webgltexture::{TexCompression, TexCompressionValidation};
+use canvas_traits::webgl::{TexFormat, WebGLVersion};
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct WEBGLCompressedTextureETC1 {
+ reflector_: Reflector,
+}
+
+impl WEBGLCompressedTextureETC1 {
+ fn new_inherited() -> WEBGLCompressedTextureETC1 {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for WEBGLCompressedTextureETC1 {
+ type Extension = WEBGLCompressedTextureETC1;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<WEBGLCompressedTextureETC1> {
+ reflect_dom_object(
+ Box::new(WEBGLCompressedTextureETC1::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_gl_extension("GL_OES_compressed_ETC1_RGB8_texture")
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.add_tex_compression_formats(&[TexCompression {
+ format: TexFormat::CompressedRgbEtc1,
+ bytes_per_block: 8,
+ block_width: 4,
+ block_height: 4,
+ validation: TexCompressionValidation::None,
+ }]);
+ }
+
+ fn name() -> &'static str {
+ "WEBGL_compressed_texture_etc1"
+ }
+}
diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs
new file mode 100644
index 00000000000..362dbe67117
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs
@@ -0,0 +1,84 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::webglrenderingcontext::WebGLRenderingContext;
+use crate::dom::webgltexture::{TexCompression, TexCompressionValidation};
+use canvas_traits::webgl::{TexFormat, WebGLVersion};
+use dom_struct::dom_struct;
+
+#[dom_struct]
+pub struct WEBGLCompressedTextureS3TC {
+ reflector_: Reflector,
+}
+
+impl WEBGLCompressedTextureS3TC {
+ fn new_inherited() -> WEBGLCompressedTextureS3TC {
+ Self {
+ reflector_: Reflector::new(),
+ }
+ }
+}
+
+impl WebGLExtension for WEBGLCompressedTextureS3TC {
+ type Extension = WEBGLCompressedTextureS3TC;
+ fn new(ctx: &WebGLRenderingContext) -> DomRoot<WEBGLCompressedTextureS3TC> {
+ reflect_dom_object(
+ Box::new(WEBGLCompressedTextureS3TC::new_inherited()),
+ &*ctx.global(),
+ )
+ }
+
+ fn spec() -> WebGLExtensionSpec {
+ WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
+ }
+
+ fn is_supported(ext: &WebGLExtensions) -> bool {
+ ext.supports_gl_extension("GL_EXT_texture_compression_s3tc") ||
+ ext.supports_all_gl_extension(&[
+ "GL_EXT_texture_compression_dxt1",
+ "GL_ANGLE_texture_compression_dxt3",
+ "GL_ANGLE_texture_compression_dxt5",
+ ])
+ }
+
+ fn enable(ext: &WebGLExtensions) {
+ ext.add_tex_compression_formats(&[
+ TexCompression {
+ format: TexFormat::CompressedRgbS3tcDxt1,
+ bytes_per_block: 8,
+ block_width: 4,
+ block_height: 4,
+ validation: TexCompressionValidation::S3TC,
+ },
+ TexCompression {
+ format: TexFormat::CompressedRgbaS3tcDxt1,
+ bytes_per_block: 8,
+ block_width: 4,
+ block_height: 4,
+ validation: TexCompressionValidation::S3TC,
+ },
+ TexCompression {
+ format: TexFormat::CompressedRgbaS3tcDxt3,
+ bytes_per_block: 16,
+ block_width: 4,
+ block_height: 4,
+ validation: TexCompressionValidation::S3TC,
+ },
+ TexCompression {
+ format: TexFormat::CompressedRgbaS3tcDxt5,
+ bytes_per_block: 16,
+ block_width: 4,
+ block_height: 4,
+ validation: TexCompressionValidation::S3TC,
+ },
+ ]);
+ }
+
+ fn name() -> &'static str {
+ "WEBGL_compressed_texture_s3tc"
+ }
+}