Issue #20593: Implement proper checks in WebGLRenderingContext's getFramebufferAttachmentParameter().

This commit is contained in:
Simon Martin 2018-04-27 09:53:38 +02:00
parent ab39f6dbc7
commit 08b193c922
3 changed files with 154 additions and 1 deletions

View file

@ -2339,7 +2339,36 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
_ => false
};
if !target_matches || !attachment_matches || !pname_matches {
let bound_attachment_matches = match self.bound_framebuffer.get().unwrap().attachment(attachment) {
Some(attachment_root) => {
match attachment_root {
WebGLFramebufferAttachmentRoot::Renderbuffer(_) => {
match pname {
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE |
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME => true,
_ => false
}
},
WebGLFramebufferAttachmentRoot::Texture(_) => {
match pname {
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE |
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME |
constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL |
constants::FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE => true,
_ => false
}
}
}
},
_ => {
match pname {
constants::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE => true,
_ => false
}
}
};
if !target_matches || !attachment_matches || !pname_matches || !bound_attachment_matches {
self.webgl_error(InvalidEnum);
return NullValue();
}