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

View file

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