aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-06-22 08:11:33 -0400
committerGitHub <noreply@github.com>2018-06-22 08:11:33 -0400
commit728ebcc932e33b36f0fb76e6e794ef1c1dc15e32 (patch)
treec1e04726ab05293134290950115c882ef465464d
parent6a4bd8d3fa8c0c8fe4a85a04fe8405673dbd8513 (diff)
parent02b8766e7533d7318a3588e59bde78f3d639a89b (diff)
downloadservo-728ebcc932e33b36f0fb76e6e794ef1c1dc15e32.tar.gz
servo-728ebcc932e33b36f0fb76e6e794ef1c1dc15e32.zip
Auto merge of #21080 - servo:webgl, r=emilio
Implement EXT_blend_minmax <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21080) <!-- Reviewable:end -->
-rw-r--r--components/script/dom/webgl_extensions/ext/extblendminmax.rs50
-rw-r--r--components/script/dom/webgl_extensions/ext/mod.rs1
-rw-r--r--components/script/dom/webgl_extensions/extensions.rs16
-rw-r--r--components/script/dom/webglrenderingcontext.rs40
-rw-r--r--components/script/dom/webidls/EXTBlendMinmax.webidl13
-rw-r--r--tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/extensions/ext-blend-minmax.html.ini44
6 files changed, 99 insertions, 65 deletions
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..70bf828ccc8
--- /dev/null
+++ b/components/script/dom/webgl_extensions/ext/extblendminmax.rs
@@ -0,0 +1,50 @@
+/* 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 http://mozilla.org/MPL/2.0/. */
+
+use canvas_traits::webgl::WebGLVersion;
+use dom::bindings::codegen::Bindings::EXTBlendMinmaxBinding;
+use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
+use dom::bindings::root::DomRoot;
+use dom::webglrenderingcontext::WebGLRenderingContext;
+use dom_struct::dom_struct;
+use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
+
+#[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(),
+ EXTBlendMinmaxBinding::Wrap,
+ )
+ }
+
+ 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/mod.rs b/components/script/dom/webgl_extensions/ext/mod.rs
index e0c7b1f189a..bdf19d5327a 100644
--- a/components/script/dom/webgl_extensions/ext/mod.rs
+++ b/components/script/dom/webgl_extensions/ext/mod.rs
@@ -5,6 +5,7 @@
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use super::{ext_constants, WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
+pub mod extblendminmax;
pub mod extshadertexturelod;
pub mod exttexturefilteranisotropic;
pub mod oeselementindexuint;
diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs
index ca81e2d10e8..c5413ea1eb2 100644
--- a/components/script/dom/webgl_extensions/extensions.rs
+++ b/components/script/dom/webgl_extensions/extensions.rs
@@ -70,6 +70,8 @@ struct WebGLExtensionFeatures {
disabled_get_tex_parameter_names: FnvHashSet<GLenum>,
/// WebGL OES_element_index_uint extension.
element_index_uint_enabled: bool,
+ /// WebGL EXT_blend_minmax extension.
+ blend_minmax_enabled: bool,
}
impl WebGLExtensionFeatures {
@@ -79,6 +81,7 @@ impl WebGLExtensionFeatures {
disabled_get_parameter_names,
disabled_get_tex_parameter_names,
element_index_uint_enabled,
+ blend_minmax_enabled,
) = match webgl_version {
WebGLVersion::WebGL1 => {
(
@@ -86,10 +89,11 @@ impl WebGLExtensionFeatures {
DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL1.iter().cloned().collect(),
DEFAULT_DISABLED_GET_TEX_PARAMETER_NAMES_WEBGL1.iter().cloned().collect(),
false,
+ false,
)
},
WebGLVersion::WebGL2 => {
- (Default::default(), Default::default(), Default::default(), true)
+ (Default::default(), Default::default(), Default::default(), true, true)
}
};
Self {
@@ -102,6 +106,7 @@ impl WebGLExtensionFeatures {
disabled_get_parameter_names,
disabled_get_tex_parameter_names,
element_index_uint_enabled,
+ blend_minmax_enabled,
}
}
}
@@ -265,6 +270,7 @@ impl WebGLExtensions {
}
fn register_all_extensions(&self) {
+ self.register::<ext::extblendminmax::EXTBlendMinmax>();
self.register::<ext::extshadertexturelod::EXTShaderTextureLod>();
self.register::<ext::exttexturefilteranisotropic::EXTTextureFilterAnisotropic>();
self.register::<ext::oeselementindexuint::OESElementIndexUint>();
@@ -283,6 +289,14 @@ impl WebGLExtensions {
pub fn is_element_index_uint_enabled(&self) -> bool {
self.features.borrow().element_index_uint_enabled
}
+
+ pub fn enable_blend_minmax(&self) {
+ self.features.borrow_mut().blend_minmax_enabled = true;
+ }
+
+ pub fn is_blend_minmax_enabled(&self) -> bool {
+ self.features.borrow().blend_minmax_enabled
+ }
}
// Helper structs
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index d712b8cc58a..7079bbcc76b 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -12,6 +12,7 @@ use canvas_traits::webgl::{WebGLResult, WebGLSLVersion, WebGLVersion};
use canvas_traits::webgl::{WebVRCommand, webgl_channel};
use canvas_traits::webgl::WebGLError::*;
use dom::bindings::cell::DomRefCell;
+use dom::bindings::codegen::Bindings::EXTBlendMinmaxBinding::EXTBlendMinmaxConstants;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{self, WebGLContextAttributes};
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
@@ -1193,6 +1194,21 @@ impl WebGLRenderingContext {
_ => Err(WebGLError::InvalidEnum),
}
}
+
+ fn validate_blend_mode(&self, mode: u32) -> WebGLResult<()> {
+ match mode {
+ constants::FUNC_ADD |
+ constants::FUNC_SUBTRACT |
+ constants::FUNC_REVERSE_SUBTRACT => {
+ Ok(())
+ }
+ EXTBlendMinmaxConstants::MIN_EXT |
+ EXTBlendMinmaxConstants::MAX_EXT if self.extension_manager.is_blend_minmax_enabled() => {
+ Ok(())
+ }
+ _ => Err(InvalidEnum),
+ }
+ }
}
impl Drop for WebGLRenderingContext {
@@ -1547,30 +1563,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn BlendEquation(&self, mode: u32) {
- match mode {
- constants::FUNC_ADD |
- constants::FUNC_SUBTRACT |
- constants::FUNC_REVERSE_SUBTRACT => {
- self.send_command(WebGLCommand::BlendEquation(mode))
- }
- _ => self.webgl_error(InvalidEnum),
- }
+ handle_potential_webgl_error!(self, self.validate_blend_mode(mode), return);
+ self.send_command(WebGLCommand::BlendEquation(mode))
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn BlendEquationSeparate(&self, mode_rgb: u32, mode_alpha: u32) {
- match mode_rgb {
- constants::FUNC_ADD |
- constants::FUNC_SUBTRACT |
- constants::FUNC_REVERSE_SUBTRACT => {},
- _ => return self.webgl_error(InvalidEnum),
- }
- match mode_alpha {
- constants::FUNC_ADD |
- constants::FUNC_SUBTRACT |
- constants::FUNC_REVERSE_SUBTRACT => {},
- _ => return self.webgl_error(InvalidEnum),
- }
+ handle_potential_webgl_error!(self, self.validate_blend_mode(mode_rgb), return);
+ handle_potential_webgl_error!(self, self.validate_blend_mode(mode_alpha), return);
self.send_command(WebGLCommand::BlendEquationSeparate(mode_rgb, mode_alpha));
}
diff --git a/components/script/dom/webidls/EXTBlendMinmax.webidl b/components/script/dom/webidls/EXTBlendMinmax.webidl
new file mode 100644
index 00000000000..bbdbee874f5
--- /dev/null
+++ b/components/script/dom/webidls/EXTBlendMinmax.webidl
@@ -0,0 +1,13 @@
+/* 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 http://mozilla.org/MPL/2.0/. */
+/*
+ * WebGL IDL definitions scraped from the Khronos specification:
+ * https://www.khronos.org/registry/webgl/extensions/EXT_blend_minmax/
+ */
+
+[NoInterfaceObject]
+interface EXTBlendMinmax {
+ const GLenum MIN_EXT = 0x8007;
+ const GLenum MAX_EXT = 0x8008;
+};
diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/extensions/ext-blend-minmax.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/extensions/ext-blend-minmax.html.ini
deleted file mode 100644
index 47c604ed3cf..00000000000
--- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/extensions/ext-blend-minmax.html.ini
+++ /dev/null
@@ -1,44 +0,0 @@
-[ext-blend-minmax.html]
- type: testharness
- [WebGL test #1: getError expected: INVALID_ENUM. Was NO_ERROR : after evaluating: gl.blendEquation(MIN_EXT)]
- expected: FAIL
-
- [WebGL test #2: gl.getParameter(gl.BLEND_EQUATION) should be 32774. Was 32775.]
- expected: FAIL
-
- [WebGL test #3: getError expected: INVALID_ENUM. Was NO_ERROR : after evaluating: gl.blendEquation(MAX_EXT)]
- expected: FAIL
-
- [WebGL test #4: gl.getParameter(gl.BLEND_EQUATION) should be 32774. Was 32776.]
- expected: FAIL
-
- [WebGL test #5: getError expected: INVALID_ENUM. Was NO_ERROR : after evaluating: gl.blendEquationSeparate(MIN_EXT, gl.FUNC_ADD)]
- expected: FAIL
-
- [WebGL test #6: gl.getParameter(gl.BLEND_EQUATION_RGB) should be 32774. Was 32775.]
- expected: FAIL
-
- [WebGL test #7: getError expected: INVALID_ENUM. Was NO_ERROR : after evaluating: gl.blendEquationSeparate(gl.FUNC_ADD, MIN_EXT)]
- expected: FAIL
-
- [WebGL test #8: gl.getParameter(gl.BLEND_EQUATION_ALPHA) should be 32774. Was 32775.]
- expected: FAIL
-
- [WebGL test #9: getError expected: INVALID_ENUM. Was NO_ERROR : after evaluating: gl.blendEquationSeparate(MAX_EXT, gl.FUNC_ADD)]
- expected: FAIL
-
- [WebGL test #10: gl.getParameter(gl.BLEND_EQUATION_RGB) should be 32774. Was 32776.]
- expected: FAIL
-
- [WebGL test #11: getError expected: INVALID_ENUM. Was NO_ERROR : after evaluating: gl.blendEquationSeparate(gl.FUNC_ADD, MAX_EXT)]
- expected: FAIL
-
- [WebGL test #12: gl.getParameter(gl.BLEND_EQUATION_ALPHA) should be 32774. Was 32776.]
- expected: FAIL
-
- [WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
- expected: FAIL
-
- [WebGL test #1: WebGL context does not exist]
- expected: FAIL
-