Upgrade to Blitz v0.2.0 (#4731)
* Bump Rust CI version to 1.88 Signed-off-by: Nico Burns <nico@nicoburns.com> * Upgrade to Blitz v0.2.0 Signed-off-by: Nico Burns <nico@nicoburns.com> * Native: enable clipboard and file_dialog support by default * Fix clippy errors Signed-off-by: Nico Burns <nico@nicoburns.com> * See if cargo update magically fixes build Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix compile err Signed-off-by: Nico Burns <nico@nicoburns.com> * Remove unused wasm-opt dep * Fix wgpu_child_window example Signed-off-by: Nico Burns <nico@nicoburns.com> * Update blitz-shell Signed-off-by: Nico Burns <nico@nicoburns.com> * cargo fmt Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow clippy lint Signed-off-by: Nico Burns <nico@nicoburns.com> * CI: Bump pinned nightly version Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow clippy lint in whole module Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix more clippy lints Signed-off-by: Nico Burns <nico@nicoburns.com> * Use Rust 1.90 for clippy Signed-off-by: Nico Burns <nico@nicoburns.com> * cargo update --ignore-rust-version * revert cargo updates Signed-off-by: Nico Burns <nico@nicoburns.com> * Revert another silly clippy lint --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
1 parent
0b1f2fc8c2
commit
9359446017
26 files changed
+1029
-807
No files matched your search
+14
-14
@@ -39,7 +39,7 @@ env:
|
|||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
CARGO_INCREMENTAL: 0 # todo(jon): cargo-cache wipes incremental artifacts, but we eventually want to cache them
|
CARGO_INCREMENTAL: 0 # todo(jon): cargo-cache wipes incremental artifacts, but we eventually want to cache them
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
rust_nightly: nightly-2025-04-07
|
rust_nightly: nightly-2025-10-05
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-msrv:
|
check-msrv:
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: dtolnay/rust-toolchain@1.86.0
|
- uses: dtolnay/rust-toolchain@1.88.0
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
cache-all-crates: "true"
|
cache-all-crates: "true"
|
||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||||
version: 1.0
|
version: 1.0
|
||||||
- uses: dtolnay/rust-toolchain@1.86.0
|
- uses: dtolnay/rust-toolchain@1.88.0
|
||||||
with:
|
with:
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
@@ -96,7 +96,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||||
version: 1.0
|
version: 1.0
|
||||||
- uses: dtolnay/rust-toolchain@1.86.0
|
- uses: dtolnay/rust-toolchain@1.88.0
|
||||||
with:
|
with:
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
@@ -111,7 +111,7 @@ jobs:
|
|||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: dtolnay/rust-toolchain@1.86.0
|
- uses: dtolnay/rust-toolchain@1.88.0
|
||||||
with:
|
with:
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
@@ -173,7 +173,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||||
version: 1.0
|
version: 1.0
|
||||||
- uses: dtolnay/rust-toolchain@1.86.0
|
- uses: dtolnay/rust-toolchain@1.88.0
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
cache-all-crates: "true"
|
cache-all-crates: "true"
|
||||||
@@ -189,7 +189,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev
|
||||||
version: 1.0
|
version: 1.0
|
||||||
- uses: dtolnay/rust-toolchain@1.86.0
|
- uses: dtolnay/rust-toolchain@1.90.0
|
||||||
with:
|
with:
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
@@ -281,7 +281,7 @@ jobs:
|
|||||||
- {
|
- {
|
||||||
target: aarch64-apple-darwin,
|
target: aarch64-apple-darwin,
|
||||||
os: macos-latest,
|
os: macos-latest,
|
||||||
toolchain: "1.86.0",
|
toolchain: "1.88.0",
|
||||||
cross: false,
|
cross: false,
|
||||||
command: "test",
|
command: "test",
|
||||||
args: "--all --tests",
|
args: "--all --tests",
|
||||||
@@ -290,7 +290,7 @@ jobs:
|
|||||||
- {
|
- {
|
||||||
target: x86_64-apple-darwin,
|
target: x86_64-apple-darwin,
|
||||||
os: macos-13,
|
os: macos-13,
|
||||||
toolchain: "1.86.0",
|
toolchain: "1.88.0",
|
||||||
cross: false,
|
cross: false,
|
||||||
command: "test",
|
command: "test",
|
||||||
args: "--all --tests",
|
args: "--all --tests",
|
||||||
@@ -299,7 +299,7 @@ jobs:
|
|||||||
- {
|
- {
|
||||||
target: aarch64-apple-ios,
|
target: aarch64-apple-ios,
|
||||||
os: macos-latest,
|
os: macos-latest,
|
||||||
toolchain: "1.86.0",
|
toolchain: "1.88.0",
|
||||||
cross: false,
|
cross: false,
|
||||||
command: "build",
|
command: "build",
|
||||||
args: "--package dioxus-desktop",
|
args: "--package dioxus-desktop",
|
||||||
@@ -308,7 +308,7 @@ jobs:
|
|||||||
- {
|
- {
|
||||||
target: aarch64-unknown-linux-gnu,
|
target: aarch64-unknown-linux-gnu,
|
||||||
os: blacksmith-4vcpu-ubuntu-2404-arm,
|
os: blacksmith-4vcpu-ubuntu-2404-arm,
|
||||||
toolchain: "1.86.0",
|
toolchain: "1.88.0",
|
||||||
cross: false,
|
cross: false,
|
||||||
command: "build",
|
command: "build",
|
||||||
args: "--all --tests",
|
args: "--all --tests",
|
||||||
@@ -317,7 +317,7 @@ jobs:
|
|||||||
- {
|
- {
|
||||||
target: aarch64-linux-android,
|
target: aarch64-linux-android,
|
||||||
os: blacksmith-4vcpu-ubuntu-2404,
|
os: blacksmith-4vcpu-ubuntu-2404,
|
||||||
toolchain: "1.86.0",
|
toolchain: "1.88.0",
|
||||||
cross: true,
|
cross: true,
|
||||||
command: "build",
|
command: "build",
|
||||||
args: "--package dioxus-desktop",
|
args: "--package dioxus-desktop",
|
||||||
@@ -327,7 +327,7 @@ jobs:
|
|||||||
# - {
|
# - {
|
||||||
# target: x86_64-unknown-linux-gnu,
|
# target: x86_64-unknown-linux-gnu,
|
||||||
# os: ubuntu-24.04,
|
# os: ubuntu-24.04,
|
||||||
# toolchain: "1.86.0",
|
# toolchain: "1.88.0",
|
||||||
# cross: false,
|
# cross: false,
|
||||||
# command: "build",
|
# command: "build",
|
||||||
# args: "--all --tests",
|
# args: "--all --tests",
|
||||||
@@ -379,7 +379,7 @@ jobs:
|
|||||||
name: "cargo test | windows"
|
name: "cargo test | windows"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: dtolnay/rust-toolchain@1.86.0
|
- uses: dtolnay/rust-toolchain@1.88.0
|
||||||
with:
|
with:
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ jobs:
|
|||||||
- name: Install stable
|
- name: Install stable
|
||||||
uses: dtolnay/rust-toolchain@master
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: "1.86.0"
|
toolchain: "1.88.0"
|
||||||
targets: ${{ matrix.platform.target }}
|
targets: ${{ matrix.platform.target }}
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|||||||
Generated
+857
-679
File diff suppressed because it is too large.
Load diff
+43
-24
@@ -137,7 +137,7 @@ members = [
|
|||||||
"packages/playwright-tests/nested-suspense",
|
"packages/playwright-tests/nested-suspense",
|
||||||
"packages/playwright-tests/cli-optimization",
|
"packages/playwright-tests/cli-optimization",
|
||||||
"packages/playwright-tests/wasm-split-harness",
|
"packages/playwright-tests/wasm-split-harness",
|
||||||
"packages/playwright-tests/default-features-disabled"
|
"packages/playwright-tests/default-features-disabled",
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
@@ -172,8 +172,8 @@ dioxus-stores = { path = "packages/stores", version = "0.7.0-rc.0" }
|
|||||||
dioxus-stores-macro = { path = "packages/stores-macro", version = "0.7.0-rc.0" }
|
dioxus-stores-macro = { path = "packages/stores-macro", version = "0.7.0-rc.0" }
|
||||||
dioxus-devtools = { path = "packages/devtools", version = "0.7.0-rc.0" }
|
dioxus-devtools = { path = "packages/devtools", version = "0.7.0-rc.0" }
|
||||||
dioxus-devtools-types = { path = "packages/devtools-types", version = "0.7.0-rc.0" }
|
dioxus-devtools-types = { path = "packages/devtools-types", version = "0.7.0-rc.0" }
|
||||||
dioxus-fullstack = { path = "packages/fullstack", version = "0.7.0-rc.0", default-features = false}
|
dioxus-fullstack = { path = "packages/fullstack", version = "0.7.0-rc.0", default-features = false }
|
||||||
dioxus-fullstack-core = { path = "packages/fullstack-core", version = "0.7.0-rc.0", default-features = false}
|
dioxus-fullstack-core = { path = "packages/fullstack-core", version = "0.7.0-rc.0", default-features = false }
|
||||||
dioxus-fullstack-macro = { path = "packages/fullstack-macro", version = "0.7.0-rc.0", default-features = false }
|
dioxus-fullstack-macro = { path = "packages/fullstack-macro", version = "0.7.0-rc.0", default-features = false }
|
||||||
dioxus-server = { path = "packages/fullstack-server", version = "0.7.0-rc.0" }
|
dioxus-server = { path = "packages/fullstack-server", version = "0.7.0-rc.0" }
|
||||||
dioxus-dx-wire-format = { path = "packages/dx-wire-format", version = "0.7.0-rc.0" }
|
dioxus-dx-wire-format = { path = "packages/dx-wire-format", version = "0.7.0-rc.0" }
|
||||||
@@ -214,15 +214,19 @@ depinfo = { path = "packages/depinfo", version = "0.7.0-rc.0" }
|
|||||||
warnings = { version = "0.2.1" }
|
warnings = { version = "0.2.1" }
|
||||||
|
|
||||||
# blitz
|
# blitz
|
||||||
blitz-dom = { version = "0.1", default-features = false }
|
blitz-dom = { version = "0.2", default-features = false }
|
||||||
blitz-net = { version = "0.1" }
|
blitz-net = { version = "0.2" }
|
||||||
blitz-html = { version = "0.1" }
|
blitz-html = { version = "0.2" }
|
||||||
blitz-paint = { version = "0.1" }
|
blitz-paint = { version = "0.2" }
|
||||||
blitz-traits = { version = "0.1" }
|
blitz-traits = { version = "0.2" }
|
||||||
blitz-shell = { version = "0.1", default-features = false }
|
blitz-shell = { version = "0.2", default-features = false }
|
||||||
anyrender = { version = "0.5", default-features = false }
|
anyrender = { version = "0.6", default-features = false }
|
||||||
anyrender_vello = { version = "0.5", default-features = false }
|
anyrender_vello = { version = "0.6", default-features = false }
|
||||||
wgpu = { version = "24.0" }
|
wgpu_context = { version = "0.1", default-features = false }
|
||||||
|
wgpu = { version = "26.0" }
|
||||||
|
vello = "0.6"
|
||||||
|
bevy = "0.17"
|
||||||
|
|
||||||
|
|
||||||
# a fork of pretty please for tests - let's get off of this if we can!
|
# a fork of pretty please for tests - let's get off of this if we can!
|
||||||
prettier-please = { version = "0.3.0", features = ["verbatim"] }
|
prettier-please = { version = "0.3.0", features = ["verbatim"] }
|
||||||
@@ -257,21 +261,26 @@ lru = "0.16.0"
|
|||||||
async-trait = "0.1.88"
|
async-trait = "0.1.88"
|
||||||
axum = { version = "0.8.4", default-features = false }
|
axum = { version = "0.8.4", default-features = false }
|
||||||
axum-server = { version = "0.7.2", default-features = false }
|
axum-server = { version = "0.7.2", default-features = false }
|
||||||
http-body = { version = "1.0"}
|
http-body = { version = "1.0" }
|
||||||
tower = "0.5.2"
|
tower = "0.5.2"
|
||||||
http = "1.3.1"
|
http = "1.3.1"
|
||||||
notify = { version = "8.1.0" }
|
notify = { version = "8.1.0" }
|
||||||
tower-http = "0.6.6"
|
tower-http = "0.6.6"
|
||||||
hyper = "1.6.0"
|
hyper = "1.6.0"
|
||||||
hyper-rustls = { version = "0.27.7", default-features = false, features = [
|
hyper-rustls = { version = "0.27.7", default-features = false, features = [
|
||||||
"native-tokio",
|
"native-tokio",
|
||||||
"http1",
|
"http1",
|
||||||
"http2",
|
"http2",
|
||||||
"tls12",
|
"tls12",
|
||||||
"logging",
|
"logging",
|
||||||
"ring",
|
"ring",
|
||||||
|
] }
|
||||||
|
rustls = { version = "0.23.28", default-features = false, features = [
|
||||||
|
"logging",
|
||||||
|
"std",
|
||||||
|
"tls12",
|
||||||
|
"ring",
|
||||||
] }
|
] }
|
||||||
rustls = { version = "0.23.28", default-features = false, features = ["logging", "std", "tls12", "ring"] }
|
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
serde = "1.0.219"
|
serde = "1.0.219"
|
||||||
syn = "2.0"
|
syn = "2.0"
|
||||||
@@ -310,7 +319,11 @@ digest = "0.10.7"
|
|||||||
sha2 = "0.10.9"
|
sha2 = "0.10.9"
|
||||||
walrus = { version = "0.23.3", features = ["parallel"] }
|
walrus = { version = "0.23.3", features = ["parallel"] }
|
||||||
id-arena = "2.2.1"
|
id-arena = "2.2.1"
|
||||||
async-compression = { version = "0.4", features = ["futures-io", "gzip", "brotli"] }
|
async-compression = { version = "0.4", features = [
|
||||||
|
"futures-io",
|
||||||
|
"gzip",
|
||||||
|
"brotli",
|
||||||
|
] }
|
||||||
getrandom = { version = "0.3.3" }
|
getrandom = { version = "0.3.3" }
|
||||||
async-once-cell = { version = "0.5.4" }
|
async-once-cell = { version = "0.5.4" }
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
@@ -330,7 +343,7 @@ libloading = "0.8.8"
|
|||||||
libc = "0.2.174"
|
libc = "0.2.174"
|
||||||
memmap2 = "0.9.5"
|
memmap2 = "0.9.5"
|
||||||
memfd = "0.6.4"
|
memfd = "0.6.4"
|
||||||
xxhash-rust = {version = "0.8.15", default-features = false}
|
xxhash-rust = { version = "0.8.15", default-features = false }
|
||||||
serde_qs = "0.15.0"
|
serde_qs = "0.15.0"
|
||||||
multer = "3.1.0"
|
multer = "3.1.0"
|
||||||
const-str = "0.7.0"
|
const-str = "0.7.0"
|
||||||
@@ -469,7 +482,13 @@ uuid = { workspace = true, features = ["v4", "serde"] }
|
|||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
||||||
getrandom = { workspace = true, features = ["wasm_js"] }
|
getrandom = { workspace = true, features = ["wasm_js"] }
|
||||||
tokio = { version = "1.46", default-features = false, features = ["sync", "macros", "io-util", "rt", "time"] }
|
tokio = { version = "1.46", default-features = false, features = [
|
||||||
|
"sync",
|
||||||
|
"macros",
|
||||||
|
"io-util",
|
||||||
|
"rt",
|
||||||
|
"time",
|
||||||
|
] }
|
||||||
uuid = { workspace = true, features = ["v4", "serde", "js"] }
|
uuid = { workspace = true, features = ["v4", "serde", "js"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||||
@@ -929,4 +948,4 @@ doc-scrape-examples = true
|
|||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "__scrape_example_list"
|
name = "__scrape_example_list"
|
||||||
path = "examples/scripts/scrape_examples.rs"
|
path = "examples/scripts/scrape_examples.rs"
|
||||||
@@ -118,17 +118,15 @@ impl<'a> GraphicsResources<'a> {
|
|||||||
|
|
||||||
// Create the logical device and command queue
|
// Create the logical device and command queue
|
||||||
let (device, queue) = adapter
|
let (device, queue) = adapter
|
||||||
.request_device(
|
.request_device(&wgpu::DeviceDescriptor {
|
||||||
&wgpu::DeviceDescriptor {
|
label: None,
|
||||||
label: None,
|
required_features: wgpu::Features::empty(),
|
||||||
required_features: wgpu::Features::empty(),
|
// Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
|
||||||
// Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
|
required_limits: wgpu::Limits::downlevel_webgl2_defaults()
|
||||||
required_limits: wgpu::Limits::downlevel_webgl2_defaults()
|
.using_resolution(adapter.limits()),
|
||||||
.using_resolution(adapter.limits()),
|
memory_hints: wgpu::MemoryHints::default(),
|
||||||
memory_hints: wgpu::MemoryHints::default(),
|
..Default::default()
|
||||||
},
|
})
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create device");
|
.expect("Failed to create device");
|
||||||
|
|
||||||
@@ -235,6 +233,7 @@ fn fs_main() -> @location(0) vec4<f32> {
|
|||||||
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
||||||
store: wgpu::StoreOp::Store,
|
store: wgpu::StoreOp::Store,
|
||||||
},
|
},
|
||||||
|
depth_slice: None,
|
||||||
})],
|
})],
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
timestamp_writes: None,
|
timestamp_writes: None,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ native = ["dioxus/native"]
|
|||||||
tracing = ["dep:tracing-subscriber", "dioxus-native/tracing"]
|
tracing = ["dep:tracing-subscriber", "dioxus-native/tracing"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.16" }
|
bevy = { workspace = true }
|
||||||
dioxus-native = { workspace = true }
|
dioxus-native = { workspace = true }
|
||||||
dioxus = { workspace = true }
|
dioxus = { workspace = true }
|
||||||
wgpu = { workspace = true }
|
wgpu = { workspace = true }
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
use crate::bevy_scene_plugin::BevyScenePlugin;
|
use crate::bevy_scene_plugin::BevyScenePlugin;
|
||||||
use bevy::{
|
use bevy::{
|
||||||
|
camera::{ManualTextureViewHandle, RenderTarget},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::{
|
||||||
camera::{ManualTextureView, ManualTextureViewHandle, ManualTextureViews, RenderTarget},
|
|
||||||
render_resource::TextureFormat,
|
render_resource::TextureFormat,
|
||||||
renderer::{
|
renderer::{
|
||||||
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue,
|
RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue,
|
||||||
WgpuWrapper,
|
WgpuWrapper,
|
||||||
},
|
},
|
||||||
settings::{RenderCreation, RenderResources},
|
settings::{RenderCreation, RenderResources},
|
||||||
|
texture::ManualTextureView,
|
||||||
RenderPlugin,
|
RenderPlugin,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use dioxus_native::{CustomPaintCtx, DeviceHandle, TextureHandle};
|
use dioxus_native::{CustomPaintCtx, DeviceHandle, TextureHandle};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu::Instance;
|
|
||||||
|
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
pub struct UIData {
|
pub struct UIData {
|
||||||
@@ -30,7 +30,7 @@ pub struct BevyRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BevyRenderer {
|
impl BevyRenderer {
|
||||||
pub fn new(instance: &Instance, device_handle: &DeviceHandle) -> Self {
|
pub fn new(device_handle: &DeviceHandle) -> Self {
|
||||||
// Create a headless Bevy App.
|
// Create a headless Bevy App.
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins(
|
app.add_plugins(
|
||||||
@@ -42,7 +42,7 @@ impl BevyRenderer {
|
|||||||
RenderQueue(Arc::new(WgpuWrapper::new(device_handle.queue.clone()))),
|
RenderQueue(Arc::new(WgpuWrapper::new(device_handle.queue.clone()))),
|
||||||
RenderAdapterInfo(WgpuWrapper::new(device_handle.adapter.get_info())),
|
RenderAdapterInfo(WgpuWrapper::new(device_handle.adapter.get_info())),
|
||||||
RenderAdapter(Arc::new(WgpuWrapper::new(device_handle.adapter.clone()))),
|
RenderAdapter(Arc::new(WgpuWrapper::new(device_handle.adapter.clone()))),
|
||||||
RenderInstance(Arc::new(WgpuWrapper::new(instance.clone()))),
|
RenderInstance(Arc::new(WgpuWrapper::new(device_handle.instance.clone()))),
|
||||||
)),
|
)),
|
||||||
synchronous_pipeline_compilation: true,
|
synchronous_pipeline_compilation: true,
|
||||||
..default()
|
..default()
|
||||||
@@ -51,6 +51,7 @@ impl BevyRenderer {
|
|||||||
primary_window: None,
|
primary_window: None,
|
||||||
exit_condition: bevy::window::ExitCondition::DontExit,
|
exit_condition: bevy::window::ExitCondition::DontExit,
|
||||||
close_when_requested: false,
|
close_when_requested: false,
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
.disable::<bevy::winit::WinitPlugin>(),
|
.disable::<bevy::winit::WinitPlugin>(),
|
||||||
);
|
);
|
||||||
@@ -95,7 +96,7 @@ impl BevyRenderer {
|
|||||||
// Run one frame of the Bevy app to render the 3D scene.
|
// Run one frame of the Bevy app to render the 3D scene.
|
||||||
self.app.update();
|
self.app.update();
|
||||||
|
|
||||||
self.texture_handle
|
self.texture_handle.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_texture(&mut self, mut ctx: CustomPaintCtx<'_>, width: u32, height: u32) {
|
fn init_texture(&mut self, mut ctx: CustomPaintCtx<'_>, width: u32, height: u32) {
|
||||||
@@ -114,9 +115,8 @@ impl BevyRenderer {
|
|||||||
|
|
||||||
if let Some(mut manual_texture_views) = world.get_resource_mut::<ManualTextureViews>() {
|
if let Some(mut manual_texture_views) = world.get_resource_mut::<ManualTextureViews>() {
|
||||||
// Clean previous texture if any.
|
// Clean previous texture if any.
|
||||||
if let Some(texture_handle) = self.texture_handle {
|
if self.texture_handle.is_some() {
|
||||||
ctx.unregister_texture(texture_handle);
|
ctx.unregister_texture(self.texture_handle.take().unwrap());
|
||||||
self.texture_handle = None;
|
|
||||||
}
|
}
|
||||||
if let Some(old_handle) = self.manual_texture_view_handle {
|
if let Some(old_handle) = self.manual_texture_view_handle {
|
||||||
manual_texture_views.remove(&old_handle);
|
manual_texture_views.remove(&old_handle);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use crate::bevy_renderer::BevyRenderer;
|
|||||||
use crate::Color;
|
use crate::Color;
|
||||||
use dioxus_native::{CustomPaintCtx, CustomPaintSource, DeviceHandle, TextureHandle};
|
use dioxus_native::{CustomPaintCtx, CustomPaintSource, DeviceHandle, TextureHandle};
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use wgpu::Instance;
|
|
||||||
|
|
||||||
pub enum DemoMessage {
|
pub enum DemoMessage {
|
||||||
// Color in RGB format
|
// Color in RGB format
|
||||||
@@ -71,8 +70,8 @@ impl DemoPaintSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CustomPaintSource for DemoPaintSource {
|
impl CustomPaintSource for DemoPaintSource {
|
||||||
fn resume(&mut self, instance: &Instance, device_handle: &DeviceHandle) {
|
fn resume(&mut self, device_handle: &DeviceHandle) {
|
||||||
let active_state = BevyRenderer::new(instance, device_handle);
|
let active_state = BevyRenderer::new(device_handle);
|
||||||
self.state = DemoRendererState::Active(Box::new(active_state));
|
self.state = DemoRendererState::Active(Box::new(active_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ blitz-traits = { workspace = true, default-features = true }
|
|||||||
anyrender_vello = { workspace = true }
|
anyrender_vello = { workspace = true }
|
||||||
wgpu = { workspace = true }
|
wgpu = { workspace = true }
|
||||||
tracing-subscriber = { workspace = true, optional = true }
|
tracing-subscriber = { workspace = true, optional = true }
|
||||||
bevy = { version = "0.16" }
|
bevy = { workspace = true }
|
||||||
|
vello = { workspace = true }
|
||||||
async-std = "1.13"
|
async-std = "1.13"
|
||||||
crossbeam-channel = "0.5"
|
crossbeam-channel = "0.5"
|
||||||
paste = "1.0"
|
paste = "1.0"
|
||||||
rustc-hash = "1"
|
rustc-hash = "1"
|
||||||
vello = "0.5"
|
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ fn animate(
|
|||||||
|
|
||||||
fn orbit_camera_system(
|
fn orbit_camera_system(
|
||||||
mut camera_query: Query<(&mut Transform, &mut OrbitCamera), With<Camera3d>>,
|
mut camera_query: Query<(&mut Transform, &mut OrbitCamera), With<Camera3d>>,
|
||||||
mut mouse_motion_events: EventReader<MouseMotion>,
|
mut mouse_motion_events: MessageReader<MouseMotion>,
|
||||||
mouse_button_input: Res<ButtonInput<MouseButton>>,
|
mouse_button_input: Res<ButtonInput<MouseButton>>,
|
||||||
) {
|
) {
|
||||||
for (mut transform, mut orbit_camera) in camera_query.iter_mut() {
|
for (mut transform, mut orbit_camera) in camera_query.iter_mut() {
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use bevy::asset::RenderAssetUsages;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::{
|
use bevy::{
|
||||||
input::{
|
input::{
|
||||||
keyboard::{Key as BevyKey, KeyCode as BevyKeyCode, KeyboardInput},
|
keyboard::{Key as BevyKey, KeyCode as BevyKeyCode, KeyboardInput},
|
||||||
mouse::{MouseButton, MouseButtonInput},
|
mouse::{MouseButton, MouseButtonInput},
|
||||||
ButtonInput, ButtonState, InputSystem,
|
ButtonInput, ButtonState, InputSystems,
|
||||||
},
|
},
|
||||||
render::{
|
render::{
|
||||||
render_asset::{RenderAssetUsages, RenderAssets},
|
render_asset::RenderAssets,
|
||||||
render_graph::{self, NodeRunError, RenderGraph, RenderGraphContext, RenderLabel},
|
render_graph::{self, NodeRunError, RenderGraph, RenderGraphContext, RenderLabel},
|
||||||
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
||||||
renderer::{RenderContext, RenderDevice, RenderQueue},
|
renderer::{RenderContext, RenderDevice, RenderQueue},
|
||||||
@@ -16,7 +19,7 @@ use bevy::{
|
|||||||
window::{CursorMoved, WindowResized},
|
window::{CursorMoved, WindowResized},
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyrender_vello::{CustomPaintSource, VelloScenePainter};
|
use anyrender_vello::VelloScenePainter;
|
||||||
use blitz_dom::{Document as _, DocumentConfig};
|
use blitz_dom::{Document as _, DocumentConfig};
|
||||||
use blitz_paint::paint_scene;
|
use blitz_paint::paint_scene;
|
||||||
use blitz_traits::events::{
|
use blitz_traits::events::{
|
||||||
@@ -26,7 +29,6 @@ use blitz_traits::shell::{ColorScheme, Viewport};
|
|||||||
use crossbeam_channel::{Receiver, Sender};
|
use crossbeam_channel::{Receiver, Sender};
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_native_dom::DioxusDocument;
|
use dioxus_native_dom::DioxusDocument;
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use vello::{
|
use vello::{
|
||||||
peniko::color::AlphaColor, RenderParams, Renderer as VelloRenderer, RendererOptions, Scene,
|
peniko::color::AlphaColor, RenderParams, Renderer as VelloRenderer, RendererOptions, Scene,
|
||||||
};
|
};
|
||||||
@@ -41,17 +43,22 @@ pub struct DioxusInBevyPlugin<UIProps> {
|
|||||||
pub props: UIProps,
|
pub props: UIProps,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
struct AnimationTime(Instant);
|
||||||
|
|
||||||
impl<UIProps: std::marker::Send + std::marker::Sync + std::clone::Clone + 'static> Plugin
|
impl<UIProps: std::marker::Send + std::marker::Sync + std::clone::Clone + 'static> Plugin
|
||||||
for DioxusInBevyPlugin<UIProps>
|
for DioxusInBevyPlugin<UIProps>
|
||||||
{
|
{
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
|
let epoch = AnimationTime(Instant::now());
|
||||||
|
|
||||||
// Create the dioxus virtual dom and the dioxus-native document
|
// Create the dioxus virtual dom and the dioxus-native document
|
||||||
// The viewport will be set in setup_ui after we get the window size
|
// The viewport will be set in setup_ui after we get the window size
|
||||||
let vdom = VirtualDom::new_with_props(self.ui, self.props.clone());
|
let vdom = VirtualDom::new_with_props(self.ui, self.props.clone());
|
||||||
// FIXME add a NetProvider
|
// FIXME add a NetProvider
|
||||||
let mut dioxus_doc = DioxusDocument::new(vdom, DocumentConfig::default());
|
let mut dioxus_doc = DioxusDocument::new(vdom, DocumentConfig::default());
|
||||||
dioxus_doc.initial_build();
|
dioxus_doc.initial_build();
|
||||||
dioxus_doc.resolve();
|
dioxus_doc.resolve(0.0);
|
||||||
|
|
||||||
// Dummy waker
|
// Dummy waker
|
||||||
struct NullWake;
|
struct NullWake;
|
||||||
@@ -62,13 +69,14 @@ impl<UIProps: std::marker::Send + std::marker::Sync + std::clone::Clone + 'stati
|
|||||||
|
|
||||||
app.insert_non_send_resource(dioxus_doc);
|
app.insert_non_send_resource(dioxus_doc);
|
||||||
app.insert_non_send_resource(waker);
|
app.insert_non_send_resource(waker);
|
||||||
|
app.insert_resource(epoch);
|
||||||
app.add_systems(Startup, setup_ui);
|
app.add_systems(Startup, setup_ui);
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
(
|
(
|
||||||
handle_window_resize,
|
handle_window_resize,
|
||||||
handle_mouse_events.after(InputSystem),
|
handle_mouse_events.after(InputSystems),
|
||||||
handle_keyboard_events.after(InputSystem),
|
handle_keyboard_events.after(InputSystems),
|
||||||
)
|
)
|
||||||
.chain(),
|
.chain(),
|
||||||
);
|
);
|
||||||
@@ -202,6 +210,7 @@ fn setup_ui(
|
|||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
mut images: ResMut<Assets<Image>>,
|
mut images: ResMut<Assets<Image>>,
|
||||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||||
|
mut animation_epoch: ResMut<AnimationTime>,
|
||||||
windows: Query<&Window>,
|
windows: Query<&Window>,
|
||||||
) {
|
) {
|
||||||
let window = windows
|
let window = windows
|
||||||
@@ -214,8 +223,9 @@ fn setup_ui(
|
|||||||
debug!("Initial window size: {}x{}", width, height);
|
debug!("Initial window size: {}x{}", width, height);
|
||||||
|
|
||||||
// Set the initial viewport
|
// Set the initial viewport
|
||||||
|
animation_epoch.0 = Instant::now();
|
||||||
dioxus_doc.set_viewport(Viewport::new(width, height, SCALE_FACTOR, COLOR_SCHEME));
|
dioxus_doc.set_viewport(Viewport::new(width, height, SCALE_FACTOR, COLOR_SCHEME));
|
||||||
dioxus_doc.resolve();
|
dioxus_doc.resolve(0.0);
|
||||||
|
|
||||||
// Create Bevy Image from the texture data
|
// Create Bevy Image from the texture data
|
||||||
let image = create_ui_texture(width, height);
|
let image = create_ui_texture(width, height);
|
||||||
@@ -242,6 +252,7 @@ fn setup_ui(
|
|||||||
commands.insert_resource(TextureImage(handle));
|
commands.insert_resource(TextureImage(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn update_ui(
|
fn update_ui(
|
||||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||||
waker: NonSendMut<std::task::Waker>,
|
waker: NonSendMut<std::task::Waker>,
|
||||||
@@ -249,6 +260,7 @@ fn update_ui(
|
|||||||
render_device: Res<RenderDevice>,
|
render_device: Res<RenderDevice>,
|
||||||
render_queue: Res<RenderQueue>,
|
render_queue: Res<RenderQueue>,
|
||||||
receiver: Res<MainWorldReceiver>,
|
receiver: Res<MainWorldReceiver>,
|
||||||
|
animation_epoch: Res<AnimationTime>,
|
||||||
mut cached_texture: Local<Option<RenderTexture>>,
|
mut cached_texture: Local<Option<RenderTexture>>,
|
||||||
) {
|
) {
|
||||||
while let Ok(texture) = receiver.try_recv() {
|
while let Ok(texture) = receiver.try_recv() {
|
||||||
@@ -261,29 +273,21 @@ fn update_ui(
|
|||||||
dioxus_doc.poll(Some(std::task::Context::from_waker(&waker)));
|
dioxus_doc.poll(Some(std::task::Context::from_waker(&waker)));
|
||||||
|
|
||||||
// Refresh the document
|
// Refresh the document
|
||||||
dioxus_doc.resolve();
|
let animation_time = animation_epoch.0.elapsed().as_secs_f64();
|
||||||
|
dioxus_doc.resolve(animation_time);
|
||||||
|
|
||||||
// Create a `VelloScenePainter` to paint into
|
// Create a `vello::Scene` to paint into
|
||||||
let mut custom_paint_sources =
|
let mut scene = Scene::new();
|
||||||
FxHashMap::<u64, Box<dyn CustomPaintSource + 'static>>::default();
|
|
||||||
let mut scene_painter = VelloScenePainter {
|
|
||||||
inner: Scene::new(),
|
|
||||||
renderer: &mut vello_renderer,
|
|
||||||
custom_paint_sources: &mut custom_paint_sources,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Paint the document
|
// Paint the document
|
||||||
paint_scene(
|
paint_scene(
|
||||||
&mut scene_painter,
|
&mut VelloScenePainter::new(&mut scene),
|
||||||
&dioxus_doc,
|
&dioxus_doc,
|
||||||
SCALE_FACTOR as f64,
|
SCALE_FACTOR as f64,
|
||||||
texture.width,
|
texture.width,
|
||||||
texture.height,
|
texture.height,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Extract the `vello::Scene` from the `VelloScenePainter`
|
|
||||||
let scene = scene_painter.finish();
|
|
||||||
|
|
||||||
// Render the `vello::Scene` to the Texture using the `VelloRenderer`
|
// Render the `vello::Scene` to the Texture using the `VelloRenderer`
|
||||||
vello_renderer
|
vello_renderer
|
||||||
.render_to_texture(
|
.render_to_texture(
|
||||||
@@ -304,7 +308,7 @@ fn update_ui(
|
|||||||
|
|
||||||
fn handle_window_resize(
|
fn handle_window_resize(
|
||||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||||
mut resize_events: EventReader<WindowResized>,
|
mut resize_events: MessageReader<WindowResized>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut images: ResMut<Assets<Image>>,
|
mut images: ResMut<Assets<Image>>,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
@@ -319,7 +323,7 @@ fn handle_window_resize(
|
|||||||
|
|
||||||
// Update the dioxus viewport
|
// Update the dioxus viewport
|
||||||
dioxus_doc.set_viewport(Viewport::new(width, height, SCALE_FACTOR, COLOR_SCHEME));
|
dioxus_doc.set_viewport(Viewport::new(width, height, SCALE_FACTOR, COLOR_SCHEME));
|
||||||
dioxus_doc.resolve();
|
// dioxus_doc.resolve();
|
||||||
|
|
||||||
// Create a new texture with the new size
|
// Create a new texture with the new size
|
||||||
let new_image = create_ui_texture(width, height);
|
let new_image = create_ui_texture(width, height);
|
||||||
@@ -369,8 +373,8 @@ fn does_catch_events(dioxus_doc: &DioxusDocument, node_id: usize) -> bool {
|
|||||||
|
|
||||||
fn handle_mouse_events(
|
fn handle_mouse_events(
|
||||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||||
mut cursor_moved: EventReader<CursorMoved>,
|
mut cursor_moved: MessageReader<CursorMoved>,
|
||||||
mut mouse_button_input_events: ResMut<Events<MouseButtonInput>>,
|
mut mouse_button_input_events: ResMut<Messages<MouseButtonInput>>,
|
||||||
mut mouse_buttons: ResMut<ButtonInput<MouseButton>>,
|
mut mouse_buttons: ResMut<ButtonInput<MouseButton>>,
|
||||||
mut last_mouse_state: Local<MouseState>,
|
mut last_mouse_state: Local<MouseState>,
|
||||||
) {
|
) {
|
||||||
@@ -438,12 +442,12 @@ fn handle_mouse_events(
|
|||||||
mouse_buttons.reset_all();
|
mouse_buttons.reset_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
dioxus_doc.resolve();
|
// dioxus_doc.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_keyboard_events(
|
fn handle_keyboard_events(
|
||||||
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
mut dioxus_doc: NonSendMut<DioxusDocument>,
|
||||||
mut keyboard_input_events: ResMut<Events<KeyboardInput>>,
|
mut keyboard_input_events: ResMut<Messages<KeyboardInput>>,
|
||||||
mut keys: ResMut<ButtonInput<BevyKeyCode>>,
|
mut keys: ResMut<ButtonInput<BevyKeyCode>>,
|
||||||
mut last_mouse_state: Local<MouseState>,
|
mut last_mouse_state: Local<MouseState>,
|
||||||
) {
|
) {
|
||||||
@@ -512,7 +516,7 @@ fn handle_keyboard_events(
|
|||||||
keys.reset_all();
|
keys.reset_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
dioxus_doc.resolve();
|
// dioxus_doc.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bevy_key_to_blitz_key(key: &BevyKey) -> Key {
|
fn bevy_key_to_blitz_key(key: &BevyKey) -> Key {
|
||||||
|
|||||||
@@ -62,6 +62,17 @@ html, body, #main {
|
|||||||
background-color: blue;
|
background-color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spin-box {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
animation: spin 4s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
from { transform:rotate(0deg); }
|
||||||
|
to { transform:rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
#translation-speed-control, #rotation-speed-control {
|
#translation-speed-control, #rotation-speed-control {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ pub fn ui(props: UIProps) -> Element {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let color = *state.cube_color.read();
|
||||||
|
let [r, g, b, a] = color.map(|c| (c * 255.0) as u8);
|
||||||
|
|
||||||
|
println!("rgba({r}, {g}, {b}, {a})");
|
||||||
|
|
||||||
rsx! {
|
rsx! {
|
||||||
style { {include_str!("./ui.css")} }
|
style { {include_str!("./ui.css")} }
|
||||||
div {
|
div {
|
||||||
@@ -163,6 +168,16 @@ pub fn ui(props: UIProps) -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
div {
|
||||||
|
flex: "0 0 150px",
|
||||||
|
display: "grid",
|
||||||
|
align_items: "center",
|
||||||
|
justify_items: "center",
|
||||||
|
div {
|
||||||
|
class: "spin-box",
|
||||||
|
background: "rgba({r}, {g}, {b}, {a}",
|
||||||
|
}
|
||||||
|
}
|
||||||
div {
|
div {
|
||||||
id: "footer",
|
id: "footer",
|
||||||
p { "Bevy framerate: {state.fps}" }
|
p { "Bevy framerate: {state.fps}" }
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ tracing = ["dep:tracing-subscriber", "dioxus-native-dom/tracing"]
|
|||||||
dioxus = { workspace = true, features = ["html", "hooks", "signals"] }
|
dioxus = { workspace = true, features = ["html", "hooks", "signals"] }
|
||||||
dioxus-native-dom = { workspace = true }
|
dioxus-native-dom = { workspace = true }
|
||||||
anyrender_vello = { workspace = true }
|
anyrender_vello = { workspace = true }
|
||||||
vello = "0.5"
|
vello = { workspace = true }
|
||||||
rustc-hash = "1"
|
rustc-hash = "1"
|
||||||
futures-util = { workspace = true }
|
futures-util = { workspace = true }
|
||||||
tracing-subscriber = { workspace = true, optional = true }
|
tracing-subscriber = { workspace = true, optional = true }
|
||||||
wgpu = { workspace = true }
|
wgpu = { workspace = true }
|
||||||
|
wgpu_context = { workspace = true }
|
||||||
pollster = "0.4"
|
pollster = "0.4"
|
||||||
bytemuck = "1"
|
bytemuck = "1"
|
||||||
blitz-paint = { workspace = true, default-features = true }
|
blitz-paint = { workspace = true, default-features = true }
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//!
|
//!
|
||||||
//! (this example is not really intended to be run as-is, and requires you to fill
|
//! (this example is not really intended to be run as-is, and requires you to fill
|
||||||
//! in the missing pieces)
|
//! in the missing pieces)
|
||||||
use anyrender_vello::{wgpu_context::WGPUContext, CustomPaintSource, VelloScenePainter};
|
use anyrender_vello::VelloScenePainter;
|
||||||
use blitz_dom::{Document as _, DocumentConfig};
|
use blitz_dom::{Document as _, DocumentConfig};
|
||||||
use blitz_paint::paint_scene;
|
use blitz_paint::paint_scene;
|
||||||
use blitz_traits::{
|
use blitz_traits::{
|
||||||
@@ -13,13 +13,13 @@ use blitz_traits::{
|
|||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_native_dom::DioxusDocument;
|
use dioxus_native_dom::DioxusDocument;
|
||||||
use pollster::FutureExt as _;
|
use pollster::FutureExt as _;
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::task::Context;
|
use std::task::Context;
|
||||||
use vello::{
|
use vello::{
|
||||||
peniko::color::AlphaColor, RenderParams, Renderer as VelloRenderer, RendererOptions, Scene,
|
peniko::color::AlphaColor, RenderParams, Renderer as VelloRenderer, RendererOptions, Scene,
|
||||||
};
|
};
|
||||||
use wgpu::TextureFormat;
|
use wgpu::TextureFormat;
|
||||||
|
use wgpu_context::WGPUContext;
|
||||||
|
|
||||||
// Constant width, height, scale factor and color schemefor example purposes
|
// Constant width, height, scale factor and color schemefor example purposes
|
||||||
const SCALE_FACTOR: f32 = 1.0;
|
const SCALE_FACTOR: f32 = 1.0;
|
||||||
@@ -102,14 +102,8 @@ fn main() {
|
|||||||
// Poll the vdom
|
// Poll the vdom
|
||||||
dioxus_doc.poll(Some(Context::from_waker(&waker)));
|
dioxus_doc.poll(Some(Context::from_waker(&waker)));
|
||||||
|
|
||||||
// Create a `VelloScenePainter` to paint into
|
// Create a `vello::Scene` to paint into
|
||||||
let mut custom_paint_sources =
|
let mut scene = Scene::new();
|
||||||
FxHashMap::<u64, Box<dyn CustomPaintSource + 'static>>::default();
|
|
||||||
let mut scene_painter = VelloScenePainter {
|
|
||||||
inner: Scene::new(),
|
|
||||||
renderer: &mut vello_renderer,
|
|
||||||
custom_paint_sources: &mut custom_paint_sources,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Paint the document using `blitz_paint::paint_scene`
|
// Paint the document using `blitz_paint::paint_scene`
|
||||||
//
|
//
|
||||||
@@ -117,16 +111,13 @@ fn main() {
|
|||||||
// so you could also write your own implementation if you want more control over rendering
|
// so you could also write your own implementation if you want more control over rendering
|
||||||
// (i.e. to render a custom renderer instead of Vello)
|
// (i.e. to render a custom renderer instead of Vello)
|
||||||
paint_scene(
|
paint_scene(
|
||||||
&mut scene_painter,
|
&mut VelloScenePainter::new(&mut scene),
|
||||||
&dioxus_doc,
|
&dioxus_doc,
|
||||||
SCALE_FACTOR as f64,
|
SCALE_FACTOR as f64,
|
||||||
WIDTH,
|
WIDTH,
|
||||||
HEIGHT,
|
HEIGHT,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Extract the `vello::Scene` from the `VelloScenePainter`
|
|
||||||
let scene = scene_painter.finish();
|
|
||||||
|
|
||||||
// Render the `vello::Scene` to the Texture using the `VelloRenderer`
|
// Render the `vello::Scene` to the Texture using the `VelloRenderer`
|
||||||
vello_renderer
|
vello_renderer
|
||||||
.render_to_texture(
|
.render_to_texture(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use dioxus_native::{CustomPaintCtx, CustomPaintSource, DeviceHandle, TextureHand
|
|||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use wgpu::{
|
use wgpu::{
|
||||||
CommandEncoderDescriptor, Device, Extent3d, FragmentState, Instance, LoadOp, MultisampleState,
|
CommandEncoderDescriptor, Device, Extent3d, FragmentState, LoadOp, MultisampleState,
|
||||||
Operations, PipelineLayoutDescriptor, PrimitiveState, PushConstantRange, Queue,
|
Operations, PipelineLayoutDescriptor, PrimitiveState, PushConstantRange, Queue,
|
||||||
RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor,
|
RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor,
|
||||||
ShaderModuleDescriptor, ShaderSource, ShaderStages, StoreOp, Texture, TextureDescriptor,
|
ShaderModuleDescriptor, ShaderSource, ShaderStages, StoreOp, Texture, TextureDescriptor,
|
||||||
@@ -21,7 +21,7 @@ pub struct DemoPaintSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CustomPaintSource for DemoPaintSource {
|
impl CustomPaintSource for DemoPaintSource {
|
||||||
fn resume(&mut self, _instance: &Instance, device_handle: &DeviceHandle) {
|
fn resume(&mut self, device_handle: &DeviceHandle) {
|
||||||
// Extract device and queue from device_handle
|
// Extract device and queue from device_handle
|
||||||
let device = &device_handle.device;
|
let device = &device_handle.device;
|
||||||
let queue = &device_handle.queue;
|
let queue = &device_handle.queue;
|
||||||
@@ -175,8 +175,7 @@ impl ActiveDemoRenderer {
|
|||||||
// If "next texture" size doesn't match specified size then unregister and drop texture
|
// If "next texture" size doesn't match specified size then unregister and drop texture
|
||||||
if let Some(next) = &self.next_texture {
|
if let Some(next) = &self.next_texture {
|
||||||
if next.texture.width() != width || next.texture.height() != height {
|
if next.texture.width() != width || next.texture.height() != height {
|
||||||
ctx.unregister_texture(next.handle);
|
ctx.unregister_texture(self.next_texture.take().unwrap().handle);
|
||||||
self.next_texture = None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +191,7 @@ impl ActiveDemoRenderer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let next_texture = &texture_and_handle.texture;
|
let next_texture = &texture_and_handle.texture;
|
||||||
let next_texture_handle = texture_and_handle.handle;
|
let next_texture_handle = texture_and_handle.handle.clone();
|
||||||
|
|
||||||
let elapsed: f32 = start_time.elapsed().as_millis() as f32 / 500.;
|
let elapsed: f32 = start_time.elapsed().as_millis() as f32 / 500.;
|
||||||
let [light_red, light_green, light_blue] = light;
|
let [light_red, light_green, light_blue] = light;
|
||||||
@@ -213,6 +212,7 @@ impl ActiveDemoRenderer {
|
|||||||
load: LoadOp::Clear(wgpu::Color::GREEN),
|
load: LoadOp::Clear(wgpu::Color::GREEN),
|
||||||
store: StoreOp::Store,
|
store: StoreOp::Store,
|
||||||
},
|
},
|
||||||
|
depth_slice: None,
|
||||||
})],
|
})],
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
timestamp_writes: None,
|
timestamp_writes: None,
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ body {
|
|||||||
padding: 15px 15px 15px 60px;
|
padding: 15px 15px 15px 60px;
|
||||||
display: block;
|
display: block;
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
|
transition: color 0.4s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.todo-list li.completed label {
|
.todo-list li.completed label {
|
||||||
@@ -230,6 +231,7 @@ body {
|
|||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
color: #cc9a9a;
|
color: #cc9a9a;
|
||||||
margin-bottom: 11px;
|
margin-bottom: 11px;
|
||||||
|
transition: color 0.2s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.todo-list li .destroy:hover {
|
.todo-list li .destroy:hover {
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ tracing-subscriber = { version = "0.3.19", features = [
|
|||||||
] }
|
] }
|
||||||
console-subscriber = { version = "0.4.1", optional = true }
|
console-subscriber = { version = "0.4.1", optional = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
wasm-opt = { version = "0.116.1", optional = true }
|
|
||||||
ansi-to-tui = { workspace = true }
|
ansi-to-tui = { workspace = true }
|
||||||
ansi-to-html = { workspace = true }
|
ansi-to-html = { workspace = true }
|
||||||
path-absolutize = { workspace = true }
|
path-absolutize = { workspace = true }
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ fn merge_profiles(target: &mut Profiles, new: Profiles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
if let Some(new_doc) = new.doc {
|
if let Some(new_doc) = new.doc {
|
||||||
if target.doc.is_none() {
|
if target.doc.is_none() {
|
||||||
target.doc = Some(new_doc);
|
target.doc = Some(new_doc);
|
||||||
|
|||||||
@@ -193,11 +193,7 @@ pub(crate) fn post_create(path: &Path, vcs: &Vcs) -> Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut toml = toml.parse::<toml_edit::DocumentMut>().map_err(|e| {
|
let mut toml = toml.parse::<toml_edit::DocumentMut>().map_err(|e| {
|
||||||
anyhow::anyhow!(
|
anyhow::anyhow!("failed to parse toml at {}: {}", toml_path.display(), e)
|
||||||
"failed to parse toml at {}: {}",
|
|
||||||
toml_path.display(),
|
|
||||||
e.to_string()
|
|
||||||
)
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
toml.as_table_mut().fmt();
|
toml.as_table_mut().fmt();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::IncrementalRendererConfig;
|
|||||||
pub(crate) type ContextProviders =
|
pub(crate) type ContextProviders =
|
||||||
Arc<Vec<Box<dyn Fn() -> Box<dyn std::any::Any> + Send + Sync + 'static>>>;
|
Arc<Vec<Box<dyn Fn() -> Box<dyn std::any::Any> + Send + Sync + 'static>>>;
|
||||||
|
|
||||||
/// A ServeConfig is used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus-ssr`].
|
/// A ServeConfig is used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus_ssr`].
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct ServeConfigBuilder {
|
pub struct ServeConfigBuilder {
|
||||||
pub(crate) root_id: Option<&'static str>,
|
pub(crate) root_id: Option<&'static str>,
|
||||||
@@ -491,7 +491,7 @@ pub enum StreamingMode {
|
|||||||
OutOfOrder,
|
OutOfOrder,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus-ssr`].
|
/// Used to configure how to serve a Dioxus application. It contains information about how to serve static assets, and what content to render with [`dioxus_ssr`].
|
||||||
/// See [`ServeConfigBuilder`] to create a ServeConfig
|
/// See [`ServeConfigBuilder`] to create a ServeConfig
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ServeConfig {
|
pub struct ServeConfig {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
//! Generational box errors
|
||||||
|
#![allow(clippy::uninlined_format_args, reason = "causes compile error")]
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub(crate) enum RwLockStorageEntryData {
|
|||||||
impl Debug for RwLockStorageEntryData {
|
impl Debug for RwLockStorageEntryData {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Reference(location) => write!(f, "Reference({:?})", location),
|
Self::Reference(location) => write!(f, "Reference({location:?})"),
|
||||||
Self::Rc(_) => write!(f, "Rc"),
|
Self::Rc(_) => write!(f, "Rc"),
|
||||||
Self::Data(_) => write!(f, "Data"),
|
Self::Data(_) => write!(f, "Data"),
|
||||||
Self::Empty => write!(f, "Empty"),
|
Self::Empty => write!(f, "Empty"),
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ homepage = "https://dioxuslabs.com/learn/0.6/getting_started"
|
|||||||
keywords = ["dom", "ui", "gui", "react"]
|
keywords = ["dom", "ui", "gui", "react"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["accessibility", "hot-reload", "tracing", "net", "html", "svg", "system-fonts"]
|
default = ["accessibility", "hot-reload", "tracing", "net", "html", "svg", "system-fonts", "clipboard", "file_dialog"]
|
||||||
|
clipboard = ["blitz-shell/clipboard"]
|
||||||
|
file_dialog = ["blitz-shell/file_dialog"]
|
||||||
svg = ["blitz-dom/svg", "blitz-paint/svg"]
|
svg = ["blitz-dom/svg", "blitz-paint/svg"]
|
||||||
net = ["dep:tokio", "dep:blitz-net"]
|
net = ["dep:tokio", "dep:blitz-net"]
|
||||||
html = ["dep:blitz-html"]
|
html = ["dep:blitz-html"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use anyrender::WindowRenderer;
|
|||||||
|
|
||||||
pub use anyrender_vello::{
|
pub use anyrender_vello::{
|
||||||
wgpu::{Features, Limits},
|
wgpu::{Features, Limits},
|
||||||
CustomPaintSource, VelloWindowRenderer as InnerRenderer,
|
CustomPaintSource, VelloRendererOptions, VelloWindowRenderer as InnerRenderer,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn use_wgpu<T: CustomPaintSource>(create_source: impl FnOnce() -> T) -> u64 {
|
pub fn use_wgpu<T: CustomPaintSource>(create_source: impl FnOnce() -> T) -> u64 {
|
||||||
@@ -45,7 +45,11 @@ impl DioxusNativeWindowRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_features_and_limits(features: Option<Features>, limits: Option<Limits>) -> Self {
|
pub fn with_features_and_limits(features: Option<Features>, limits: Option<Limits>) -> Self {
|
||||||
let vello_renderer = InnerRenderer::with_features_and_limits(features, limits);
|
let vello_renderer = InnerRenderer::with_options(VelloRendererOptions {
|
||||||
|
features,
|
||||||
|
limits,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
Self::with_inner_renderer(vello_renderer)
|
Self::with_inner_renderer(vello_renderer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ mod link_handler;
|
|||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use dioxus_native_dom::*;
|
pub use dioxus_native_dom::*;
|
||||||
|
|
||||||
pub use anyrender_vello::{
|
pub use anyrender_vello::{CustomPaintCtx, CustomPaintSource, DeviceHandle, TextureHandle};
|
||||||
wgpu_context::DeviceHandle, CustomPaintCtx, CustomPaintSource, TextureHandle,
|
|
||||||
};
|
|
||||||
use assets::DioxusNativeNetProvider;
|
use assets::DioxusNativeNetProvider;
|
||||||
pub use dioxus_application::{DioxusNativeApplication, DioxusNativeEvent};
|
pub use dioxus_application::{DioxusNativeApplication, DioxusNativeEvent};
|
||||||
pub use dioxus_renderer::{use_wgpu, DioxusNativeWindowRenderer, Features, Limits};
|
pub use dioxus_renderer::{use_wgpu, DioxusNativeWindowRenderer, Features, Limits};
|
||||||
|
|||||||
Reference in new issue
Block a user