diff options
author | Fausto Núñez Alberro <fausto.nunez@mailbox.org> | 2018-04-12 14:24:51 +0200 |
---|---|---|
committer | Fausto Núñez Alberro <fausto.nunez@mailbox.org> | 2018-04-24 18:16:51 +0200 |
commit | 58760d91d1830ce0bd75c22ebad42c4f9e332845 (patch) | |
tree | 3200e955264b921b50b4026933bc3d4a14c94759 /components/script/dom/webglrenderingcontext.rs | |
parent | 05fe8fa08d507836ce5659ff56f83022a90b241a (diff) | |
download | servo-58760d91d1830ce0bd75c22ebad42c4f9e332845.tar.gz servo-58760d91d1830ce0bd75c22ebad42c4f9e332845.zip |
Implement WebGL GetRenderbufferParameter
This needed a bump of gleam to version 0.4.33
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 8e4757a5841..d68f817dcd6 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -2348,6 +2348,45 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { Int32Value(receiver.recv().unwrap()) } + #[allow(unsafe_code)] + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7 + unsafe fn GetRenderbufferParameter( + &self, + _cx: *mut JSContext, + target: u32, + pname: u32 + ) -> JSVal { + let target_matches = target == constants::RENDERBUFFER; + + let pname_matches = match pname { + constants::RENDERBUFFER_WIDTH | + constants::RENDERBUFFER_HEIGHT | + constants::RENDERBUFFER_INTERNAL_FORMAT | + constants::RENDERBUFFER_RED_SIZE | + constants::RENDERBUFFER_GREEN_SIZE | + constants::RENDERBUFFER_BLUE_SIZE | + constants::RENDERBUFFER_ALPHA_SIZE | + constants::RENDERBUFFER_DEPTH_SIZE | + constants::RENDERBUFFER_STENCIL_SIZE => true, + _ => false, + }; + + if !target_matches || !pname_matches { + self.webgl_error(InvalidEnum); + return NullValue(); + } + + if self.bound_renderbuffer.get().is_none() { + self.webgl_error(InvalidOperation); + return NullValue(); + } + + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetRenderbufferParameter(target, pname, sender)); + + Int32Value(receiver.recv().unwrap()) + } + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 fn GetProgramInfoLog(&self, program: &WebGLProgram) -> Option<DOMString> { match program.get_info_log() { |