Fix a small texSubImage2D bug

This commit is contained in:
Anthony Ramine 2018-09-18 10:49:31 +02:00
parent 8c100b23b1
commit fe6f53ffb4
2 changed files with 6 additions and 8 deletions

View file

@ -3613,7 +3613,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
height: i32, height: i32,
format: u32, format: u32,
data_type: u32, data_type: u32,
mut pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>, pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>,
) -> ErrorResult { ) -> ErrorResult {
let validator = TexImage2DValidator::new(self, target, level, let validator = TexImage2DValidator::new(self, target, level,
format, width, height, format, width, height,
@ -3644,10 +3644,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// If data is null, a buffer of sufficient size // If data is null, a buffer of sufficient size
// initialized to 0 is passed. // initialized to 0 is passed.
let buff = match *pixels { let buff = handle_potential_webgl_error!(
None => vec![0u8; expected_byte_length as usize], self,
Some(ref mut data) => data.to_vec(), pixels.as_ref().map(|p| p.to_vec()).ok_or(InvalidValue),
}; return Ok(())
);
// From the WebGL spec: // From the WebGL spec:
// //

View file

@ -1,7 +1,4 @@
[tex-sub-image-2d-bad-args.html] [tex-sub-image-2d-bad-args.html]
[WebGL test #9: getError expected: INVALID_VALUE. Was NO_ERROR : null pixels]
expected: FAIL
[WebGL test #0: getError expected: INVALID_OPERATION. Was INVALID_VALUE : no previously defined texture image] [WebGL test #0: getError expected: INVALID_OPERATION. Was INVALID_VALUE : no previously defined texture image]
expected: FAIL expected: FAIL