From 0f917128009d09343a952ca31369537a6bbf907e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 18 Apr 2018 16:21:42 +0200 Subject: [PATCH] Update to gleam 0.5 --- Cargo.lock | 71 ++-- components/canvas/Cargo.toml | 4 +- components/canvas/webgl_thread.rs | 349 +++++++----------- components/canvas_traits/Cargo.toml | 3 +- components/canvas_traits/lib.rs | 1 + components/canvas_traits/webgl.rs | 205 ++++++++-- components/compositing/Cargo.toml | 2 +- components/compositing/compositor.rs | 2 +- components/layout/display_list/background.rs | 28 +- components/layout/display_list/items.rs | 10 +- .../layout/display_list/webrender_helpers.rs | 2 +- components/malloc_size_of/lib.rs | 2 +- components/script/Cargo.toml | 4 +- components/script/dom/webglprogram.rs | 9 +- .../script/dom/webglrenderingcontext.rs | 162 ++++---- components/script/dom/webglshader.rs | 14 +- components/servo/Cargo.toml | 2 +- ports/servo/Cargo.toml | 2 +- 18 files changed, 473 insertions(+), 399 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f9a5a4dba8e..fda43b567a45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,14 +81,14 @@ dependencies = [ [[package]] name = "azure" -version = "0.28.0" -source = "git+https://github.com/servo/rust-azure#29f0c063ad366b5364e06af26d3e9d1ee588e3b2" +version = "0.29.0" +source = "git+https://github.com/servo/rust-azure#1ca68f302f5e914e2c63b0ec5b72af8f761f977d" dependencies = [ "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)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "servo-skia 0.30000013.1 (registry+https://github.com/rust-lang/crates.io-index)", + "servo-skia 0.30000014.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -265,17 +265,17 @@ dependencies = [ name = "canvas" version = "0.0.1" dependencies = [ - "azure 0.28.0 (git+https://github.com/servo/rust-azure)", + "azure 0.29.0 (git+https://github.com/servo/rust-azure)", "canvas_traits 0.0.1", "compositing 0.0.1", "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)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.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.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "offscreen_gl_context 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", + "offscreen_gl_context 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "servo_config 0.0.1", "webrender 0.57.2 (git+https://github.com/servo/webrender)", @@ -288,12 +288,13 @@ version = "0.0.1" dependencies = [ "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)", + "gleam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", "nonzero 0.0.1", - "offscreen_gl_context 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", + "offscreen_gl_context 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "servo_config 0.0.1", @@ -329,10 +330,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cgl" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -420,7 +421,7 @@ version = "0.0.1" dependencies = [ "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.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)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1088,7 +1089,7 @@ dependencies = [ [[package]] name = "gleam" -version = "0.4.34" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1105,7 +1106,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cgl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "cocoa 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1309,12 +1310,12 @@ dependencies = [ [[package]] name = "io-surface" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cgl 0.2.2 (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.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.0 (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)", ] @@ -1573,7 +1574,7 @@ dependencies = [ "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "gaol 0.0.1 (git+https://github.com/servo/gaol)", "gfx 0.0.1", - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.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", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2067,14 +2068,14 @@ dependencies = [ [[package]] name = "offscreen_gl_context" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cgl 0.2.2 (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)", "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.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)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2521,7 +2522,7 @@ dependencies = [ "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)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.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.3 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2544,7 +2545,7 @@ dependencies = [ "msg 0.0.1", "net_traits 0.0.1", "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "offscreen_gl_context 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", + "offscreen_gl_context 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2742,7 +2743,7 @@ dependencies = [ "bitflags 1.0.0 (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)", - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libservo 0.0.1", @@ -2797,17 +2798,17 @@ dependencies = [ [[package]] name = "servo-skia" -version = "0.30000013.1" +version = "0.30000014.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cgl 0.2.2 (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)", "expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.0 (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)", - "io-surface 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "io-surface 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "servo-fontconfig-sys 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3563,7 +3564,7 @@ dependencies = [ [[package]] name = "webrender" version = "0.57.2" -source = "git+https://github.com/servo/webrender#81920df73bdf4f129cfc732a2bd6d2587088e838" +source = "git+https://github.com/servo/webrender#f94683560dc4b2a8092d218600da4fc380131d6a" dependencies = [ "app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3578,7 +3579,7 @@ dependencies = [ "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.4.0 (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.34 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.5.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)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3598,7 +3599,7 @@ dependencies = [ [[package]] name = "webrender_api" version = "0.57.2" -source = "git+https://github.com/servo/webrender#81920df73bdf4f129cfc732a2bd6d2587088e838" +source = "git+https://github.com/servo/webrender#f94683560dc4b2a8092d218600da4fc380131d6a" dependencies = [ "app_units 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3818,7 +3819,7 @@ dependencies = [ "checksum atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb2dcb6e6d35f20276943cc04bb98e538b348d525a04ac79c10021561d202f21" "checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860" "checksum audio-video-metadata 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "71536082079f5ba92c274fba7c2dcd4e2f9d5c13ce6d7f8fe9acbbb258916d18" -"checksum azure 0.28.0 (git+https://github.com/servo/rust-azure)" = "" +"checksum azure 0.29.0 (git+https://github.com/servo/rust-azure)" = "" "checksum backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72f9b4182546f4b04ebc4ab7f84948953a118bd6021a1b6a6c909e3e94f6be76" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" "checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9" @@ -3841,7 +3842,7 @@ dependencies = [ "checksum cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9be26b24e988625409b19736d130f0c7d224f01d06454b5f81d8d23d6c1a618f" "checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "86765cb42c2a2c497e142af72517c1b4d7ae5bb2f25dfa77a5c69642f2342d89" +"checksum cgl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "80f05e25f9631fdee56693110feda284a49308ca1e768857a0ad3906cfc1502a" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum clang-sys 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "939a1a34310b120d26eba35c29475933128b0ec58e24b43327f8dbe6036fc538" "checksum clap 2.28.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc34bf7d5d66268b466b9852bca925ec1d2650654dab4da081e63fd230145c2e" @@ -3901,7 +3902,7 @@ dependencies = [ "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 gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a" -"checksum gleam 0.4.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b4e5e2cdcadecdf3886e7808b6a38eae0a48dfe98c5c12b776fc861b80edf4a2" +"checksum gleam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e47b39459e47b76be4d2c82702932cdc66df09dcb8f813424167991adb8b3380" "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 glx 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "63a6e7c2846e12626455f45ebaff9d92161436dd0fa703d9d198012e528ca7b9" @@ -3923,7 +3924,7 @@ dependencies = [ "checksum immeta 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1aaaa557fbc7323c857871ce15f2b2c08d90548cba4aabda4251fac1b4778337" "checksum inflate 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10ec05638adf7c5c788bc0cfa608cd479a13572beda20feb4898fe1d85d2c64b" "checksum influent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a22b311b83431be3ab9af96ca9ea41554bb4a8551ea871ae44c3ce0c57e55f2c" -"checksum io-surface 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "623ace1e5f7de3512ec45302572a72349fdadcbef650c3dfc5d8244209be7653" +"checksum io-surface 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b506cf08070106ec8d802dd7c3b4290bf1f844e4cf6b0aaff68ede2a58b5922" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db9daf099728ac5390c73f54e6e3708f0c514d2b51f24373830f568702eadfca" "checksum itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b07332223953b5051bceb67e8c4700aa65291535568e1f12408c43c4a42c0394" @@ -3976,7 +3977,7 @@ dependencies = [ "checksum objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "877f30f37acef6749b1841cceab289707f211aecfc756553cd63976190e6cc2e" "checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" "checksum objc_id 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4730aa1c64d722db45f7ccc4113a3e2c465d018de6db4d3e7dfe031e8c8a297" -"checksum offscreen_gl_context 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b0daacb4e8c5760ab0addb80938f6bde4cd23b71b39a84d90080ae0c7215716a" +"checksum offscreen_gl_context 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84e4be9374dd9e7caf6771b68b5e9e9a458c34ea2677b57993edada51abb0544" "checksum ogg 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7137bf02687385302f4c0aecd77cfce052b69f5b4ee937be778e125c62f67e30" "checksum ogg_metadata 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc665717454399cba557c55ad226148996e9266ee291f8a37a98bb2cded0a490" "checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" @@ -4033,7 +4034,7 @@ dependencies = [ "checksum servo-fontconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "93f799b649b4a2bf362398910eca35240704c7e765e780349b2bb1070d892262" "checksum servo-fontconfig-sys 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "38b494f03009ee81914b0e7d387ad7c145cafcd69747c2ec89b0e17bb94f303a" "checksum servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9232032c2e85118c0282c6562c84cab12316e655491ba0a5d1905b2320060d1b" -"checksum servo-skia 0.30000013.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3fb707c7dc3d8a053b8c9d48ed9eb7f2a0c0751616dfbe3598f526948408bc33" +"checksum servo-skia 0.30000014.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb39ffad573e5696b37bf4fad0b1a33ef3d3b8c92dcbdc04b550023ea97c4c8" "checksum servo-websocket 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6bac1e2295e72f0525147d993c626761811acf0441dac1cee8707f12dc7f3363" "checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" "checksum shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8254bf098ce4d8d7cc7cc6de438c5488adc5297e5b7ffef88816c0a91bd289c1" diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index b03c016ea383..ffb319f6bb05 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -16,11 +16,11 @@ compositing = {path = "../compositing"} cssparser = "0.23.0" euclid = "0.17" fnv = "1.0" -gleam = "0.4.34" +gleam = "0.5" ipc-channel = "0.10" log = "0.4" num-traits = "0.1.32" -offscreen_gl_context = { version = "0.15", features = ["serde", "osmesa"] } +offscreen_gl_context = {version = "0.16", features = ["serde", "osmesa"]} serde_bytes = "0.10" servo_config = {path = "../config"} webrender = {git = "https://github.com/servo/webrender"} diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 7e44f2c0d42e..298bacfe8607 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -648,6 +648,7 @@ struct DOMToTextureData { pub struct WebGLImpl; impl WebGLImpl { + #[allow(unsafe_code)] pub fn apply(ctx: &GLContext, command: WebGLCommand) { match command { WebGLCommand::GetContextAttributes(sender) => @@ -758,18 +759,11 @@ impl WebGLImpl { Self::get_renderbuffer_parameter(ctx.gl(), target, pname, chan), WebGLCommand::GetFramebufferAttachmentParameter(target, attachment, pname, chan) => Self::get_framebuffer_attachment_parameter(ctx.gl(), target, attachment, pname, chan), - WebGLCommand::GetVertexAttrib(index, pname, chan) => - Self::vertex_attrib(ctx.gl(), index, pname, chan), WebGLCommand::GetVertexAttribOffset(index, pname, chan) => Self::vertex_attrib_offset(ctx.gl(), index, pname, chan), - WebGLCommand::GetParameter(param_id, chan) => - Self::parameter(ctx.gl(), param_id, chan), - WebGLCommand::GetTexParameter(target, pname, chan) => - Self::get_tex_parameter(ctx.gl(), target, pname, chan), - WebGLCommand::GetProgramParameter(program_id, param_id, chan) => - Self::program_parameter(ctx.gl(), program_id, param_id, chan), - WebGLCommand::GetShaderParameter(shader_id, param_id, chan) => - Self::shader_parameter(ctx.gl(), shader_id, param_id, chan), + WebGLCommand::GetTexParameter(target, pname, chan) => { + chan.send(ctx.gl().get_tex_parameter_iv(target, pname)).unwrap(); + } WebGLCommand::GetShaderPrecisionFormat(shader_type, precision_type, chan) => Self::shader_precision_format(ctx.gl(), shader_type, precision_type, chan), WebGLCommand::GetExtensions(chan) => @@ -864,9 +858,6 @@ impl WebGLImpl { ctx.gl().vertex_attrib_pointer_f32(attrib_id, size, 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), - WebGLCommand::GetViewport(sender) => { - sender.send(ctx.gl().get_viewport()).unwrap(); - } WebGLCommand::SetViewport(x, y, width, height) => { ctx.gl().viewport(x, y, width, height); } @@ -895,10 +886,119 @@ impl WebGLImpl { ctx.gl().delete_vertex_arrays(&[id.get()]), WebGLCommand::BindVertexArray(id) => ctx.gl().bind_vertex_array(id.map_or(0, WebGLVertexArrayId::get)), - WebGLCommand::AliasedPointSizeRange(sender) => - sender.send(ctx.gl().alias_point_size_range()).unwrap(), - WebGLCommand::AliasedLineWidthRange(sender) => { - sender.send(ctx.gl().alias_line_width_range()).unwrap() + WebGLCommand::GetParameterBool(param, sender) => { + let mut value = [0]; + unsafe { + ctx.gl().get_boolean_v(param as u32, &mut value); + } + sender.send(value[0] != 0).unwrap() + } + WebGLCommand::GetParameterInt(param, sender) => { + let mut value = [0]; + unsafe { + ctx.gl().get_integer_v(param as u32, &mut value); + } + sender.send(value[0]).unwrap() + } + WebGLCommand::GetParameterInt4(param, sender) => { + let mut value = [0; 4]; + unsafe { + ctx.gl().get_integer_v(param as u32, &mut value); + } + sender.send(value).unwrap() + } + WebGLCommand::GetParameterFloat(param, sender) => { + let mut value = [0.]; + unsafe { + ctx.gl().get_float_v(param as u32, &mut value); + } + sender.send(value[0]).unwrap() + } + WebGLCommand::GetParameterFloat2(param, sender) => { + let mut value = [0.; 2]; + unsafe { + ctx.gl().get_float_v(param as u32, &mut value); + } + sender.send(value).unwrap() + } + WebGLCommand::GetProgramParameterBool(program, param, sender) => { + let mut value = [0]; + unsafe { + ctx.gl().get_program_iv(program.get(), param as u32, &mut value); + } + sender.send(value[0] != 0).unwrap() + } + WebGLCommand::GetProgramParameterInt(program, param, sender) => { + let mut value = [0]; + unsafe { + ctx.gl().get_program_iv(program.get(), param as u32, &mut value); + } + sender.send(value[0]).unwrap() + } + WebGLCommand::GetShaderParameterBool(shader, param, sender) => { + let mut value = [0]; + unsafe { + ctx.gl().get_shader_iv(shader.get(), param as u32, &mut value); + } + sender.send(value[0] != 0).unwrap() + } + WebGLCommand::GetShaderParameterInt(shader, param, sender) => { + let mut value = [0]; + unsafe { + ctx.gl().get_shader_iv(shader.get(), param as u32, &mut value); + } + sender.send(value[0]).unwrap() + } + WebGLCommand::GetVertexAttribBool(index, param, sender) => { + // FIXME(nox): https://github.com/servo/servo/issues/20608 + let mut max = [0]; + unsafe { + ctx.gl().get_integer_v(gl::MAX_VERTEX_ATTRIBS, &mut max); + } + let result = if index >= max[0] as u32 { + Err(WebGLError::InvalidValue) + } else { + let mut value = [0]; + unsafe { + ctx.gl().get_vertex_attrib_iv(index, param as u32, &mut value); + } + Ok(value[0] != 0) + }; + sender.send(result).unwrap(); + } + WebGLCommand::GetVertexAttribInt(index, param, sender) => { + // FIXME(nox): https://github.com/servo/servo/issues/20608 + let mut max = [0]; + unsafe { + ctx.gl().get_integer_v(gl::MAX_VERTEX_ATTRIBS, &mut max); + } + let result = if index >= max[0] as u32 { + Err(WebGLError::InvalidValue) + } else { + let mut value = [0]; + unsafe { + ctx.gl().get_vertex_attrib_iv(index, param as u32, &mut value); + } + Ok(value[0]) + }; + sender.send(result).unwrap(); + } + WebGLCommand::GetVertexAttribFloat4(index, param, sender) => { + // FIXME(nox): https://github.com/servo/servo/issues/20608 + let mut max = [0]; + unsafe { + ctx.gl().get_integer_v(gl::MAX_VERTEX_ATTRIBS, &mut max); + } + let result = if index >= max[0] as u32 { + Err(WebGLError::InvalidValue) + } else { + let mut value = [0.; 4]; + unsafe { + ctx.gl().get_vertex_attrib_fv(index, param as u32, &mut value); + } + Ok(value) + }; + sender.send(result).unwrap(); } } @@ -923,11 +1023,18 @@ impl WebGLImpl { chan.send(result.into()).unwrap() } - fn active_attrib(gl: &gl::Gl, - program_id: WebGLProgramId, - index: u32, - chan: WebGLSender>) { - let result = if index >= gl.get_program_iv(program_id.get(), gl::ACTIVE_ATTRIBUTES) as u32 { + #[allow(unsafe_code)] + fn active_attrib( + gl: &gl::Gl, + program_id: WebGLProgramId, + index: u32, + chan: WebGLSender>, + ) { + let mut max = [0]; + unsafe { + gl.get_program_iv(program_id.get(), gl::ACTIVE_ATTRIBUTES, &mut max); + } + let result = if index >= max[0] as u32 { Err(WebGLError::InvalidValue) } else { Ok(gl.get_active_attrib(program_id.get(), index)) @@ -935,11 +1042,16 @@ impl WebGLImpl { chan.send(result).unwrap(); } + #[allow(unsafe_code)] fn active_uniform(gl: &gl::Gl, program_id: WebGLProgramId, index: u32, chan: WebGLSender>) { - let result = if index >= gl.get_program_iv(program_id.get(), gl::ACTIVE_UNIFORMS) as u32 { + let mut max = [0]; + unsafe { + gl.get_program_iv(program_id.get(), gl::ACTIVE_UNIFORMS, &mut max); + } + let result = if index >= max[0] as u32 { Err(WebGLError::InvalidValue) } else { Ok(gl.get_active_uniform(program_id.get(), index)) @@ -962,167 +1074,11 @@ impl WebGLImpl { chan.send(attrib_location).unwrap(); } - fn parameter(gl: &gl::Gl, - param_id: u32, - chan: WebGLSender>) { - let result = match param_id { - gl::ACTIVE_TEXTURE | - gl::ALPHA_BITS | - gl::BLEND_DST_ALPHA | - gl::BLEND_DST_RGB | - gl::BLEND_EQUATION_ALPHA | - gl::BLEND_EQUATION_RGB | - gl::BLEND_SRC_ALPHA | - gl::BLEND_SRC_RGB | - gl::BLUE_BITS | - gl::CULL_FACE_MODE | - gl::DEPTH_BITS | - gl::DEPTH_FUNC | - gl::FRONT_FACE | - //gl::GENERATE_MIPMAP_HINT | - gl::GREEN_BITS | - //gl::IMPLEMENTATION_COLOR_READ_FORMAT | - //gl::IMPLEMENTATION_COLOR_READ_TYPE | - gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS | - gl::MAX_CUBE_MAP_TEXTURE_SIZE | - //gl::MAX_FRAGMENT_UNIFORM_VECTORS | - gl::MAX_RENDERBUFFER_SIZE | - gl::MAX_TEXTURE_IMAGE_UNITS | - gl::MAX_TEXTURE_SIZE | - //gl::MAX_VARYING_VECTORS | - gl::MAX_VERTEX_ATTRIBS | - gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS | - //gl::MAX_VERTEX_UNIFORM_VECTORS | - gl::PACK_ALIGNMENT | - gl::RED_BITS | - gl::SAMPLE_BUFFERS | - gl::SAMPLES | - gl::STENCIL_BACK_FAIL | - gl::STENCIL_BACK_FUNC | - gl::STENCIL_BACK_PASS_DEPTH_FAIL | - gl::STENCIL_BACK_PASS_DEPTH_PASS | - gl::STENCIL_BACK_REF | - gl::STENCIL_BACK_VALUE_MASK | - gl::STENCIL_BACK_WRITEMASK | - gl::STENCIL_BITS | - gl::STENCIL_CLEAR_VALUE | - gl::STENCIL_FAIL | - gl::STENCIL_FUNC | - gl::STENCIL_PASS_DEPTH_FAIL | - gl::STENCIL_PASS_DEPTH_PASS | - gl::STENCIL_REF | - gl::STENCIL_VALUE_MASK | - gl::STENCIL_WRITEMASK | - gl::SUBPIXEL_BITS | - gl::UNPACK_ALIGNMENT | - gl::FRAGMENT_SHADER_DERIVATIVE_HINT => - //gl::UNPACK_COLORSPACE_CONVERSION_WEBGL => - Ok(WebGLParameter::Int(gl.get_integer_v(param_id))), - - gl::BLEND | - gl::CULL_FACE | - gl::DEPTH_TEST | - gl::DEPTH_WRITEMASK | - gl::DITHER | - gl::POLYGON_OFFSET_FILL | - gl::SAMPLE_COVERAGE_INVERT | - gl::STENCIL_TEST => - //gl::UNPACK_FLIP_Y_WEBGL | - //gl::UNPACK_PREMULTIPLY_ALPHA_WEBGL => - Ok(WebGLParameter::Bool(gl.get_boolean_v(param_id) != 0)), - - gl::DEPTH_CLEAR_VALUE | - gl::LINE_WIDTH | - gl::POLYGON_OFFSET_FACTOR | - gl::POLYGON_OFFSET_UNITS | - gl::SAMPLE_COVERAGE_VALUE => - Ok(WebGLParameter::Float(gl.get_float_v(param_id))), - - gl::VERSION => Ok(WebGLParameter::String("WebGL 1.0".to_owned())), - gl::RENDERER | - gl::VENDOR => Ok(WebGLParameter::String("Mozilla/Servo".to_owned())), - gl::SHADING_LANGUAGE_VERSION => Ok(WebGLParameter::String("WebGL GLSL ES 1.0".to_owned())), - - // TODO(zbarsky, emilio): Implement support for the following valid parameters - // Float32Array - gl::ALIASED_LINE_WIDTH_RANGE | - //gl::ALIASED_POINT_SIZE_RANGE | - //gl::BLEND_COLOR | - gl::COLOR_CLEAR_VALUE | - gl::DEPTH_RANGE | - - // WebGLBuffer - gl::ARRAY_BUFFER_BINDING | - gl::ELEMENT_ARRAY_BUFFER_BINDING | - - // WebGLFrameBuffer - gl::FRAMEBUFFER_BINDING | - - // WebGLRenderBuffer - gl::RENDERBUFFER_BINDING | - - // WebGLProgram - gl::CURRENT_PROGRAM | - - // WebGLTexture - gl::TEXTURE_BINDING_2D | - gl::TEXTURE_BINDING_CUBE_MAP | - - // sequence - gl::COLOR_WRITEMASK | - - // Uint32Array - gl::COMPRESSED_TEXTURE_FORMATS | - - // Int32Array - gl::MAX_VIEWPORT_DIMS | - gl::SCISSOR_BOX => Err(WebGLError::InvalidEnum), - - // Invalid parameters - _ => Err(WebGLError::InvalidEnum) - }; - - chan.send(result).unwrap(); - } - - fn get_tex_parameter(gl: &gl::Gl, - target: u32, - pname: u32, - chan: WebGLSender ) { - let result = gl.get_tex_parameter_iv(target, pname); - chan.send(result).unwrap(); - } - fn finish(gl: &gl::Gl, chan: WebGLSender<()>) { gl.finish(); chan.send(()).unwrap(); } - fn vertex_attrib(gl: &gl::Gl, - index: u32, - pname: u32, - chan: WebGLSender>) { - let result = if index >= gl.get_integer_v(gl::MAX_VERTEX_ATTRIBS) as u32 { - Err(WebGLError::InvalidValue) - } else { - match pname { - gl::VERTEX_ATTRIB_ARRAY_ENABLED | - gl::VERTEX_ATTRIB_ARRAY_NORMALIZED => - Ok(WebGLParameter::Bool(gl.get_vertex_attrib_iv(index, pname) != 0)), - gl::VERTEX_ATTRIB_ARRAY_SIZE | - gl::VERTEX_ATTRIB_ARRAY_STRIDE | - gl::VERTEX_ATTRIB_ARRAY_TYPE => - Ok(WebGLParameter::Int(gl.get_vertex_attrib_iv(index, pname))), - gl::CURRENT_VERTEX_ATTRIB => - Ok(WebGLParameter::FloatArray(gl.get_vertex_attrib_fv(index, pname))), - // gl::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING should return WebGLBuffer - _ => Err(WebGLError::InvalidEnum), - } - }; - - chan.send(result).unwrap(); - } - fn vertex_attrib_offset(gl: &gl::Gl, index: u32, pname: u32, @@ -1131,41 +1087,6 @@ impl WebGLImpl { chan.send(result).unwrap(); } - fn program_parameter(gl: &gl::Gl, - program_id: WebGLProgramId, - param_id: u32, - chan: WebGLSender>) { - let result = match param_id { - gl::DELETE_STATUS | - gl::LINK_STATUS | - gl::VALIDATE_STATUS => - Ok(WebGLParameter::Bool(gl.get_program_iv(program_id.get(), param_id) != 0)), - gl::ATTACHED_SHADERS | - gl::ACTIVE_ATTRIBUTES | - gl::ACTIVE_UNIFORMS => - Ok(WebGLParameter::Int(gl.get_program_iv(program_id.get(), param_id))), - _ => Err(WebGLError::InvalidEnum), - }; - - chan.send(result).unwrap(); - } - - fn shader_parameter(gl: &gl::Gl, - shader_id: WebGLShaderId, - param_id: u32, - chan: WebGLSender>) { - let result = match param_id { - gl::SHADER_TYPE => - Ok(WebGLParameter::Int(gl.get_shader_iv(shader_id.get(), param_id))), - gl::DELETE_STATUS | - gl::COMPILE_STATUS => - Ok(WebGLParameter::Bool(gl.get_shader_iv(shader_id.get(), param_id) != 0)), - _ => Err(WebGLError::InvalidEnum), - }; - - chan.send(result).unwrap(); - } - fn shader_precision_format(gl: &gl::Gl, shader_type: u32, precision_type: u32, diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index 3758e9205565..ffe498484c25 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -13,11 +13,12 @@ path = "lib.rs" cssparser = "0.23.0" euclid = "0.17" ipc-channel = "0.10" +gleam = "0.5" lazy_static = "1" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = { path = "../malloc_size_of_derive" } nonzero = {path = "../nonzero"} -offscreen_gl_context = { version = "0.15", features = ["serde"] } +offscreen_gl_context = {version = "0.16", features = ["serde"]} serde = "1.0" serde_bytes = "0.10" servo_config = {path = "../config"} diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index 20423143e21f..642f4ed363a4 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -9,6 +9,7 @@ extern crate cssparser; extern crate euclid; +extern crate gleam; extern crate ipc_channel; #[macro_use] extern crate lazy_static; extern crate malloc_size_of; diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index df527178ad1c..1758b20d8639 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use euclid::Size2D; +use gleam::gl; use nonzero::NonZeroU32; use offscreen_gl_context::{GLContextAttributes, GLLimits}; use serde_bytes::ByteBuf; @@ -206,16 +207,12 @@ pub enum WebGLCommand { FramebufferRenderbuffer(u32, u32, u32, Option), FramebufferTexture2D(u32, u32, u32, Option, i32), GetExtensions(WebGLSender), - GetParameter(u32, WebGLSender>), GetTexParameter(u32, u32, WebGLSender), - GetProgramParameter(WebGLProgramId, u32, WebGLSender>), - GetShaderParameter(WebGLShaderId, u32, WebGLSender>), GetShaderPrecisionFormat(u32, u32, WebGLSender<(i32, i32, i32)>), GetActiveAttrib(WebGLProgramId, u32, WebGLSender>), GetActiveUniform(WebGLProgramId, u32, WebGLSender>), GetAttribLocation(WebGLProgramId, String, WebGLSender>), GetUniformLocation(WebGLProgramId, String, WebGLSender>), - GetVertexAttrib(u32, u32, WebGLSender>), GetVertexAttribOffset(u32, u32, WebGLSender), GetShaderInfoLog(WebGLShaderId, WebGLSender), GetProgramInfoLog(WebGLProgramId, WebGLSender), @@ -261,7 +258,6 @@ pub enum WebGLCommand { VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer(u32, i32, u32, bool, i32, u32), VertexAttribPointer2f(u32, i32, bool, i32, u32), - GetViewport(WebGLSender<(i32, i32, i32, i32)>), SetViewport(i32, i32, i32, i32), TexImage2D(u32, i32, i32, i32, i32, u32, u32, ByteBuf), TexParameteri(u32, u32, i32), @@ -275,8 +271,18 @@ pub enum WebGLCommand { CreateVertexArray(WebGLSender>), DeleteVertexArray(WebGLVertexArrayId), BindVertexArray(Option), - AliasedPointSizeRange(WebGLSender<(f32, f32)>), - AliasedLineWidthRange(WebGLSender<(f32, f32)>), + GetParameterBool(ParameterBool, WebGLSender), + GetParameterInt(ParameterInt, WebGLSender), + GetParameterInt4(ParameterInt4, WebGLSender<[i32; 4]>), + GetParameterFloat(ParameterFloat, WebGLSender), + GetParameterFloat2(ParameterFloat2, WebGLSender<[f32; 2]>), + GetProgramParameterBool(WebGLProgramId, ProgramParameterBool, WebGLSender), + GetProgramParameterInt(WebGLProgramId, ProgramParameterInt, WebGLSender), + GetShaderParameterBool(WebGLShaderId, ShaderParameterBool, WebGLSender), + GetShaderParameterInt(WebGLShaderId, ShaderParameterInt, WebGLSender), + GetVertexAttribBool(u32, VertexAttribBool, WebGLSender>), + GetVertexAttribInt(u32, VertexAttribInt, WebGLSender>), + GetVertexAttribFloat4(u32, VertexAttribFloat4, WebGLSender>), } macro_rules! define_resource_id_struct { @@ -376,25 +382,8 @@ pub enum WebGLFramebufferBindingRequest { Default, } -#[derive(Clone, Debug, Deserialize, Serialize)] -pub enum WebGLParameter { - Int(i32), - Bool(bool), - String(String), - Float(f32), - FloatArray(Vec), - Invalid, -} - pub type WebGLResult = Result; -#[derive(Clone, Debug, Deserialize, Serialize)] -pub enum WebGLShaderParameter { - Int(i32), - Bool(bool), - Invalid, -} - pub type WebVRDeviceId = u32; // WebVR commands that must be called in the WebGL render thread. @@ -481,10 +470,7 @@ impl fmt::Debug for WebGLCommand { FramebufferRenderbuffer(..) => "FramebufferRenderbuffer", FramebufferTexture2D(..) => "FramebufferTexture2D", GetExtensions(..) => "GetExtensions", - GetParameter(..) => "GetParameter", GetTexParameter(..) => "GetTexParameter", - GetProgramParameter(..) => "GetProgramParameter", - GetShaderParameter(..) => "GetShaderParameter", GetShaderPrecisionFormat(..) => "GetShaderPrecisionFormat", GetActiveAttrib(..) => "GetActiveAttrib", GetActiveUniform(..) => "GetActiveUniform", @@ -492,7 +478,6 @@ impl fmt::Debug for WebGLCommand { GetUniformLocation(..) => "GetUniformLocation", GetShaderInfoLog(..) => "GetShaderInfoLog", GetProgramInfoLog(..) => "GetProgramInfoLog", - GetVertexAttrib(..) => "GetVertexAttrib", GetVertexAttribOffset(..) => "GetVertexAttribOffset", GetFramebufferAttachmentParameter(..) => "GetFramebufferAttachmentParameter", GetRenderbufferParameter(..) => "GetRenderbufferParameter", @@ -536,7 +521,6 @@ impl fmt::Debug for WebGLCommand { VertexAttrib(..) => "VertexAttrib", VertexAttribPointer2f(..) => "VertexAttribPointer2f", VertexAttribPointer(..) => "VertexAttribPointer", - GetViewport(..) => "GetViewport", SetViewport(..) => "SetViewport", TexImage2D(..) => "TexImage2D", TexParameteri(..) => "TexParameteri", @@ -550,10 +534,169 @@ impl fmt::Debug for WebGLCommand { CreateVertexArray(..) => "CreateVertexArray", DeleteVertexArray(..) => "DeleteVertexArray", BindVertexArray(..) => "BindVertexArray", - AliasedPointSizeRange(..) => "AliasedPointSizeRange", - AliasedLineWidthRange(..) => "AliasedLineWidthRange", + GetParameterBool(..) => "GetParameterBool", + GetParameterInt(..) => "GetParameterInt", + GetParameterInt4(..) => "GetParameterInt4", + GetParameterFloat(..) => "GetParameterFloat", + GetParameterFloat2(..) => "GetParameterFloat2", + GetProgramParameterBool(..) => "GetProgramParameterBool", + GetProgramParameterInt(..) => "GetProgramParameterInt", + GetShaderParameterBool(..) => "GetShaderParameterBool", + GetShaderParameterInt(..) => "GetShaderParameterInt", + GetVertexAttribBool(..) => "GetVertexAttribBool", + GetVertexAttribInt(..) => "GetVertexAttribInt", + GetVertexAttribFloat4(..) => "GetVertexAttribFloat4", }; write!(f, "CanvasWebGLMsg::{}(..)", name) } } + +macro_rules! parameters { + ($name:ident { $( + $variant:ident($kind:ident { $( + $param:ident = gl::$value:ident, + )+ }), + )+ }) => { + #[derive(Clone, Deserialize, Serialize)] + pub enum $name { $( + $variant($kind), + )+} + + $( + #[derive(Clone, Deserialize, Serialize)] + #[repr(u32)] + pub enum $kind { $( + $param = gl::$value, + )+} + )+ + + impl $name { + pub fn from_u32(value: u32) -> WebGLResult { + match value { + $($(gl::$value => Ok($name::$variant($kind::$param)),)+)+ + _ => Err(WebGLError::InvalidEnum) + } + } + } + } +} + +parameters! { + Parameter { + Bool(ParameterBool { + Blend = gl::BLEND, + CullFace = gl::CULL_FACE, + DepthTest = gl::DEPTH_TEST, + DepthWritemask = gl::DEPTH_WRITEMASK, + Dither = gl::DITHER, + PolygonOffsetFill = gl::POLYGON_OFFSET_FILL, + SampleCoverageInvert = gl::SAMPLE_COVERAGE_INVERT, + StencilTest = gl::STENCIL_TEST, + }), + Int(ParameterInt { + ActiveTexture = gl::ACTIVE_TEXTURE, + AlphaBits = gl::ALPHA_BITS, + BlendDstAlpha = gl::BLEND_DST_ALPHA, + BlendDstRgb = gl::BLEND_DST_RGB, + BlendEquationAlpha = gl::BLEND_EQUATION_ALPHA, + BlendEquationRgb = gl::BLEND_EQUATION_RGB, + BlendSrcAlpha = gl::BLEND_SRC_ALPHA, + BlendSrcRgb = gl::BLEND_SRC_RGB, + BlueBits = gl::BLUE_BITS, + CullFaceMode = gl::CULL_FACE_MODE, + DepthBits = gl::DEPTH_BITS, + DepthFunc = gl::DEPTH_FUNC, + FrontFace = gl::FRONT_FACE, + GreenBits = gl::GREEN_BITS, + MaxCombinedTextureImageUnits = gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS, + MaxCubeMapTextureSize = gl::MAX_CUBE_MAP_TEXTURE_SIZE, + MaxRenderbufferSize = gl::MAX_RENDERBUFFER_SIZE, + MaxTextureImageUnits = gl::MAX_TEXTURE_IMAGE_UNITS, + MaxTextureSize = gl::MAX_TEXTURE_SIZE, + MaxVertexAttribs = gl::MAX_VERTEX_ATTRIBS, + MaxVertexTextureImageUnits = gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS, + PackAlignment = gl::PACK_ALIGNMENT, + RedBits = gl::RED_BITS, + SampleBuffers = gl::SAMPLE_BUFFERS, + Samples = gl::SAMPLES, + StencilBackFail = gl::STENCIL_BACK_FAIL, + StencilBackFunc = gl::STENCIL_BACK_FUNC, + StencilBackPassDepthFail = gl::STENCIL_BACK_PASS_DEPTH_FAIL, + StencilBackPassDepthPass = gl::STENCIL_BACK_PASS_DEPTH_PASS, + StencilBackRef = gl::STENCIL_BACK_REF, + StencilBackValueMask = gl::STENCIL_BACK_VALUE_MASK, + StencilBackWritemask = gl::STENCIL_BACK_WRITEMASK, + StencilBits = gl::STENCIL_BITS, + StencilClearValue = gl::STENCIL_CLEAR_VALUE, + StencilFail = gl::STENCIL_FAIL, + StencilFunc = gl::STENCIL_FUNC, + StencilPassDepthFail = gl::STENCIL_PASS_DEPTH_FAIL, + StencilPassDepthPass = gl::STENCIL_PASS_DEPTH_PASS, + StencilRef = gl::STENCIL_REF, + StencilValueMask = gl::STENCIL_VALUE_MASK, + StencilWritemask = gl::STENCIL_WRITEMASK, + SubpixelBits = gl::SUBPIXEL_BITS, + UnpackAlignment = gl::UNPACK_ALIGNMENT, + FragmentShaderDerivativeHint = gl::FRAGMENT_SHADER_DERIVATIVE_HINT, + }), + Int4(ParameterInt4 { + Viewport = gl::VIEWPORT, + }), + Float(ParameterFloat { + DepthClearValue = gl::DEPTH_CLEAR_VALUE, + LineWidth = gl::LINE_WIDTH, + PolygonOffsetFactor = gl::POLYGON_OFFSET_FACTOR, + PolygonOffsetUnits = gl::POLYGON_OFFSET_UNITS, + SampleCoverageValue = gl::SAMPLE_COVERAGE_VALUE, + }), + Float2(ParameterFloat2 { + AliasedPointSizeRange = gl::ALIASED_POINT_SIZE_RANGE, + AliasedLineWidthRange = gl::ALIASED_LINE_WIDTH_RANGE, + }), + } +} + +parameters! { + ProgramParameter { + Bool(ProgramParameterBool { + DeleteStatus = gl::DELETE_STATUS, + LinkStatus = gl::LINK_STATUS, + ValidateStatus = gl::VALIDATE_STATUS, + }), + Int(ProgramParameterInt { + AttachedShaders = gl::ATTACHED_SHADERS, + ActiveAttributes = gl::ACTIVE_ATTRIBUTES, + ActiveUniforms = gl::ACTIVE_UNIFORMS, + }), + } +} + +parameters! { + ShaderParameter { + Bool(ShaderParameterBool { + DeleteStatus = gl::DELETE_STATUS, + CompileStatus = gl::COMPILE_STATUS, + }), + Int(ShaderParameterInt { + ShaderType = gl::SHADER_TYPE, + }), + } +} + +parameters! { + VertexAttrib { + Bool(VertexAttribBool { + VertexAttribArrayEnabled = gl::VERTEX_ATTRIB_ARRAY_ENABLED, + VertexAttribArrayNormalized = gl::VERTEX_ATTRIB_ARRAY_NORMALIZED, + }), + Int(VertexAttribInt { + VertexAttribArraySize = gl::VERTEX_ATTRIB_ARRAY_SIZE, + VertexAttribArrayStride = gl::VERTEX_ATTRIB_ARRAY_STRIDE, + VertexAttribArrayType = gl::VERTEX_ATTRIB_ARRAY_TYPE, + }), + Float4(VertexAttribFloat4 { + CurrentVertexAttrib = gl::CURRENT_VERTEX_ATTRIB, + }), + } +} diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 879dfe00249b..7715effd5512 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -16,7 +16,7 @@ default = [] [dependencies] euclid = "0.17" gfx_traits = {path = "../gfx_traits"} -gleam = { version = "0.4.34", optional = true } +gleam = {version = "0.5", optional = true} image = "0.18" ipc-channel = "0.10" libc = "0.2" diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 44e662191bbd..3989ed5e000a 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -276,7 +276,7 @@ impl webrender_api::RenderNotifier for RenderNotifier { self.compositor_proxy.recomposite(CompositingReason::NewWebRenderFrame); } - fn new_document_ready( + fn new_frame_ready( &self, _document_id: webrender_api::DocumentId, scrolled: bool, diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs index 1aa8e86453e6..b62a143c3731 100644 --- a/components/layout/display_list/background.rs +++ b/components/layout/display_list/background.rs @@ -32,8 +32,8 @@ use style::values::generics::image::EndingShape as GenericEndingShape; use style::values::generics::image::GradientItem as GenericGradientItem; use style::values::specified::background::BackgroundRepeatKeyword; use style::values::specified::position::{X, Y}; -use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF, ExtendMode, ImageBorder}; -use webrender_api::{GradientStop, LayoutSize, NinePatchDescriptor, NormalBorder}; +use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF, ExtendMode, GradientStop}; +use webrender_api::{LayoutSize, NinePatchBorder, NinePatchBorderSource, NormalBorder}; /// A helper data structure for gradients. #[derive(Clone, Copy)] @@ -791,22 +791,20 @@ pub fn build_image_border_details( let corners = &border_style_struct.border_image_slice.offsets; let border_image_repeat = &border_style_struct.border_image_repeat; if let Some(image_key) = webrender_image.key { - Some(BorderDetails::Image(ImageBorder { - image_key: image_key, - patch: NinePatchDescriptor { - width: webrender_image.width, - height: webrender_image.height, - slice: SideOffsets2D::new( - corners.0.resolve(webrender_image.height), - corners.1.resolve(webrender_image.width), - corners.2.resolve(webrender_image.height), - corners.3.resolve(webrender_image.width), - ), - }, + Some(BorderDetails::Image(NinePatchBorder { + source: NinePatchBorderSource::Image(image_key), + width: webrender_image.width, + height: webrender_image.height, + slice: SideOffsets2D::new( + corners.0.resolve(webrender_image.height), + corners.1.resolve(webrender_image.width), + corners.2.resolve(webrender_image.height), + corners.3.resolve(webrender_image.width), + ), fill: border_style_struct.border_image_slice.fill, - outset: outset, repeat_horizontal: border_image_repeat.0.to_layout(), repeat_vertical: border_image_repeat.1.to_layout(), + outset: outset, })) } else { None diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs index 3ea11c565d71..09539050789a 100644 --- a/components/layout/display_list/items.rs +++ b/components/layout/display_list/items.rs @@ -24,10 +24,10 @@ use std::f32; use std::fmt; use webrender_api::{BorderRadius, BorderWidths, BoxShadowClipMode, ClipMode, ColorF}; use webrender_api::{ComplexClipRegion, ExtendMode, ExternalScrollId, FilterOp, FontInstanceKey}; -use webrender_api::{GlyphInstance, GradientStop, ImageBorder, ImageKey, ImageRendering}; -use webrender_api::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D}; -use webrender_api::{LineStyle, MixBlendMode, NormalBorder, ScrollPolicy, ScrollSensitivity, Shadow}; -use webrender_api::{StickyOffsetBounds, TransformStyle}; +use webrender_api::{GlyphInstance, GradientStop, ImageKey, ImageRendering, LayoutPoint}; +use webrender_api::{LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D, LineStyle}; +use webrender_api::{MixBlendMode, NinePatchBorder, NormalBorder, ScrollPolicy, ScrollSensitivity}; +use webrender_api::{Shadow, StickyOffsetBounds, TransformStyle}; pub use style::dom::OpaqueNode; @@ -775,7 +775,7 @@ pub struct RadialGradientBorder { #[derive(Clone, Serialize)] pub enum BorderDetails { Normal(NormalBorder), - Image(ImageBorder), + Image(NinePatchBorder), Gradient(GradientBorder), RadialGradient(RadialGradientBorder), } diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs index b7cd250fd2ea..30f61386b925 100644 --- a/components/layout/display_list/webrender_helpers.rs +++ b/components/layout/display_list/webrender_helpers.rs @@ -127,7 +127,7 @@ impl WebRenderDisplayItemConverter for DisplayItem { BorderDetails::Normal(ref border) => { webrender_api::BorderDetails::Normal(*border) }, - BorderDetails::Image(ref image) => webrender_api::BorderDetails::Image(*image), + BorderDetails::Image(ref image) => webrender_api::BorderDetails::NinePatch(*image), BorderDetails::Gradient(ref gradient) => { webrender_api::BorderDetails::Gradient(webrender_api::GradientBorder { gradient: builder.create_gradient( diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 779287183edb..b4c7c4232fbf 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -793,7 +793,7 @@ malloc_size_of_is_0!(webrender_api::GradientStop); #[cfg(feature = "webrender_api")] malloc_size_of_is_0!(webrender_api::GlyphInstance); #[cfg(feature = "webrender_api")] -malloc_size_of_is_0!(webrender_api::ImageBorder); +malloc_size_of_is_0!(webrender_api::NinePatchBorder); #[cfg(feature = "webrender_api")] malloc_size_of_is_0!(webrender_api::ImageKey); #[cfg(feature = "webrender_api")] diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index d0adbdbf6b12..adb12eeb0a14 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -46,7 +46,7 @@ embedder_traits = {path = "../embedder_traits"} encoding_rs = "0.7" euclid = "0.17" fnv = "1.0" -gleam = "0.4.34" +gleam = "0.5" half = "1.0" html5ever = "0.22" hyper = "0.10" @@ -68,7 +68,7 @@ mozjs = { version = "0.6", features = ["promises"]} msg = {path = "../msg"} net_traits = {path = "../net_traits"} num-traits = "0.1.32" -offscreen_gl_context = { version = "0.15", features = ["serde"] } +offscreen_gl_context = {version = "0.16", features = ["serde"]} parking_lot = "0.5" phf = "0.7.18" profile_traits = {path = "../profile_traits"} diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 3d4cb5f593cd..d710568d1ca2 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use canvas_traits::webgl::{WebGLCommand, WebGLError, WebGLMsgSender, WebGLParameter, WebGLProgramId, WebGLResult}; +use canvas_traits::webgl::{WebGLCommand, WebGLError, WebGLMsgSender, WebGLProgramId, WebGLResult}; use canvas_traits::webgl::webgl_channel; use dom::bindings::codegen::Bindings::WebGLProgramBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -362,13 +362,6 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - /// glGetProgramParameter - pub fn parameter(&self, param_id: u32) -> WebGLResult { - let (sender, receiver) = webgl_channel().unwrap(); - self.renderer.send(WebGLCommand::GetProgramParameter(self.id, param_id, sender)).unwrap(); - receiver.recv().unwrap() - } - pub fn attached_shaders(&self) -> WebGLResult>> { if self.is_deleted.get() { return Err(WebGLError::InvalidValue); diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index d68f817dcd67..d1383cded5d9 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -4,12 +4,13 @@ use byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; use canvas_traits::canvas::{byte_swap, multiply_u8_pixel}; -use canvas_traits::webgl::{WebGLCommand, WebGLContextShareMode, WebGLError}; +use canvas_traits::webgl::{DOMToTextureCommand, Parameter, ProgramParameter}; +use canvas_traits::webgl::{ShaderParameter, VertexAttrib, WebGLCommand}; +use canvas_traits::webgl::{WebGLContextShareMode, WebGLError}; use canvas_traits::webgl::{WebGLFramebufferBindingRequest, WebGLMsg, WebGLMsgSender}; -use canvas_traits::webgl::{WebGLParameter, WebGLResult, WebGLSLVersion, WebGLVersion, WebVRCommand}; -use canvas_traits::webgl::DOMToTextureCommand; +use canvas_traits::webgl::{WebGLResult, WebGLSLVersion, WebGLVersion}; +use canvas_traits::webgl::{WebVRCommand, webgl_channel}; use canvas_traits::webgl::WebGLError::*; -use canvas_traits::webgl::webgl_channel; use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{self, WebGLContextAttributes}; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -1310,36 +1311,27 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { 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(); + constants::VERSION => { rooted!(in(cx) let mut rval = UndefinedValue()); - [x, y, width, height].to_jsval(cx, rval.handle_mut()); + "WebGL 1.0".to_jsval(cx, rval.handle_mut()); return rval.get(); } - constants::ALIASED_POINT_SIZE_RANGE => { - let (sender, receiver) = webgl_channel().unwrap(); - self.send_command(WebGLCommand::AliasedPointSizeRange(sender)); - let (width, height) = receiver.recv().unwrap(); + constants::RENDERER | constants::VENDOR => { rooted!(in(cx) let mut rval = UndefinedValue()); - [width, height].to_jsval(cx, rval.handle_mut()); + "Mozilla/Servo".to_jsval(cx, rval.handle_mut()); return rval.get(); } - constants::ALIASED_LINE_WIDTH_RANGE => { - let (sender, receiver) = webgl_channel().unwrap(); - self.send_command(WebGLCommand::AliasedLineWidthRange(sender)); - let (width, height) = receiver.recv().unwrap(); + constants::SHADING_LANGUAGE_VERSION => { rooted!(in(cx) let mut rval = UndefinedValue()); - [width, height].to_jsval(cx, rval.handle_mut()); + "WebGL GLSL ES 1.0".to_jsval(cx, rval.handle_mut()); return rval.get(); } - _ => { - if !self.extension_manager.is_get_parameter_name_enabled(parameter) { - self.webgl_error(WebGLError::InvalidEnum); - return NullValue(); - } - } + _ => {} + } + + if !self.extension_manager.is_get_parameter_name_enabled(parameter) { + self.webgl_error(WebGLError::InvalidEnum); + return NullValue(); } // Handle GetParameter getters injected via WebGL extensions @@ -1355,20 +1347,38 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } } - let (sender, receiver) = webgl_channel().unwrap(); - self.send_command(WebGLCommand::GetParameter(parameter, sender)); - - match handle_potential_webgl_error!(self, receiver.recv().unwrap(), WebGLParameter::Invalid) { - WebGLParameter::Int(val) => Int32Value(val), - WebGLParameter::Bool(val) => BooleanValue(val), - WebGLParameter::Float(val) => DoubleValue(val as f64), - WebGLParameter::FloatArray(_) => panic!("Parameter should not be float array"), - WebGLParameter::String(val) => { + match handle_potential_webgl_error!(self, Parameter::from_u32(parameter), return NullValue()) { + Parameter::Bool(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetParameterBool(param, sender)); + BooleanValue(receiver.recv().unwrap()) + } + Parameter::Int(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetParameterInt(param, sender)); + Int32Value(receiver.recv().unwrap()) + } + Parameter::Int4(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetParameterInt4(param, sender)); + // FIXME(nox): https://github.com/servo/servo/issues/20655 + rooted!(in(cx) let mut rval = UndefinedValue()); + receiver.recv().unwrap().to_jsval(cx, rval.handle_mut()); + rval.get() + } + Parameter::Float(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetParameterFloat(param, sender)); + DoubleValue(receiver.recv().unwrap() as f64) + } + Parameter::Float2(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetParameterFloat2(param, sender)); + // FIXME(nox): https://github.com/servo/servo/issues/20655 rooted!(in(cx) let mut rval = UndefinedValue()); - val.to_jsval(cx, rval.handle_mut()); + receiver.recv().unwrap().to_jsval(cx, rval.handle_mut()); rval.get() } - WebGLParameter::Invalid => NullValue(), } } @@ -2400,16 +2410,18 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { #[allow(unsafe_code)] // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 - unsafe fn GetProgramParameter(&self, _: *mut JSContext, program: &WebGLProgram, param_id: u32) -> JSVal { - match handle_potential_webgl_error!(self, program.parameter(param_id), WebGLParameter::Invalid) { - WebGLParameter::Int(val) => Int32Value(val), - WebGLParameter::Bool(val) => BooleanValue(val), - WebGLParameter::String(_) => panic!("Program parameter should not be string"), - WebGLParameter::Float(_) => panic!("Program parameter should not be float"), - WebGLParameter::FloatArray(_) => { - panic!("Program paramenter should not be float array") + unsafe fn GetProgramParameter(&self, _: *mut JSContext, program: &WebGLProgram, param: u32) -> JSVal { + match handle_potential_webgl_error!(self, ProgramParameter::from_u32(param), return NullValue()) { + ProgramParameter::Bool(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetProgramParameterBool(program.id(), param, sender)); + BooleanValue(receiver.recv().unwrap()) + } + ProgramParameter::Int(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetProgramParameterInt(program.id(), param, sender)); + Int32Value(receiver.recv().unwrap()) } - WebGLParameter::Invalid => NullValue(), } } @@ -2420,16 +2432,22 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { #[allow(unsafe_code)] // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 - unsafe fn GetShaderParameter(&self, _: *mut JSContext, shader: &WebGLShader, param_id: u32) -> JSVal { - match handle_potential_webgl_error!(self, shader.parameter(param_id), WebGLParameter::Invalid) { - WebGLParameter::Int(val) => Int32Value(val), - WebGLParameter::Bool(val) => BooleanValue(val), - WebGLParameter::String(_) => panic!("Shader parameter should not be string"), - WebGLParameter::Float(_) => panic!("Shader parameter should not be float"), - WebGLParameter::FloatArray(_) => { - panic!("Shader paramenter should not be float array") + unsafe fn GetShaderParameter(&self, _: *mut JSContext, shader: &WebGLShader, param: u32) -> JSVal { + if shader.is_deleted() && !shader.is_attached() { + self.webgl_error(InvalidValue); + return NullValue(); + } + match handle_potential_webgl_error!(self, ShaderParameter::from_u32(param), return NullValue()) { + ShaderParameter::Bool(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetShaderParameterBool(shader.id(), param, sender)); + BooleanValue(receiver.recv().unwrap()) + } + ShaderParameter::Int(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetShaderParameterInt(shader.id(), param, sender)); + Int32Value(receiver.recv().unwrap()) } - WebGLParameter::Invalid => NullValue(), } } @@ -2474,8 +2492,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { #[allow(unsafe_code)] // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 - unsafe fn GetVertexAttrib(&self, cx: *mut JSContext, index: u32, pname: u32) -> JSVal { - if index == 0 && pname == constants::CURRENT_VERTEX_ATTRIB { + unsafe fn GetVertexAttrib(&self, cx: *mut JSContext, index: u32, param: u32) -> JSVal { + if index == 0 && param == constants::CURRENT_VERTEX_ATTRIB { rooted!(in(cx) let mut result = UndefinedValue()); let (x, y, z, w) = self.current_vertex_attrib_0.get(); let attrib = vec![x, y, z, w]; @@ -2483,7 +2501,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { return result.get() } - if pname == constants::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING { + if param == constants::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING { rooted!(in(cx) let mut jsval = NullValue()); if let Some(buffer) = self.bound_attrib_buffers.borrow().get(&index) { buffer.to_jsval(cx, jsval.handle_mut()); @@ -2491,20 +2509,28 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { return jsval.get(); } - let (sender, receiver) = webgl_channel().unwrap(); - self.send_command(WebGLCommand::GetVertexAttrib(index, pname, sender)); - - match handle_potential_webgl_error!(self, receiver.recv().unwrap(), WebGLParameter::Invalid) { - WebGLParameter::Int(val) => Int32Value(val), - WebGLParameter::Bool(val) => BooleanValue(val), - WebGLParameter::String(_) => panic!("Vertex attrib should not be string"), - WebGLParameter::Float(_) => panic!("Vertex attrib should not be float"), - WebGLParameter::FloatArray(val) => { + match handle_potential_webgl_error!(self, VertexAttrib::from_u32(param), return NullValue()) { + VertexAttrib::Bool(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetVertexAttribBool(index, param, sender)); + let value = handle_potential_webgl_error!(self, receiver.recv().unwrap(), return NullValue()); + BooleanValue(value) + } + VertexAttrib::Int(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetVertexAttribInt(index, param, sender)); + let value = handle_potential_webgl_error!(self, receiver.recv().unwrap(), return NullValue()); + Int32Value(value) + } + VertexAttrib::Float4(param) => { + let (sender, receiver) = webgl_channel().unwrap(); + self.send_command(WebGLCommand::GetVertexAttribFloat4(index, param, sender)); + let value = handle_potential_webgl_error!(self, receiver.recv().unwrap(), return NullValue()); + // FIXME(nox): https://github.com/servo/servo/issues/20655 rooted!(in(cx) let mut result = UndefinedValue()); - val.to_jsval(cx, result.handle_mut()); + value.to_jsval(cx, result.handle_mut()); result.get() } - WebGLParameter::Invalid => NullValue(), } } diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 0e965b01b3b6..2fa975939c01 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -4,8 +4,8 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLCommand, WebGLError, WebGLMsgSender}; -use canvas_traits::webgl::{WebGLParameter, WebGLResult, WebGLSLVersion}; -use canvas_traits::webgl::{WebGLShaderId, WebGLVersion, webgl_channel}; +use canvas_traits::webgl::{WebGLResult, WebGLSLVersion, WebGLShaderId}; +use canvas_traits::webgl::{WebGLVersion, webgl_channel}; use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLShaderBinding; use dom::bindings::reflector::reflect_dom_object; @@ -210,16 +210,6 @@ impl WebGLShader { self.info_log.borrow().clone() } - /// glGetParameter - pub fn parameter(&self, param_id: u32) -> WebGLResult { - if self.is_deleted.get() && !self.is_attached() { - return Err(WebGLError::InvalidValue); - } - let (sender, receiver) = webgl_channel().unwrap(); - self.renderer.send(WebGLCommand::GetShaderParameter(self.id, param_id, sender)).unwrap(); - receiver.recv().unwrap() - } - /// Get the shader source pub fn source(&self) -> Option { self.source.borrow().clone() diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 9d616ec2885a..f86b47de925a 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -41,7 +41,7 @@ embedder_traits = {path = "../embedder_traits"} env_logger = "0.5" euclid = "0.17" gfx = {path = "../gfx"} -gleam = "0.4.34" +gleam = "0.5" ipc-channel = "0.10" layout_thread = {path = "../layout_thread"} log = "0.4" diff --git a/ports/servo/Cargo.toml b/ports/servo/Cargo.toml index 3a3cbe5481dc..fcd38b722cc6 100644 --- a/ports/servo/Cargo.toml +++ b/ports/servo/Cargo.toml @@ -37,7 +37,7 @@ unstable = ["libservo/unstable"] backtrace = "0.3" bitflags = "1.0" euclid = "0.17" -gleam = "0.4.34" +gleam = "0.5" glutin = "0.13" lazy_static = "1" libservo = {path = "../../components/servo"}