mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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:
parent
8e681dddc1
commit
d77373654a
2 changed files with 45 additions and 8 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -465,7 +465,11 @@ impl WebGLRenderingContext {
|
|||
|
||||
self.ipc_renderer
|
||||
.send(CanvasMsg::WebGL(msg))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
if let Some(fb) = self.bound_framebuffer.get() {
|
||||
fb.invalidate_texture(&*texture);
|
||||
}
|
||||
}
|
||||
|
||||
fn tex_sub_image_2d(&self,
|
||||
|
@ -2621,7 +2625,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
}
|
||||
|
||||
match self.bound_renderbuffer.get() {
|
||||
Some(rb) => handle_potential_webgl_error!(self, rb.storage(internal_format, width, height)),
|
||||
Some(rb) => {
|
||||
handle_potential_webgl_error!(self, rb.storage(internal_format, width, height));
|
||||
if let Some(fb) = self.bound_framebuffer.get() {
|
||||
fb.invalidate_renderbuffer(&*rb);
|
||||
}
|
||||
}
|
||||
None => self.webgl_error(InvalidOperation),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue