From 1d85b6e887761ae885bec3f0b5405bf902ef8b64 Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Sun, 21 Mar 2021 14:36:06 +1100 Subject: feat(web): Support in-memory image data I had to create two methods which basically do the same thing, `from_memory` and `from_slice`, but `from_memory` takes ownership of the bytes to be compatible with `iced_native`. Also, `Data` is incompatible, because if I stored the bytes in `Data` and created a new object URL every render, it would have caused a memory leak because bumpalo doesn't call destructors and there'd be no way to call URL.revokeObjectUrl on it. It's also more efficient this way. --- web/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'web/Cargo.toml') diff --git a/web/Cargo.toml b/web/Cargo.toml index e063a021..b3f9ec31 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -20,6 +20,7 @@ wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" url = "2.0" num-traits = "0.2" +js-sys = "0.3" [dependencies.iced_core] version = "0.3" @@ -44,4 +45,5 @@ features = [ "EventTarget", "InputEvent", "KeyboardEvent", + "Url", ] -- cgit From e9d122b1aaa47dc8dad5bd857a7430e56b8a8105 Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Sun, 21 Mar 2021 14:40:39 +1100 Subject: Add `Blob` to web-sys features rust-analyzer lied to me --- web/Cargo.toml | 1 + 1 file changed, 1 insertion(+) (limited to 'web/Cargo.toml') diff --git a/web/Cargo.toml b/web/Cargo.toml index b3f9ec31..d6bc34da 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -46,4 +46,5 @@ features = [ "InputEvent", "KeyboardEvent", "Url", + "Blob", ] -- cgit From 11f29bca86e299ed3e2c0d3db0d8058efe4be7ef Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Sat, 10 Apr 2021 17:18:04 +1000 Subject: Use data urls instead of blob URLs I didn't do this originally because I was half doing it in the first place to mess with Blob URLs, and it feels kinda wrong to be encoding it as base64 when that option is available. But not having memory leaks is more important. --- web/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'web/Cargo.toml') diff --git a/web/Cargo.toml b/web/Cargo.toml index d6bc34da..f8630780 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -20,7 +20,7 @@ wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" url = "2.0" num-traits = "0.2" -js-sys = "0.3" +base64 = "0.13" [dependencies.iced_core] version = "0.3" @@ -45,6 +45,4 @@ features = [ "EventTarget", "InputEvent", "KeyboardEvent", - "Url", - "Blob", ] -- cgit