Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
361b860
no message
Sep 4, 2019
b579347
Fixes
laktyushin Oct 19, 2019
c490c7a
Don't try entering object if it's not one
laktyushin Oct 19, 2019
a09896b
Disable asserts in lottieparser
laktyushin Oct 21, 2019
d531c4a
no message
overtake Nov 6, 2019
19f6964
no message
overtake Nov 7, 2019
010860e
- bugfixes and improvements
overtake Jan 10, 2020
1f3265b
return old raster
overtake Jan 17, 2020
05a40a3
update raster
Jan 19, 2020
0ee2e9c
Check buffer length in vrle.
john-preston Jan 21, 2020
2edff77
- bugfixes and improvements
overtake Jan 21, 2020
75b31e4
Try to silence compare signess warnings.
john-preston Jan 23, 2020
d513b02
Add LOTTIE_THREAD_SAFE to limit object sharing when LOTTIE_THREAD_SUP…
Apr 13, 2020
3c280ce
Fix crash in malformed lottie animations.
john-preston May 1, 2020
7bfda26
- crash fix
May 4, 2020
e0ea6af
Fix some crashes on invalid data.
john-preston May 11, 2020
970fa3a
Merge commit 'e0ea6af518345c4a46195c4951e023e621a9eb8f'
May 14, 2020
598f540
no message
May 30, 2020
d369d84
Add some more checks for invalid data.
john-preston Aug 21, 2020
af8d931
Merge commit 'd369d84e868352886cee48eecb60b462f6dfe067'
Aug 27, 2020
69ccd75
skip 3d keys. we don't support it
overtake Sep 4, 2020
839dcab
Add some more checks for input data.
john-preston Sep 24, 2020
c567dad
Merge commit '839dcab7f083a51b8130061ea5ec245195af6c58'
Sep 25, 2020
ac21d30
Merge branch 'master' of github.com:desktop-app/rlottie
overtake Sep 25, 2020
7fdc010
Fix check
Jun 24, 2021
707c030
Merge branch 'master' of https://github.com/TelegramMessenger/rlottie
overtake Aug 2, 2021
67f103b
Add Fitzpatrick skin type based color replacement
laktyushin Nov 17, 2021
0e8cb25
cache lottie
May 26, 2022
29896c5
Merge branch 'master' of gitlab.com:peter-iakovlev/rlottie
Sep 27, 2022
78bfd25
Create Lottie
Nuttapon-Makchoos Nov 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lottie
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 10 additions & 1 deletion inc/rlottie.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ struct LOTLayerNode;

namespace rlottie {

enum class FitzModifier {
None,
Type12,
Type3,
Type4,
Type5,
Type6
};

/**
* @brief Configures rlottie model cache policy.
*
Expand Down Expand Up @@ -293,7 +302,7 @@ class LOT_EXPORT Animation {
loadFromData(std::string jsonData, const std::string &key,
const std::string &resourcePath="", bool cachePolicy=true,
const std::vector<std::pair<std::uint32_t, std::uint32_t>>
&colorReplacements = {});
&colorReplacements = {}, FitzModifier fitzModifier = FitzModifier::None);

/**
* @brief Returns default framerate of the Lottie resource.
Expand Down
4 changes: 2 additions & 2 deletions src/lottie/lottieanimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ std::unique_ptr<Animation> Animation::loadFromData(
std::string jsonData, const std::string &key,
const std::string &resourcePath, bool cachePolicy,
const std::vector<std::pair<std::uint32_t, std::uint32_t>>
&colorReplacements)
&colorReplacements, FitzModifier fitzModifier)
{
if (jsonData.empty()) {
vWarning << "jason data is empty";
Expand All @@ -252,7 +252,7 @@ std::unique_ptr<Animation> Animation::loadFromData(
LottieLoader loader;
if (loader.loadFromData(std::move(jsonData), key,
(resourcePath.empty() ? " " : resourcePath),
cachePolicy, colorReplacements)) {
cachePolicy, colorReplacements, fitzModifier)) {
auto animation = std::unique_ptr<Animation>(new Animation);
animation->d->init(loader.model());
return animation;
Expand Down
6 changes: 5 additions & 1 deletion src/lottie/lottieitem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
*
* This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -92,6 +92,7 @@ void LOTCompItem::setValue(const std::string &keypath, LOTVariant &value)
{
LOTKeyPath key(keypath);
mRootLayer->resolveKeyPath(key, 0, value);
mCurFrameNo = -1;
}

std::unique_ptr<LOTLayerItem> LOTCompItem::createLayerItem(
Expand Down Expand Up @@ -518,6 +519,9 @@ LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel)
{
// 1. create layer item
for (auto &i : mLayerData->mChildren) {
if (i->type() != LOTData::Type::Layer) {
continue;
}
auto model = static_cast<LOTLayerData *>(i.get());
auto item = LOTCompItem::createLayerItem(model);
if (item) mLayers.push_back(std::move(item));
Expand Down
9 changes: 5 additions & 4 deletions src/lottie/lottieloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class LottieModelCache {

std::unordered_map<std::string, std::shared_ptr<LOTModel>> mHash;
std::mutex mMutex;
size_t mcacheSize{10};
size_t mcacheSize{10000};
};

#else
Expand Down Expand Up @@ -144,15 +144,16 @@ bool LottieLoader::loadFromData(
std::string &&jsonData, const std::string &key,
const std::string &resourcePath, bool cachePolicy,
const std::vector<std::pair<std::uint32_t, std::uint32_t>>
&colorReplacements)
&colorReplacements, rlottie::FitzModifier fitzModifier)
{
if (cachePolicy) {
mModel = LottieModelCache::instance().find(key);
if (mModel) return true;
if (mModel)
return true;
}

LottieParser parser(const_cast<char *>(jsonData.c_str()),
resourcePath.c_str(), colorReplacements);
resourcePath.c_str(), colorReplacements, fitzModifier);
mModel = parser.model();

if (!mModel) return false;
Expand Down
4 changes: 3 additions & 1 deletion src/lottie/lottieloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include<memory>
#include<vector>

#include "rlottie.h"

class LOTModel;
class LottieLoader
{
Expand All @@ -32,7 +34,7 @@ class LottieLoader
bool loadFromData(std::string &&jsonData, const std::string &key,
const std::string &resourcePath, bool cachePolicy,
const std::vector<std::pair<std::uint32_t, std::uint32_t>>
&colorReplacements);
&colorReplacements, rlottie::FitzModifier fitzModifier);
std::shared_ptr<LOTModel> model();
private:
std::shared_ptr<LOTModel> mModel;
Expand Down
11 changes: 10 additions & 1 deletion src/lottie/lottiemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,17 @@ void LOTGradient::populate(VGradientStops &stops, int frameNo)
LottieGradient gradData = mGradient.value(frameNo);
auto size = gradData.mGradient.size();
float * ptr = gradData.mGradient.data();
if (!ptr) {
return;
}
int colorPoints = mColorPoints;
if (colorPoints == -1) { // for legacy bodymovin (ref: lottie-android)
if (colorPoints < 0 || colorPoints > size / 4) { // for legacy bodymovin (ref: lottie-android)
colorPoints = int(size / 4);
}
auto opacityArraySize = size - colorPoints * 4;
if ((opacityArraySize % 2 != 0) || (colorPoints > opacityArraySize / 2 && opacityArraySize < 4)) {
opacityArraySize = 0;
}
float *opacityPtr = ptr + (colorPoints * 4);
stops.clear();
size_t j = 0;
Expand Down Expand Up @@ -242,6 +248,9 @@ void LOTGradient::populate(VGradientStops &stops, int frameNo)
}
ptr += 4;
}
if (stops.empty()) {
stops.push_back(std::make_pair(0.0f, VColor(255, 255, 255, 255)));
}
}

void LOTGradient::update(std::unique_ptr<VGradient> &grad, int frameNo)
Expand Down
12 changes: 9 additions & 3 deletions src/lottie/lottiemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,13 @@ class LOTAnimInfo
{
public:
T value(int frameNo) const {
if (mKeyFrames.empty())
return T();

if (mKeyFrames.front().mStartFrame >= frameNo)
return mKeyFrames.front().mValue.mStartValue;
if(mKeyFrames.back().mEndFrame <= frameNo)
if (mKeyFrames.back().mEndFrame <= frameNo)
return mKeyFrames.back().mValue.mEndValue;

for(const auto &keyFrame : mKeyFrames) {
if (frameNo >= keyFrame.mStartFrame && frameNo < keyFrame.mEndFrame)
return keyFrame.value(frameNo);
Expand All @@ -238,7 +240,8 @@ class LOTAnimInfo
}

float angle(int frameNo) const {
if ((mKeyFrames.front().mStartFrame >= frameNo) ||
if (mKeyFrames.empty() ||
(mKeyFrames.front().mStartFrame >= frameNo) ||
(mKeyFrames.back().mEndFrame <= frameNo) )
return 0;

Expand All @@ -250,6 +253,9 @@ class LOTAnimInfo
}

bool changed(int prevFrame, int curFrame) const {
if (mKeyFrames.empty())
return false;

auto first = mKeyFrames.front().mStartFrame;
auto last = mKeyFrames.back().mEndFrame;

Expand Down
Loading