lottie: copy the data only necessarily.

This commit is contained in:
Hermet Park 2024-03-03 00:34:08 +09:00 committed by Hermet Park
parent 5abe777118
commit 3b6b538a19
2 changed files with 12 additions and 16 deletions

View file

@ -84,7 +84,7 @@ struct LottieStroke
struct LottieMask
{
LottiePathSet pathset = PathSet{nullptr, nullptr, 0, 0};
LottiePathSet pathset;
LottieOpacity opacity = 255;
CompositeMethod method;
bool inverse = false;
@ -245,7 +245,7 @@ struct LottiePath : LottieShape
if (pathset.frames) statical = false;
}
LottiePathSet pathset = PathSet{nullptr, nullptr, 0, 0};
LottiePathSet pathset;
};

View file

@ -31,10 +31,10 @@
struct PathSet
{
Point* pts;
PathCommand* cmds;
uint16_t ptsCnt;
uint16_t cmdsCnt;
Point* pts = nullptr;
PathCommand* cmds = nullptr;
uint16_t ptsCnt = 0;
uint16_t cmdsCnt = 0;
};
@ -253,8 +253,8 @@ struct LottieGenericProperty : LottieProperty
{
//shallow copy, used for slot overriding
delete(frames);
frames = other.frames;
value = other.value;
if (other.frames) frames = other.frames;
else value = other.value;
const_cast<T&>(other).frames = nullptr;
return *this;
}
@ -269,10 +269,6 @@ struct LottiePathSet : LottieProperty
Array<LottieScalarFrame<PathSet>>* frames = nullptr;
PathSet value;
LottiePathSet(PathSet v) : value(v)
{
}
~LottiePathSet()
{
free(value.cmds);
@ -447,8 +443,8 @@ struct LottieColorStop : LottieProperty
{
//shallow copy, used for slot overriding
delete(frames);
frames = other.frames;
value = other.value;
if (other.frames) frames = other.frames;
else value = other.value;
count = other.count;
const_cast<LottieColorStop&>(other).frames = nullptr;
return *this;
@ -569,8 +565,8 @@ struct LottieTextDoc : LottieProperty
{
//shallow copy, used for slot overriding
delete(frames);
frames = other.frames;
value = other.value;
if (other.frames) frames = other.frames;
else value = other.value;
const_cast<LottieTextDoc&>(other).frames = nullptr;
return *this;
}