mirror of
https://github.com/servo/servo
synced 2026-04-27 18:07:52 +02:00
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.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user