From 96e92b41eacfe193bb910e6e93f136e0bb4c99d4 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Thu, 21 Mar 2024 20:58:24 +0700 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20revert=20loaded=20th?= =?UTF-8?q?eme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo-player/src/main.rs | 4 ++++ demo-player/src/theming_example.lottie | Bin 1469 -> 1360 bytes deps/modules/thorvg | 2 +- dotlottie-rs/src/dotlottie_player.rs | 4 ++++ dotlottie-rs/src/thorvg.rs | 17 ++++++++++------- web-example.html | 18 +++++++++--------- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/demo-player/src/main.rs b/demo-player/src/main.rs index 2a9eb005..ae2145fb 100644 --- a/demo-player/src/main.rs +++ b/demo-player/src/main.rs @@ -230,6 +230,10 @@ fn main() { } } + if window.is_key_pressed(Key::Y, KeyRepeat::No) { + lottie_player.load_theme(""); + } + if window.is_key_pressed(Key::Right, KeyRepeat::No) { if let Some(manifest) = lottie_player.manifest() { println!("{:?}", i); diff --git a/demo-player/src/theming_example.lottie b/demo-player/src/theming_example.lottie index 44792e5a90e59055cdb8c7906850666163a75c1e..deac8722bede23941a1c5c4b92a067144928a767 100644 GIT binary patch delta 858 zcmdnXeSu3nz?+#xgaHI9my|}xb(m?IFfuThOcW1h2~NyaoLFkWXf$zI&*UIRJ6@2A zpLfDltC<)WOefD}RIV?+WgzfZd!}u+jnF2;AJ@ue#Z_fhoi>p5l6`crrRQy3ip`(z z`=%O9<2|P4$EMRc^~*QU{PIH2dJU!fvnwaDs0 zf|8#?={9S>+lz)|sF@e&s1Gt$!fn>=!Uv@iUU7Im0g zfInHsT%at>_wZw#e#2;qoHUh>o1ff2ct&cA{r4sFbiVE3JFasxDrJB2!2-Uu2hyV& z-Y$9i<7(aPP~V-N9;_dDy`C3@$k(@V>70mRovYA%V#Bq?H-G4w8TiKDIV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Wf*AtT|TwFHEZbZnS=X(8N+g zHB5HvrrOIFzprm|PW!oXzTbrWM@hN+^TdDG!*T%!I2UZleYh_Pm?Mr%)?jh*7dZNp zwe#dm)u}U1_3}Q*>iXm@Eoc(%!CEZM;t=8 zG6Z-tGKnx?$yt*pvFOQT<`Hlfgc5C&@3Uxt)xcc>lo3Q$!Vo%Hja7y184E}d08oyr AJOBUy diff --git a/deps/modules/thorvg b/deps/modules/thorvg index 8545cf5a..38e248bb 160000 --- a/deps/modules/thorvg +++ b/deps/modules/thorvg @@ -1 +1 @@ -Subproject commit 8545cf5ab8632c1860aa09fe5732081415fd6f11 +Subproject commit 38e248bbe4405778524ce3a89dcf4aa9e76a988c diff --git a/dotlottie-rs/src/dotlottie_player.rs b/dotlottie-rs/src/dotlottie_player.rs index a6d1b8d8..6c89fd28 100644 --- a/dotlottie-rs/src/dotlottie_player.rs +++ b/dotlottie-rs/src/dotlottie_player.rs @@ -710,6 +710,10 @@ impl DotLottieRuntime { } pub fn load_theme(&mut self, theme_id: &str) -> bool { + if theme_id.is_empty() { + return self.renderer.load_theme_data("").is_ok(); + } + self.manifest() .and_then(|manifest| manifest.themes) .map_or(false, |themes| { diff --git a/dotlottie-rs/src/thorvg.rs b/dotlottie-rs/src/thorvg.rs index 7927efec..11f15b24 100644 --- a/dotlottie-rs/src/thorvg.rs +++ b/dotlottie-rs/src/thorvg.rs @@ -1,7 +1,7 @@ #![allow(non_upper_case_globals)] #![allow(non_snake_case)] -use std::ffi::CString; +use std::{ffi::CString, ptr}; use thiserror::Error; include!(concat!(env!("OUT_DIR"), "/bindings.rs")); @@ -71,7 +71,7 @@ pub trait Drawable { pub struct Canvas { raw_canvas: *mut Tvg_Canvas, - engine_method: Tvg_Engine + engine_method: Tvg_Engine, } impl Canvas { @@ -89,7 +89,7 @@ impl Canvas { Canvas { raw_canvas: unsafe { tvg_swcanvas_create() }, - engine_method: engine + engine_method: engine, } } @@ -274,11 +274,14 @@ impl Animation { } pub fn set_slots(&mut self, slots: &str) -> Result<(), TvgError> { - let slots = CString::new(slots).expect("Failed to create CString"); - - let result = unsafe { tvg_lottie_animation_override(self.raw_animation, slots.as_ptr()) }; + let result = if slots.is_empty() { + unsafe { tvg_lottie_animation_override(self.raw_animation, ptr::null()) } + } else { + let slots_cstr = CString::new(slots).expect("Failed to create CString"); + unsafe { tvg_lottie_animation_override(self.raw_animation, slots_cstr.as_ptr()) } + }; - convert_tvg_result(result, "tvg_animation_override") + convert_tvg_result(result, "tvg_lottie_animation_override") } } diff --git a/web-example.html b/web-example.html index 682e078d..815fcc20 100644 --- a/web-example.html +++ b/web-example.html @@ -36,8 +36,8 @@ - + { @@ -88,7 +88,7 @@ }, }); - function createSegments(startFrame, endFrame) { + function createSegment(startFrame, endFrame) { const vector = new Module.VectorFloat(); if (typeof startFrame === "number" && typeof endFrame === "number") { @@ -118,7 +118,7 @@ mode: Module.Mode.values[3], speed: 1, useFrameInterpolation: true, - segments: createSegments(0, 40), + segment: createSegment(0, 40), backgroundColor: 0, marker: "feather", layout: Module.createDefaultLayout(), @@ -129,8 +129,8 @@ // ); const data = await fetch( - "https://lottie.host/5c89381e-0d1a-4422-8247-f5b7e4b3c4e2/mqs5juC4PW.lottie" - // "./demo-player/src/theming_example.lottie", + // "https://lottie.host/5c89381e-0d1a-4422-8247-f5b7e4b3c4e2/mqs5juC4PW.lottie" + "./demo-player/src/theming_example.lottie" // "https://lottie.host/294b684d-d6b4-4116-ab35-85ef566d4379/VkGHcqcMUI.lottie", // "https://lottie.host/edff17eb-9a84-41f7-810a-22b94fbf9143/uYveqJ1Kqn.lottie" ).then((res) => res.arrayBuffer()); @@ -155,7 +155,7 @@ dotLottiePlayer.setConfig({ ...dotLottiePlayer.config(), mode: Module.Mode.values[1], - segments: createSegments(), + segment: createSegment(), }); console.log(dotLottiePlayer.markers()); @@ -336,7 +336,7 @@ themeSelect.addEventListener("change", (event) => { const theme = event.target.value; - if (theme === "theme") { + if (theme) { dotLottiePlayer.loadTheme(theme); } else { dotLottiePlayer.loadTheme(""); From 5a4ad4063e3f9fcbcab4bf967e759d7c7212ffb6 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Thu, 21 Mar 2024 21:36:15 +0700 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=F0=9F=A4=96=20upgrade=20uniffi-bi?= =?UTF-8?q?ndgen-cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .mac-setup.sh | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.mac-setup.sh b/.mac-setup.sh index 142f1cf3..269a1bc5 100755 --- a/.mac-setup.sh +++ b/.mac-setup.sh @@ -11,7 +11,7 @@ NC=$(tput sgr0) # Environment EMSDK_VERSION=${EMSDK_VERSION:-latest} -UNIFFI_BINDGEN_CPP_VERSION=${UNIFFI_BINDGEN_CPP_VERSION:-"v0.4.1+v0.25.0"} +UNIFFI_BINDGEN_CPP_VERSION=${UNIFFI_BINDGEN_CPP_VERSION:-"v0.4.2+v0.25.0"} die() { printf %s "${@+$@$'\n'}" 1>&2 ; exit 1; } diff --git a/Makefile b/Makefile index d9b6c099..67264ea3 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ EMSDK_VERSION := 3.1.51 EMSDK_ENV := emsdk_env.sh UNIFFI_BINDGEN_CPP := uniffi-bindgen-cpp -UNIFFI_BINDGEN_CPP_VERSION := v0.4.1+v0.25.0 +UNIFFI_BINDGEN_CPP_VERSION := v0.4.2+v0.25.0 WASM_MODULE := DotLottiePlayer From 5bdfee1a40a4153eff642d3ad282dbd1f2620f4e Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Fri, 22 Mar 2024 14:09:12 +0700 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=F0=9F=A4=96=20update=20ThorVG=20t?= =?UTF-8?q?o=20v0.12.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deps/modules/thorvg | 2 +- dotlottie-ffi/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/modules/thorvg b/deps/modules/thorvg index 38e248bb..afa6d849 160000 --- a/deps/modules/thorvg +++ b/deps/modules/thorvg @@ -1 +1 @@ -Subproject commit 38e248bbe4405778524ce3a89dcf4aa9e76a988c +Subproject commit afa6d8499bd49141d99d5e40a4620bd9f6bc0467 diff --git a/dotlottie-ffi/Cargo.toml b/dotlottie-ffi/Cargo.toml index 2501205c..33fcc666 100644 --- a/dotlottie-ffi/Cargo.toml +++ b/dotlottie-ffi/Cargo.toml @@ -22,7 +22,7 @@ path = "uniffi-bindgen.rs" [dependencies] # uncomment uniffi v0.25.3 when building with uniffi-cpp-bindgen targetting C++/WASM # uniffi = { version = "0.25.3", features = ["cli"] } -uniffi = { version = "0.26.0", features = ["cli"] } +uniffi = { version = "0.26.1", features = ["cli"] } dotlottie_player = { path = "../dotlottie-rs" } dotlottie_fms = { path = "../dotlottie-fms" } cfg-if = "1.0" @@ -30,5 +30,5 @@ cfg-if = "1.0" [build-dependencies] # uncomment uniffi v0.25.3 when building with uniffi-cpp-bindgen targetting C++/WASM # uniffi = { version = "0.25.3", features = ["build"] } -uniffi = { version = "0.26.0", features = ["build"] } +uniffi = { version = "0.26.1", features = ["build"] } lazy_static = "1.4"