From ee5bdbbd8b99b58eda19c117b1a06e4a90a61bb1 Mon Sep 17 00:00:00 2001 From: Igor Gutorov Date: Wed, 14 Mar 2018 20:41:36 +0200 Subject: Implement WebGL getFramebufferAttachmentParameter API --- components/script/dom/webglframebuffer.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'components/script/dom/webglframebuffer.rs') diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index c9165609cdb..ccea1efec7b 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -25,6 +25,12 @@ enum WebGLFramebufferAttachment { Texture { texture: Dom, level: i32 }, } +#[derive(Clone, JSTraceable, MallocSizeOf)] +pub enum WebGLFramebufferAttachmentRoot { + Renderbuffer(DomRoot), + Texture(DomRoot), +} + #[dom_struct] pub struct WebGLFramebuffer { webgl_object: WebGLObject, @@ -213,6 +219,25 @@ impl WebGLFramebuffer { Ok(()) } + pub fn attachment(&self, attachment: u32) -> Option { + let binding = match attachment { + constants::COLOR_ATTACHMENT0 => &self.color, + constants::DEPTH_ATTACHMENT => &self.depth, + constants::STENCIL_ATTACHMENT => &self.stencil, + constants::DEPTH_STENCIL_ATTACHMENT => &self.depthstencil, + _ => return None, + }; + + binding.borrow().as_ref().map(|bin| { + match bin { + &WebGLFramebufferAttachment::Renderbuffer(ref rb) => + WebGLFramebufferAttachmentRoot::Renderbuffer(DomRoot::from_ref(&rb)), + &WebGLFramebufferAttachment::Texture { ref texture, .. } => + WebGLFramebufferAttachmentRoot::Texture(DomRoot::from_ref(&texture)), + } + }) + } + pub fn texture2d(&self, attachment: u32, textarget: u32, texture: Option<&WebGLTexture>, level: i32) -> WebGLResult<()> { let binding = match attachment { -- cgit v1.2.3