webgl: Allow TexImage data argument to be larger than necessary.

texture-size-limit.html is using a large array for all of its calls at
various sizes, and we were throwing errors on the calls that should
have passed.
This commit is contained in:
Eric Anholt 2016-10-23 16:09:59 -07:00
parent 62689ba64d
commit 2f68297051
4 changed files with 1164 additions and 1356 deletions

View file

@ -2359,7 +2359,13 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
Some(data) => data,
};
if buff.len() != expected_byte_length as usize {
// From the WebGL spec:
//
// "If pixels is non-null but its size is less than what
// is required by the specified width, height, format,
// type, and pixel storage parameters, generates an
// INVALID_OPERATION error."
if buff.len() < expected_byte_length as usize {
return Ok(self.webgl_error(InvalidOperation));
}
@ -2459,8 +2465,13 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
Some(data) => data,
};
if expected_byte_length != 0 &&
buff.len() != expected_byte_length as usize {
// From the WebGL spec:
//
// "If pixels is non-null but its size is less than what
// is required by the specified width, height, format,
// type, and pixel storage parameters, generates an
// INVALID_OPERATION error."
if buff.len() < expected_byte_length as usize {
return Ok(self.webgl_error(InvalidOperation));
}