aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-09-22 11:05:55 -0500
committerGitHub <noreply@github.com>2016-09-22 11:05:55 -0500
commitf09595e8af6cd480238d29559579434d94f868cc (patch)
tree4f6f24dbd783d9c2f6cb37224e27e052a56e3a3f
parentefdd94a2b629e4ae41d81a4209ad80b89eb6b937 (diff)
parentee149cdac7171178964b5b42b7f7569b045e8a65 (diff)
downloadservo-f09595e8af6cd480238d29559579434d94f868cc.tar.gz
servo-f09595e8af6cd480238d29559579434d94f868cc.zip
Auto merge of #13337 - ofekd:implement-webgl-isEnabled, r=emilio
Implement WebGLRenderingContext::isEnabled Implemented WebGLRenderingContext::isEnabled - Please note the return value of the implementation, not sure about returning `false` on `InvalidEnum`. - the `webgl/conformance-1.0.3/conformance/state/gl-enable-enum-test.html` wpt test is disabled on linux but was enabled on my machine and run to validate expectations. - the `/webgl/conformance-1.0.3/conformance/context/methods.html` test is disabled everywhere. Enabling and running on my machine showed incorrect expectations beyond `isEnabled`. The test was temporarily edited to test just for `isEnabled` and it ran successfully. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #13040 - [X] There are tests for these changes (please read details above) - [ ] These changes do not require tests because _____ <!-- 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/13337) <!-- Reviewable:end -->
-rw-r--r--components/script/dom/webglrenderingcontext.rs51
-rw-r--r--components/script/dom/webidls/WebGLRenderingContext.webidl2
-rw-r--r--tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini7
-rw-r--r--tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enable-enum-test.html.ini54
4 files changed, 37 insertions, 77 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index f42eeab4dbf..d1342190f73 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -511,6 +511,19 @@ impl WebGLRenderingContext {
.send(CanvasMsg::WebGL(msg))
.unwrap()
}
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14
+ fn validate_feature_enum(&self, cap: u32) -> bool {
+ match cap {
+ constants::BLEND | constants::CULL_FACE | constants::DEPTH_TEST | constants::DITHER |
+ constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE |
+ constants::SAMPLE_COVERAGE_INVERT | constants::SCISSOR_TEST => true,
+ _ => {
+ self.webgl_error(InvalidEnum);
+ false
+ },
+ }
+ }
}
impl Drop for WebGLRenderingContext {
@@ -1114,27 +1127,19 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn Enable(&self, cap: u32) {
- match cap {
- constants::BLEND | constants::CULL_FACE | constants::DEPTH_TEST | constants::DITHER |
- constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE |
- constants::SAMPLE_COVERAGE_INVERT | constants::SCISSOR_TEST =>
- self.ipc_renderer
- .send(CanvasMsg::WebGL(WebGLCommand::Enable(cap)))
- .unwrap(),
- _ => self.webgl_error(InvalidEnum),
+ if self.validate_feature_enum(cap) {
+ self.ipc_renderer
+ .send(CanvasMsg::WebGL(WebGLCommand::Enable(cap)))
+ .unwrap();
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn Disable(&self, cap: u32) {
- match cap {
- constants::BLEND | constants::CULL_FACE | constants::DEPTH_TEST | constants::DITHER |
- constants::POLYGON_OFFSET_FILL | constants::SAMPLE_ALPHA_TO_COVERAGE | constants::SAMPLE_COVERAGE |
- constants::SAMPLE_COVERAGE_INVERT | constants::SCISSOR_TEST =>
- self.ipc_renderer
- .send(CanvasMsg::WebGL(WebGLCommand::Disable(cap)))
- .unwrap(),
- _ => self.webgl_error(InvalidEnum),
+ if self.validate_feature_enum(cap) {
+ self.ipc_renderer
+ .send(CanvasMsg::WebGL(WebGLCommand::Disable(cap)))
+ .unwrap()
}
}
@@ -1455,6 +1460,20 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
buffer.map_or(false, |buf| buf.target().is_some() && !buf.is_deleted())
}
+ // TODO: We could write this without IPC, recording the calls to `enable` and `disable`.
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
+ fn IsEnabled(&self, cap: u32) -> bool {
+ if self.validate_feature_enum(cap) {
+ let (sender, receiver) = ipc::channel().unwrap();
+ self.ipc_renderer
+ .send(CanvasMsg::WebGL(WebGLCommand::IsEnabled(cap, sender)))
+ .unwrap();
+ return receiver.recv().unwrap();
+ }
+
+ false
+ }
+
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
fn IsFramebuffer(&self, frame_buffer: Option<&WebGLFramebuffer>) -> bool {
frame_buffer.map_or(false, |buf| buf.target().is_some() && !buf.is_deleted())
diff --git a/components/script/dom/webidls/WebGLRenderingContext.webidl b/components/script/dom/webidls/WebGLRenderingContext.webidl
index e95ce00e5e5..06727b3a536 100644
--- a/components/script/dom/webidls/WebGLRenderingContext.webidl
+++ b/components/script/dom/webidls/WebGLRenderingContext.webidl
@@ -603,7 +603,7 @@ interface WebGLRenderingContextBase
void hint(GLenum target, GLenum mode);
[WebGLHandlesContextLoss] GLboolean isBuffer(WebGLBuffer? buffer);
- //[WebGLHandlesContextLoss] GLboolean isEnabled(GLenum cap);
+ [WebGLHandlesContextLoss] GLboolean isEnabled(GLenum cap);
[WebGLHandlesContextLoss] GLboolean isFramebuffer(WebGLFramebuffer? framebuffer);
[WebGLHandlesContextLoss] GLboolean isProgram(WebGLProgram? program);
[WebGLHandlesContextLoss] GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer);
diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini
index f2b90d3e9b6..ab02f21b3bd 100644
--- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini
+++ b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/context/methods.html.ini
@@ -71,9 +71,6 @@
[WebGL test #22: Property either does not exist or is not a function: isContextLost]
expected: FAIL
- [WebGL test #23: Property either does not exist or is not a function: isEnabled]
- expected: FAIL
-
[WebGL test #24: Property either does not exist or is not a function: isFramebuffer]
expected: FAIL
@@ -215,9 +212,6 @@
[WebGL test #18: Property either does not exist or is not a function: isContextLost]
expected: FAIL
- [WebGL test #19: Property either does not exist or is not a function: isEnabled]
- expected: FAIL
-
[WebGL test #20: Property either does not exist or is not a function: isFramebuffer]
expected: FAIL
@@ -307,4 +301,3 @@
[WebGL test #49: Property either does not exist or is not a function: validateProgram]
expected: FAIL
-
diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enable-enum-test.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enable-enum-test.html.ini
index eb7f288f864..0bcdb50b83f 100644
--- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enable-enum-test.html.ini
+++ b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/state/gl-enable-enum-test.html.ini
@@ -1,62 +1,10 @@
[gl-enable-enum-test.html]
type: testharness
- [WebGL test #59: gl.isEnabled(gl.BLEND) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #60: gl.isEnabled(gl.BLEND) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #62: gl.isEnabled(gl.CULL_FACE) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #63: gl.isEnabled(gl.CULL_FACE) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #65: gl.isEnabled(gl.DEPTH_TEST) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #66: gl.isEnabled(gl.DEPTH_TEST) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #68: gl.isEnabled(gl.DITHER) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #69: gl.isEnabled(gl.DITHER) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #71: gl.isEnabled(gl.POLYGON_OFFSET_FILL) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #72: gl.isEnabled(gl.POLYGON_OFFSET_FILL) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #74: gl.isEnabled(gl.SAMPLE_ALPHA_TO_COVERAGE) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #75: gl.isEnabled(gl.SAMPLE_ALPHA_TO_COVERAGE) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #77: gl.isEnabled(gl.SAMPLE_COVERAGE) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #78: gl.isEnabled(gl.SAMPLE_COVERAGE) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #80: gl.isEnabled(gl.SCISSOR_TEST) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #81: gl.isEnabled(gl.SCISSOR_TEST) should be false. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
[WebGL test #82: getError expected: NO_ERROR. Was INVALID_ENUM : gl.enable must succeed when passed gl.STENCIL_TEST]
expected: FAIL
- [WebGL test #83: gl.isEnabled(gl.STENCIL_TEST) should be true. Threw exception TypeError: gl.isEnabled is not a function]
- expected: FAIL
-
- [WebGL test #84: gl.isEnabled(gl.STENCIL_TEST) should be false. Threw exception TypeError: gl.isEnabled is not a function]
+ [WebGL test #83: gl.isEnabled(gl.STENCIL_TEST) should be true. Was false.]
expected: FAIL
[WebGL test #85: getError expected: NO_ERROR. Was INVALID_ENUM : there should be no errors]
expected: FAIL
-