diff options
author | Eric Anholt <eric@anholt.net> | 2016-09-18 13:17:41 +0100 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2016-10-25 22:19:26 -0700 |
commit | dba7d5eb51b5eb433f47a948f66df77920b06191 (patch) | |
tree | fabceedf764f49742c3cf7b8779604e52fc2b407 /components/script/dom/webglframebuffer.rs | |
parent | 6c10d5ca75d8d6064fa36c3ec3309fdd54e5f1c7 (diff) | |
download | servo-dba7d5eb51b5eb433f47a948f66df77920b06191.tar.gz servo-dba7d5eb51b5eb433f47a948f66df77920b06191.zip |
webgl: Detach RBs and textures from the bound FBO on deletion.
This is part of general GL behavior: when an object is deleted, look
through the currently bound objects and detach the deleted object from
them. Detaching an object from an FBO causes it to need to be
re-checked for its status.
Diffstat (limited to 'components/script/dom/webglframebuffer.rs')
-rw-r--r-- | components/script/dom/webglframebuffer.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 4dddfb047a0..0211a0bc31f 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -231,6 +231,7 @@ impl WebGLFramebuffer { _ => { *binding.borrow_mut() = None; + self.update_status(); None } }; @@ -245,6 +246,49 @@ impl WebGLFramebuffer { Ok(()) } + pub fn detach_renderbuffer(&self, rb: &WebGLRenderbuffer) { + let attachments = [&self.color, + &self.depth, + &self.stencil, + &self.depthstencil]; + + for attachment in &attachments { + let matched = { + match *attachment.borrow() { + Some(WebGLFramebufferAttachment::Renderbuffer(ref att_rb)) + if rb.id() == att_rb.id() => true, + _ => false, + } + }; + + if matched { + *attachment.borrow_mut() = None; + self.update_status(); + } + } + } + + pub fn detach_texture(&self, texture: &WebGLTexture) { + let attachments = [&self.color, + &self.depth, + &self.stencil, + &self.depthstencil]; + + for attachment in &attachments { + let matched = { + match *attachment.borrow() { + Some(WebGLFramebufferAttachment::Texture(ref att_texture)) + if texture.id() == att_texture.id() => true, + _ => false, + } + }; + + if matched { + *attachment.borrow_mut() = None; + } + } + } + pub fn target(&self) -> Option<u32> { self.target.get() } |