aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglframebuffer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/webglframebuffer.rs')
-rw-r--r--components/script/dom/webglframebuffer.rs39
1 files changed, 35 insertions, 4 deletions
diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs
index e271f1c7034..8586b09d5bf 100644
--- a/components/script/dom/webglframebuffer.rs
+++ b/components/script/dom/webglframebuffer.rs
@@ -111,10 +111,15 @@ impl WebGLFramebuffer {
}
fn update_status(&self) {
- let has_c = self.color.borrow().is_some();
- let has_z = self.depth.borrow().is_some();
- let has_s = self.stencil.borrow().is_some();
- let has_zs = self.depthstencil.borrow().is_some();
+ let c = self.color.borrow();
+ let z = self.depth.borrow();
+ let s = self.stencil.borrow();
+ let zs = self.depthstencil.borrow();
+ let has_c = c.is_some();
+ let has_z = z.is_some();
+ let has_s = s.is_some();
+ let has_zs = zs.is_some();
+ let attachments = [&*c, &*z, &*s, &*zs];
// From the WebGL spec, 6.6 ("Framebuffer Object Attachments"):
//
@@ -135,6 +140,32 @@ impl WebGLFramebuffer {
return;
}
+ let mut fb_size = None;
+ for attachment in &attachments {
+ // Get the size of this attachment.
+ let size = match **attachment {
+ Some(WebGLFramebufferAttachment::Renderbuffer(ref att_rb)) => {
+ att_rb.size()
+ }
+ Some(WebGLFramebufferAttachment::Texture { texture: ref att_tex, level } ) => {
+ let info = att_tex.image_info_at_face(0, level as u32);
+ Some((info.width() as i32, info.height() as i32))
+ }
+ None => None,
+ };
+
+ // Make sure that, if we've found any other attachment,
+ // that the size matches.
+ if size.is_some() {
+ if fb_size.is_some() && size != fb_size {
+ self.status.set(constants::FRAMEBUFFER_INCOMPLETE_DIMENSIONS);
+ return;
+ } else {
+ fb_size = size;
+ }
+ }
+ }
+
if has_c || has_z || has_zs || has_s {
self.status.set(constants::FRAMEBUFFER_COMPLETE);
} else {