loader lottie: image optimization

In every frame, the image undergoes a Colorspace conversion attempt.

This approach aims to bypass the step by retaining the pre-converted image data.

I acknowledge that this might not be the best approach,
but it is proving to be quite effective at the moment.
This commit is contained in:
Hermet Park 2023-08-14 11:38:28 +09:00
parent 765b02b49d
commit 86aabb4df0
3 changed files with 15 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -240,12 +240,15 @@ static Shape* _updatePath(LottieGroup* parent, LottiePath* path, int32_t frameNo
static void _updateImage(LottieGroup* parent, LottieImage* image, int32_t frameNo, Paint* baseShape)
{
auto picture = Picture::gen();
auto picture = image->picture;
if (image->size > 0) {
if (picture->load((const char*)image->b64Data, image->size, image->mimeType, false) != Result::Success) return;
} else {
if (picture->load(image->path) != Result::Success) return;
if (!picture) {
picture = Picture::gen().release();
if (image->size > 0) {
if (picture->load((const char*)image->b64Data, image->size, image->mimeType, false) != Result::Success) return;
} else {
if (picture->load(image->path) != Result::Success) return;
}
}
if (baseShape) {
@ -254,7 +257,11 @@ static void _updateImage(LottieGroup* parent, LottieImage* image, int32_t frameN
}
picture->opacity(baseShape->opacity());
}
parent->scene->push(std::move(picture));
//TODO: remove duplicate.
image->picture = (Picture*)picture->duplicate();
parent->scene->push(cast<Picture>(picture));
}

View file

@ -309,6 +309,8 @@ struct LottieImage : LottieObject
char* mimeType = nullptr;
uint32_t size = 0;
Picture* picture = nullptr; //tvg render data
~LottieImage()
{
free(b64Data);