diff options
Diffstat (limited to 'components/script/dom/webgl2renderingcontext.rs')
-rw-r--r-- | components/script/dom/webgl2renderingcontext.rs | 321 |
1 files changed, 185 insertions, 136 deletions
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index 71ec9388d87..dd0701ace99 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -8,6 +8,7 @@ use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding; use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextMethods; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; +use dom::bindings::codegen::UnionTypes::ArrayBufferOrArrayBufferView; use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -30,6 +31,8 @@ use dom_struct::dom_struct; use euclid::Size2D; use js::jsapi::{JSContext, JSObject}; use js::jsval::JSVal; +use js::rust::CustomAutoRooterGuard; +use js::typedarray::{ArrayBufferView, Float32Array, Int32Array}; use offscreen_gl_context::GLContextAttributes; use script_layout_interface::HTMLCanvasDataSource; use std::ptr::NonNull; @@ -235,25 +238,23 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { self.base.BufferData_(target, size, usage) } - #[allow(unsafe_code)] /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5 - unsafe fn BufferSubData(&self, cx: *mut JSContext, target: u32, offset: i64, data: *mut JSObject) -> Fallible<()> { - self.base.BufferSubData(cx, target, offset, data) + fn BufferSubData(&self, target: u32, offset: i64, data: Option<ArrayBufferOrArrayBufferView>) { + self.base.BufferSubData(target, offset, data) } - #[allow(unsafe_code)] /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 - unsafe fn CompressedTexImage2D(&self, cx: *mut JSContext, target: u32, level: i32, internal_format: u32, - width: i32, height: i32, border: i32, pixels: *mut JSObject) -> Fallible<()> { - self.base.CompressedTexImage2D(cx, target, level, internal_format, width, height, border, pixels) + fn CompressedTexImage2D(&self, target: u32, level: i32, internal_format: u32, + width: i32, height: i32, border: i32, + pixels: CustomAutoRooterGuard<ArrayBufferView>) { + self.base.CompressedTexImage2D(target, level, internal_format, width, height, border, pixels) } - #[allow(unsafe_code)] /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 - unsafe fn CompressedTexSubImage2D(&self, cx: *mut JSContext, target: u32, level: i32, - xoffset: i32, yoffset: i32, width: i32, height: i32, - format: u32, pixels: *mut JSObject) -> Fallible<()> { - self.base.CompressedTexSubImage2D(cx, target, level, xoffset, yoffset, width, height, format, pixels) + fn CompressedTexSubImage2D(&self, target: u32, level: i32, xoffset: i32, + yoffset: i32, width: i32, height: i32, format: u32, + pixels: CustomAutoRooterGuard<ArrayBufferView>) { + self.base.CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, pixels) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 @@ -533,11 +534,10 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { self.base.PolygonOffset(factor, units) } - #[allow(unsafe_code)] /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12 - unsafe fn ReadPixels(&self, cx: *mut JSContext, x: i32, y: i32, width: i32, height: i32, - format: u32, pixel_type: u32, pixels: *mut JSObject) -> Fallible<()> { - self.base.ReadPixels(cx, x, y, width, height, format, pixel_type, pixels) + fn ReadPixels(&self, x: i32, y: i32, width: i32, height: i32, format: u32, pixel_type: u32, + pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) { + self.base.ReadPixels(x, y, width, height, format, pixel_type, pixels) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 @@ -597,161 +597,198 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform1f(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, val: f32) { - self.base.Uniform1f(uniform, val) + self.base.Uniform1f(location, val) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform1i(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, val: i32) { - self.base.Uniform1i(uniform, val) + self.base.Uniform1i(location, val) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform1iv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform1iv(cx, uniform, data) + fn Uniform1iv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Int32Array>) { + self.base.Uniform1iv(location, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform1fv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform1fv(cx, uniform, data) + fn Uniform1iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) { + self.base.Uniform1iv_(location, v); + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform1fv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Float32Array>) { + self.base.Uniform1fv(location, v); + } + + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform1fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) { + self.base.Uniform1fv_(location, v); } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform2f(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, x: f32, y: f32) { - self.base.Uniform2f(uniform, x, y) + self.base.Uniform2f(location, x, y) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform2fv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform2fv(cx, uniform, data) + fn Uniform2fv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Float32Array>) { + self.base.Uniform2fv(location, v) + } + + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform2fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) { + self.base.Uniform2fv_(location, v); } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform2i(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, x: i32, y: i32) { - self.base.Uniform2i(uniform, x, y) + self.base.Uniform2i(location, x, y) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform2iv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform2iv(cx, uniform, data) + fn Uniform2iv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Int32Array>) { + self.base.Uniform2iv(location, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform2iv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<i32>) { + self.base.Uniform2iv_(location, v); } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform3f(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, x: f32, y: f32, z: f32) { - self.base.Uniform3f(uniform, x, y, z) + self.base.Uniform3f(location, x, y, z) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform3fv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform3fv(cx, uniform, data) + fn Uniform3fv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Float32Array>) { + self.base.Uniform3fv(location, v) + } + + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform3fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) { + self.base.Uniform3fv_(location, v); } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform3i(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, x: i32, y: i32, z: i32) { - self.base.Uniform3i(uniform, x, y, z) + self.base.Uniform3i(location, x, y, z) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform3iv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform3iv(cx, uniform, data) + fn Uniform3iv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Int32Array>) { + self.base.Uniform3iv(location, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform3iv_(&self, + location: Option<&WebGLUniformLocation>, + v: Vec<i32>) { + self.base.Uniform3iv_(location, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform4i(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, x: i32, y: i32, z: i32, w: i32) { - self.base.Uniform4i(uniform, x, y, z, w) + self.base.Uniform4i(location, x, y, z, w) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform4iv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform4iv(cx, uniform, data) + fn Uniform4iv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Int32Array>) { + self.base.Uniform4iv(location, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform4iv_(&self, + location: Option<&WebGLUniformLocation>, + v: Vec<i32>) { + self.base.Uniform4iv_(location, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn Uniform4f(&self, - uniform: Option<&WebGLUniformLocation>, + location: Option<&WebGLUniformLocation>, x: f32, y: f32, z: f32, w: f32) { - self.base.Uniform4f(uniform, x, y, z, w) + self.base.Uniform4f(location, x, y, z, w) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn Uniform4fv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, - data: *mut JSObject) -> Fallible<()> { - self.base.Uniform4fv(cx, uniform, data) + fn Uniform4fv(&self, + location: Option<&WebGLUniformLocation>, + v: CustomAutoRooterGuard<Float32Array>) { + self.base.Uniform4fv(location, v) + } + + // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn Uniform4fv_(&self, location: Option<&WebGLUniformLocation>, v: Vec<f32>) { + self.base.Uniform4fv_(location, v); } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn UniformMatrix2fv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, + fn UniformMatrix2fv(&self, + location: Option<&WebGLUniformLocation>, transpose: bool, - data: *mut JSObject) -> Fallible<()> { - self.base.UniformMatrix2fv(cx, uniform, transpose, data) + v: CustomAutoRooterGuard<Float32Array>) { + self.base.UniformMatrix2fv(location, transpose, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn UniformMatrix3fv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, + fn UniformMatrix2fv_(&self, location: Option<&WebGLUniformLocation>, transpose: bool, value: Vec<f32>) { + self.base.UniformMatrix2fv_(location, transpose, value); + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn UniformMatrix3fv(&self, + location: Option<&WebGLUniformLocation>, transpose: bool, - data: *mut JSObject) -> Fallible<()> { - self.base.UniformMatrix3fv(cx, uniform, transpose, data) + v: CustomAutoRooterGuard<Float32Array>) { + self.base.UniformMatrix3fv(location, transpose, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn UniformMatrix4fv(&self, - cx: *mut JSContext, - uniform: Option<&WebGLUniformLocation>, + fn UniformMatrix3fv_(&self, location: Option<&WebGLUniformLocation>, transpose: bool, value: Vec<f32>) { + self.base.UniformMatrix3fv_(location, transpose, value); + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn UniformMatrix4fv(&self, + location: Option<&WebGLUniformLocation>, transpose: bool, - data: *mut JSObject) -> Fallible<()> { - self.base.UniformMatrix4fv(cx, uniform, transpose, data) + v: CustomAutoRooterGuard<Float32Array>) { + self.base.UniformMatrix4fv(location, transpose, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn UniformMatrix4fv_(&self, location: Option<&WebGLUniformLocation>, transpose: bool, value: Vec<f32>) { + self.base.UniformMatrix4fv_(location, transpose, value); } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 @@ -770,9 +807,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn VertexAttrib1fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> { - self.base.VertexAttrib1fv(cx, indx, data) + fn VertexAttrib1fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) { + self.base.VertexAttrib1fv(indx, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn VertexAttrib1fv_(&self, indx: u32, v: Vec<f32>) { + self.base.VertexAttrib1fv_(indx, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 @@ -781,9 +822,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn VertexAttrib2fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> { - self.base.VertexAttrib2fv(cx, indx, data) + fn VertexAttrib2fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) { + self.base.VertexAttrib2fv(indx, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn VertexAttrib2fv_(&self, indx: u32, v: Vec<f32>) { + self.base.VertexAttrib2fv_(indx, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 @@ -792,9 +837,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn VertexAttrib3fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> { - self.base.VertexAttrib3fv(cx, indx, data) + fn VertexAttrib3fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) { + self.base.VertexAttrib3fv(indx, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn VertexAttrib3fv_(&self, indx: u32, v: Vec<f32>) { + self.base.VertexAttrib3fv_(indx, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 @@ -803,9 +852,13 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - #[allow(unsafe_code)] - unsafe fn VertexAttrib4fv(&self, cx: *mut JSContext, indx: u32, data: *mut JSObject) -> Fallible<()> { - self.base.VertexAttrib4fv(cx, indx, data) + fn VertexAttrib4fv(&self, indx: u32, v: CustomAutoRooterGuard<Float32Array>) { + self.base.VertexAttrib4fv(indx, v) + } + + /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 + fn VertexAttrib4fv_(&self, indx: u32, v: Vec<f32>) { + self.base.VertexAttrib4fv_(indx, v) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 @@ -820,19 +873,17 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 - #[allow(unsafe_code)] - unsafe fn TexImage2D(&self, - cx: *mut JSContext, - target: u32, - level: i32, - internal_format: u32, - width: i32, - height: i32, - border: i32, - format: u32, - data_type: u32, - data_ptr: *mut JSObject) -> Fallible<()> { - self.base.TexImage2D(cx, target, level, internal_format, width, height, border, format, data_type, data_ptr) + fn TexImage2D(&self, + target: u32, + level: i32, + internal_format: u32, + width: i32, + height: i32, + border: i32, + format: u32, + data_type: u32, + pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) -> Fallible<()> { + self.base.TexImage2D(target, level, internal_format, width, height, border, format, data_type, pixels) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 @@ -862,19 +913,17 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 - #[allow(unsafe_code)] - unsafe fn TexSubImage2D(&self, - cx: *mut JSContext, - target: u32, - level: i32, - xoffset: i32, - yoffset: i32, - width: i32, - height: i32, - format: u32, - data_type: u32, - data_ptr: *mut JSObject) -> Fallible<()> { - self.base.TexSubImage2D(cx, target, level, xoffset, yoffset, width, height, format, data_type, data_ptr) + fn TexSubImage2D(&self, + target: u32, + level: i32, + xoffset: i32, + yoffset: i32, + width: i32, + height: i32, + format: u32, + data_type: u32, + pixels: CustomAutoRooterGuard<Option<ArrayBufferView>>) -> Fallible<()> { + self.base.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, data_type, pixels) } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 |