From da553c4dab597dd44ab9d071d735211ce9c40838 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 16 Aug 2018 13:37:21 +0900 Subject: [PATCH] lottie/optimization: keep drawablelist in layer to avoid memory allocation in every frame. Change-Id: I80eebb9e1ab16a424a26a17ce67274c7518efca9 --- src/lottie/lottieitem.cpp | 18 +++++++++--------- src/lottie/lottieitem.h | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index 25056cf..5896543 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -160,14 +160,14 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerIt { VRle matteRle; if (matteSource) { - std::vector matteList; - matteSource->renderList(matteList); - for (auto &i : matteList) { + mDrawableList.clear(); + matteSource->renderList(mDrawableList); + for (auto &i : mDrawableList) { matteRle = matteRle + i->rle(); } } - std::vector list; - renderList(list); + mDrawableList.clear(); + renderList(mDrawableList); VRle mask = inheritMask; if (hasMask()) { if (mask.isEmpty()) @@ -176,7 +176,7 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerIt mask = mask & inheritMask; } - for (auto &i : list) { + for (auto &i : mDrawableList) { painter->setBrush(i->mBrush); VRle rle = i->rle(); if (!mask.isEmpty()) rle = i->rle() & mask; @@ -343,9 +343,9 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLay { VRle matteRle; if (matteSource) { - std::vector matteList; - matteSource->renderList(matteList); - for (auto &i : matteList) { + mDrawableList.clear(); + matteSource->renderList(mDrawableList); + for (auto &i : mDrawableList) { matteRle = matteRle + i->rle(); } } diff --git a/src/lottie/lottieitem.h b/src/lottie/lottieitem.h index 6c769e0..c3d5066 100644 --- a/src/lottie/lottieitem.h +++ b/src/lottie/lottieitem.h @@ -79,6 +79,7 @@ protected: VRle maskRle(const VRect &clipRect); bool hasMask() const {return !mMasks.empty();} protected: + std::vector mDrawableList; std::vector> mMasks; LOTLayerData *mLayerData; LOTLayerItem *mParentLayer; -- 2.34.1