Skip to content

Commit

Permalink
Do not skip update when it has dynamic property
Browse files Browse the repository at this point in the history
In following cases,

```c++
animation->setValue<Property::FillColor>("**", red);
animation->render(0, surface);
// after render is finished
animation->setValue<Property::FillColor>("**", blue);
animation->render(0, surface);
```
Or
```c++
animation->setValue<Property::FillColor>("**", [&](const FrameInfo& info) {
    return colors->getColor();
});

colors->setColor(red);
animation->render(0, surface);
// after render is finished
colors->setColor(blue);
animation->render(0, surface);

```
the second render request for both cases should not be ignored even if it's the same request as previous.

Signed-off-by: Jiyun Yang <[email protected]>
  • Loading branch information
rabbitfor authored and JoogabYun committed Aug 31, 2023
1 parent f969abf commit d400087
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lottie/lottieitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ renderer::Composition::Composition(std::shared_ptr<model::Composition> model)
void renderer::Composition::setValue(const std::string &keypath,
LOTVariant & value)
{
mHasDynamicValue = true;
LOTKeyPath key(keypath);
mRootLayer->resolveKeyPath(key, 0, value);
}
Expand All @@ -117,7 +118,7 @@ bool renderer::Composition::update(int frameNo, const VSize &size,
bool keepAspectRatio)
{
// check if cached frame is same as requested frame.
if ((mViewSize == size) && (mCurFrameNo == frameNo) &&
if (!mHasDynamicValue && (mViewSize == size) && (mCurFrameNo == frameNo) &&
(mKeepAspectRatio == keepAspectRatio))
return false;

Expand Down
1 change: 1 addition & 0 deletions src/lottie/lottieitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class Composition {
VArenaAlloc mAllocator{2048};
int mCurFrameNo;
bool mKeepAspectRatio{true};
bool mHasDynamicValue{false};
};

class Layer {
Expand Down

0 comments on commit d400087

Please sign in to comment.