servo: Merge #20375 - Fall down the WebGL rabbit hole and fix some bugs there (from servo:webgl); r=emilio

Source-Repo: https://github.com/servo/servo
Source-Revision: c20d0c00d711cda61ad1b35f15f2fb563c042c5e

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 6e41661fca27ace97b3e6eaea9de5aeb7586bc09
This commit is contained in:
Anthony Ramine 2018-03-22 15:32:45 -04:00
Родитель bd50b6df06
Коммит a565ce6df3
6 изменённых файлов: 185 добавлений и 215 удалений

32
servo/Cargo.lock сгенерированный
Просмотреть файл

@ -269,7 +269,7 @@ dependencies = [
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
@ -328,7 +328,7 @@ name = "cgl"
version = "0.2.1" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -416,7 +416,7 @@ version = "0.0.1"
dependencies = [ dependencies = [
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1", "gfx_traits 0.0.1",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1076,7 +1076,7 @@ dependencies = [
[[package]] [[package]]
name = "gleam" name = "gleam"
version = "0.4.24" version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1289,7 +1289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"leaky-cow 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "leaky-cow 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1553,7 +1553,7 @@ dependencies = [
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gaol 0.0.1 (git+https://github.com/servo/gaol)", "gaol 0.0.1 (git+https://github.com/servo/gaol)",
"gfx 0.0.1", "gfx 0.0.1",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"layout_thread 0.0.1", "layout_thread 0.0.1",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1630,7 +1630,7 @@ dependencies = [
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0", "hashglobe 0.1.0",
"mozjs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "mozjs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0", "selectors 0.19.0",
"servo_arc 0.1.1", "servo_arc 0.1.1",
"smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1807,7 +1807,7 @@ dependencies = [
[[package]] [[package]]
name = "mozjs" name = "mozjs"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2035,7 +2035,7 @@ dependencies = [
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2475,7 +2475,7 @@ dependencies = [
"encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"html5ever 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2493,7 +2493,7 @@ dependencies = [
"mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mozjs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "mozjs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1", "msg 0.0.1",
"net_traits 0.0.1", "net_traits 0.0.1",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2693,7 +2693,7 @@ dependencies = [
"compositing 0.0.1", "compositing 0.0.1",
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libservo 0.0.1", "libservo 0.0.1",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2760,7 +2760,7 @@ dependencies = [
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glx 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "glx 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"io-surface 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "io-surface 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3522,7 +3522,7 @@ dependencies = [
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3836,7 +3836,7 @@ dependencies = [
"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
"checksum gif 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8a80d6fe9e52f637df9afd4779449a7be17c39cc9c35b01589bb833f956ba596" "checksum gif 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8a80d6fe9e52f637df9afd4779449a7be17c39cc9c35b01589bb833f956ba596"
"checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a" "checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a"
"checksum gleam 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "8d9997e65a2cfec0f3290a8378652e3aacdb3f19d29a7ca20c11e11ca550eec9" "checksum gleam 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)" = "0afb2d0a8283b336c9569b1dead35415f550dcf1d4f3b970b507f7373d0be626"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90de8e0391e57098acfbfe693b23065e9186255d370ebae12c933b7d77df8424" "checksum glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90de8e0391e57098acfbfe693b23065e9186255d370ebae12c933b7d77df8424"
"checksum glx 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "63a6e7c2846e12626455f45ebaff9d92161436dd0fa703d9d198012e528ca7b9" "checksum glx 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "63a6e7c2846e12626455f45ebaff9d92161436dd0fa703d9d198012e528ca7b9"
@ -3893,7 +3893,7 @@ dependencies = [
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
"checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f" "checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f"
"checksum mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1f0583e6792917f498bb3a7440f777a59353102063445ab7f5e9d1dc4ed593aa" "checksum mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1f0583e6792917f498bb3a7440f777a59353102063445ab7f5e9d1dc4ed593aa"
"checksum mozjs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "53720714c395cbc3b8f31411ca855a97c51618c76fa5584654a0e3e2ecfc16cc" "checksum mozjs 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "896b93aaf26a4cbdcd878b6a9e3b4b90ac018dccebaaac1fe67d2d0724f6a711"
"checksum mozjs_sys 0.50.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e61a792a125b1364c5ec50255ed8343ce02dc56098f8868dd209d472c8de006a" "checksum mozjs_sys 0.50.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e61a792a125b1364c5ec50255ed8343ce02dc56098f8868dd209d472c8de006a"
"checksum mp3-metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ab5f1d2693586420208d1200ce5a51cd44726f055b635176188137aff42c7de" "checksum mp3-metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ab5f1d2693586420208d1200ce5a51cd44726f055b635176188137aff42c7de"
"checksum mp4parse 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f821e3799bc0fd16d9b861fb02fa7ee1b5fba29f45ad591dade105c48ca9a1a0" "checksum mp4parse 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f821e3799bc0fd16d9b861fb02fa7ee1b5fba29f45ad591dade105c48ca9a1a0"

Просмотреть файл

@ -860,8 +860,12 @@ impl WebGLImpl {
ctx.gl().vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset), ctx.gl().vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset),
WebGLCommand::VertexAttribPointer(attrib_id, size, data_type, normalized, stride, offset) => WebGLCommand::VertexAttribPointer(attrib_id, size, data_type, normalized, stride, offset) =>
ctx.gl().vertex_attrib_pointer(attrib_id, size, data_type, normalized, stride, offset), ctx.gl().vertex_attrib_pointer(attrib_id, size, data_type, normalized, stride, offset),
WebGLCommand::Viewport(x, y, width, height) => WebGLCommand::GetViewport(sender) => {
ctx.gl().viewport(x, y, width, height), sender.send(ctx.gl().get_viewport()).unwrap();
}
WebGLCommand::SetViewport(x, y, width, height) => {
ctx.gl().viewport(x, y, width, height);
}
WebGLCommand::TexImage2D(target, level, internal, width, height, format, data_type, data) => WebGLCommand::TexImage2D(target, level, internal, width, height, format, data_type, data) =>
ctx.gl().tex_image_2d(target, level, internal, width, height, ctx.gl().tex_image_2d(target, level, internal, width, height,
/*border*/0, format, data_type, Some(&data)), /*border*/0, format, data_type, Some(&data)),
@ -1055,8 +1059,7 @@ impl WebGLImpl {
// Int32Array // Int32Array
gl::MAX_VIEWPORT_DIMS | gl::MAX_VIEWPORT_DIMS |
gl::SCISSOR_BOX | gl::SCISSOR_BOX => Err(WebGLError::InvalidEnum),
gl::VIEWPORT => Err(WebGLError::InvalidEnum),
// Invalid parameters // Invalid parameters
_ => Err(WebGLError::InvalidEnum) _ => Err(WebGLError::InvalidEnum)

Просмотреть файл

@ -260,7 +260,8 @@ pub enum WebGLCommand {
VertexAttrib(u32, f32, f32, f32, f32), VertexAttrib(u32, f32, f32, f32, f32),
VertexAttribPointer(u32, i32, u32, bool, i32, u32), VertexAttribPointer(u32, i32, u32, bool, i32, u32),
VertexAttribPointer2f(u32, i32, bool, i32, u32), VertexAttribPointer2f(u32, i32, bool, i32, u32),
Viewport(i32, i32, i32, i32), GetViewport(WebGLSender<(i32, i32, i32, i32)>),
SetViewport(i32, i32, i32, i32),
TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec<u8>), TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec<u8>),
TexParameteri(u32, u32, i32), TexParameteri(u32, u32, i32),
TexParameterf(u32, u32, f32), TexParameterf(u32, u32, f32),
@ -532,7 +533,8 @@ impl fmt::Debug for WebGLCommand {
VertexAttrib(..) => "VertexAttrib", VertexAttrib(..) => "VertexAttrib",
VertexAttribPointer2f(..) => "VertexAttribPointer2f", VertexAttribPointer2f(..) => "VertexAttribPointer2f",
VertexAttribPointer(..) => "VertexAttribPointer", VertexAttribPointer(..) => "VertexAttribPointer",
Viewport(..) => "Viewport", GetViewport(..) => "GetViewport",
SetViewport(..) => "SetViewport",
TexImage2D(..) => "TexImage2D", TexImage2D(..) => "TexImage2D",
TexParameteri(..) => "TexParameteri", TexParameteri(..) => "TexParameteri",
TexParameterf(..) => "TexParameterf", TexParameterf(..) => "TexParameterf",

Просмотреть файл

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2Rende
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement; use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement;
use dom::bindings::error::Fallible; use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::reflector::{reflect_dom_object, Reflector}; use dom::bindings::reflector::{reflect_dom_object, Reflector};
use dom::bindings::root::{Dom, DomRoot, LayoutDom}; use dom::bindings::root::{Dom, DomRoot, LayoutDom};
use dom::bindings::str::DOMString; use dom::bindings::str::DOMString;
@ -329,7 +329,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn CompileShader(&self, shader: Option<&WebGLShader>) { fn CompileShader(&self, shader: &WebGLShader) {
self.base.CompileShader(shader) self.base.CompileShader(shader)
} }
@ -414,39 +414,39 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetActiveUniform(&self, program: Option<&WebGLProgram>, index: u32) -> Option<DomRoot<WebGLActiveInfo>> { fn GetActiveUniform(&self, program: &WebGLProgram, index: u32) -> Option<DomRoot<WebGLActiveInfo>> {
self.base.GetActiveUniform(program, index) self.base.GetActiveUniform(program, index)
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetActiveAttrib(&self, program: Option<&WebGLProgram>, index: u32) -> Option<DomRoot<WebGLActiveInfo>> { fn GetActiveAttrib(&self, program: &WebGLProgram, index: u32) -> Option<DomRoot<WebGLActiveInfo>> {
self.base.GetActiveAttrib(program, index) self.base.GetActiveAttrib(program, index)
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetAttribLocation(&self, program: Option<&WebGLProgram>, name: DOMString) -> i32 { fn GetAttribLocation(&self, program: &WebGLProgram, name: DOMString) -> i32 {
self.base.GetAttribLocation(program, name) self.base.GetAttribLocation(program, name)
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetProgramInfoLog(&self, program: Option<&WebGLProgram>) -> Option<DOMString> { fn GetProgramInfoLog(&self, program: &WebGLProgram) -> Option<DOMString> {
self.base.GetProgramInfoLog(program) self.base.GetProgramInfoLog(program)
} }
#[allow(unsafe_code)] #[allow(unsafe_code)]
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
unsafe fn GetProgramParameter(&self, cx: *mut JSContext, program: Option<&WebGLProgram>, param_id: u32) -> JSVal { unsafe fn GetProgramParameter(&self, cx: *mut JSContext, program: &WebGLProgram, param_id: u32) -> JSVal {
self.base.GetProgramParameter(cx, program, param_id) self.base.GetProgramParameter(cx, program, param_id)
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetShaderInfoLog(&self, shader: Option<&WebGLShader>) -> Option<DOMString> { fn GetShaderInfoLog(&self, shader: &WebGLShader) -> Option<DOMString> {
self.base.GetShaderInfoLog(shader) self.base.GetShaderInfoLog(shader)
} }
#[allow(unsafe_code)] #[allow(unsafe_code)]
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
unsafe fn GetShaderParameter(&self, cx: *mut JSContext, shader: Option<&WebGLShader>, param_id: u32) -> JSVal { unsafe fn GetShaderParameter(&self, cx: *mut JSContext, shader: &WebGLShader, param_id: u32) -> JSVal {
self.base.GetShaderParameter(cx, shader, param_id) self.base.GetShaderParameter(cx, shader, param_id)
} }
@ -459,9 +459,11 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetUniformLocation(&self, fn GetUniformLocation(
program: Option<&WebGLProgram>, &self,
name: DOMString) -> Option<DomRoot<WebGLUniformLocation>> { program: &WebGLProgram,
name: DOMString,
) -> Option<DomRoot<WebGLUniformLocation>> {
self.base.GetUniformLocation(program, name) self.base.GetUniformLocation(program, name)
} }
@ -585,12 +587,12 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn ShaderSource(&self, shader: Option<&WebGLShader>, source: DOMString) { fn ShaderSource(&self, shader: &WebGLShader, source: DOMString) {
self.base.ShaderSource(shader, source) self.base.ShaderSource(shader, source)
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetShaderSource(&self, shader: Option<&WebGLShader>) -> Option<DOMString> { fn GetShaderSource(&self, shader: &WebGLShader) -> Option<DOMString> {
self.base.GetShaderSource(shader) self.base.GetShaderSource(shader)
} }
@ -759,7 +761,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn ValidateProgram(&self, program: Option<&WebGLProgram>) { fn ValidateProgram(&self, program: &WebGLProgram) {
self.base.ValidateProgram(program) self.base.ValidateProgram(program)
} }
@ -835,13 +837,15 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
fn TexImage2D_(&self, fn TexImage2D_(
&self,
target: u32, target: u32,
level: i32, level: i32,
internal_format: u32, internal_format: u32,
format: u32, format: u32,
data_type: u32, data_type: u32,
source: Option<ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement>) -> Fallible<()> { source: ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement,
) -> ErrorResult {
self.base.TexImage2D_(target, level, internal_format, format, data_type, source) self.base.TexImage2D_(target, level, internal_format, format, data_type, source)
} }
@ -875,15 +879,16 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
fn TexSubImage2D_(&self, fn TexSubImage2D_(
&self,
target: u32, target: u32,
level: i32, level: i32,
xoffset: i32, xoffset: i32,
yoffset: i32, yoffset: i32,
format: u32, format: u32,
data_type: u32, data_type: u32,
source: Option<ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement>) source: ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement,
-> Fallible<()> { ) -> ErrorResult {
self.base.TexSubImage2D_(target, level, xoffset, yoffset, format, data_type, source) self.base.TexSubImage2D_(target, level, xoffset, yoffset, format, data_type, source)
} }

Просмотреть файл

@ -16,7 +16,7 @@ use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderi
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement; use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement;
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible}; use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
use dom::bindings::error::{Error, Fallible}; use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom}; use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
@ -471,7 +471,7 @@ impl WebGLRenderingContext {
} }
fn vertex_attrib(&self, indx: u32, x: f32, y: f32, z: f32, w: f32) { fn vertex_attrib(&self, indx: u32, x: f32, y: f32, z: f32, w: f32) {
if indx > self.limits.max_vertex_attribs { if indx >= self.limits.max_vertex_attribs {
return self.webgl_error(InvalidValue); return self.webgl_error(InvalidValue);
} }
@ -763,14 +763,10 @@ impl WebGLRenderingContext {
} }
} }
fn get_image_pixels(&self, fn get_image_pixels(
source: Option<ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement>) &self,
-> ImagePixelResult { source: ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement,
let source = match source { ) -> ImagePixelResult {
Some(s) => s,
None => return Err(()),
};
// NOTE: Getting the pixels probably can be short-circuited if some // NOTE: Getting the pixels probably can be short-circuited if some
// parameter is invalid. // parameter is invalid.
// //
@ -1273,6 +1269,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
match parameter { match parameter {
constants::ARRAY_BUFFER_BINDING => constants::ARRAY_BUFFER_BINDING =>
return object_binding_to_js_or_null!(cx, &self.bound_buffer_array), return object_binding_to_js_or_null!(cx, &self.bound_buffer_array),
constants::CURRENT_PROGRAM => {
return object_binding_to_js_or_null!(cx, &self.current_program);
}
constants::ELEMENT_ARRAY_BUFFER_BINDING => constants::ELEMENT_ARRAY_BUFFER_BINDING =>
return object_binding_to_js_or_null!(cx, &self.bound_buffer_element_array), return object_binding_to_js_or_null!(cx, &self.bound_buffer_element_array),
constants::FRAMEBUFFER_BINDING => constants::FRAMEBUFFER_BINDING =>
@ -1306,6 +1305,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
return Int32Value(constants::UNSIGNED_BYTE as i32); return Int32Value(constants::UNSIGNED_BYTE as i32);
} }
} }
constants::VIEWPORT => {
let (sender, receiver) = webgl_channel().unwrap();
self.send_command(WebGLCommand::GetViewport(sender));
let (x, y, width, height) = receiver.recv().unwrap();
rooted!(in(cx) let mut rval = UndefinedValue());
[x, y, width, height].to_jsval(cx, rval.handle_mut());
return rval.get();
}
_ => { _ => {
if !self.extension_manager.is_get_parameter_name_enabled(parameter) { if !self.extension_manager.is_get_parameter_name_enabled(parameter) {
self.webgl_error(WebGLError::InvalidEnum); self.webgl_error(WebGLError::InvalidEnum);
@ -1965,11 +1972,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn CompileShader(&self, shader: Option<&WebGLShader>) { fn CompileShader(&self, shader: &WebGLShader) {
if let Some(shader) = shader {
shader.compile(self.webgl_version, self.glsl_version, &self.extension_manager) shader.compile(self.webgl_version, self.glsl_version, &self.extension_manager)
} }
}
// TODO(emilio): Probably in the future we should keep track of the // TODO(emilio): Probably in the future we should keep track of the
// generated objects, either here or in the webgl thread // generated objects, either here or in the webgl thread
@ -2137,24 +2142,28 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
constants::POINTS | constants::LINE_STRIP | constants::POINTS | constants::LINE_STRIP |
constants::LINE_LOOP | constants::LINES | constants::LINE_LOOP | constants::LINES |
constants::TRIANGLE_STRIP | constants::TRIANGLE_FAN | constants::TRIANGLE_STRIP | constants::TRIANGLE_FAN |
constants::TRIANGLES => { constants::TRIANGLES => {},
if self.current_program.get().is_none() { _ => {
return self.webgl_error(InvalidOperation); return self.webgl_error(InvalidEnum);
}
} }
if first < 0 || count < 0 { if first < 0 || count < 0 {
return self.webgl_error(InvalidValue); return self.webgl_error(InvalidValue);
} }
if self.current_program.get().is_none() {
return self.webgl_error(InvalidOperation);
}
if let Some(array_buffer) = self.bound_buffer_array.get() {
if count > 0 && (first as u64 + count as u64 > array_buffer.capacity() as u64) {
return self.webgl_error(InvalidOperation);
}
}
if !self.validate_framebuffer_complete() { if !self.validate_framebuffer_complete() {
return; return;
} }
self.send_command(WebGLCommand::DrawArrays(mode, first, count)); self.send_command(WebGLCommand::DrawArrays(mode, first, count));
self.mark_as_dirty(); self.mark_as_dirty();
},
_ => self.webgl_error(InvalidEnum),
}
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11
@ -2223,7 +2232,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn EnableVertexAttribArray(&self, attrib_id: u32) { fn EnableVertexAttribArray(&self, attrib_id: u32) {
if attrib_id > self.limits.max_vertex_attribs { if attrib_id >= self.limits.max_vertex_attribs {
return self.webgl_error(InvalidValue); return self.webgl_error(InvalidValue);
} }
@ -2232,7 +2241,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn DisableVertexAttribArray(&self, attrib_id: u32) { fn DisableVertexAttribArray(&self, attrib_id: u32) {
if attrib_id > self.limits.max_vertex_attribs { if attrib_id >= self.limits.max_vertex_attribs {
return self.webgl_error(InvalidValue); return self.webgl_error(InvalidValue);
} }
@ -2240,23 +2249,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetActiveUniform(&self, program: Option<&WebGLProgram>, index: u32) -> Option<DomRoot<WebGLActiveInfo>> { fn GetActiveUniform(&self, program: &WebGLProgram, index: u32) -> Option<DomRoot<WebGLActiveInfo>> {
let program = match program {
Some(program) => program,
None => {
// Reasons to generate InvalidValue error
// From the GLES 2.0 spec
//
// "INVALID_VALUE is generated if index is greater than or equal
// to the number of active uniform variables in program"
//
// A null program has no uniforms so any index is always greater than the active uniforms
// WebGl conformance expects error with null programs. Check tests in get-active-test.html
self.webgl_error(InvalidValue);
return None;
}
};
match program.get_active_uniform(index) { match program.get_active_uniform(index) {
Ok(ret) => Some(ret), Ok(ret) => Some(ret),
Err(e) => { Err(e) => {
@ -2267,23 +2260,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetActiveAttrib(&self, program: Option<&WebGLProgram>, index: u32) -> Option<DomRoot<WebGLActiveInfo>> { fn GetActiveAttrib(&self, program: &WebGLProgram, index: u32) -> Option<DomRoot<WebGLActiveInfo>> {
let program = match program {
Some(program) => program,
None => {
// Reasons to generate InvalidValue error
// From the GLES 2.0 spec
//
// "INVALID_VALUE is generated if index is greater than or equal
// to the number of active attribute variables in program"
//
// A null program has no attributes so any index is always greater than the active uniforms
// WebGl conformance expects error with null programs. Check tests in get-active-test.html
self.webgl_error(InvalidValue);
return None;
}
};
match program.get_active_attrib(index) { match program.get_active_attrib(index) {
Ok(ret) => Some(ret), Ok(ret) => Some(ret),
Err(e) => { Err(e) => {
@ -2294,12 +2271,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetAttribLocation(&self, program: Option<&WebGLProgram>, name: DOMString) -> i32 { fn GetAttribLocation(&self, program: &WebGLProgram, name: DOMString) -> i32 {
if let Some(program) = program {
handle_potential_webgl_error!(self, program.get_attrib_location(name), None).unwrap_or(-1) handle_potential_webgl_error!(self, program.get_attrib_location(name), None).unwrap_or(-1)
} else {
-1
}
} }
#[allow(unsafe_code)] #[allow(unsafe_code)]
@ -2390,8 +2363,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetProgramInfoLog(&self, program: Option<&WebGLProgram>) -> Option<DOMString> { fn GetProgramInfoLog(&self, program: &WebGLProgram) -> Option<DOMString> {
if let Some(program) = program {
match program.get_info_log() { match program.get_info_log() {
Ok(value) => Some(DOMString::from(value)), Ok(value) => Some(DOMString::from(value)),
Err(e) => { Err(e) => {
@ -2399,16 +2371,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
None None
} }
} }
} else {
self.webgl_error(WebGLError::InvalidValue);
None
}
} }
#[allow(unsafe_code)] #[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
unsafe fn GetProgramParameter(&self, _: *mut JSContext, program: Option<&WebGLProgram>, param_id: u32) -> JSVal { unsafe fn GetProgramParameter(&self, _: *mut JSContext, program: &WebGLProgram, param_id: u32) -> JSVal {
if let Some(program) = program {
match handle_potential_webgl_error!(self, program.parameter(param_id), WebGLParameter::Invalid) { match handle_potential_webgl_error!(self, program.parameter(param_id), WebGLParameter::Invalid) {
WebGLParameter::Int(val) => Int32Value(val), WebGLParameter::Int(val) => Int32Value(val),
WebGLParameter::Bool(val) => BooleanValue(val), WebGLParameter::Bool(val) => BooleanValue(val),
@ -2419,20 +2386,16 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
WebGLParameter::Invalid => NullValue(), WebGLParameter::Invalid => NullValue(),
} }
} else {
NullValue()
}
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetShaderInfoLog(&self, shader: Option<&WebGLShader>) -> Option<DOMString> { fn GetShaderInfoLog(&self, shader: &WebGLShader) -> Option<DOMString> {
shader.and_then(|s| s.info_log()).map(DOMString::from) shader.info_log().map(DOMString::from)
} }
#[allow(unsafe_code)] #[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
unsafe fn GetShaderParameter(&self, _: *mut JSContext, shader: Option<&WebGLShader>, param_id: u32) -> JSVal { unsafe fn GetShaderParameter(&self, _: *mut JSContext, shader: &WebGLShader, param_id: u32) -> JSVal {
if let Some(shader) = shader {
match handle_potential_webgl_error!(self, shader.parameter(param_id), WebGLParameter::Invalid) { match handle_potential_webgl_error!(self, shader.parameter(param_id), WebGLParameter::Invalid) {
WebGLParameter::Int(val) => Int32Value(val), WebGLParameter::Int(val) => Int32Value(val),
WebGLParameter::Bool(val) => BooleanValue(val), WebGLParameter::Bool(val) => BooleanValue(val),
@ -2443,9 +2406,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
WebGLParameter::Invalid => NullValue(), WebGLParameter::Invalid => NullValue(),
} }
} else {
NullValue()
}
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
@ -2477,12 +2437,13 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn GetUniformLocation(&self, fn GetUniformLocation(
program: Option<&WebGLProgram>, &self,
name: DOMString) -> Option<DomRoot<WebGLUniformLocation>> { program: &WebGLProgram,
program.and_then(|p| { name: DOMString,
handle_potential_webgl_error!(self, p.get_uniform_location(name), None) ) -> Option<DomRoot<WebGLUniformLocation>> {
.map(|location| WebGLUniformLocation::new(self.global().as_window(), location, p.id())) handle_potential_webgl_error!(self, program.get_uniform_location(name), None).map(|location| {
WebGLUniformLocation::new(self.global().as_window(), location, program.id())
}) })
} }
@ -2859,15 +2820,13 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn ShaderSource(&self, shader: Option<&WebGLShader>, source: DOMString) { fn ShaderSource(&self, shader: &WebGLShader, source: DOMString) {
if let Some(shader) = shader {
shader.set_source(source) shader.set_source(source)
} }
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetShaderSource(&self, shader: Option<&WebGLShader>) -> Option<DOMString> { fn GetShaderSource(&self, shader: &WebGLShader) -> Option<DOMString> {
shader.and_then(|s| s.source()) shader.source()
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
@ -3158,13 +3117,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn ValidateProgram(&self, program: Option<&WebGLProgram>) { fn ValidateProgram(&self, program: &WebGLProgram) {
if let Some(program) = program {
if let Err(e) = program.validate() { if let Err(e) = program.validate() {
self.webgl_error(e); self.webgl_error(e);
} }
} }
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn VertexAttrib1f(&self, indx: u32, x: f32) { fn VertexAttrib1f(&self, indx: u32, x: f32) {
@ -3238,7 +3195,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn VertexAttribPointer(&self, attrib_id: u32, size: i32, data_type: u32, fn VertexAttribPointer(&self, attrib_id: u32, size: i32, data_type: u32,
normalized: bool, stride: i32, offset: i64) { normalized: bool, stride: i32, offset: i64) {
if attrib_id > self.limits.max_vertex_attribs { if attrib_id >= self.limits.max_vertex_attribs {
return self.webgl_error(InvalidValue); return self.webgl_error(InvalidValue);
} }
@ -3287,7 +3244,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
return self.webgl_error(InvalidValue) return self.webgl_error(InvalidValue)
} }
self.send_command(WebGLCommand::Viewport(x, y, width, height)) self.send_command(WebGLCommand::SetViewport(x, y, width, height))
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
@ -3372,13 +3329,15 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
fn TexImage2D_(&self, fn TexImage2D_(
&self,
target: u32, target: u32,
level: i32, level: i32,
internal_format: u32, internal_format: u32,
format: u32, format: u32,
data_type: u32, data_type: u32,
source: Option<ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement>) -> Fallible<()> { source: ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement,
) -> ErrorResult {
if !self.extension_manager.is_tex_type_enabled(data_type) { if !self.extension_manager.is_tex_type_enabled(data_type) {
return Ok(self.webgl_error(InvalidEnum)); return Ok(self.webgl_error(InvalidEnum));
} }
@ -3533,15 +3492,16 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
} }
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
fn TexSubImage2D_(&self, fn TexSubImage2D_(
&self,
target: u32, target: u32,
level: i32, level: i32,
xoffset: i32, xoffset: i32,
yoffset: i32, yoffset: i32,
format: u32, format: u32,
data_type: u32, data_type: u32,
source: Option<ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement>) source: ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement,
-> Fallible<()> { ) -> ErrorResult {
let (pixels, size, premultiplied) = match self.get_image_pixels(source) { let (pixels, size, premultiplied) = match self.get_image_pixels(source) {
Ok((pixels, size, premultiplied)) => (pixels, size, premultiplied), Ok((pixels, size, premultiplied)) => (pixels, size, premultiplied),
Err(_) => return Ok(()), Err(_) => return Ok(()),

Просмотреть файл

@ -510,7 +510,7 @@ interface WebGLRenderingContextBase
void clearDepth(GLclampf depth); void clearDepth(GLclampf depth);
void clearStencil(GLint s); void clearStencil(GLint s);
void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void compileShader(WebGLShader? shader); void compileShader(WebGLShader shader);
// FIXME(simartin) The Code generator doesn't handle ArrayBufferView so we're // FIXME(simartin) The Code generator doesn't handle ArrayBufferView so we're
// using 'object' in the meantime, and marking the function as Throws to // using 'object' in the meantime, and marking the function as Throws to
@ -578,11 +578,11 @@ interface WebGLRenderingContextBase
void generateMipmap(GLenum target); void generateMipmap(GLenum target);
WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index); WebGLActiveInfo? getActiveAttrib(WebGLProgram program, GLuint index);
WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index); WebGLActiveInfo? getActiveUniform(WebGLProgram program, GLuint index);
//sequence<WebGLShader>? getAttachedShaders(WebGLProgram? program); //sequence<WebGLShader>? getAttachedShaders(WebGLProgram? program);
[WebGLHandlesContextLoss] GLint getAttribLocation(WebGLProgram? program, DOMString name); [WebGLHandlesContextLoss] GLint getAttribLocation(WebGLProgram program, DOMString name);
any getBufferParameter(GLenum target, GLenum pname); any getBufferParameter(GLenum target, GLenum pname);
any getParameter(GLenum pname); any getParameter(GLenum pname);
@ -591,20 +591,20 @@ interface WebGLRenderingContextBase
any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, any getFramebufferAttachmentParameter(GLenum target, GLenum attachment,
GLenum pname); GLenum pname);
any getProgramParameter(WebGLProgram? program, GLenum pname); any getProgramParameter(WebGLProgram program, GLenum pname);
DOMString? getProgramInfoLog(WebGLProgram? program); DOMString? getProgramInfoLog(WebGLProgram program);
//any getRenderbufferParameter(GLenum target, GLenum pname); //any getRenderbufferParameter(GLenum target, GLenum pname);
any getShaderParameter(WebGLShader? shader, GLenum pname); any getShaderParameter(WebGLShader shader, GLenum pname);
WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype); WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
DOMString? getShaderInfoLog(WebGLShader? shader); DOMString? getShaderInfoLog(WebGLShader shader);
DOMString? getShaderSource(WebGLShader? shader); DOMString? getShaderSource(WebGLShader shader);
any getTexParameter(GLenum target, GLenum pname); any getTexParameter(GLenum target, GLenum pname);
//any getUniform(WebGLProgram? program, WebGLUniformLocation? location); //any getUniform(WebGLProgram program, WebGLUniformLocation location);
WebGLUniformLocation? getUniformLocation(WebGLProgram? program, DOMString name); WebGLUniformLocation? getUniformLocation(WebGLProgram program, DOMString name);
any getVertexAttrib(GLuint index, GLenum pname); any getVertexAttrib(GLuint index, GLenum pname);
@ -634,7 +634,7 @@ interface WebGLRenderingContextBase
void sampleCoverage(GLclampf value, GLboolean invert); void sampleCoverage(GLclampf value, GLboolean invert);
void scissor(GLint x, GLint y, GLsizei width, GLsizei height); void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
void shaderSource(WebGLShader? shader, DOMString source); void shaderSource(WebGLShader shader, DOMString source);
void stencilFunc(GLenum func, GLint ref, GLuint mask); void stencilFunc(GLenum func, GLint ref, GLuint mask);
void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
@ -653,7 +653,7 @@ interface WebGLRenderingContextBase
GLenum type, object? data); GLenum type, object? data);
[Throws] [Throws]
void texImage2D(GLenum target, GLint level, GLenum internalformat, void texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, TexImageSource? source); // May throw DOMException GLenum format, GLenum type, TexImageSource source); // May throw DOMException
[Throws, Pref="dom.webgl.dom_to_texture.enabled"] [Throws, Pref="dom.webgl.dom_to_texture.enabled"]
void texImageDOM(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, void texImageDOM(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
GLenum format, GLenum type, HTMLIFrameElement source); // May throw DOMException GLenum format, GLenum type, HTMLIFrameElement source); // May throw DOMException
@ -667,7 +667,7 @@ interface WebGLRenderingContextBase
GLenum format, GLenum type, object? data); GLenum format, GLenum type, object? data);
[Throws] [Throws]
void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLenum format, GLenum type, TexImageSource? source); // May throw DOMException GLenum format, GLenum type, TexImageSource source); // May throw DOMException
void uniform1f(WebGLUniformLocation? location, GLfloat x); void uniform1f(WebGLUniformLocation? location, GLfloat x);
//void uniform1fv(WebGLUniformLocation? location, Float32Array v); //void uniform1fv(WebGLUniformLocation? location, Float32Array v);
@ -738,7 +738,7 @@ interface WebGLRenderingContextBase
object v); object v);
void useProgram(WebGLProgram? program); void useProgram(WebGLProgram? program);
void validateProgram(WebGLProgram? program); void validateProgram(WebGLProgram program);
// FIXME(dmarcos) // FIXME(dmarcos)
// The code generator doesn't handle Float32Array so we're using 'object' // The code generator doesn't handle Float32Array so we're using 'object'