lottie: apply matte feature to LOTCompLayerItem

The LOTCompLayerItem's MatteRle has to be inherited to its all children layers.
You can test it with "personal_character.json".

Change-Id: I225e16397441f9771286c6fcc821b5050b165ecc
This commit is contained in:
Youngbok Shin 2018-08-20 20:39:46 +09:00 committed by subhransu mohanty
parent 57b58412b6
commit 083ec1abb8
2 changed files with 17 additions and 8 deletions

View File

@ -120,8 +120,7 @@ bool LOTCompItem::render(const LOTBuffer &buffer)
}
VPainter painter(&bitmap);
VRle mask;
mRootLayer->render(&painter, mask, nullptr);
mRootLayer->render(&painter, {}, {}, nullptr);
return true;
}
@ -158,7 +157,7 @@ VRle LOTMaskItem::rle()
return mRle;
}
void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerItem *matteSource)
void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, const VRle &inheritMatte, LOTLayerItem *matteSource)
{
VRle matteRle;
if (matteSource) {
@ -167,6 +166,11 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerIt
for (auto &i : mDrawableList) {
matteRle = matteRle + i->rle();
}
if (!inheritMatte.isEmpty())
matteRle = matteRle & inheritMatte;
} else {
matteRle = inheritMatte;
}
mDrawableList.clear();
renderList(mDrawableList);
@ -344,7 +348,7 @@ void LOTCompLayerItem::updateStaticProperty()
}
}
void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerItem *matteSource)
void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, const VRle &inheritMatte, LOTLayerItem *matteSource)
{
VRle matteRle;
if (matteSource) {
@ -353,6 +357,11 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLay
for (auto &i : mDrawableList) {
matteRle = matteRle + i->rle();
}
if (!inheritMatte.isEmpty())
matteRle = matteRle & inheritMatte;
} else {
matteRle = inheritMatte;
}
VRle mask;
@ -377,10 +386,10 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLay
}
if (matteLayer) {
matteLayer->render(painter, mask, layer);
matteLayer->render(painter, mask, matteRle, layer);
matteLayer = nullptr;
} else {
layer->render(painter, mask, nullptr);
layer->render(painter, mask, matteRle, nullptr);
}
}
}

View File

@ -64,7 +64,7 @@ public:
VMatrix matrix(int frameNo) const;
virtual void renderList(std::vector<VDrawable *> &list){}
virtual void updateStaticProperty();
virtual void render(VPainter *painter, const VRle &mask, LOTLayerItem *matteSource);
virtual void render(VPainter *painter, const VRle &mask, const VRle &inheritMatte, LOTLayerItem *matteSource);
bool hasMatte() { if (mLayerData->mMatteType == MatteType::None) return false; return true; }
protected:
@ -98,7 +98,7 @@ public:
LOTCompLayerItem(LOTLayerData *layerData);
void renderList(std::vector<VDrawable *> &list)final;
void updateStaticProperty() final;
void render(VPainter *painter, const VRle &mask, LOTLayerItem *matteSource) final;
void render(VPainter *painter, const VRle &mask, const VRle &inheritMatte, LOTLayerItem *matteSource) final;
protected:
void updateContent() final;
private: