Skip to content

Commit

Permalink
chore: 🤖 update dependencies (thorvg@v0.13.4) (#148)
Browse files Browse the repository at this point in the history
* chore: 🤖 update dependencies (thorvg@v0.13.3)

* chore: 🤖 update workflow

* chore: 🤖 rerun tests

* chore: 🤖 enable lottie expressions for ios and android

* chore: 🤖 upgrade thorvg to 0.13.4

* chore: 🤖 update thorvg

* run ci
  • Loading branch information
theashraf authored May 21, 2024
1 parent af5e597 commit 9b9a8da
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
- name: Build Artifacts
env:
APPLE_MACOSX_SDK: MacOSX13
run: make all
run: make demo-player
- name: Run Tests
run: make test
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ define SETUP_MESON
-Dbindings=capi \
-Dlog=$(LOG) \
-Dstatic=$(STATIC) \
-Dsavers=$(SAVERS) \
-Dthreads=true \
-Dextra=$(EXTRA) \
$(CROSS_FILE) "$(THORVG_DEP_SOURCE_DIR)" "$(THORVG_DEP_BUILD_DIR)"
endef

Expand Down Expand Up @@ -583,7 +582,7 @@ $$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): THORVG_DEP_BUILD_DIR := $$($1_T
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): CROSS_FILE := --cross-file $$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE)
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): LOG := $2
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): STATIC := $3
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): SAVERS := $4
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): EXTRA := $4
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): $$($1_THORVG_DEP_BUILD_DIR)/../$(MESON_CROSS_FILE)
$(if $(filter $3,false),
$$($1_THORVG_DEP_BUILD_DIR)/$(NINJA_BUILD_FILE): $$($1_DEPS_LIB_DIR)/$(LIBJPEG_TURBO_LIB)
Expand All @@ -605,7 +604,7 @@ $(eval $(call NEW_ANDROID_CMAKE_BUILD,$1,LIBPNG_LIB,$(LIBPNG),$$($1_LIBPNG_DEP_B
$(eval $(call NEW_ANDROID_CMAKE_BUILD,$1,ZLIB,$(ZLIB),$$($1_ZLIB_DEP_BUILD_DIR),$(ZLIB_LIB)))
$(eval $(call NEW_ANDROID_CMAKE_BUILD,$1,WEBP,$(WEBP),$$($1_WEBP_DEP_BUILD_DIR),$(WEBP_LIB)))
$(eval $(call NEW_ANDROID_CROSS_FILE,$1))
$(eval $(call NEW_THORVG_BUILD,$1,true,false,all))
$(eval $(call NEW_THORVG_BUILD,$1,false,false,"lottie_expressions"))
endef

define NEW_APPLE_DEPS_BUILD
Expand All @@ -614,12 +613,12 @@ $(eval $(call NEW_APPLE_CMAKE_BUILD,$1,LIBPNG_LIB,$(LIBPNG),$$($1_LIBPNG_DEP_BUI
$(eval $(call NEW_APPLE_CMAKE_BUILD,$1,ZLIB,$(ZLIB),$$($1_ZLIB_DEP_BUILD_DIR),$(ZLIB_LIB)))
$(eval $(call NEW_APPLE_CMAKE_BUILD,$1,WEBP,$(WEBP),$$($1_WEBP_DEP_BUILD_DIR),$(WEBP_LIB)))
$(eval $(call NEW_APPLE_CROSS_FILE,$1))
$(eval $(call NEW_THORVG_BUILD,$1,true,false,all))
$(eval $(call NEW_THORVG_BUILD,$1,false,false,"lottie_expressions"))
endef

define NEW_WASM_DEPS_BUILD
$(eval $(call NEW_WASM_CROSS_FILE,$1,$$($1_THORVG_DEP_BUILD_DIR)/..,windows))
$(eval $(call NEW_THORVG_BUILD,$1,false,true,))
$(eval $(call NEW_THORVG_BUILD,$1,false,true,"lottie_expressions"))
endef

define NEW_ANDROID_BUILD
Expand Down Expand Up @@ -784,7 +783,7 @@ $(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): THORVG_DEP_SOURCE_DIR := $(D
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): THORVG_DEP_BUILD_DIR := $(THORVG_LOCAL_ARCH_BUILD_DIR)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): LOG := false
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): STATIC := false
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): SAVERS := all
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): EXTRA := lottie_expressions
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): $(LOCAL_ARCH_LIB_DIR)/$(LIBJPEG_TURBO_LIB)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): $(LOCAL_ARCH_LIB_DIR)/$(LIBPNG_LIB)
$(THORVG_LOCAL_ARCH_BUILD_DIR)/$(NINJA_BUILD_FILE): $(LOCAL_ARCH_LIB_DIR)/$(ZLIB_LIB)
Expand Down
2 changes: 1 addition & 1 deletion deps/modules/thorvg
Submodule thorvg updated 463 files
30 changes: 8 additions & 22 deletions dotlottie-rs/src/dotlottie_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ impl Default for Config {
}
}

const FRAME_DIFF_THRESHOLD: f32 = 0.001;

struct DotLottieRuntime {
renderer: LottieRenderer,
playback_state: PlaybackState,
Expand Down Expand Up @@ -281,29 +279,17 @@ impl DotLottieRuntime {
Direction::Reverse => end_frame - raw_next_frame,
};

if !self.config.use_frame_interpolation {
next_frame = next_frame.round();
}

/*
Note:
If we're close to the end frame, we should snap to it as tvg_set_frame ignore the frame which is 0.001 less than the current frame.
*/
match self.direction {
Direction::Forward => {
if (next_frame - end_frame).abs() < FRAME_DIFF_THRESHOLD {
next_frame = end_frame;
}
}
Direction::Reverse => {
if (next_frame - start_frame).abs() < FRAME_DIFF_THRESHOLD {
next_frame = start_frame
}
}
// Apply frame interpolation
next_frame = if self.config.use_frame_interpolation {
(next_frame * 1000.0).round() / 1000.0
} else {
next_frame.round()
};

// Clamp the next frame to the start & end frames
next_frame = next_frame.clamp(start_frame, end_frame);

// Handle different modes
next_frame = match self.config.mode {
Mode::Forward => self.handle_forward_mode(next_frame, end_frame),
Mode::Reverse => self.handle_reverse_mode(next_frame, start_frame),
Expand Down Expand Up @@ -505,7 +491,7 @@ impl DotLottieRuntime {
}

pub fn current_frame(&self) -> f32 {
self.renderer.current_frame().unwrap_or(0.0)
self.renderer.current_frame
}

pub fn loop_count(&self) -> u32 {
Expand Down
29 changes: 15 additions & 14 deletions dotlottie-rs/src/lottie_renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct LottieRenderer {
pub height: u32,
pub buffer: Vec<u32>,
pub background_color: u32,
pub current_frame: f32,
layout: Layout,
}

Expand All @@ -43,6 +44,7 @@ impl LottieRenderer {
picture_width: 0.0,
picture_height: 0.0,
background_color: 0,
current_frame: 0.0,
layout: Layout::default(),
}
}
Expand Down Expand Up @@ -80,9 +82,8 @@ impl LottieRenderer {
self.picture_width = pw;
self.picture_height = ph;

let (scaled_picture_width, scaled_picture_height, shift_x, shift_y) = self
.layout
.compute_layout_transform(
let (scaled_picture_width, scaled_picture_height, shift_x, shift_y) =
self.layout.compute_layout_transform(
self.width as f32,
self.height as f32,
self.picture_width,
Expand Down Expand Up @@ -123,10 +124,8 @@ impl LottieRenderer {
.map_err(|e| LottieRendererError::ThorvgError(e))
}

pub fn current_frame(&self) -> Result<f32, LottieRendererError> {
self.thorvg_animation
.get_frame()
.map_err(|e| LottieRendererError::ThorvgError(e))
pub fn current_frame(&self) -> f32 {
self.current_frame
}

pub fn clear(&mut self) {
Expand Down Expand Up @@ -156,7 +155,11 @@ impl LottieRenderer {

self.thorvg_animation
.set_frame(no)
.map_err(|e| LottieRendererError::ThorvgError(e))
.map_err(LottieRendererError::ThorvgError)?;

self.current_frame = no;

Ok(())
}

pub fn resize(&mut self, width: u32, height: u32) -> Result<(), LottieRendererError> {
Expand Down Expand Up @@ -186,9 +189,8 @@ impl LottieRenderer {
)
.map_err(LottieRendererError::ThorvgError)?;

let (scaled_picture_width, scaled_picture_height, shift_x, shift_y) = self
.layout
.compute_layout_transform(
let (scaled_picture_width, scaled_picture_height, shift_x, shift_y) =
self.layout.compute_layout_transform(
self.width as f32,
self.height as f32,
self.picture_width,
Expand Down Expand Up @@ -242,9 +244,8 @@ impl LottieRenderer {

self.layout = layout.clone();

let (scaled_picture_width, scaled_picture_height, shift_x, shift_y) = self
.layout
.compute_layout_transform(
let (scaled_picture_width, scaled_picture_height, shift_x, shift_y) =
self.layout.compute_layout_transform(
self.width as f32,
self.height as f32,
self.picture_width,
Expand Down

0 comments on commit 9b9a8da

Please sign in to comment.