Skip to content

Commit

Permalink
fix: 🐛 avoid copying the animation data
Browse files Browse the repository at this point in the history
  • Loading branch information
theashraf committed Jan 12, 2024
1 parent 8946539 commit 7b0592d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions demo-player/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ fn main() {
let mut path = path::PathBuf::from(base_path);
path.push("src/cartoon.json");

let animation_data = read_to_string(path.to_str().unwrap()).unwrap();

let mut lottie_player: DotLottiePlayer = DotLottiePlayer::new(Config {
mode: Mode::Reverse,
loop_animation: true,
speed: 2.5,
use_frame_interpolation: true,
autoplay: true,
});
lottie_player.load_animation_data(animation_data.as_str(), WIDTH as u32, HEIGHT as u32);
lottie_player.load_animation_path(path.to_str().unwrap(), WIDTH as u32, HEIGHT as u32);

let mut timer = Timer::new();

Expand Down
4 changes: 2 additions & 2 deletions dotlottie-rs/src/dotlottie_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl DotLottieRuntime {
pub fn load_animation_data(&mut self, animation_data: &str, width: u32, height: u32) -> bool {
let loaded = self
.renderer
.load_data(animation_data, width, height, true)
.load_data(animation_data, width, height, false)
.is_ok();

self.is_loaded = loaded;
Expand Down Expand Up @@ -305,7 +305,7 @@ impl DotLottiePlayer {
}

pub fn buffer_ptr(&self) -> u64 {
self.runtime.read().unwrap().buffer().as_ptr() as u64
self.runtime.read().unwrap().buffer().as_ptr().cast::<u32>() as u64
}

pub fn buffer_len(&self) -> u64 {
Expand Down

0 comments on commit 7b0592d

Please sign in to comment.