From fa555d0e2e66bd7bd63e57299ef53cb3c7f132ab Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Fri, 4 Dec 2015 23:23:17 +0100 Subject: [PATCH] Issue #6791: Allow more array types in bufferData and bufferSubData. --- components/canvas_traits/lib.rs | 4 +- .../script/dom/webglrenderingcontext.rs | 10 ++--- tests/wpt/mozilla/meta/MANIFEST.json | 6 +++ .../tests/mozilla/webgl/bufferData.html | 44 +++++++++++++++++++ 4 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/webgl/bufferData.html diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index 305704b584d..7bf10fe41ed 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -127,8 +127,8 @@ pub enum CanvasWebGLMsg { BlendFunc(u32, u32), BlendFuncSeparate(u32, u32, u32, u32), AttachShader(u32, u32), - BufferData(u32, Vec, u32), - BufferSubData(u32, isize, Vec), + BufferData(u32, Vec, u32), + BufferSubData(u32, isize, Vec), Clear(u32), ClearColor(f32, f32, f32, f32), ClearDepth(f64), diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 6655a56f921..37fc47d9d78 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -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::() 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::() 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 diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 5fa510c5fe0..cdb4e4b59ae 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -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", diff --git a/tests/wpt/mozilla/tests/mozilla/webgl/bufferData.html b/tests/wpt/mozilla/tests/mozilla/webgl/bufferData.html new file mode 100644 index 00000000000..f278d7513dc --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/webgl/bufferData.html @@ -0,0 +1,44 @@ + + +bufferData and bufferSubData input array type check (issue #6791) + + +