aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorOfek <ofek@outlook.com>2016-09-17 21:36:55 +0300
committerOfek <ofek@outlook.com>2016-09-22 13:44:35 +0300
commitee149cdac7171178964b5b42b7f7569b045e8a65 (patch)
tree75e40ee4c5c6ff55e615288d60470e41d0b1b103 /components/script/dom/webglrenderingcontext.rs
parent73b296350927bad6d526cce21434ce68a75216fa (diff)
downloadservo-ee149cdac7171178964b5b42b7f7569b045e8a65.tar.gz
servo-ee149cdac7171178964b5b42b7f7569b045e8a65.zip
implement WebGLRenderingContext::isEnabled
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs51
1 files changed, 35 insertions, 16 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())