mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
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:
parent
765b02b49d
commit
86aabb4df0
3 changed files with 15 additions and 7 deletions
File diff suppressed because one or more lines are too long
|
@ -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)
|
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) {
|
||||||
if (picture->load((const char*)image->b64Data, image->size, image->mimeType, false) != Result::Success) return;
|
picture = Picture::gen().release();
|
||||||
} else {
|
if (image->size > 0) {
|
||||||
if (picture->load(image->path) != Result::Success) return;
|
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) {
|
if (baseShape) {
|
||||||
|
@ -254,7 +257,11 @@ static void _updateImage(LottieGroup* parent, LottieImage* image, int32_t frameN
|
||||||
}
|
}
|
||||||
picture->opacity(baseShape->opacity());
|
picture->opacity(baseShape->opacity());
|
||||||
}
|
}
|
||||||
parent->scene->push(std::move(picture));
|
|
||||||
|
//TODO: remove duplicate.
|
||||||
|
image->picture = (Picture*)picture->duplicate();
|
||||||
|
|
||||||
|
parent->scene->push(cast<Picture>(picture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,8 @@ struct LottieImage : LottieObject
|
||||||
char* mimeType = nullptr;
|
char* mimeType = nullptr;
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
|
|
||||||
|
Picture* picture = nullptr; //tvg render data
|
||||||
|
|
||||||
~LottieImage()
|
~LottieImage()
|
||||||
{
|
{
|
||||||
free(b64Data);
|
free(b64Data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue