aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglframebuffer.rs
diff options
context:
space:
mode:
authorIgor Gutorov <igootorov@gmail.com>2018-03-14 20:41:36 +0200
committerIgor Gutorov <igootorov@gmail.com>2018-03-22 18:26:18 +0200
commitee5bdbbd8b99b58eda19c117b1a06e4a90a61bb1 (patch)
treef4c3a2dcc85b6e576ddaaa585210bc293ffbff6c /components/script/dom/webglframebuffer.rs
parentf92f0809f89593d4b70eb0f507f6ca4409c9ed91 (diff)
downloadservo-ee5bdbbd8b99b58eda19c117b1a06e4a90a61bb1.tar.gz
servo-ee5bdbbd8b99b58eda19c117b1a06e4a90a61bb1.zip
Implement WebGL getFramebufferAttachmentParameter API
Diffstat (limited to 'components/script/dom/webglframebuffer.rs')
-rw-r--r--components/script/dom/webglframebuffer.rs25
1 files changed, 25 insertions, 0 deletions
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<WebGLTexture>, level: i32 },
}
+#[derive(Clone, JSTraceable, MallocSizeOf)]
+pub enum WebGLFramebufferAttachmentRoot {
+ Renderbuffer(DomRoot<WebGLRenderbuffer>),
+ Texture(DomRoot<WebGLTexture>),
+}
+
#[dom_struct]
pub struct WebGLFramebuffer {
webgl_object: WebGLObject,
@@ -213,6 +219,25 @@ impl WebGLFramebuffer {
Ok(())
}
+ pub fn attachment(&self, attachment: u32) -> Option<WebGLFramebufferAttachmentRoot> {
+ 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 {