diff --git a/.vscode/settings.json b/.vscode/settings.json index 1ba51e7..2cea097 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,16 +1,16 @@ { "wgsl-analyzer.customImports": { - "bbox": "${workspaceFolder}/piet-wgsl/shader/shared/bbox.wgsl", - "blend": "${workspaceFolder}/piet-wgsl/shader/shared/blend.wgsl", - "bump": "${workspaceFolder}/piet-wgsl/shader/shared/bump.wgsl", - "clip": "${workspaceFolder}/piet-wgsl/shader/shared/clip.wgsl", - "config": "${workspaceFolder}/piet-wgsl/shader/shared/config.wgsl", - "cubic": "${workspaceFolder}/piet-wgsl/shader/shared/cubic.wgsl", - "drawtag": "${workspaceFolder}/piet-wgsl/shader/shared/drawtag.wgsl", - "pathtag": "${workspaceFolder}/piet-wgsl/shader/shared/pathtag.wgsl", - "ptcl": "${workspaceFolder}/piet-wgsl/shader/shared/ptcl.wgsl", - "segment": "${workspaceFolder}/piet-wgsl/shader/shared/segment.wgsl", - "tile": "${workspaceFolder}/piet-wgsl/shader/shared/tile.wgsl" + "bbox": "${workspaceFolder}/vello/shader/shared/bbox.wgsl", + "blend": "${workspaceFolder}/vello/shader/shared/blend.wgsl", + "bump": "${workspaceFolder}/vello/shader/shared/bump.wgsl", + "clip": "${workspaceFolder}/vello/shader/shared/clip.wgsl", + "config": "${workspaceFolder}/vello/shader/shared/config.wgsl", + "cubic": "${workspaceFolder}/vello/shader/shared/cubic.wgsl", + "drawtag": "${workspaceFolder}/vello/shader/shared/drawtag.wgsl", + "pathtag": "${workspaceFolder}/vello/shader/shared/pathtag.wgsl", + "ptcl": "${workspaceFolder}/vello/shader/shared/ptcl.wgsl", + "segment": "${workspaceFolder}/vello/shader/shared/segment.wgsl", + "tile": "${workspaceFolder}/vello/shader/shared/tile.wgsl" }, "wgsl-analyzer.diagnostics.nagaVersion": "main", "wgsl-analyzer.preprocessor.shaderDefs": ["full"] diff --git a/Cargo.lock b/Cargo.lock index d7f99c4..f7a002f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "ash" -version = "0.37.0+1.3.209" +version = "0.37.1+1.3.235" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006ca68e0f2b03f22d6fa9f2860f85aed430d257fec20f8879b2145e7c7ae1a6" +checksum = "911015c962d56e2e4052f40182ca5462ba60a3d2ff04e827c365a0ab3d65726d" dependencies = [ "libloading", ] @@ -112,18 +112,18 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "bytemuck" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da" +checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9e1f5fa78f69496407a27ae9ed989e3c3b072310286f5ef385525e4cbc24a9" +checksum = "5fe233b960f12f8007e3db2d136e3cb1c291bfd7396e384ee76025fc1a3932b4" dependencies = [ "proc-macro2", "quote", @@ -138,12 +138,12 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "calloop" -version = "0.10.1" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a22a6a8f622f797120d452c630b0ab12e1331a1a753e2039ce7868d4ac77b4ee" +checksum = "19457a0da465234abd76134a5c2a910c14bd3c5558463e4396ab9a37a328e465" dependencies = [ "log", - "nix", + "nix 0.25.1", "slotmap", "thiserror", "vec_map", @@ -162,9 +162,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cfg-if" @@ -189,9 +189,9 @@ dependencies = [ [[package]] name = "cocoa" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" +checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" dependencies = [ "bitflags", "block", @@ -447,9 +447,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ "crc32fast", "miniz_oxide", @@ -553,9 +553,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -651,9 +651,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", "hashbrown", @@ -726,15 +726,15 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.135" +version = "0.2.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" [[package]] name = "libloading" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", @@ -776,9 +776,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95af15f345b17af2efc8ead6080fb8bc376f8cec1b35277b935637595fe77498" +checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" dependencies = [ "libc", ] @@ -814,9 +814,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] @@ -911,18 +911,18 @@ dependencies = [ [[package]] name = "ndk-sys" -version = "0.4.0" +version = "0.4.1+23.1.7779620" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046" +checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" dependencies = [ "jni-sys", ] [[package]] name = "nix" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags", "cfg-if", @@ -930,6 +930,19 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +dependencies = [ + "autocfg", + "bitflags", + "cfg-if", + "libc", + "memoffset", +] + [[package]] name = "nom" version = "7.1.1" @@ -991,9 +1004,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "parking_lot" @@ -1007,9 +1020,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" dependencies = [ "cfg-if", "libc", @@ -1039,28 +1052,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" -[[package]] -name = "piet-scene" -version = "0.1.0" -dependencies = [ - "bytemuck", - "moscato", - "peniko", - "smallvec", -] - -[[package]] -name = "piet-wgsl" -version = "0.1.0" -dependencies = [ - "bytemuck", - "futures-intrusive", - "parking_lot", - "piet-scene", - "raw-window-handle 0.5.0", - "wgpu", -] - [[package]] name = "pinot" version = "0.1.5" @@ -1069,15 +1060,15 @@ checksum = "6ba3013ff85036c414a4a3cf826135db204de2bd80d684728550e7130421809a" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "png" -version = "0.17.6" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c" +checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" dependencies = [ "bitflags", "crc32fast", @@ -1225,9 +1216,9 @@ checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" [[package]] name = "scoped-tls" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" @@ -1249,15 +1240,15 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.147" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "256b9932320c590e707b94576e3cc1f7c9024d0ee6612dfbcf1cb106cbe8e055" [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "b4eae9b04cbffdfd550eb462ed33bc6a1b68c935127d008b27444d08380f94e4" dependencies = [ "proc-macro2", "quote", @@ -1323,7 +1314,7 @@ dependencies = [ "lazy_static", "log", "memmap2", - "nix", + "nix 0.24.3", "pkg-config", "wayland-client", "wayland-cursor", @@ -1354,9 +1345,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.102" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" dependencies = [ "proc-macro2", "quote", @@ -1470,6 +1461,20 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "vello" +version = "0.1.0" +dependencies = [ + "bytemuck", + "futures-intrusive", + "moscato", + "parking_lot", + "peniko", + "raw-window-handle 0.5.0", + "smallvec", + "wgpu", +] + [[package]] name = "version_check" version = "0.9.4" @@ -1681,7 +1686,7 @@ dependencies = [ "bitflags", "downcast-rs", "libc", - "nix", + "nix 0.24.3", "scoped-tls", "wayland-commons", "wayland-scanner", @@ -1694,7 +1699,7 @@ version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" dependencies = [ - "nix", + "nix 0.24.3", "once_cell", "smallvec", "wayland-sys", @@ -1706,7 +1711,7 @@ version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" dependencies = [ - "nix", + "nix 0.24.3", "wayland-client", "xcursor", ] @@ -1757,9 +1762,9 @@ dependencies = [ [[package]] name = "wgpu" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2272b17bffc8a0c7d53897435da7c1db587c87d3a14e8dae9cdb8d1d210fc0f" +checksum = "81f643110d228fd62a60c5ed2ab56c4d5b3704520bd50561174ec4ec74932937" dependencies = [ "arrayvec 0.7.2", "js-sys", @@ -1779,9 +1784,9 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73d14cad393054caf992ee02b7da6a372245d39a484f7461c1f44f6f6359bd28" +checksum = "6000d1284ef8eec6076fd5544a73125fd7eb9b635f18dceeb829d826f41724ca" dependencies = [ "arrayvec 0.7.2", "bit-vec", @@ -1803,9 +1808,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdae6a80dbc725343f02f854b310b37190be946aeea65e9d83afaa7d840ebaac" +checksum = "3cc320a61acb26be4f549c9b1b53405c10a223fbfea363ec39474c32c348d12f" dependencies = [ "android_system_properties", "arrayvec 0.7.2", @@ -1842,9 +1847,9 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28fb86c1909233c804aa79b7dd1ad06ebd979b2a465e3e980582db0ea9e69f3f" +checksum = "fb6b28ef22cac17b9109b25b3bf8c9a103eeb293d7c5f78653979b09140375f6" dependencies = [ "bitflags", ] @@ -2019,10 +2024,9 @@ version = "0.1.0" dependencies = [ "console_error_panic_hook", "console_log", - "piet-scene", - "piet-wgsl", "pollster", "roxmltree", + "vello", "wasm-bindgen-futures", "web-sys", "wgpu", @@ -2104,9 +2108,9 @@ dependencies = [ [[package]] name = "x11-dl" -version = "2.20.0" +version = "2.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c83627bc137605acc00bb399c7b908ef460b621fc37c953db2b09f88c449ea6" +checksum = "b1536d6965a5d4e573c7ef73a2c15ebcd0b2de3347bdf526c34c297c00ac40f0" dependencies = [ "lazy_static", "libc", diff --git a/Cargo.toml b/Cargo.toml index d2f030a..6c94702 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" -members = ["piet-scene", "piet-wgsl", "piet-wgsl/examples/winit", "run-wasm"] +members = ["vello", "vello/examples/winit", "run-wasm"] [workspace.package] edition = "2021" diff --git a/README.md b/README.md index d379c74..274866b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# piet-gpu +# vello -This repo contains the new prototype for a new compute-centric 2D GPU renderer. +This repo contains the new prototype for a new compute-centric 2D GPU renderer (formerly known as piet-gpu). It succeeds the previous prototype, [piet-metal]. diff --git a/piet-scene/Cargo.toml b/piet-scene/Cargo.toml deleted file mode 100644 index 239176c..0000000 --- a/piet-scene/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "piet-scene" -version = "0.1.0" -license = "MIT/Apache-2.0" -edition = "2021" - -[dependencies] -bytemuck = { version = "1.7.2", features = ["derive"] } -smallvec = "1.8.0" -moscato = { git = "https://github.com/dfrg/pinot" } -peniko = { git = "https://github.com/linebender/peniko" } diff --git a/piet-scene/src/conv.rs b/piet-scene/src/conv.rs deleted file mode 100644 index ad16062..0000000 --- a/piet-scene/src/conv.rs +++ /dev/null @@ -1,28 +0,0 @@ -use peniko::kurbo::{Affine, Point}; - -pub fn affine_to_f32(affine: &Affine) -> [f32; 6] { - let c = affine.as_coeffs(); - [ - c[0] as f32, - c[1] as f32, - c[2] as f32, - c[3] as f32, - c[4] as f32, - c[5] as f32, - ] -} - -pub fn affine_from_f32(coeffs: &[f32; 6]) -> Affine { - Affine::new([ - coeffs[0] as f64, - coeffs[1] as f64, - coeffs[2] as f64, - coeffs[3] as f64, - coeffs[4] as f64, - coeffs[5] as f64, - ]) -} - -pub fn point_to_f32(point: Point) -> [f32; 2] { - [point.x as f32, point.y as f32] -} diff --git a/piet-scene/src/lib.rs b/piet-scene/src/lib.rs deleted file mode 100644 index 04ac3c7..0000000 --- a/piet-scene/src/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The piet-gpu authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Also licensed under MIT license, at your choice. - -pub use peniko; - -mod conv; -mod scene; - -pub mod glyph; - -pub use peniko::*; -pub use scene::*; diff --git a/piet-scene/src/scene/mod.rs b/piet-scene/src/scene/mod.rs deleted file mode 100644 index f2aecb4..0000000 --- a/piet-scene/src/scene/mod.rs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2022 The piet-gpu authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Also licensed under MIT license, at your choice. - -mod builder; -mod resource; - -pub use builder::SceneBuilder; -pub use resource::{ResourceBundle, ResourcePatch}; - -use super::conv; -use peniko::kurbo::Affine; - -/// Raw data streams describing an encoded scene. -#[derive(Default)] -pub struct SceneData { - pub transform_stream: Vec<[f32; 6]>, - pub tag_stream: Vec, - pub pathseg_stream: Vec, - pub linewidth_stream: Vec, - pub drawtag_stream: Vec, - pub drawdata_stream: Vec, - pub n_path: u32, - pub n_pathseg: u32, - pub n_clip: u32, - pub resources: ResourceBundle, -} - -impl SceneData { - fn is_empty(&self) -> bool { - self.pathseg_stream.is_empty() - } - - fn reset(&mut self, is_fragment: bool) { - self.transform_stream.clear(); - self.tag_stream.clear(); - self.pathseg_stream.clear(); - self.linewidth_stream.clear(); - self.drawtag_stream.clear(); - self.drawdata_stream.clear(); - self.n_path = 0; - self.n_pathseg = 0; - self.n_clip = 0; - self.resources.clear(); - if !is_fragment { - self.transform_stream.push([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]); - self.linewidth_stream.push(-1.0); - } - } - - fn append(&mut self, other: &SceneData, transform: &Option) { - let stops_base = self.resources.stops.len(); - let drawdata_base = self.drawdata_stream.len(); - if let Some(transform) = *transform { - self.transform_stream.extend( - other - .transform_stream - .iter() - .map(|x| conv::affine_to_f32(&(transform * conv::affine_from_f32(x)))), - ); - } else { - self.transform_stream - .extend_from_slice(&other.transform_stream); - } - self.tag_stream.extend_from_slice(&other.tag_stream); - self.pathseg_stream.extend_from_slice(&other.pathseg_stream); - self.linewidth_stream - .extend_from_slice(&other.linewidth_stream); - self.drawtag_stream.extend_from_slice(&other.drawtag_stream); - self.drawdata_stream - .extend_from_slice(&other.drawdata_stream); - self.n_path += other.n_path; - self.n_pathseg += other.n_pathseg; - self.n_clip += other.n_clip; - self.resources - .stops - .extend_from_slice(&other.resources.stops); - self.resources - .patches - .extend(other.resources.patches.iter().map(|patch| match patch { - ResourcePatch::Ramp { offset, stops } => { - let stops = stops.start + stops_base..stops.end + stops_base; - ResourcePatch::Ramp { - offset: drawdata_base + offset, - stops, - } - } - })); - } -} - -/// Encoded definition of a scene that is ready for rendering when paired with -/// an associated resource context. -#[derive(Default)] -pub struct Scene { - data: SceneData, -} - -impl Scene { - /// Returns the raw encoded scene data streams. - pub fn data(&self) -> &SceneData { - &self.data - } -} - -/// Encoded definition of a scene fragment and associated resources. -#[derive(Default)] -pub struct SceneFragment { - data: SceneData, -} - -impl SceneFragment { - /// Returns true if the fragment does not contain any paths. - pub fn is_empty(&self) -> bool { - self.data.is_empty() - } - - /// Returns the the entire sequence of points in the scene fragment. - pub fn points(&self) -> &[[f32; 2]] { - if self.is_empty() { - &[] - } else { - bytemuck::cast_slice(&self.data.pathseg_stream) - } - } -} diff --git a/piet-scene/src/scene/resource.rs b/piet-scene/src/scene/resource.rs deleted file mode 100644 index 3f0fafa..0000000 --- a/piet-scene/src/scene/resource.rs +++ /dev/null @@ -1,31 +0,0 @@ -use core::ops::Range; -use peniko::ColorStop; - -#[derive(Default)] -/// Collection of late bound resources for a scene or scene fragment. -pub struct ResourceBundle { - /// Sequence of resource patches. - pub patches: Vec, - /// Cache of color stops, referenced by range from the patches. - pub stops: Vec, -} - -impl ResourceBundle { - /// Clears the resource set. - pub(crate) fn clear(&mut self) { - self.patches.clear(); - self.stops.clear(); - } -} - -#[derive(Clone)] -/// Description of a late bound resource. -pub enum ResourcePatch { - /// Gradient ramp resource. - Ramp { - /// Byte offset to the ramp id in the draw data stream. - offset: usize, - /// Range of the gradient stops in the resource set. - stops: Range, - }, -} diff --git a/piet-wgsl/Cargo.toml b/vello/Cargo.toml similarity index 65% rename from piet-wgsl/Cargo.toml rename to vello/Cargo.toml index d74eb15..423680c 100644 --- a/piet-wgsl/Cargo.toml +++ b/vello/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "piet-wgsl" +name = "vello" version = "0.1.0" authors = ["Raph Levien "] license = "MIT/Apache-2.0" @@ -11,4 +11,6 @@ raw-window-handle = "0.5" futures-intrusive = "0.5.0" parking_lot = "0.12" bytemuck = { version = "1.12.1", features = ["derive"] } -piet-scene = { path = "../piet-scene" } +smallvec = "1.8.0" +moscato = { git = "https://github.com/dfrg/pinot" } +peniko = { git = "https://github.com/linebender/peniko" } diff --git a/piet-wgsl/README.md b/vello/README.md similarity index 99% rename from piet-wgsl/README.md rename to vello/README.md index cc7f0e0..858292d 100644 --- a/piet-wgsl/README.md +++ b/vello/README.md @@ -1,4 +1,4 @@ -# piet-wgsl +# vello This crate is currently a highly experimental proof-of-concept port of the piet-gpu renderer to the WGSL shader language, so it could be run on WebGPU. Depending on how well it works out, it may become the authoritative source for piet-gpu. diff --git a/piet-wgsl/examples/assets/Ghostscript_Tiger.svg b/vello/examples/assets/Ghostscript_Tiger.svg similarity index 100% rename from piet-wgsl/examples/assets/Ghostscript_Tiger.svg rename to vello/examples/assets/Ghostscript_Tiger.svg diff --git a/piet-wgsl/examples/assets/third-party/LICENSE.txt b/vello/examples/assets/third-party/LICENSE.txt similarity index 100% rename from piet-wgsl/examples/assets/third-party/LICENSE.txt rename to vello/examples/assets/third-party/LICENSE.txt diff --git a/piet-wgsl/examples/assets/third-party/Roboto-Regular.ttf b/vello/examples/assets/third-party/Roboto-Regular.ttf similarity index 100% rename from piet-wgsl/examples/assets/third-party/Roboto-Regular.ttf rename to vello/examples/assets/third-party/Roboto-Regular.ttf diff --git a/piet-wgsl/examples/winit/Cargo.toml b/vello/examples/winit/Cargo.toml similarity index 84% rename from piet-wgsl/examples/winit/Cargo.toml rename to vello/examples/winit/Cargo.toml index d4719f1..e0d7987 100644 --- a/piet-wgsl/examples/winit/Cargo.toml +++ b/vello/examples/winit/Cargo.toml @@ -9,8 +9,7 @@ publish = false [dependencies] wgpu = "0.14" -piet-wgsl = { path = "../../../piet-wgsl" } -piet-scene = { path = "../../../piet-scene" } +vello = { path = "../../../vello" } winit = "0.27.5" pollster = "0.2.5" # for picosvg diff --git a/piet-wgsl/examples/winit/src/main.rs b/vello/examples/winit/src/main.rs similarity index 97% rename from piet-wgsl/examples/winit/src/main.rs rename to vello/examples/winit/src/main.rs index 0a98af3..4e6a403 100644 --- a/piet-wgsl/examples/winit/src/main.rs +++ b/vello/examples/winit/src/main.rs @@ -18,8 +18,7 @@ mod pico_svg; mod simple_text; mod test_scene; -use piet_scene::{Scene, SceneBuilder}; -use piet_wgsl::{util::RenderContext, Renderer}; +use vello::{util::RenderContext, Renderer, Scene, SceneBuilder}; use winit::{event_loop::EventLoop, window::Window}; async fn run(event_loop: EventLoop<()>, window: Window) { @@ -31,7 +30,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) { let mut simple_text = simple_text::SimpleText::new(); let mut current_frame = 0usize; let mut scene_ix = 0usize; - let mut scene = Scene::default(); + let mut scene = Scene::new(); event_loop.run(move |event, _, control_flow| match event { Event::WindowEvent { ref event, diff --git a/piet-wgsl/examples/winit/src/pico_svg.rs b/vello/examples/winit/src/pico_svg.rs similarity index 98% rename from piet-wgsl/examples/winit/src/pico_svg.rs rename to vello/examples/winit/src/pico_svg.rs index 673b195..2883ede 100644 --- a/piet-wgsl/examples/winit/src/pico_svg.rs +++ b/vello/examples/winit/src/pico_svg.rs @@ -3,9 +3,10 @@ use std::str::FromStr; use roxmltree::{Document, Node}; - -use piet_scene::kurbo::{Affine, BezPath}; -use piet_scene::Color; +use vello::{ + kurbo::{Affine, BezPath}, + peniko::Color, +}; pub struct PicoSvg { pub items: Vec, diff --git a/piet-wgsl/examples/winit/src/simple_text.rs b/vello/examples/winit/src/simple_text.rs similarity index 94% rename from piet-wgsl/examples/winit/src/simple_text.rs rename to vello/examples/winit/src/simple_text.rs index f35ef56..a7d1827 100644 --- a/piet-wgsl/examples/winit/src/simple_text.rs +++ b/vello/examples/winit/src/simple_text.rs @@ -14,11 +14,16 @@ // // Also licensed under MIT license, at your choice. -use piet_scene::glyph::{pinot, pinot::TableProvider, GlyphContext}; -use piet_scene::kurbo::Affine; -use piet_scene::{Brush, SceneBuilder}; - -pub use pinot::FontRef; +use vello::{ + glyph::{ + pinot, + pinot::{FontRef, TableProvider}, + GlyphContext, + }, + kurbo::Affine, + peniko::Brush, + SceneBuilder, +}; // This is very much a hack to get things working. // On Windows, can set this to "c:\\Windows\\Fonts\\seguiemj.ttf" to get color emoji diff --git a/piet-wgsl/examples/winit/src/test_scene.rs b/vello/examples/winit/src/test_scene.rs similarity index 99% rename from piet-wgsl/examples/winit/src/test_scene.rs rename to vello/examples/winit/src/test_scene.rs index dccb050..2dd81cd 100644 --- a/piet-wgsl/examples/winit/src/test_scene.rs +++ b/vello/examples/winit/src/test_scene.rs @@ -1,7 +1,8 @@ use crate::pico_svg::PicoSvg; use crate::simple_text::SimpleText; -use piet_scene::kurbo::{Affine, BezPath, Ellipse, PathEl, Point, Rect}; -use piet_scene::*; +use vello::kurbo::{Affine, BezPath, Ellipse, PathEl, Point, Rect}; +use vello::peniko::*; +use vello::*; pub fn render_funky_paths(sb: &mut SceneBuilder) { use PathEl::*; diff --git a/piet-wgsl/shader/backdrop.wgsl b/vello/shader/backdrop.wgsl similarity index 100% rename from piet-wgsl/shader/backdrop.wgsl rename to vello/shader/backdrop.wgsl diff --git a/piet-wgsl/shader/backdrop_dyn.wgsl b/vello/shader/backdrop_dyn.wgsl similarity index 100% rename from piet-wgsl/shader/backdrop_dyn.wgsl rename to vello/shader/backdrop_dyn.wgsl diff --git a/piet-wgsl/shader/bbox_clear.wgsl b/vello/shader/bbox_clear.wgsl similarity index 100% rename from piet-wgsl/shader/bbox_clear.wgsl rename to vello/shader/bbox_clear.wgsl diff --git a/piet-wgsl/shader/binning.wgsl b/vello/shader/binning.wgsl similarity index 100% rename from piet-wgsl/shader/binning.wgsl rename to vello/shader/binning.wgsl diff --git a/piet-wgsl/shader/clip_leaf.wgsl b/vello/shader/clip_leaf.wgsl similarity index 100% rename from piet-wgsl/shader/clip_leaf.wgsl rename to vello/shader/clip_leaf.wgsl diff --git a/piet-wgsl/shader/clip_reduce.wgsl b/vello/shader/clip_reduce.wgsl similarity index 100% rename from piet-wgsl/shader/clip_reduce.wgsl rename to vello/shader/clip_reduce.wgsl diff --git a/piet-wgsl/shader/coarse.wgsl b/vello/shader/coarse.wgsl similarity index 100% rename from piet-wgsl/shader/coarse.wgsl rename to vello/shader/coarse.wgsl diff --git a/piet-wgsl/shader/draw_leaf.wgsl b/vello/shader/draw_leaf.wgsl similarity index 100% rename from piet-wgsl/shader/draw_leaf.wgsl rename to vello/shader/draw_leaf.wgsl diff --git a/piet-wgsl/shader/draw_reduce.wgsl b/vello/shader/draw_reduce.wgsl similarity index 100% rename from piet-wgsl/shader/draw_reduce.wgsl rename to vello/shader/draw_reduce.wgsl diff --git a/piet-wgsl/shader/fine.wgsl b/vello/shader/fine.wgsl similarity index 100% rename from piet-wgsl/shader/fine.wgsl rename to vello/shader/fine.wgsl diff --git a/piet-wgsl/shader/path_coarse.wgsl b/vello/shader/path_coarse.wgsl similarity index 100% rename from piet-wgsl/shader/path_coarse.wgsl rename to vello/shader/path_coarse.wgsl diff --git a/piet-wgsl/shader/path_coarse_full.wgsl b/vello/shader/path_coarse_full.wgsl similarity index 100% rename from piet-wgsl/shader/path_coarse_full.wgsl rename to vello/shader/path_coarse_full.wgsl diff --git a/piet-wgsl/shader/pathseg.wgsl b/vello/shader/pathseg.wgsl similarity index 100% rename from piet-wgsl/shader/pathseg.wgsl rename to vello/shader/pathseg.wgsl diff --git a/piet-wgsl/shader/pathtag_reduce.wgsl b/vello/shader/pathtag_reduce.wgsl similarity index 100% rename from piet-wgsl/shader/pathtag_reduce.wgsl rename to vello/shader/pathtag_reduce.wgsl diff --git a/piet-wgsl/shader/pathtag_scan.wgsl b/vello/shader/pathtag_scan.wgsl similarity index 100% rename from piet-wgsl/shader/pathtag_scan.wgsl rename to vello/shader/pathtag_scan.wgsl diff --git a/piet-wgsl/shader/shared/bbox.wgsl b/vello/shader/shared/bbox.wgsl similarity index 100% rename from piet-wgsl/shader/shared/bbox.wgsl rename to vello/shader/shared/bbox.wgsl diff --git a/piet-wgsl/shader/shared/blend.wgsl b/vello/shader/shared/blend.wgsl similarity index 100% rename from piet-wgsl/shader/shared/blend.wgsl rename to vello/shader/shared/blend.wgsl diff --git a/piet-wgsl/shader/shared/bump.wgsl b/vello/shader/shared/bump.wgsl similarity index 100% rename from piet-wgsl/shader/shared/bump.wgsl rename to vello/shader/shared/bump.wgsl diff --git a/piet-wgsl/shader/shared/clip.wgsl b/vello/shader/shared/clip.wgsl similarity index 100% rename from piet-wgsl/shader/shared/clip.wgsl rename to vello/shader/shared/clip.wgsl diff --git a/piet-wgsl/shader/shared/config.wgsl b/vello/shader/shared/config.wgsl similarity index 100% rename from piet-wgsl/shader/shared/config.wgsl rename to vello/shader/shared/config.wgsl diff --git a/piet-wgsl/shader/shared/cubic.wgsl b/vello/shader/shared/cubic.wgsl similarity index 100% rename from piet-wgsl/shader/shared/cubic.wgsl rename to vello/shader/shared/cubic.wgsl diff --git a/piet-wgsl/shader/shared/drawtag.wgsl b/vello/shader/shared/drawtag.wgsl similarity index 100% rename from piet-wgsl/shader/shared/drawtag.wgsl rename to vello/shader/shared/drawtag.wgsl diff --git a/piet-wgsl/shader/shared/pathtag.wgsl b/vello/shader/shared/pathtag.wgsl similarity index 100% rename from piet-wgsl/shader/shared/pathtag.wgsl rename to vello/shader/shared/pathtag.wgsl diff --git a/piet-wgsl/shader/shared/ptcl.wgsl b/vello/shader/shared/ptcl.wgsl similarity index 100% rename from piet-wgsl/shader/shared/ptcl.wgsl rename to vello/shader/shared/ptcl.wgsl diff --git a/piet-wgsl/shader/shared/segment.wgsl b/vello/shader/shared/segment.wgsl similarity index 100% rename from piet-wgsl/shader/shared/segment.wgsl rename to vello/shader/shared/segment.wgsl diff --git a/piet-wgsl/shader/shared/tile.wgsl b/vello/shader/shared/tile.wgsl similarity index 100% rename from piet-wgsl/shader/shared/tile.wgsl rename to vello/shader/shared/tile.wgsl diff --git a/piet-wgsl/shader/tile_alloc.wgsl b/vello/shader/tile_alloc.wgsl similarity index 100% rename from piet-wgsl/shader/tile_alloc.wgsl rename to vello/shader/tile_alloc.wgsl diff --git a/piet-wgsl/src/engine.rs b/vello/src/engine.rs similarity index 100% rename from piet-wgsl/src/engine.rs rename to vello/src/engine.rs diff --git a/piet-scene/src/glyph.rs b/vello/src/glyph.rs similarity index 100% rename from piet-scene/src/glyph.rs rename to vello/src/glyph.rs diff --git a/piet-wgsl/src/lib.rs b/vello/src/lib.rs similarity index 96% rename from piet-wgsl/src/lib.rs rename to vello/src/lib.rs index dde1ad2..d468bd7 100644 --- a/piet-wgsl/src/lib.rs +++ b/vello/src/lib.rs @@ -17,15 +17,23 @@ mod engine; mod ramp; mod render; +mod scene; mod shaders; +/// Styling and composition primitives. +pub use peniko; +/// 2D geometry, with a focus on curves. +pub use peniko::kurbo; + +pub mod glyph; pub mod util; +pub use scene::{ResourceBundle, ResourcePatch, Scene, SceneBuilder, SceneData, SceneFragment}; + use engine::{Engine, ExternalResource}; use shaders::FullShaders; -use piet_scene::Scene; -use wgpu::{Device, Queue, SurfaceTexture, Texture, TextureFormat, TextureView}; +use wgpu::{Device, Queue, SurfaceTexture, TextureFormat, TextureView}; /// Catch-all error type. pub type Error = Box; diff --git a/piet-wgsl/src/ramp.rs b/vello/src/ramp.rs similarity index 98% rename from piet-wgsl/src/ramp.rs rename to vello/src/ramp.rs index a97c9c7..0d83881 100644 --- a/piet-wgsl/src/ramp.rs +++ b/vello/src/ramp.rs @@ -1,4 +1,4 @@ -use piet_scene::{Color, ColorStop, ColorStops}; +use peniko::{Color, ColorStop, ColorStops}; use std::collections::HashMap; diff --git a/piet-wgsl/src/render.rs b/vello/src/render.rs similarity index 99% rename from piet-wgsl/src/render.rs rename to vello/src/render.rs index 8c4fa96..97fd53c 100644 --- a/piet-wgsl/src/render.rs +++ b/vello/src/render.rs @@ -1,11 +1,11 @@ //! Take an encoded scene and create a graph to render it use bytemuck::{Pod, Zeroable}; -use piet_scene::Scene; use crate::{ engine::{BufProxy, ImageFormat, ImageProxy, Recording, ResourceProxy}, shaders::{self, FullShaders, Shaders}, + ResourcePatch, Scene, }; const TAG_MONOID_SIZE: u64 = 12; @@ -150,7 +150,6 @@ pub fn render_full( let data = scene.data(); let stop_data = &data.resources.stops; for patch in &data.resources.patches { - use piet_scene::ResourcePatch; match patch { ResourcePatch::Ramp { offset, stops } => { let ramp_id = ramps.add(&stop_data[stops.clone()]); diff --git a/piet-scene/src/scene/builder.rs b/vello/src/scene.rs similarity index 73% rename from piet-scene/src/scene/builder.rs rename to vello/src/scene.rs index fd1e3f7..06201f6 100644 --- a/piet-scene/src/scene/builder.rs +++ b/vello/src/scene.rs @@ -14,12 +14,163 @@ // // Also licensed under MIT license, at your choice. -use super::{conv, Scene, SceneData, SceneFragment}; -use crate::ResourcePatch; -use bytemuck::{Pod, Zeroable}; -use peniko::kurbo::{Affine, PathEl, Rect, Shape}; +use peniko::kurbo::{Affine, PathEl, Point, Rect, Shape}; use peniko::{BlendMode, BrushRef, ColorStop, Fill, Stroke}; -use smallvec::SmallVec; + +use bytemuck::{Pod, Zeroable}; +use std::ops::Range; + +/// Raw data streams describing an encoded scene. +#[derive(Default)] +pub struct SceneData { + pub transform_stream: Vec<[f32; 6]>, + pub tag_stream: Vec, + pub pathseg_stream: Vec, + pub linewidth_stream: Vec, + pub drawtag_stream: Vec, + pub drawdata_stream: Vec, + pub n_path: u32, + pub n_pathseg: u32, + pub n_clip: u32, + pub resources: ResourceBundle, +} + +impl SceneData { + fn is_empty(&self) -> bool { + self.pathseg_stream.is_empty() + } + + fn reset(&mut self, is_fragment: bool) { + self.transform_stream.clear(); + self.tag_stream.clear(); + self.pathseg_stream.clear(); + self.linewidth_stream.clear(); + self.drawtag_stream.clear(); + self.drawdata_stream.clear(); + self.n_path = 0; + self.n_pathseg = 0; + self.n_clip = 0; + self.resources.clear(); + if !is_fragment { + self.transform_stream.push([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]); + self.linewidth_stream.push(-1.0); + } + } + + fn append(&mut self, other: &SceneData, transform: &Option) { + let stops_base = self.resources.stops.len(); + let drawdata_base = self.drawdata_stream.len(); + if let Some(transform) = *transform { + self.transform_stream.extend( + other + .transform_stream + .iter() + .map(|x| affine_to_f32(&(transform * affine_from_f32(x)))), + ); + } else { + self.transform_stream + .extend_from_slice(&other.transform_stream); + } + self.tag_stream.extend_from_slice(&other.tag_stream); + self.pathseg_stream.extend_from_slice(&other.pathseg_stream); + self.linewidth_stream + .extend_from_slice(&other.linewidth_stream); + self.drawtag_stream.extend_from_slice(&other.drawtag_stream); + self.drawdata_stream + .extend_from_slice(&other.drawdata_stream); + self.n_path += other.n_path; + self.n_pathseg += other.n_pathseg; + self.n_clip += other.n_clip; + self.resources + .stops + .extend_from_slice(&other.resources.stops); + self.resources + .patches + .extend(other.resources.patches.iter().map(|patch| match patch { + ResourcePatch::Ramp { offset, stops } => { + let stops = stops.start + stops_base..stops.end + stops_base; + ResourcePatch::Ramp { + offset: drawdata_base + offset, + stops, + } + } + })); + } +} + +/// Encoded definition of a scene and associated resources. +#[derive(Default)] +pub struct Scene { + data: SceneData, +} + +impl Scene { + /// Creates a new scene. + pub fn new() -> Self { + Self::default() + } + + /// Returns the raw encoded scene data streams. + pub fn data(&self) -> &SceneData { + &self.data + } +} + +/// Encoded definition of a scene fragment and associated resources. +#[derive(Default)] +pub struct SceneFragment { + data: SceneData, +} + +impl SceneFragment { + /// Creates a new scene fragment. + pub fn new() -> Self { + Self::default() + } + + /// Returns true if the fragment does not contain any paths. + pub fn is_empty(&self) -> bool { + self.data.is_empty() + } + + /// Returns the the entire sequence of points in the scene fragment. + pub fn points(&self) -> &[[f32; 2]] { + if self.is_empty() { + &[] + } else { + bytemuck::cast_slice(&self.data.pathseg_stream) + } + } +} + +#[derive(Default)] +/// Collection of late bound resources for a scene or scene fragment. +pub struct ResourceBundle { + /// Sequence of resource patches. + pub patches: Vec, + /// Cache of color stops, referenced by range from the patches. + pub stops: Vec, +} + +impl ResourceBundle { + /// Clears the resource set. + pub(crate) fn clear(&mut self) { + self.patches.clear(); + self.stops.clear(); + } +} + +#[derive(Clone)] +/// Description of a late bound resource. +pub enum ResourcePatch { + /// Gradient ramp resource. + Ramp { + /// Byte offset to the ramp id in the draw data stream. + offset: usize, + /// Range of the gradient stops in the resource set. + stops: Range, + }, +} /// Builder for constructing a scene or scene fragment. pub struct SceneBuilder<'a> { @@ -175,16 +326,14 @@ impl<'a> SceneBuilder<'a> { } fn maybe_encode_transform(&mut self, transform: Affine) { - if self.scene.transform_stream.last() != Some(&conv::affine_to_f32(&transform)) { + if self.scene.transform_stream.last() != Some(&affine_to_f32(&transform)) { self.encode_transform(transform); } } fn encode_transform(&mut self, transform: Affine) { self.scene.tag_stream.push(0x20); - self.scene - .transform_stream - .push(conv::affine_to_f32(&transform)); + self.scene.transform_stream.push(affine_to_f32(&transform)); } // Swap the last two tags in the tag stream; used for transformed @@ -218,8 +367,8 @@ impl<'a> SceneBuilder<'a> { .drawdata_stream .extend(bytemuck::bytes_of(&FillLinGradient { index, - p0: conv::point_to_f32(gradient.start), - p1: conv::point_to_f32(gradient.end), + p0: point_to_f32(gradient.start), + p1: point_to_f32(gradient.end), })); } BrushRef::RadialGradient(gradient) => { @@ -229,8 +378,8 @@ impl<'a> SceneBuilder<'a> { .drawdata_stream .extend(bytemuck::bytes_of(&FillRadGradient { index, - p0: conv::point_to_f32(gradient.start_center), - p1: conv::point_to_f32(gradient.end_center), + p0: point_to_f32(gradient.start_center), + p1: point_to_f32(gradient.end_center), r0: gradient.start_radius, r1: gradient.end_radius, })); @@ -469,3 +618,15 @@ impl<'a> PathBuilder<'a> { } } } + +fn affine_to_f32(affine: &Affine) -> [f32; 6] { + affine.as_coeffs().map(|value| value as f32) +} + +fn affine_from_f32(coeffs: &[f32; 6]) -> Affine { + Affine::new(coeffs.map(|value| value as f64)) +} + +fn point_to_f32(point: Point) -> [f32; 2] { + [point.x as f32, point.y as f32] +} diff --git a/piet-wgsl/src/shaders.rs b/vello/src/shaders.rs similarity index 100% rename from piet-wgsl/src/shaders.rs rename to vello/src/shaders.rs diff --git a/piet-wgsl/src/shaders/preprocess.rs b/vello/src/shaders/preprocess.rs similarity index 100% rename from piet-wgsl/src/shaders/preprocess.rs rename to vello/src/shaders/preprocess.rs diff --git a/piet-wgsl/src/util.rs b/vello/src/util.rs similarity index 100% rename from piet-wgsl/src/util.rs rename to vello/src/util.rs