mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
lottie/property: code refactoring
introduce the release() method for memory freeing. This method can be used for any demands.
This commit is contained in:
parent
727b699223
commit
3cb8c4311d
1 changed files with 20 additions and 2 deletions
|
@ -215,8 +215,14 @@ struct LottieGenericProperty : LottieProperty
|
|||
T value;
|
||||
|
||||
LottieGenericProperty(T v) : value(v) {}
|
||||
LottieGenericProperty() {}
|
||||
|
||||
~LottieGenericProperty()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
delete(frames);
|
||||
}
|
||||
|
@ -271,11 +277,17 @@ struct LottiePathSet : LottieProperty
|
|||
PathSet value;
|
||||
|
||||
~LottiePathSet()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
free(value.cmds);
|
||||
free(value.pts);
|
||||
|
||||
if (!frames) return;
|
||||
|
||||
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
||||
free((*p).value.cmds);
|
||||
free((*p).value.pts);
|
||||
|
@ -461,10 +473,11 @@ struct LottieColorStop : LottieProperty
|
|||
const_cast<LottieColorStop&>(other).frames = nullptr;
|
||||
} else {
|
||||
value = other.value;
|
||||
const_cast<LottieColorStop&>(other).value.data = nullptr;
|
||||
const_cast<LottieColorStop&>(other).value = {nullptr, nullptr};
|
||||
}
|
||||
populated = other.populated;
|
||||
count = other.count;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -482,6 +495,11 @@ struct LottiePosition : LottieProperty
|
|||
}
|
||||
|
||||
~LottiePosition()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
delete(frames);
|
||||
}
|
||||
|
@ -616,4 +634,4 @@ using LottieFloat = LottieGenericProperty<float>;
|
|||
using LottieOpacity = LottieGenericProperty<uint8_t>;
|
||||
using LottieColor = LottieGenericProperty<RGB24>;
|
||||
|
||||
#endif //_TVG_LOTTIE_PROPERTY_H_
|
||||
#endif //_TVG_LOTTIE_PROPERTY_H_
|
||||
|
|
Loading…
Add table
Reference in a new issue