diff options
author | Eric Anholt <eric@anholt.net> | 2016-11-01 21:45:29 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2016-11-05 10:43:12 -0700 |
commit | d77373654a4d168092fb51d1810236d4bf0b3b52 (patch) | |
tree | 8a2d17f657b11e81df0e4249e91f5704393e7cf6 /components/script/dom/webglframebuffer.rs | |
parent | 8e681dddc18c7aaaa7df5f7974274a62430c99f5 (diff) | |
download | servo-d77373654a4d168092fb51d1810236d4bf0b3b52.tar.gz servo-d77373654a4d168092fb51d1810236d4bf0b3b52.zip |
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.
Diffstat (limited to 'components/script/dom/webglframebuffer.rs')
-rw-r--r-- | components/script/dom/webglframebuffer.rs | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 2571586ab11..e271f1c7034 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -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() } |