webgl: Update FBO status when textures or RBs are reallocated.

FBO status is supposed to depend on the size of the attachments all
matching, so we need to re-check when it changes.  We don't ensure
matching yet, but this will prevent regressions when we do.
This commit is contained in:
Eric Anholt 2016-11-01 21:45:29 -07:00
parent 8e681dddc1
commit d77373654a
2 changed files with 45 additions and 8 deletions

View file

@ -254,7 +254,9 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn detach_renderbuffer(&self, rb: &WebGLRenderbuffer) {
fn with_matching_renderbuffers<F>(&self, rb: &WebGLRenderbuffer, mut closure: F)
where F: FnMut(&DOMRefCell<Option<WebGLFramebufferAttachment>>)
{
let attachments = [&self.color,
&self.depth,
&self.stencil,
@ -270,13 +272,14 @@ impl WebGLFramebuffer {
};
if matched {
*attachment.borrow_mut() = None;
self.update_status();
closure(attachment);
}
}
}
pub fn detach_texture(&self, texture: &WebGLTexture) {
fn with_matching_textures<F>(&self, texture: &WebGLTexture, mut closure: F)
where F: FnMut(&DOMRefCell<Option<WebGLFramebufferAttachment>>)
{
let attachments = [&self.color,
&self.depth,
&self.stencil,
@ -292,12 +295,37 @@ impl WebGLFramebuffer {
};
if matched {
*attachment.borrow_mut() = None;
self.update_status();
closure(attachment);
}
}
}
pub fn detach_renderbuffer(&self, rb: &WebGLRenderbuffer) {
self.with_matching_renderbuffers(rb, |att| {
*att.borrow_mut() = None;
self.update_status();
});
}
pub fn detach_texture(&self, texture: &WebGLTexture) {
self.with_matching_textures(texture, |att| {
*att.borrow_mut() = None;
self.update_status();
});
}
pub fn invalidate_renderbuffer(&self, rb: &WebGLRenderbuffer) {
self.with_matching_renderbuffers(rb, |_att| {
self.update_status();
});
}
pub fn invalidate_texture(&self, texture: &WebGLTexture) {
self.with_matching_textures(texture, |_att| {
self.update_status();
});
}
pub fn target(&self) -> Option<u32> {
self.target.get()
}