diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index e271f1c70340..8586b09d5bf6 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 { diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index 31fdaafcffdc..3ba8eefca85e 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -332,7 +332,7 @@ impl WebGLTexture { self.image_info_at_face(face_index, level) } - fn image_info_at_face(&self, face: u8, level: u32) -> ImageInfo { + pub fn image_info_at_face(&self, face: u8, level: u32) -> ImageInfo { let pos = (level * self.face_count.get() as u32) + face as u32; self.image_info_array.borrow()[pos as usize] }