mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Issue #6791: Allow more array types in bufferData and bufferSubData.
This commit is contained in:
parent
2cfcc26d9e
commit
fa555d0e2e
4 changed files with 55 additions and 9 deletions
|
@ -127,8 +127,8 @@ pub enum CanvasWebGLMsg {
|
|||
BlendFunc(u32, u32),
|
||||
BlendFuncSeparate(u32, u32, u32, u32),
|
||||
AttachShader(u32, u32),
|
||||
BufferData(u32, Vec<f32>, u32),
|
||||
BufferSubData(u32, isize, Vec<f32>),
|
||||
BufferData(u32, Vec<u8>, u32),
|
||||
BufferSubData(u32, isize, Vec<u8>),
|
||||
Clear(u32),
|
||||
ClearColor(f32, f32, f32, f32),
|
||||
ClearDepth(f64),
|
||||
|
|
|
@ -37,7 +37,7 @@ use net_traits::image_cache_task::ImageResponse;
|
|||
use offscreen_gl_context::GLContextAttributes;
|
||||
use std::cell::Cell;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::{mem, ptr, slice};
|
||||
use std::{ptr, slice};
|
||||
use util::str::DOMString;
|
||||
use util::vec::byte_swap;
|
||||
|
||||
|
@ -400,9 +400,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
if buffer_data.is_null() {
|
||||
return self.webgl_error(InvalidValue) // https://github.com/servo/servo/issues/5014
|
||||
}
|
||||
let data_f32 = JS_GetFloat32ArrayData(buffer_data, ptr::null());
|
||||
let data_vec_length = length / mem::size_of::<f32>() as u32;
|
||||
slice::from_raw_parts(data_f32, data_vec_length as usize).to_vec()
|
||||
slice::from_raw_parts(ptr, length as usize).to_vec()
|
||||
};
|
||||
self.ipc_renderer
|
||||
.send(CanvasMsg::WebGL(CanvasWebGLMsg::BufferData(target, data_vec, usage)))
|
||||
|
@ -431,9 +429,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
if buffer_data.is_null() {
|
||||
return self.webgl_error(InvalidValue) // https://github.com/servo/servo/issues/5014
|
||||
}
|
||||
let data_f32 = JS_GetFloat32ArrayData(buffer_data, ptr::null());
|
||||
let data_vec_length = length / mem::size_of::<f32>() as u32;
|
||||
slice::from_raw_parts(data_f32, data_vec_length as usize).to_vec()
|
||||
slice::from_raw_parts(ptr, length as usize).to_vec()
|
||||
};
|
||||
// FIXME(simartin) Check that the defined region is inside the allocated one
|
||||
// https://github.com/servo/servo/issues/8738
|
||||
|
|
|
@ -5787,6 +5787,12 @@
|
|||
"url": "/_mozilla/mozilla/variadic-interface.html"
|
||||
}
|
||||
],
|
||||
"mozilla/webgl/bufferData.html": [
|
||||
{
|
||||
"path": "mozilla/webgl/bufferData.html",
|
||||
"url": "/_mozilla/mozilla/webgl/bufferData.html"
|
||||
}
|
||||
],
|
||||
"mozilla/webgl/context_creation_error.html": [
|
||||
{
|
||||
"path": "mozilla/webgl/context_creation_error.html",
|
||||
|
|
44
tests/wpt/mozilla/tests/mozilla/webgl/bufferData.html
Normal file
44
tests/wpt/mozilla/tests/mozilla/webgl/bufferData.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>bufferData and bufferSubData input array type check (issue #6791)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
test(function() {
|
||||
var gl = document.createElement("canvas").getContext("webgl");
|
||||
var texture_buffer = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, texture_buffer);
|
||||
|
||||
var coordI8 = new Int8Array([ 1, 0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordI8, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordI8);
|
||||
|
||||
var coordU8 = new Uint8Array([ 1, 0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordU8, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordU8);
|
||||
|
||||
var coordI16 = new Int16Array([ 1, 0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordI16, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordI16);
|
||||
|
||||
var coordU16 = new Uint16Array([ 1, 0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordU16, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordU16);
|
||||
|
||||
var coordI32 = new Int32Array([ 1, 0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordI32, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordI32);
|
||||
|
||||
var coordU32 = new Uint32Array([ 1, 0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordU32, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordU32);
|
||||
|
||||
var coordF32 = new Float32Array([ 1.0, 0.0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordF32, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordF32);
|
||||
|
||||
var coordF64 = new Float64Array([ 1.0, 0.0 ]);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, coordF64, gl.STATIC_DRAW);
|
||||
gl.bufferSubData(gl.ARRAY_BUFFER, 1, coordF64);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue