lottie: always get the item by ref or const ref.

Change-Id: Id798812b135d2e1ef1fb593412808f15e2645761
This commit is contained in:
subhransu mohanty 2018-08-02 14:57:08 +09:00
parent e8cb8100e6
commit 649c463f4e

View File

@ -17,7 +17,7 @@ LOTCompItem::LOTCompItem(LOTModel *model)
{ {
// 1. build layer item list // 1. build layer item list
mCompData = model->mRoot.get(); mCompData = model->mRoot.get();
for (auto i : mCompData->mChildren) { for (auto &i : mCompData->mChildren) {
LOTLayerData *layerData = dynamic_cast<LOTLayerData *>(i.get()); LOTLayerData *layerData = dynamic_cast<LOTLayerData *>(i.get());
if (layerData) { if (layerData) {
LOTLayerItem *layerItem = LOTCompItem::createLayerItem(layerData); LOTLayerItem *layerItem = LOTCompItem::createLayerItem(layerData);
@ -29,7 +29,7 @@ LOTCompItem::LOTCompItem(LOTModel *model)
} }
// 2. update parent layer // 2. update parent layer
for (auto i : mLayers) { for (auto &i : mLayers) {
int id = i->parentId(); int id = i->parentId();
if (id >= 0) { if (id >= 0) {
auto search = mLayerMap.find(id); auto search = mLayerMap.find(id);
@ -40,7 +40,7 @@ LOTCompItem::LOTCompItem(LOTModel *model)
} }
} }
// 3. update static property of each layer // 3. update static property of each layer
for (auto i : mLayers) { for (auto &i : mLayers) {
i->updateStaticProperty(); i->updateStaticProperty();
} }
@ -49,7 +49,7 @@ LOTCompItem::LOTCompItem(LOTModel *model)
LOTCompItem::~LOTCompItem() LOTCompItem::~LOTCompItem()
{ {
for (auto i : mLayers) { for (auto &i : mLayers) {
delete i; delete i;
} }
} }
@ -133,7 +133,7 @@ void LOTCompItem::buildRenderList()
} }
mRenderList.clear(); mRenderList.clear();
for (auto i : mDrawableList) { for (auto &i : mDrawableList) {
LOTDrawable *lotDrawable = static_cast<LOTDrawable *>(i); LOTDrawable *lotDrawable = static_cast<LOTDrawable *>(i);
lotDrawable->sync(); lotDrawable->sync();
mRenderList.push_back(&lotDrawable->mCNode); mRenderList.push_back(&lotDrawable->mCNode);
@ -210,7 +210,7 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask)
mask = mask & inheritMask; mask = mask & inheritMask;
} }
for (auto i : list) { for (auto &i : list) {
painter->setBrush(i->mBrush); painter->setBrush(i->mBrush);
if (!mask.isEmpty()) { if (!mask.isEmpty()) {
VRle rle = i->rle() & mask; VRle rle = i->rle() & mask;
@ -256,7 +256,7 @@ LOTLayerItem::LOTLayerItem(LOTLayerData *layerData)
mDirtyFlag(DirtyFlagBit::All) mDirtyFlag(DirtyFlagBit::All)
{ {
if (mLayerData->mHasMask) { if (mLayerData->mHasMask) {
for (auto i : mLayerData->mMasks) { for (auto &i : mLayerData->mMasks) {
mMasks.push_back(std::make_unique<LOTMaskItem>(i.get())); mMasks.push_back(std::make_unique<LOTMaskItem>(i.get()));
} }
} }
@ -334,7 +334,7 @@ bool LOTLayerItem::visible() const
LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel) LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel)
: LOTLayerItem(layerModel) : LOTLayerItem(layerModel)
{ {
for (auto i : mLayerData->mChildren) { for (auto &i : mLayerData->mChildren) {
LOTLayerData *layerModel = dynamic_cast<LOTLayerData *>(i.get()); LOTLayerData *layerModel = dynamic_cast<LOTLayerData *>(i.get());
if (layerModel) { if (layerModel) {
LOTLayerItem *layerItem = LOTCompItem::createLayerItem(layerModel); LOTLayerItem *layerItem = LOTCompItem::createLayerItem(layerModel);
@ -346,7 +346,7 @@ LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel)
} }
// 2. update parent layer // 2. update parent layer
for (auto i : mLayers) { for (auto &i : mLayers) {
int id = i->parentId(); int id = i->parentId();
if (id >= 0) { if (id >= 0) {
auto search = mLayerMap.find(id); auto search = mLayerMap.find(id);
@ -363,7 +363,7 @@ void LOTCompLayerItem::updateStaticProperty()
{ {
LOTLayerItem::updateStaticProperty(); LOTLayerItem::updateStaticProperty();
for (auto i : mLayers) { for (auto &i : mLayers) {
i->updateStaticProperty(); i->updateStaticProperty();
} }
} }
@ -379,14 +379,14 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask)
mask = mask & inheritMask; mask = mask & inheritMask;
} }
for (auto i : mLayers) { for (auto &i : mLayers) {
i->render(painter, mask); i->render(painter, mask);
} }
} }
LOTCompLayerItem::~LOTCompLayerItem() LOTCompLayerItem::~LOTCompLayerItem()
{ {
for (auto i : mLayers) { for (auto &i : mLayers) {
delete i; delete i;
} }
} }