Skip to content

Commit

Permalink
refactor: Update build workflow and dependencies
Browse files Browse the repository at this point in the history
- Update the build workflow to include pull request labeled events for triggering builds.
- Refactor the concurrency group to include the target or label name in the group name.
- Update the build-apple job to include the 'build:apple' label as a trigger condition.
- Update the build-android job to include the 'build:android' label as a trigger condition.
- Update the build-wasm job to include the 'build:wasm' label as a trigger condition.

chore: Update Makefile

- Add the '-Dengines=sw' flag to the meson setup to enable the software rendering engine.

chore: Update dotlottie-ffi dependencies

- Update the version of dotlottie-ffi to '0.1.31' in the Cargo.toml file.

chore: Update dotlottie-ffi Cargo.wasm.toml

- Remove the 'codegen-units' and 'strip' options from the Cargo.wasm.toml file.

chore: Update dotlottie-rs dependencies

- Update the version of thiserror to '2.0.4' in the Cargo.toml file.

chore: Update dotlottie-rs build.rs

- Update the bindgen version to '0.71.0' in the build.rs file.

chore: Update dotlottie-rs lottie_renderer/mod.rs

- Update the serde_json version to '1.0.133' in the mod.rs file.

chore: Update dotlottie-rs lottie_renderer/renderer.rs

- Update the clear method signature in the renderer.rs file to include separate flags for clearing paints and buffers.

chore: Update dotlottie-rs lottie_renderer/thorvg.rs

- Update the clear method signature in the thorvg.rs file to include separate flags for clearing paints and buffers.

feat: Add thorvg-v1 feature to dotlottie-rs

- Add the 'thorvg-v1' feature to the dotlottie-rs Cargo.toml file.

fix: Update DotLottieRuntime and DotLottiePlayerContainer

- Update the new method signatures in the DotLottieRuntime and DotLottiePlayerContainer structs to include conditional compilation based on the 'thorvg-v0' and 'thorvg-v1' features.

fix: Update DotLottiePlayer

- Update the new method signature in the DotLottiePlayer struct to include conditional compilation based on the 'thorvg-v0' and 'thorvg-v1' features.

fix: Update LottieRendererImpl

- Update the render method in the LottieRendererImpl struct to include conditional compilation based on the 'thorvg-v1' feature.

fix: Update TvgRenderer

- Update the clear method in the TvgRenderer struct to include conditional compilation based on the 'thorvg-v1' feature.

docs: Update README.md

- Update the README.md file to reflect the recent changes.
  • Loading branch information
theashraf committed Dec 10, 2024
1 parent f655c90 commit bdac0e2
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 44 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ on:
commitSHA:
description: "Commit SHA (leave blank for default branch)"
required: false
pull_request:
types: [labeled]

concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.target }}-${{ github.event.inputs.commitSHA || github.ref }}
group: ${{ github.workflow }}-${{ github.event.inputs.target || github.event.label.name }}-${{ github.event.inputs.commitSHA || github.ref }}
cancel-in-progress: true

jobs:
build-apple:
runs-on: macos-latest-large
if: github.event.inputs.target == 'apple' || github.event.inputs.target == 'all'
if: >
github.event.inputs.target == 'apple' ||
github.event.inputs.target == 'all' ||
github.event.label.name == 'build:apple'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -55,7 +60,10 @@ jobs:

build-android:
runs-on: macos-latest
if: github.event.inputs.target == 'android' || github.event.inputs.target == 'all'
if: >
github.event.inputs.target == 'android' ||
github.event.inputs.target == 'all' ||
github.event.label.name == 'build:android'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -85,7 +93,10 @@ jobs:

build-wasm:
runs-on: macos-latest
if: github.event.inputs.target == 'wasm' || github.event.inputs.target == 'all'
if: >
github.event.inputs.target == 'wasm' ||
github.event.inputs.target == 'all' ||
github.event.label.name == 'build:wasm'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ define SETUP_MESON
--backend=ninja \
-Dloaders="lottie, png, jpg, webp" \
-Ddefault_library=static \
-Dengines=sw \
-Dbindings=capi \
-Dlog=false \
-Dthreads=false \
Expand Down Expand Up @@ -372,8 +373,6 @@ define CLEAN_LIBGJPEG
endef

define SIMPLE_CARGO_BUILD
IPHONEOS_DEPLOYMENT_TARGET=$(APPLE_IOS_VERSION_MIN) \
MACOSX_DEPLOYMENT_TARGET=$(APPLE_MACOS_VERSION_MIN) \
cargo build \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--release;
Expand All @@ -387,13 +386,17 @@ define CARGO_BUILD
-Z build-std-features="panic_immediate_abort,optimize_for_size" \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--target $(CARGO_TARGET) \
--no-default-features \
--features thorvg-v1 \
--release; \
else \
IPHONEOS_DEPLOYMENT_TARGET=$(APPLE_IOS_VERSION_MIN) \
MACOSX_DEPLOYMENT_TARGET=$(APPLE_MACOS_VERSION_MIN) \
cargo build \
--manifest-path $(PROJECT_DIR)/Cargo.toml \
--target $(CARGO_TARGET) \
--no-default-features \
--features thorvg-v1 \
--release; \
fi
endef
Expand Down
2 changes: 1 addition & 1 deletion deps/modules/thorvg
Submodule thorvg updated 353 files
13 changes: 9 additions & 4 deletions dotlottie-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dotlottie-ffi"
version = "0.1.34"
version = "0.1.31"
edition = "2021"
build = "build.rs"

Expand All @@ -15,13 +15,18 @@ name = "dotlottie_player"
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[features]
default = ["thorvg-v0"]
thorvg-v0 = ["dotlottie-rs/thorvg-v0"]
thorvg-v1 = ["dotlottie-rs/thorvg-v1"]

[dependencies]
uniffi = { version = "0.28", features = ["cli"] }
dotlottie-rs = { path = "../dotlottie-rs", features = ["thorvg"] }
dotlottie-rs = { path = "../dotlottie-rs", default-features = false }
cfg-if = "1.0"
bitflags = "2.6.0"

[build-dependencies]
uniffi = { version = "0.28", features = ["build"] }
lazy_static = "1.4"
cbindgen = "0.26.0"
lazy_static = "1.5"
cbindgen = "0.27"
16 changes: 9 additions & 7 deletions dotlottie-ffi/Cargo.wasm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ build = "build.rs"

[profile.release]
lto = true
opt-level = "z"
strip = true
codegen-units = 1
panic = "abort"
panic = "abort"

[lib]
crate-type = ["staticlib", "cdylib", "rlib"]
Expand All @@ -19,13 +16,18 @@ name = "dotlottie_player"
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[features]
default = ["thorvg-v0"]
thorvg-v0 = ["dotlottie-rs/thorvg-v0"]
thorvg-v1 = ["dotlottie-rs/thorvg-v1"]

[dependencies]
uniffi = { version = "0.25", features = ["cli"] }
dotlottie-rs = { path = "../dotlottie-rs", features = ["thorvg"] }
dotlottie-rs = { path = "../dotlottie-rs", default-features = false }
cfg-if = "1.0"
bitflags = "2.6.0"

[build-dependencies]
uniffi = { version = "0.25", features = ["build"] }
lazy_static = "1.4"
cbindgen = "0.26.0"
lazy_static = "1.5"
cbindgen = "0.27"
19 changes: 10 additions & 9 deletions dotlottie-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@ links = "thorvg"
crate-type = ["staticlib", "cdylib", "rlib"]

[features]
thorvg = []
thorvg-v0 = []
thorvg-v1 = []

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
thiserror = "1.0.48"
thiserror = "2.0.4"
instant = { version = "0.1.13", features = ["inaccurate"] }
serde_json = "1.0.107"
serde = { version = "1.0.188", features = ["derive"] }
zip = { version = "2.2.0", default-features = false, features = ["deflate"] }
serde_json = "1.0.133"
serde = { version = "1.0.215", features = ["derive"] }
zip = { version = "2.2.1", default-features = false, features = ["deflate"] }
base64 = "0.22.1"
json = "0.12.4"
jzon = "0.12.5"

[build-dependencies]
bindgen = "0.70.1"
lazy_static = "1.4"
bindgen = "0.71.0"
lazy_static = "1.5.0"
conan2 = "0.1"

[dev-dependencies]
criterion = "0.5.1"
# This is a workaround to enable this feature only on dev.
dotlottie-rs= { path = ".", features = ["thorvg"] }
dotlottie-rs= { path = ".", features = ["thorvg-v0"] }

[[bench]]
name = "benchmarks"
harness = false
harness = false
2 changes: 1 addition & 1 deletion dotlottie-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn apply_build_settings(build_settings: &BuildSettings) {
}

fn main() {
if !cfg!(feature = "thorvg") {
if !cfg!(feature = "thorvg-v0") && !cfg!(feature = "thorvg-v1") {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions dotlottie-rs/src/dotlottie_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct DotLottieRuntime {
}

impl DotLottieRuntime {
#[cfg(feature = "thorvg")]
#[cfg(any(feature = "thorvg-v0", feature = "thorvg-v1"))]
pub fn new(config: Config) -> Self {
Self::with_renderer(
config,
Expand Down Expand Up @@ -888,7 +888,7 @@ pub struct DotLottiePlayerContainer {
}

impl DotLottiePlayerContainer {
#[cfg(feature = "thorvg")]
#[cfg(any(feature = "thorvg-v0", feature = "thorvg-v1"))]
pub fn new(config: Config) -> Self {
DotLottiePlayerContainer {
runtime: RwLock::new(DotLottieRuntime::new(config)),
Expand Down Expand Up @@ -1276,7 +1276,7 @@ pub struct DotLottiePlayer {
}

impl DotLottiePlayer {
#[cfg(feature = "thorvg")]
#[cfg(any(feature = "thorvg-v0", feature = "thorvg-v1"))]
pub fn new(config: Config) -> Self {
DotLottiePlayer {
player: Rc::new(RwLock::new(DotLottiePlayerContainer::new(config))),
Expand Down
10 changes: 7 additions & 3 deletions dotlottie-rs/src/lottie_renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use thiserror::Error;
use crate::Layout;

mod renderer;
#[cfg(feature = "thorvg")]
#[cfg(any(feature = "thorvg-v0", feature = "thorvg-v1"))]
mod thorvg;

pub use renderer::{Animation, ColorSpace, Drawable, Renderer, Shape};
#[cfg(feature = "thorvg")]
#[cfg(any(feature = "thorvg-v0", feature = "thorvg-v1"))]
pub use thorvg::{TvgAnimation, TvgEngine, TvgError, TvgRenderer, TvgShape};

#[derive(Error, Debug)]
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<R: Renderer> LottieRenderer for LottieRendererImpl<R> {
height: u32,
copy: bool,
) -> Result<(), LottieRendererError> {
self.renderer.clear(true).map_err(into_lottie::<R>)?;
self.renderer.clear(true, false).map_err(into_lottie::<R>)?;

self.picture_width = 0.0;
self.picture_height = 0.0;
Expand Down Expand Up @@ -224,6 +224,10 @@ impl<R: Renderer> LottieRenderer for LottieRendererImpl<R> {

fn render(&mut self) -> Result<(), LottieRendererError> {
self.renderer.update().map_err(into_lottie::<R>)?;

#[cfg(feature = "thorvg-v1")]
self.renderer.clear(false, true).map_err(into_lottie::<R>)?;

self.renderer.draw().map_err(into_lottie::<R>)?;
self.renderer.sync().map_err(into_lottie::<R>)?;

Expand Down
2 changes: 1 addition & 1 deletion dotlottie-rs/src/lottie_renderer/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub trait Renderer: Sized + 'static {
color_space: ColorSpace,
) -> Result<(), Self::Error>;

fn clear(&self, free: bool) -> Result<(), Self::Error>;
fn clear(&self, paints: bool, buffer: bool) -> Result<(), Self::Error>;

fn push(&mut self, drawable: Drawable<Self>) -> Result<(), Self::Error>;

Expand Down
43 changes: 34 additions & 9 deletions dotlottie-rs/src/lottie_renderer/thorvg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,18 @@ impl Renderer for TvgRenderer {
convert_tvg_result(result, "tvg_swcanvas_set_target")
}

fn clear(&self, free: bool) -> Result<(), TvgError> {
let result = unsafe { tvg::tvg_canvas_clear(self.raw_canvas, free) };
fn clear(&self, paints: bool, _buffer: bool) -> Result<(), TvgError> {
let result = unsafe {
#[cfg(feature = "thorvg-v1")]
{
tvg::tvg_canvas_clear(self.raw_canvas, paints, _buffer)
}

#[cfg(feature = "thorvg-v0")]
{
tvg::tvg_canvas_clear(self.raw_canvas, paints)
}
};

convert_tvg_result(result, "tvg_canvas_clear")
}
Expand Down Expand Up @@ -201,13 +211,28 @@ impl Animation for TvgAnimation {
let data = CString::new(data).expect("Failed to create CString");

let result = unsafe {
tvg::tvg_picture_load_data(
self.raw_paint,
data.as_ptr(),
data.as_bytes().len() as u32,
mimetype.as_ptr(),
copy,
)
#[cfg(feature = "thorvg-v1")]
{
tvg::tvg_picture_load_data(
self.raw_paint,
data.as_ptr(),
data.as_bytes().len() as u32,
mimetype.as_ptr(),
ptr::null(),
copy,
)
}

#[cfg(feature = "thorvg-v0")]
{
tvg::tvg_picture_load_data(
self.raw_paint,
data.as_ptr(),
data.as_bytes().len() as u32,
mimetype.as_ptr(),
copy,
)
}
};

convert_tvg_result(result, "tvg_picture_load_data")?;
Expand Down

0 comments on commit bdac0e2

Please sign in to comment.